PRISM
 v0.0.0
Loading...
Searching...
No Matches
NetworkParser.h
1//* This file is a part of PRISM: Plasma Reaction Input SysteM,
2//* A library for parcing chemical reaction networks for plasma chemistry
3//* https://github.com/NCSU-ComPS-Group/prism
4//*
5//* Licensed under MIT, please see LICENSE for details
6//* https://opensource.org/license/mit
7//*
8//* Copyright 2024, North Carolina State University
9//* ALL RIGHTS RESERVED
10//*
11#pragma once
12
13#include "PrismConstants.h"
14
15#include <vector>
16#include <string>
17#include <unordered_map>
18#include "yaml-cpp/yaml.h"
19namespace prism
20{
21
22class Reaction;
23class Species;
24class SpeciesFactory;
25class BibTexHelper;
26class TableWriterBase;
28
34{
35public:
44 void parseNetwork(const std::string & file);
45
46// These methods are only available in testing mode
47// this allows for easier unit testing and should never
48// be made available for end users
49#ifdef TESTING
50 void setCheckRefs(const bool check_refs) { _check_refs = check_refs; }
51 void setReadXsecFiles(const bool read_xsec_files) { _read_xsec_files = read_xsec_files; }
52#endif
53
54 // Various getter methods for the different categories of reactions
55 // note these methods will exit the program if you have any errors in your reaction network
56 // we do not let users to perform a simulation with errors in the network or with lack of
57 // documentation
65 const std::vector<std::shared_ptr<Reaction>> & rateBasedReactions() const
66 {
67 preventInvalidDataFetch();
68 return _rate_based;
69 }
70
77 const std::vector<std::shared_ptr<Reaction>> & xsecBasedReactions() const
78 {
79 preventInvalidDataFetch();
80 return _xsec_based;
81 }
82
89 const std::vector<std::shared_ptr<const Reaction>> & tabulatedXSecReactions() const
90 {
91 preventInvalidDataFetch();
92 return _tabulated_xsec_based;
93 }
94
101 const std::vector<std::shared_ptr<const Reaction>> & functionXSecReactions() const
102 {
103 preventInvalidDataFetch();
104 return _function_xsec_based;
105 }
106
113 const std::vector<std::shared_ptr<const Reaction>> & tabulatedRateReactions() const
114 {
115 preventInvalidDataFetch();
116 return _tabulated_rate_based;
117 }
118
125 const std::vector<std::shared_ptr<const Reaction>> & functionRateReactions() const
126 {
127 preventInvalidDataFetch();
128 return _function_rate_based;
129 }
130
137 const std::vector<std::shared_ptr<const Species>> & transientSpecies() const;
145 const std::vector<std::string> & speciesNames() const;
146
154 const std::vector<std::shared_ptr<Species>> & species() const;
155
161 void writeReactionTable(const std::string & file) const;
167 void writeReactionTable(const std::string & file, TableWriterBase & writer) const;
174 void writeSpeciesSummary(const std::string & file) const;
181 void writeSpeciesSummary(const std::string & file, SpeciesSummaryWriterBase & writer) const;
182
183private:
184 SpeciesFactory & _factory;
185 BibTexHelper & _bib_helper;
187 bool _network_has_errors;
189 bool _network_has_bib_errors;
192 bool _check_refs;
195 bool _read_xsec_files;
197 std::unordered_map<std::string, YAML::Node> _networks;
199 std::unordered_map<std::string, std::string> _bibs;
201 std::unordered_map<std::string, std::string> _data_paths;
203 std::unordered_map<std::string, std::string> _delimiters;
204 ReactionId _rate_id;
205 ReactionId _xsec_id;
213 void checkFile(const std::string & file) const;
220 void checkBibFile(const YAML::Node & network, const std::string & file) const;
221
234 void parseReactions(const YAML::Node & inputs,
235 ReactionId * rxn_id,
236 std::vector<std::shared_ptr<Reaction>> * rxn_list,
237 std::vector<std::shared_ptr<const Reaction>> * tabulated_rxn_list,
238 std::vector<std::shared_ptr<const Reaction>> * function_rxn_list,
239 const std::string & type,
240 const std::string & data_path,
241 const std::string & bib_file,
242 const std::string & _delimiter);
243
244 void tableHelper(TableWriterBase & writer,
245 void (TableWriterBase::*beginTable)(),
246 void (TableWriterBase::*endTable)(),
247 void (TableWriterBase::*addReaction)(const std::shared_ptr<const Reaction> & r),
248 const std::vector<std::shared_ptr<const Reaction>> & rxn_list) const;
255 void preventInvalidDataFetch() const;
256
260 std::vector<std::shared_ptr<Reaction>> _rate_based;
261 std::vector<std::shared_ptr<const Reaction>> _tabulated_rate_based;
262 std::vector<std::shared_ptr<const Reaction>> _function_rate_based;
263 std::vector<std::shared_ptr<Reaction>> _xsec_based;
264 std::vector<std::shared_ptr<const Reaction>> _tabulated_xsec_based;
265 std::vector<std::shared_ptr<const Reaction>> _function_xsec_based;
267};
268}
Class for collecting and managing cite keys from the user provided bib files.
Definition BibTexHelper.h:24
const std::vector< std::shared_ptr< Species > > & species() const
Gets all of the species in the network This function will also exist the program if there are any err...
Definition NetworkParser.C:328
void parseNetwork(const std::string &file)
Method goes through all of the reactions in this network constructs Reaction objects and then puts th...
Definition NetworkParser.C:124
void writeReactionTable(const std::string &file, TableWriterBase &writer) const
Writes the latex table representation of the reaction mechanism this method uses whatever custom tabl...
const std::vector< std::shared_ptr< Reaction > > & xsecBasedReactions() const
Gets all of the reactions in the xsec-based block that have cross section data in a file.
Definition NetworkParser.h:77
const std::vector< std::shared_ptr< const Reaction > > & functionXSecReactions() const
Gets all of the reactions in the xsec-based block that have cross section that can be represented wit...
Definition NetworkParser.h:101
void writeSpeciesSummary(const std::string &file) const
Writes a summary of the species in the network to a file this method uses whatever custom summary wri...
const std::vector< std::shared_ptr< const Reaction > > & tabulatedXSecReactions() const
Gets all of the reactions in the xsec-based block that have cross section data in a file.
Definition NetworkParser.h:89
void writeSpeciesSummary(const std::string &file, SpeciesSummaryWriterBase &writer) const
Writes a summary of the species in the network to a file this method uses whatever custom summary wri...
const std::vector< std::shared_ptr< const Reaction > > & functionRateReactions() const
Gets all of the reactions in the xsec-based block that have rate data that can be represented with a ...
Definition NetworkParser.h:125
const std::vector< std::shared_ptr< const Reaction > > & tabulatedRateReactions() const
Gets all of the reactions in the xsec-based block that have rate data in a file.
Definition NetworkParser.h:113
const std::vector< std::shared_ptr< Reaction > > & rateBasedReactions() const
Gets all of the reactions in the xsec-based block that have cross section data in a file.
Definition NetworkParser.h:65
NetworkParser()
constructor was moved to public
Definition NetworkParser.C:32
void writeReactionTable(const std::string &file) const
Writes the latex table representation of the reaction mechanism this method uses the default table wr...
const std::vector< std::string > & speciesNames() const
Gets the names of all of the species in the network This function will also exist the program if ther...
Definition NetworkParser.C:321
const std::vector< std::shared_ptr< const Species > > & transientSpecies() const
Gets all of the species in the network that have a non-zero This function will also exist the program...
Definition NetworkParser.C:335
Stores all of the data needed to perform calculations with a specific reaction.
Definition Reaction.h:73
This factory creates and stores, and passes around all of the species that exist in a reaction mechan...
Definition SpeciesFactory.h:31
Definition SpeciesSummaryWriterBase.h:27
The species object which represents the products and reactants in the reaction.
Definition Species.h:47
Definition TableWriterBase.h:22