43 template <
typename NumericType>
45 const std::string & provided_unit,
46 const std::vector<std::string> & accepted_unit,
47 const std::string & equation,
48 const std::string & parameter_name)
50 if(provided_unit.empty() && default_unit.
is_united())
56 for(
unsigned int i = 0; i < accepted_unit.size(); i++)
66 std::string errorstring(
"Error in reaction " + equation);
67 errorstring +=
"\n" + parameter_name +
" parameter's unit should be homogeneous to \"" + accepted_unit[0] +
"\"";
68 for(
unsigned int i = 1; i < accepted_unit.size(); i++)errorstring +=
", or \"" + accepted_unit[i] +
"\"";
69 errorstring +=
" and you provided \"" + provided_unit +
"\"";
72 default_unit.
set_unit(provided_unit);
76 template<
typename NumericType>
102 unsigned int n_species = chem_mixture.
n_species();
127 std::map<std::string,KineticsModel::KineticsModel> kin_keyword;
138 std::map<KineticsModel::KineticsModel,unsigned int> kinetics_model_map;
148 std::vector<std::string> models;
149 models.push_back(
"Constant");
150 models.push_back(
"HercourtEssen");
151 models.push_back(
"Berthelot");
152 models.push_back(
"Arrhenius");
153 models.push_back(
"BerthelotHercourtEssen");
154 models.push_back(
"Kooij");
155 models.push_back(
"ModifiedArrhenius");
156 models.push_back(
"VantHoff");
157 models.push_back(
"photochemistry");
159 std::map<std::string,ReactionType::ReactionType> proc_keyword;
171 if (verbose) std::cout <<
"Reaction \"" << parser->
reaction_id() <<
"\":\n"
183 std::cerr <<
"Implemented chemical processes are:\n"
184 <<
" Elementary (default)\n"
187 <<
" LindemannFalloff\n"
189 <<
" LindemannFalloffThreeBody\n"
190 <<
" TroeFalloffThreeBody\n"
191 <<
"See Antioch documentation for more details."
199 if (verbose) std::cout <<
"reversible: " << reversible << std::endl;
211 std::cout <<
"In reaction(s) including " << parser->
reaction_id() <<
"\n"
212 <<
"An equation of the form \"A * (T/Tref)^beta * exp(-Ea/(R*T))\" is a Kooij equation,\n"
213 <<
"I guess a modified Arrhenius could be a name too. Whatever, the correct label is\n"
214 <<
"\"Kooij\", or, << à la limite >> \"ModifiedArrhenius\". Please use those terms instead,\n"
215 <<
"thanks and a good day to you, user." << std::endl;
222 reversible,typeReaction,kineticsModel);
227 bool relevant_reaction =
true;
228 NumericType order_reaction(0);
229 std::vector<std::pair<std::string,int> > molecules_pairs;
237 std::cout <<
"\n reactants: ";
238 for(
unsigned int ir = 0; ir < molecules_pairs.size(); ir++)
240 NumericType order = (orders.count(molecules_pairs[ir].first))?orders.at(molecules_pairs[ir].first):
static_cast<NumericType
>(molecules_pairs[ir].second);
241 std::cout << molecules_pairs[ir].first <<
":" << molecules_pairs[ir].second <<
"," << order <<
", ";
245 for(
unsigned int p=0; p < molecules_pairs.size(); p++ )
247 if(molecules_pairs[p].first ==
"e-") molecules_pairs[p].first =
"e";
249 if(verbose) std::cout <<
"\n " << molecules_pairs[p].first <<
" " << molecules_pairs[p].second;
253 relevant_reaction =
false;
254 if (verbose) std::cout <<
"\n -> skipping this reaction (no reactant " << molecules_pairs[p].first <<
")";
258 NumericType order = (orders.count(molecules_pairs[p].first))?orders.at(molecules_pairs[p].first):
static_cast<NumericType
>(molecules_pairs[p].second);
261 molecules_pairs[p].second, order );
262 order_reaction += order;
267 molecules_pairs.clear();
272 if(verbose) std::cout <<
"\n products: ";
273 for(
unsigned int ir = 0; ir < molecules_pairs.size(); ir++)
275 NumericType order = (orders.count(molecules_pairs[ir].first))?orders.at(molecules_pairs[ir].first):
static_cast<NumericType
>(molecules_pairs[ir].second);
276 std::cout << molecules_pairs[ir].first <<
":" << molecules_pairs[ir].second <<
"," << order <<
", ";
279 for (
unsigned int p=0; p < molecules_pairs.size(); p++)
281 if(molecules_pairs[p].first ==
"e-") molecules_pairs[p].first =
"e";
283 if(verbose) std::cout <<
"\n " << molecules_pairs[p].first <<
" " << molecules_pairs[p].second;
287 relevant_reaction =
false;
288 if (verbose) std::cout <<
"\n -> skipping this reaction (no product " << molecules_pairs[p].first <<
")";
292 NumericType order = (orders.count(molecules_pairs[p].first))?orders.at(molecules_pairs[p].first):
static_cast<NumericType
>(molecules_pairs[p].second);
295 molecules_pairs[p].second, order );
298 if(verbose) std::cout << std::endl;
301 if(!relevant_reaction)
303 if(verbose) std::cout <<
"skipped reaction\n\n";
325 std::vector<NumericType> data;
328 int pow_unit(order_reaction - 1);
329 bool is_falloff(
false);
339 is_falloff = verbose;
348 NumericType par_value(-1.);
349 std::vector<NumericType> par_values;
350 std::string par_unit;
351 std::string default_unit;
352 std::vector<std::string> accepted_unit;
355 if(verbose)std::cout <<
" rate: " << models[kinetics_model_map[kineticsModel]] <<
" model\n";
357 (is_k0)?std::cout <<
" Low pressure limit rate constant\n":std::cout <<
" High pressure limit rate constant\n";
364 accepted_unit.clear();
369 def_unit *= pow_unit;
375 accepted_unit.push_back(def_unit.
get_symbol());
381 def_unit *= pow_unit;
390 std::cout <<
" A: " << par_value
399 accepted_unit.clear();
400 accepted_unit.push_back(
"");
405 std::cerr <<
"In reaction " << parser->
reaction_id() <<
"\n"
406 <<
"An equation of the form \"A * exp(-Ea/(R*T))\" is an Arrhenius equation,\n"
407 <<
"and most certainly not a Kooij one\n"
408 <<
"it has been corrected, but please, change that in your file.\n"
409 <<
"Thanks and a good day to you, user." << std::endl;
417 std::cout <<
" b: " << par_value << std::endl;
424 accepted_unit.clear();
425 accepted_unit.push_back(
"J/mol");
426 accepted_unit.push_back(
"K");
432 std::cout <<
" E: " << par_value
441 accepted_unit.clear();
442 accepted_unit.push_back(
"K");
448 std::cout <<
" D: " << par_value
462 accepted_unit.clear();
463 accepted_unit.push_back(
"K");
470 data.push_back(par_value);
479 (par_unit.empty())?def_unit.
set_unit(default_unit):def_unit.
set_unit(par_unit);
484 Antioch::Constants::R_universal<NumericType>()
486 data.push_back(par_value);
503 accepted_unit.clear();
504 accepted_unit.push_back(
"nm");
505 accepted_unit.push_back(
"cm-1");
513 for(
unsigned int il = 0; il < par_values.size(); il++)
519 for(
unsigned int il = 0; il < par_values.size(); il++)
531 std::cerr <<
"Where is the cross-section? In what universe have you photochemistry with a wavelength grid and no cross-section on it?" << std::endl;
535 if(par_values.size() != data.size())
537 std::cerr <<
"Your cross-section vector and your lambda vector don't have the same size!\n"
538 <<
"What am I supposed to do with that?"
561 accepted_unit.clear();
562 accepted_unit.push_back(
"cm2");
563 accepted_unit.push_back(
"cm2/nm");
564 accepted_unit.push_back(
"cm2/nm-1");
570 for(
unsigned int ics = 0; ics < par_values.size(); ics++)
572 data.push_back(par_values[ics] * def_unit.
get_SI_factor() / bin_coefficient);
576 std::string target_unit = (def_unit.
is_homogeneous(
"cm2/nm"))?
"m2/nm":
"m2/nm-1";
577 for(
unsigned int ics = 0; ics < par_values.size(); ics++)
587 std::cerr <<
"Somehow, I have a bad feeling about a chemical reaction without any data parameters...\n"
588 <<
"This is too sad, I give up...\n"
589 <<
"Please, check the reaction " << my_rxn->
equation() <<
" before coming back to me." << std::endl;
611 if(parser->
where_is_k0(reading_kinetics_model) == 1)
618 std::vector<std::pair<std::string,NumericType> > efficiencies;
626 for(
unsigned int p = 0; p < efficiencies.size(); p++)
628 if(verbose)std::cout <<
"\n" << efficiencies[p].first <<
" " << efficiencies[p].second;
630 if(efficiencies[p].first ==
"e-") efficiencies[p].first =
"e";
638 efficiencies[p].second );
641 if(verbose)std::cout << std::endl;
654 NumericType par_value(-1.);
655 std::string par_unit;
656 std::string default_unit;
657 std::vector<std::string> accepted_unit;
662 std::cerr <<
"alpha parameter of Troe falloff missing!" << std::endl;
665 accepted_unit.clear();
666 accepted_unit.push_back(
"");
667 def_unit.set_unit(default_unit);
669 my_fall_rxn->F().set_alpha(par_value * def_unit.get_SI_factor());
674 std::cerr <<
"T*** parameter of Troe falloff missing!" << std::endl;
677 accepted_unit.clear();
678 accepted_unit.push_back(
"K");
679 def_unit.set_unit(default_unit);
681 my_fall_rxn->F().set_T3(par_value * def_unit.get_SI_factor());
686 std::cerr <<
"T* parameter of Troe falloff missing!" << std::endl;
690 def_unit.set_unit(default_unit);
692 my_fall_rxn->F().set_T1(par_value * def_unit.get_SI_factor());
697 def_unit.set_unit(default_unit);
699 my_fall_rxn->F().set_T2(par_value * def_unit.get_SI_factor());
705 if(verbose) std::cout <<
"\n\n";
bool is_united() const
Test if the unit is non empty.
#define antioch_assert(asserted)
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())
virtual const std::string reaction_kinetics_model(const std::vector< std::string > &) const
A single reaction mechanism.
#define antioch_unit_required(parameter, defaultunit)
const std::string get_symbol() const
String symbol getter.
virtual bool Troe_T1_parameter(NumericType &, std::string &, std::string &) const
#define antioch_not_implemented()
This class encapsulates all the reaction mechanisms considered in a chemical nonequilibrium simulatio...
const std::string & equation() const
base class for kinetics models
#define antioch_assert_equal_to(expr1, expr2)
virtual const std::string reaction_chemical_process() const
virtual bool rate_constant_lambda_parameter(std::vector< NumericType > &, std::string &, std::string &) const
virtual const std::map< std::string, NumericType > reactants_orders() const
return a map between reactants' name and found partial orders
virtual bool initialize()=0
void set_id(const std::string &id)
set the reaction id.
#define antioch_parameter_required(parameter, defaultpar)
virtual bool rate_constant_Berthelot_coefficient_parameter(NumericType &, std::string &, std::string &) const
virtual bool Troe_T2_parameter(NumericType &, std::string &, std::string &) const
virtual bool rate_constant_activation_energy_parameter(NumericType &, std::string &, std::string &) const
virtual bool rate_constant_power_parameter(NumericType &, std::string &, std::string &) const
ANTIOCH_READ_REACTION_SET_DATA_INSTANTIATE()
virtual unsigned int where_is_k0(const std::string &) const
void set_unit(const std::string &sym, std::string na)
Units setter, sets the unit to the given symbol and name.
virtual const std::map< std::string, NumericType > products_orders() const
return a map between products' name and found partial orders
virtual bool rate_constant_preexponential_parameter(NumericType &, std::string &, std::string &) const
Base class for falloff processes.
virtual bool Troe_T3_parameter(NumericType &, std::string &, std::string &) const
T get_SI_factor() const
Multiplicative coefficient getter.
virtual bool rate_constant_Tref_parameter(NumericType &, std::string &, std::string &) const
#define antioch_unit_error(description)
unsigned int n_rate_constants() const
Return the number of rate constant objects.
virtual bool Troe() const
const std::map< std::string, Species > & species_name_map() const
virtual bool reactants_pairs(std::vector< std::pair< std::string, int > > &) const
T factor_to_some_unit(const Units< T > &target) const
Calculates the factor to any given unit.
virtual const std::string reaction_id() const
void add_forward_rate(KineticsType< CoeffType, VectorCoeffType > *rate)
Add a forward rate object.
virtual bool rate_constant(const std::string &)
go to next rate constant
unsigned int n_species() const
Returns the number of species in this mixture.
virtual const std::string reaction_equation() const
const ChemicalMixture< CoeffType > & chemical_mixture() const
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())
void clear()
Clear the unit.
Nothing is stored, this parser is based on the tinyxml2 implementation.
virtual bool efficiencies(std::vector< std::pair< std::string, NumericType > > &) const
#define antioch_parsing_error(description)
bool is_homogeneous(const Units< T > &rhs) const
Homogenity testing with another Units.
Class storing chemical mixture properties.
ReactionType::ReactionType type() const
Type of reaction.
void read_reaction_set_data(const std::string &filename, const bool verbose, ReactionSet< NumericType > &reaction_set, ParsingType type=ASCII)
The parameters are reduced parameters.
virtual bool verify_Kooij_in_place_of_Arrhenius() const
#define antioch_do_once(do_this)
virtual bool Troe_alpha_parameter(NumericType &, std::string &, std::string &) const
virtual bool rate_constant_cross_section_parameter(std::vector< NumericType > &, std::string &, std::string &) const
virtual bool reaction_reversible() const
virtual bool reaction()
reaction
void set_efficiency(const std::string &, const unsigned int s, const CoeffType efficiency)
virtual bool products_pairs(std::vector< std::pair< std::string, int > > &) const
void add_reaction(Reaction< CoeffType > *reaction)
Add a reaction to the system.
A parser is an instance related to a file.
void swap_forward_rates(unsigned int irate, unsigned int jrate)
Swap two forward rates object.
void verify_unit_of_parameter(Units< NumericType > &default_unit, const std::string &provided_unit, const std::vector< std::string > &accepted_unit, const std::string &equation, const std::string ¶meter_name)
void substract(const Units< T > &rhs)
Alternative call to Units& operator-=(const Units &)
We parse the file here, with an exhaustive unit management.
ChemKin format file reader.
virtual bool is_k0(unsigned int, const std::string &) const