PRISM
 v0.0.0
Loading...
Searching...
No Matches
Reaction.h
1#pragma once
2
3#include <utility>
4#include <string>
5#include <vector>
6#include <unordered_map>
7#include "yaml-cpp/yaml.h"
8#include "Species.h"
9#include "Constants.h"
10
11namespace prism
12{
18{
20 double energy;
22 double value;
23
29 bool operator<(const TabulatedReactionData & other) const { return energy < other.energy; }
35 bool operator<(const double other) const { return energy < other; }
40 bool operator==(const TabulatedReactionData & other) const
41 {
42 return (energy == other.energy) && (value == other.value);
43 }
44};
45
51{
53 SpeciesId id;
55 unsigned int occurances;
56};
57
63{
64public:
86 Reaction(const YAML::Node & rxn_input,
87 const int rxn_id = 0,
88 const std::string & data_path = "",
89 const std::string & bib_file = "",
90 const bool check_refs = true,
91 const bool read_xsec_files = true,
92 const std::string & delimiter = " ");
93
97 const std::string & expression() const { return _expression; }
101 const std::string & latexRepresentation() const { return _latex_expression; }
109 ReactionId id() const { return _id; }
113 const std::vector<std::string> & references() const { return _references; }
117 const std::vector<std::string> & notes() const { return _notes; }
121 bool hasTabulatedData() const { return _has_tabulated_data; }
125 double deltaEnergyElectron() const { return _delta_eps_e; }
129 double deltaEnergyGas() const { return _delta_eps_g; }
133 const std::vector<SpeciesData> & reactantData() const { return _reactant_data; }
137 const std::vector<SpeciesData> & productData() const { return _product_data; }
141 bool isElastic() const { return _is_elastic; }
146 const std::vector<std::shared_ptr<const Species>> species() const;
150 const std::string getReferencesAsString() const;
156 const std::vector<double> & functionParams() const;
162 const std::vector<TabulatedReactionData> & tabulatedData() const;
171 int getStoicCoeffByName(const std::string & s_expression) const;
179 int getStoicCoeffById(const SpeciesId id) const;
184 bool operator==(const Reaction & other) const;
186 bool operator!=(const Reaction & other) const;
196 double sampleData(const double T_e, const double T_g = 0) const { return _sampler(T_e, T_g); }
197
198private:
200 friend class SpeciesFactory;
201 friend class NetworkParser;
206 std::string checkExpression(const YAML::Node & rxn_input);
207
212 unsigned int getCoeff(std::string & s);
213
218 void setSides();
220 void validateReaction();
222 void setLatexRepresentation();
224 void substituteLumped();
226 void checkReferences();
228 void collectUniqueSpecies();
230 void setSpeciesData();
236 double interpolator(const double T_e, const double T_g) const;
238 double constantRate(const double T_e, const double T_g) const;
239 double partialArrhenius1(const double T_e, const double T_g) const;
240 double partialArrhenius2(const double T_e, const double T_g) const;
241 double partialArrhenius3(const double T_e, const double T_g) const;
242 double fullArrhenius(const double T_e, const double T_g) const;
244 std::function<double(double, double)> _sampler;
246 const ReactionId _id;
248 const std::string _data_path;
250 const std::string _expression;
252 const double _delta_eps_e;
254 const double _delta_eps_g;
256 const bool _is_elastic;
258 const std::string _bib_file;
260 const std::vector<std::string> _references;
262 bool _has_tabulated_data;
264 std::vector<std::string> _notes;
266 std::vector<double> _params;
268 std::vector<TabulatedReactionData> _tabulated_data;
270 std::vector<std::weak_ptr<Species>> _species;
272 std::unordered_map<std::string, int> _stoic_coeffs;
274 std::unordered_map<SpeciesId, int> _id_stoic_map;
276 std::string _latex_expression;
277
281 std::vector<std::weak_ptr<Species>> _reactants;
282 std::vector<std::weak_ptr<Species>> _products;
283 std::unordered_map<std::string, unsigned int> _reactant_count;
284 std::unordered_map<std::string, unsigned int> _product_count;
291 std::vector<SpeciesData> _reactant_data;
292 std::vector<SpeciesData> _product_data;
294};
295}
296
297template <>
298struct std::hash<prism::Reaction>
299{
307 size_t operator()(const prism::Reaction & obj) const;
308};
This is the class that processes reaction networks and allows for interaction with the data contained...
Definition NetworkParser.h:24
Stores all of the data needed to perform calculations with a specific reaction.
Definition Reaction.h:63
double deltaEnergyElectron() const
Self descriptive getter method.
Definition Reaction.h:125
const std::vector< std::shared_ptr< const Species > > species() const
Getter method for the list of species in this reaction this is a relatively expensive method and call...
Definition Reaction.C:185
const std::string getReferencesAsString() const
Getter method for getting cite keys formatted for LaTeX.
Definition Reaction.C:671
bool hasTabulatedData() const
Self descriptive getter method.
Definition Reaction.h:121
const std::string & latexRepresentation() const
Self descriptive getter method.
Definition Reaction.h:101
Reaction(const YAML::Node &rxn_input, const int rxn_id=0, const std::string &data_path="", const std::string &bib_file="", const bool check_refs=true, const bool read_xsec_files=true, const std::string &delimiter=" ")
Definition Reaction.C:19
bool operator!=(const Reaction &other) const
returns not == operator overload
Definition Reaction.C:665
const std::string & expression() const
Self descriptive getter method.
Definition Reaction.h:97
const std::vector< std::string > & references() const
Self descriptive getter method.
Definition Reaction.h:113
bool operator==(const Reaction &other) const
equality operator override and compares the reaction name the latex name of the reaction and the reac...
Definition Reaction.C:650
const std::vector< TabulatedReactionData > & tabulatedData() const
Retrurns a reference to the struct containing data read from a file.
Definition Reaction.C:640
const std::vector< SpeciesData > & reactantData() const
Self descriptive getter method.
Definition Reaction.h:133
int getStoicCoeffById(const SpeciesId id) const
Get the stoiciometric coefficient for a species in this reaction by its id.
Definition Reaction.C:691
double deltaEnergyGas() const
Self descriptive getter method.
Definition Reaction.h:129
bool isElastic() const
Wether or not the user set a reaction as elastic or not.
Definition Reaction.h:141
const std::vector< SpeciesData > & productData() const
Self descriptive getter method.
Definition Reaction.h:137
int getStoicCoeffByName(const std::string &s_expression) const
Get the stoiciometric coefficient for a species in this reaction by the name that represents it Ex: "...
Definition Reaction.C:680
double sampleData(const double T_e, const double T_g=0) const
Samples data at the point T_e and T_g based on the provided parameters If the reaction object has tab...
Definition Reaction.h:196
const std::vector< double > & functionParams() const
Returns a reference to the function parameters if there is functional data.
Definition Reaction.C:630
const std::vector< std::string > & notes() const
Self descriptive getter method.
Definition Reaction.h:117
ReactionId id() const
Self descriptive getter method note that Reactions ids are based on the block reactions are in all re...
Definition Reaction.h:109
This factory creates and stores, and passes around all of the species that exist in a reaction mechan...
Definition SpeciesFactory.h:21
Struct for quickly accessing data about which speies are in a reaction.
Definition Reaction.h:51
SpeciesId id
the unique id for the species (guaranteed to be in the range 0-(n-1) where n in the number unique spe...
Definition Reaction.h:53
unsigned int occurances
the number of times the species occurs on a side of the reaction
Definition Reaction.h:55
Struct for holding tabulated data read from user provided files.
Definition Reaction.h:18
bool operator<(const double other) const
< operator only compares the energy values this is used for sorting and to be able to use other stand...
Definition Reaction.h:35
double value
where the data from the secdon column of the file is stored
Definition Reaction.h:22
bool operator<(const TabulatedReactionData &other) const
< operator only compares the energy values this is used for sorting and to be able to use other stand...
Definition Reaction.h:29
double energy
where the data from the first column of the file is stored
Definition Reaction.h:20
bool operator==(const TabulatedReactionData &other) const
equality operator checks to make sure both values are in the struct are the same
Definition Reaction.h:40
size_t operator()(const prism::Reaction &obj) const
Override for the hash method hash is based on std::string representation of the reaction the reaction...