PRISM
 v0.0.0
Loading...
Searching...
No Matches
SpeciesFactory.h
1#pragma once
2#include <map>
3#include <string>
4#include <unordered_map>
5
6#include "yaml-cpp/yaml.h"
7
8#include "Species.h"
9#include "Constants.h"
10
11namespace prism
12{
13class Reaction;
14class SpeciesSummaryWriterBase;
21{
22#ifndef TESTING
23private:
24#else
25public:
26#endif
28 static SpeciesFactory & instance();
30 void clear();
31 // if we are in testing mode we'll give other people access to these
32 // otherwise we want them to be private
33 void collectCustomSpecies(const YAML::Node & network);
34 void collectLumpedSpecies(const YAML::Node & network);
35 void collectLatexOverrides(const YAML::Node & network);
42 double getMass(const std::string & name) const;
43#ifdef TESTING
44private:
45#endif
47 friend class NetworkParser;
48 friend class SubSpecies;
49 friend class Reaction;
50
56 const std::string getLatexOverride(const std::string & name) const;
57
67 std::weak_ptr<Species> getSpecies(const std::string & name);
68 // /**
69 // *
70 // */
71 const std::vector<std::shared_ptr<Species>> & species() const { return _species; }
72 const std::vector<std::shared_ptr<const Species>> & transientSpecies() const
73 {
74 return _transient_species;
75 }
76
77 const std::vector<std::string> & speciesNames() const { return _species_names; }
84 std::weak_ptr<Species> getLumpedSpecies(std::weak_ptr<Species> s);
90 void indexSpecies();
91
97 void addRateBasedReaction(std::shared_ptr<const Reaction> r);
103 void addXSecBasedReaction(std::shared_ptr<const Reaction> r);
104
107 SpeciesFactory();
108 // Private copy constructor and assignment operator to prevent cloning
109 SpeciesFactory(const SpeciesFactory &) = delete;
110 SpeciesFactory & operator=(const SpeciesFactory &) = delete;
111 // Private instance of the singleton
112 static SpeciesFactory * _instance;
115
118 void writeSpeciesSummary(const std::string & file, SpeciesSummaryWriterBase & writer) const;
120 std::vector<std::shared_ptr<Species>> _species;
122 std::unordered_map<std::string, SpeciesId> _species_indicies;
125 std::vector<std::string> _species_names;
128 std::vector<std::shared_ptr<const Species>> _transient_species;
130 std::map<std::string, std::string> _lumped_map;
132 std::unordered_map<std::string, std::string> _latex_overrides;
135 std::unordered_map<std::string, double> _default_masses = {{"hnu", 0.0},
136 {"M", 1},
137 {"e", 5.4857990943E-4},
138 {"E", 5.4857990943E-4},
139 {"H", 1.00794},
140 {"D", 2.014102},
141 {"T", 3.01604928},
142 {"He", 4.002602},
143 {"Li", 6.941},
144 {"Be", 9.012182},
145 {"B", 10.811},
146 {"C", 12.0107},
147 {"N", 14.0067},
148 {"O", 15.9994},
149 {"F", 18.9984032},
150 {"Ne", 20.1797},
151 {"Na", 22.98976928},
152 {"Mg", 24.3050},
153 {"Al", 26.9815386},
154 {"Si", 28.0855},
155 {"P", 30.973762},
156 {"S", 32.065},
157 {"Cl", 35.453},
158 {"Ar", 39.948},
159 {"K", 39.0983},
160 {"Ca", 40.078},
161 {"Sc", 44.955912},
162 {"Ti", 47.867},
163 {"V", 50.9415},
164 {"Cr", 51.9961},
165 {"Mn", 54.938045},
166 {"Fe", 55.845},
167 {"Co", 58.933195},
168 {"Ni", 58.6934},
169 {"Cu", 63.546},
170 {"Zn", 65.409},
171 {"Ga", 69.723},
172 {"Ge", 72.64},
173 {"As", 74.92160},
174 {"Se", 78.96},
175 {"Br", 79.904},
176 {"Kr", 83.798},
177 {"Rb", 85.4678},
178 {"Sr", 87.62},
179 {"Y", 88.90585},
180 {"Zr", 91.224},
181 {"Nb", 92.90638},
182 {"Mo", 95.94},
183 {"Tc", 98},
184 {"Ru", 101.07},
185 {"Rh", 102.90550},
186 {"Pd", 106.42},
187 {"Ag", 107.8682},
188 {"Cd", 112.411},
189 {"In", 114.818},
190 {"Sn", 118.710},
191 {"Sb", 121.760},
192 {"Te", 126.90447},
193 {"I", 126.90447},
194 {"Xe", 131.293},
195 {"Cs", 132.9054519},
196 {"Ba", 137.327},
197 {"La", 138.90547},
198 {"Hf", 178.89},
199 {"Ta", 180.94788},
200 {"W", 183.84},
201 {"Re", 186.207},
202 {"Os", 190.23},
203 {"Ir", 192.217},
204 {"Pt", 195.084},
205 {"Au", 196.966569},
206 {"Hg", 200.59},
207 {"Ti", 204.3833},
208 {"Pb", 207.2},
209 {"Bi", 208.98040},
210 {"Po", 209},
211 {"At", 210},
212 {"Rn", 222},
213 {"Fr", 223},
214 {"Ra", 226},
215 {"Ac", 227},
216 {"Rf", 267},
217 {"Db", 268.12567},
218 {"Sg", 271.13393},
219 {"Bh", 272.13826},
220 {"Hs", 270.13429},
221 {"Mt", 276.15159},
222 {"Ds", 281.16451},
223 {"Rg", 280.16514},
224 {"Cn", 285.17712},
225 // Lanthoids
226 {"Ce", 140.116},
227 {"Pr", 140.90765},
228 {"Nd", 144.242},
229 {"Pm", 145},
230 {"Sm", 150.36},
231 {"Eu", 151.964},
232 {"Gs", 157.25},
233 {"Tb", 158.92535},
234 {"Dy", 162.500},
235 {"Ho", 164.93032},
236 {"Er", 167.259},
237 {"Tm", 168.93421},
238 {"Yb", 173.04},
239 {"Lu", 174.967},
240 // Actinoids
241 {"Th", 232.02806},
242 {"Pa", 231.03588},
243 {"U", 238.02891},
244 {"Np", 237},
245 {"Pu", 244},
246 {"Am", 241.0568293},
247 {"Cm", 243.0613893},
248 {"Bk", 247.0703073},
249 {"Cf", 249.0748539},
250 {"Es", 252.082980},
251 {"Fm", 257.0951061},
252 {"Md", 28.0984315},
253 {"No", 259.10103},
254 {"Lr", 262.10961}};
256 std::unordered_map<std::string, double> _base_masses = _default_masses;
257};
258
259}
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
This factory creates and stores, and passes around all of the species that exist in a reaction mechan...
Definition SpeciesFactory.h:21
The parts with a Species can be brokenup into Eg Speices: NH3, SubSpecies: [N, H3].
Definition SubSpecies.h:16