PRISM
 v0.0.0
Loading...
Searching...
No Matches
SpeciesFactory.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#include <map>
13#include <string>
14#include <unordered_map>
15
16#include "yaml-cpp/yaml.h"
17
18#include "Species.h"
19#include "PrismConstants.h"
20
21namespace prism
22{
23class Reaction;
30class SpeciesFactory
31{
32#ifndef TESTING
33private:
34#else
35public:
36#endif
38 static SpeciesFactory & instance();
40 void clear();
41 // if we are in testing mode we'll give other people access to these
42 // otherwise we want them to be private
43 void collectCustomSpecies(const YAML::Node & network);
44 void collectLumpedSpecies(const YAML::Node & network);
45 void collectLatexOverrides(const YAML::Node & network);
46 void collectConstantSpecies(const YAML::Node & network);
53 double getMass(const std::string & name) const;
54#ifdef TESTING
55private:
56#endif
58 friend class NetworkParser;
59 friend class SubSpecies;
60 friend class Reaction;
61
67 const std::string getLatexOverride(const std::string & name) const;
68
78 std::weak_ptr<Species> getSpecies(const std::string & name);
79 // /**
80 // *
81 // */
82 const std::vector<std::shared_ptr<Species>> & species() const { return _species; }
83 const std::vector<std::shared_ptr<const Species>> & transientSpecies() const
84 {
85 return _transient_species;
86 }
87
88 const std::vector<std::string> & speciesNames() const { return _species_names; }
95 std::weak_ptr<Species> getLumpedSpecies(std::weak_ptr<Species> s);
101 void indexSpecies();
102
108 void addRateBasedReaction(std::shared_ptr<const Reaction> r);
114 void addXSecBasedReaction(std::shared_ptr<const Reaction> r);
115
118 SpeciesFactory();
119 // Private copy constructor and assignment operator to prevent cloning
120 SpeciesFactory(const SpeciesFactory &) = delete;
121 SpeciesFactory & operator=(const SpeciesFactory &) = delete;
122 // Private instance of the singleton
123 static SpeciesFactory * _instance;
126
129 void writeSpeciesSummary(const std::string & file,
130 SpeciesSummaryWriterBase & writer,
131 const std::vector<std::shared_ptr<Reaction>> & rate_based,
132 const std::vector<std::shared_ptr<Reaction>> & xsec_based) const;
134 std::vector<std::shared_ptr<Species>> _species;
136 std::unordered_map<std::string, SpeciesId> _species_indicies;
139 std::vector<std::string> _species_names;
142 std::vector<std::shared_ptr<const Species>> _transient_species;
144 std::map<std::string, std::string> _lumped_map;
146 std::set<std::string> _constant_species;
148 std::unordered_map<std::string, std::string> _latex_overrides;
151 std::unordered_map<std::string, double> _default_masses = {{"hnu", 0.0},
152 {"M", 1},
153 {"e", 5.4857990943E-4},
154 {"E", 5.4857990943E-4},
155 {"H", 1.00794},
156 {"D", 2.014102},
157 {"T", 3.01604928},
158 {"He", 4.002602},
159 {"Li", 6.941},
160 {"Be", 9.012182},
161 {"B", 10.811},
162 {"C", 12.0107},
163 {"N", 14.0067},
164 {"O", 15.9994},
165 {"F", 18.9984032},
166 {"Ne", 20.1797},
167 {"Na", 22.98976928},
168 {"Mg", 24.3050},
169 {"Al", 26.9815386},
170 {"Si", 28.0855},
171 {"P", 30.973762},
172 {"S", 32.065},
173 {"Cl", 35.453},
174 {"Ar", 39.948},
175 {"K", 39.0983},
176 {"Ca", 40.078},
177 {"Sc", 44.955912},
178 {"Ti", 47.867},
179 {"V", 50.9415},
180 {"Cr", 51.9961},
181 {"Mn", 54.938045},
182 {"Fe", 55.845},
183 {"Co", 58.933195},
184 {"Ni", 58.6934},
185 {"Cu", 63.546},
186 {"Zn", 65.409},
187 {"Ga", 69.723},
188 {"Ge", 72.64},
189 {"As", 74.92160},
190 {"Se", 78.96},
191 {"Br", 79.904},
192 {"Kr", 83.798},
193 {"Rb", 85.4678},
194 {"Sr", 87.62},
195 {"Y", 88.90585},
196 {"Zr", 91.224},
197 {"Nb", 92.90638},
198 {"Mo", 95.94},
199 {"Tc", 98},
200 {"Ru", 101.07},
201 {"Rh", 102.90550},
202 {"Pd", 106.42},
203 {"Ag", 107.8682},
204 {"Cd", 112.411},
205 {"In", 114.818},
206 {"Sn", 118.710},
207 {"Sb", 121.760},
208 {"Te", 126.90447},
209 {"I", 126.90447},
210 {"Xe", 131.293},
211 {"Cs", 132.9054519},
212 {"Ba", 137.327},
213 {"La", 138.90547},
214 {"Hf", 178.89},
215 {"Ta", 180.94788},
216 {"W", 183.84},
217 {"Re", 186.207},
218 {"Os", 190.23},
219 {"Ir", 192.217},
220 {"Pt", 195.084},
221 {"Au", 196.966569},
222 {"Hg", 200.59},
223 {"Ti", 204.3833},
224 {"Pb", 207.2},
225 {"Bi", 208.98040},
226 {"Po", 209},
227 {"At", 210},
228 {"Rn", 222},
229 {"Fr", 223},
230 {"Ra", 226},
231 {"Ac", 227},
232 {"Rf", 267},
233 {"Db", 268.12567},
234 {"Sg", 271.13393},
235 {"Bh", 272.13826},
236 {"Hs", 270.13429},
237 {"Mt", 276.15159},
238 {"Ds", 281.16451},
239 {"Rg", 280.16514},
240 {"Cn", 285.17712},
241 // Lanthoids
242 {"Ce", 140.116},
243 {"Pr", 140.90765},
244 {"Nd", 144.242},
245 {"Pm", 145},
246 {"Sm", 150.36},
247 {"Eu", 151.964},
248 {"Gs", 157.25},
249 {"Tb", 158.92535},
250 {"Dy", 162.500},
251 {"Ho", 164.93032},
252 {"Er", 167.259},
253 {"Tm", 168.93421},
254 {"Yb", 173.04},
255 {"Lu", 174.967},
256 // Actinoids
257 {"Th", 232.02806},
258 {"Pa", 231.03588},
259 {"U", 238.02891},
260 {"Np", 237},
261 {"Pu", 244},
262 {"Am", 241.0568293},
263 {"Cm", 243.0613893},
264 {"Bk", 247.0703073},
265 {"Cf", 249.0748539},
266 {"Es", 252.082980},
267 {"Fm", 257.0951061},
268 {"Md", 28.0984315},
269 {"No", 259.10103},
270 {"Lr", 262.10961}};
272 std::unordered_map<std::string, double> _base_masses = _default_masses;
273};
274
275}
Stores all of the data needed to perform calculations with a specific reaction.
Definition Reaction.h:73
friend class NetworkParser
friend class so the parser can call several private methods
Definition SpeciesFactory.h:58
Definition SpeciesSummaryWriterBase.h:27