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, SpeciesSummaryWriterBase & writer) const;
131 std::vector<std::shared_ptr<Species>> _species;
133 std::unordered_map<std::string, SpeciesId> _species_indicies;
136 std::vector<std::string> _species_names;
139 std::vector<std::shared_ptr<const Species>> _transient_species;
141 std::map<std::string, std::string> _lumped_map;
143 std::set<std::string> _constant_species;
145 std::unordered_map<std::string, std::string> _latex_overrides;
148 std::unordered_map<std::string, double> _default_masses = {{"hnu", 0.0},
149 {"M", 1},
150 {"e", 5.4857990943E-4},
151 {"E", 5.4857990943E-4},
152 {"H", 1.00794},
153 {"D", 2.014102},
154 {"T", 3.01604928},
155 {"He", 4.002602},
156 {"Li", 6.941},
157 {"Be", 9.012182},
158 {"B", 10.811},
159 {"C", 12.0107},
160 {"N", 14.0067},
161 {"O", 15.9994},
162 {"F", 18.9984032},
163 {"Ne", 20.1797},
164 {"Na", 22.98976928},
165 {"Mg", 24.3050},
166 {"Al", 26.9815386},
167 {"Si", 28.0855},
168 {"P", 30.973762},
169 {"S", 32.065},
170 {"Cl", 35.453},
171 {"Ar", 39.948},
172 {"K", 39.0983},
173 {"Ca", 40.078},
174 {"Sc", 44.955912},
175 {"Ti", 47.867},
176 {"V", 50.9415},
177 {"Cr", 51.9961},
178 {"Mn", 54.938045},
179 {"Fe", 55.845},
180 {"Co", 58.933195},
181 {"Ni", 58.6934},
182 {"Cu", 63.546},
183 {"Zn", 65.409},
184 {"Ga", 69.723},
185 {"Ge", 72.64},
186 {"As", 74.92160},
187 {"Se", 78.96},
188 {"Br", 79.904},
189 {"Kr", 83.798},
190 {"Rb", 85.4678},
191 {"Sr", 87.62},
192 {"Y", 88.90585},
193 {"Zr", 91.224},
194 {"Nb", 92.90638},
195 {"Mo", 95.94},
196 {"Tc", 98},
197 {"Ru", 101.07},
198 {"Rh", 102.90550},
199 {"Pd", 106.42},
200 {"Ag", 107.8682},
201 {"Cd", 112.411},
202 {"In", 114.818},
203 {"Sn", 118.710},
204 {"Sb", 121.760},
205 {"Te", 126.90447},
206 {"I", 126.90447},
207 {"Xe", 131.293},
208 {"Cs", 132.9054519},
209 {"Ba", 137.327},
210 {"La", 138.90547},
211 {"Hf", 178.89},
212 {"Ta", 180.94788},
213 {"W", 183.84},
214 {"Re", 186.207},
215 {"Os", 190.23},
216 {"Ir", 192.217},
217 {"Pt", 195.084},
218 {"Au", 196.966569},
219 {"Hg", 200.59},
220 {"Ti", 204.3833},
221 {"Pb", 207.2},
222 {"Bi", 208.98040},
223 {"Po", 209},
224 {"At", 210},
225 {"Rn", 222},
226 {"Fr", 223},
227 {"Ra", 226},
228 {"Ac", 227},
229 {"Rf", 267},
230 {"Db", 268.12567},
231 {"Sg", 271.13393},
232 {"Bh", 272.13826},
233 {"Hs", 270.13429},
234 {"Mt", 276.15159},
235 {"Ds", 281.16451},
236 {"Rg", 280.16514},
237 {"Cn", 285.17712},
238 // Lanthoids
239 {"Ce", 140.116},
240 {"Pr", 140.90765},
241 {"Nd", 144.242},
242 {"Pm", 145},
243 {"Sm", 150.36},
244 {"Eu", 151.964},
245 {"Gs", 157.25},
246 {"Tb", 158.92535},
247 {"Dy", 162.500},
248 {"Ho", 164.93032},
249 {"Er", 167.259},
250 {"Tm", 168.93421},
251 {"Yb", 173.04},
252 {"Lu", 174.967},
253 // Actinoids
254 {"Th", 232.02806},
255 {"Pa", 231.03588},
256 {"U", 238.02891},
257 {"Np", 237},
258 {"Pu", 244},
259 {"Am", 241.0568293},
260 {"Cm", 243.0613893},
261 {"Bk", 247.0703073},
262 {"Cf", 249.0748539},
263 {"Es", 252.082980},
264 {"Fm", 257.0951061},
265 {"Md", 28.0984315},
266 {"No", 259.10103},
267 {"Lr", 262.10961}};
269 std::unordered_map<std::string, double> _base_masses = _default_masses;
270};
271
272}
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:23