PRISM
 v0.0.0
Loading...
Searching...
No Matches
Species.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 "SpeciesBase.h"
14#include "PrismConstants.h"
15
16#include <vector>
17#include <memory>
18
19namespace prism
20{
21
31{
33 ReactionId id;
37};
38
39class Reaction;
40class SubSpecies;
41
46class Species : public SpeciesBase
47{
48public:
53 Species(const std::string & name, const bool marked_constant = false);
58 SpeciesId id() const { return _id; }
59 bool markedConstant() const { return _marked_constant; }
60 bool isConstant() const
61 {
62 return _unbalanced_rate_based_data.size() + _unbalanced_xsec_based_data.size() == 0 ||
63 _marked_constant;
64 }
65
66 // /** Comparison operator checks if the sub species have the same member variables */
67 bool operator==(const Species & other) const;
69 bool operator!=(const Species & other) const;
77 const std::vector<std::shared_ptr<const Reaction>> rateBasedReactions() const
78 {
79 return convertToSharedPtr(_rate_based);
80 }
81
88 const std::vector<std::shared_ptr<const Reaction>> xsecBasedReactions() const
89 {
90 return convertToSharedPtr(_xsec_based);
91 }
92
99 const std::vector<std::shared_ptr<const Reaction>> tabulatedRateBasedReactions() const
100 {
101 return convertToSharedPtr(_tabulated_rate_based);
102 }
103
110 const std::vector<std::shared_ptr<const Reaction>> functionRateBasedReactions() const
111 {
112 return convertToSharedPtr(_function_rate_based);
113 }
114
121 const std::vector<std::shared_ptr<const Reaction>> tabulatedXSecBasedReactions() const
122 {
123 return convertToSharedPtr(_tabulated_xsec_based);
124 }
125
132 const std::vector<std::shared_ptr<const Reaction>> functionXSecBasedReactions() const
133 {
134 return convertToSharedPtr(_function_xsec_based);
135 }
136
140 const std::vector<ReactionData> & rateBasedReactionData() const { return _rate_based_data; }
145 const std::vector<ReactionData> & tabulatedRateBasedReactionData() const
146 {
147 return _tabulated_rate_based_data;
148 }
149
153 const std::vector<ReactionData> & functionRateBasedReactionData() const
154 {
155 return _function_rate_based_data;
156 }
157
161 const std::vector<ReactionData> & xsecBasedReactionData() const { return _xsec_based_data; }
166 const std::vector<ReactionData> & tabulatedXSecBasedReactionData() const
167 {
168 return _tabulated_xsec_based_data;
169 }
170
174 const std::vector<ReactionData> & functionXSecBasedReactionData() const
175 {
176 return _function_xsec_based_data;
177 }
178
184 const std::vector<ReactionData> & unbalancedRateBasedReactionData() const
185 {
186 return _unbalanced_rate_based_data;
187 }
188
194 const std::vector<ReactionData> & unbalancedTabulatedRateBasedReactionData() const
195 {
196 return _unbalanced_tabulated_rate_based_data;
197 }
198
204 const std::vector<ReactionData> & unbalancedFunctionRateBasedReactionData() const
205 {
206 return _unbalanced_function_rate_based_data;
207 }
208
214 const std::vector<ReactionData> & unbalancedXSecBasedReactionData() const
215 {
216 return _unbalanced_xsec_based_data;
217 }
218
224 const std::vector<ReactionData> & unbalancedTabulatedXSecBasedReactionData() const
225 {
226 return _unbalanced_tabulated_xsec_based_data;
227 }
228
234 const std::vector<ReactionData> & unbalancedFunctionXSecBasedReactionData() const
235 {
236 return _unbalanced_function_xsec_based_data;
237 }
238
239 const std::vector<SubSpecies> & subSpecies() const { return _sub_species; }
240
241 virtual std::string to_string() const override;
242 friend std::string to_string(const std::shared_ptr<prism::Species> & s);
243 friend std::string to_string(const std::shared_ptr<const prism::Species> & s);
244 friend std::ostream & operator<<(std::ostream & os, const std::shared_ptr<prism::Species> & s);
245 friend std::ostream & operator<<(std::ostream & os,
246 const std::shared_ptr<const prism::Species> & s);
247
248private:
250 friend class SpeciesFactory;
251 SpeciesId _id;
253 const bool _marked_constant;
255 const std::vector<SubSpecies> _sub_species;
258 std::vector<ReactionData> _rate_based_data;
259 std::vector<ReactionData> _tabulated_rate_based_data;
260 std::vector<ReactionData> _function_rate_based_data;
261 std::vector<ReactionData> _unbalanced_rate_based_data;
262 std::vector<ReactionData> _unbalanced_tabulated_rate_based_data;
263 std::vector<ReactionData> _unbalanced_function_rate_based_data;
264 std::vector<std::weak_ptr<const Reaction>> _rate_based;
265 std::vector<std::weak_ptr<const Reaction>> _tabulated_rate_based;
266 std::vector<std::weak_ptr<const Reaction>> _function_rate_based;
268
270 std::vector<ReactionData> _xsec_based_data;
271 std::vector<ReactionData> _tabulated_xsec_based_data;
272 std::vector<ReactionData> _function_xsec_based_data;
273 std::vector<ReactionData> _unbalanced_xsec_based_data;
274 std::vector<ReactionData> _unbalanced_tabulated_xsec_based_data;
275 std::vector<ReactionData> _unbalanced_function_xsec_based_data;
276 std::vector<std::weak_ptr<const Reaction>> _xsec_based;
277 std::vector<std::weak_ptr<const Reaction>> _tabulated_xsec_based;
278 std::vector<std::weak_ptr<const Reaction>> _function_xsec_based;
280
282 void setLatexName() override;
287 const std::vector<SubSpecies> decomposeSpecies();
289 void setMass() override;
291 void setCharge() override;
293 virtual void setNeutralGroundState() override;
295 const std::vector<std::shared_ptr<const Reaction>>
296 convertToSharedPtr(const std::vector<std::weak_ptr<const Reaction>> & vec) const;
297
298 void setId(SpeciesId id) { _id = id; }
299};
300}
301
302template <>
303struct std::hash<prism::Species>
304{
313 size_t operator()(const prism::Species & obj) const;
314};
Stores all of the data needed to perform calculations with a specific reaction.
Definition Reaction.h:73
const std::string & name() const
Getter method for the name of species.
Definition SpeciesBase.h:33
SpeciesBase(const std::string &name)
Definition SpeciesBase.C:21
The species object which represents the products and reactants in the reaction.
Definition Species.h:47
const std::vector< ReactionData > & tabulatedRateBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:145
Species(const std::string &name, const bool marked_constant=false)
Constructor for the species based on its symbolic representation.
Definition Species.C:23
const std::vector< ReactionData > & xsecBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:161
const std::vector< std::shared_ptr< const Reaction > > functionXSecBasedReactions() const
Getter methods for the reactions of specific types this species is either a product or reactant of Wa...
Definition Species.h:132
const std::vector< ReactionData > & unbalancedTabulatedRateBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:194
const std::vector< std::shared_ptr< const Reaction > > tabulatedXSecBasedReactions() const
Getter methods for the reactions of specific types this species is either a product or reactant of Wa...
Definition Species.h:121
const std::vector< SubSpecies > & subSpecies() const
Getter method for the subspecies list.
Definition Species.h:239
SpeciesId id() const
getter for the unique id for the species
Definition Species.h:58
const std::vector< std::shared_ptr< const Reaction > > rateBasedReactions() const
Getter methods for the reactions of specific types this species is either a product or reactant of Wa...
Definition Species.h:77
const std::vector< ReactionData > & unbalancedFunctionXSecBasedReactionData() const
Getter methods for the reaction data of specific types this species getting the unbalanced data only ...
Definition Species.h:234
const std::vector< ReactionData > & rateBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:140
const std::vector< ReactionData > & unbalancedFunctionRateBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:204
const std::vector< std::shared_ptr< const Reaction > > xsecBasedReactions() const
Getter methods for the reactions of specific types this species is either a product or reactant of Wa...
Definition Species.h:88
const std::vector< ReactionData > & tabulatedXSecBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:166
const std::vector< std::shared_ptr< const Reaction > > functionRateBasedReactions() const
Getter methods for the reactions of specific types this species is either a product or reactant of Wa...
Definition Species.h:110
bool operator!=(const Species &other) const
Comparison for checking whether or not the two are not equal.
Definition Species.C:125
const std::vector< std::shared_ptr< const Reaction > > tabulatedRateBasedReactions() const
Getter methods for the reactions of specific types this species is either a product or reactant of Wa...
Definition Species.h:99
friend class SpeciesFactory
The species factory helps add reactionts to our lists.
Definition Species.h:250
const std::vector< ReactionData > & unbalancedTabulatedXSecBasedReactionData() const
Getter methods for the reaction data of specific types this species getting the unbalanced data only ...
Definition Species.h:224
const std::vector< ReactionData > & functionXSecBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:174
const std::vector< ReactionData > & unbalancedXSecBasedReactionData() const
Getter methods for the reaction data of specific types this species getting the unbalanced data only ...
Definition Species.h:214
bool operator==(const Species &other) const
Comparison operator checks if the sub species have the same member variables.
Definition Species.C:103
const std::vector< ReactionData > & unbalancedRateBasedReactionData() const
Getter methods for the reaction data of specific types this species getting the unbalanced data only ...
Definition Species.h:184
const std::vector< ReactionData > & functionRateBasedReactionData() const
Getter methods for the reaction data of specific types this species.
Definition Species.h:153
The parts with a Species can be brokenup into Eg Speices: NH3, SubSpecies: [N, H3].
Definition SubSpecies.h:26
Struct for a quick way to access which reactions the species is in Since we keep track of rate_based ...
Definition Species.h:31
ReactionId id
the id of a given reaction that this species is a part of
Definition Species.h:33
int stoic_coeff
the species stoichiometry for the species in the reaction with the prescribed if
Definition Species.h:36
size_t operator()(const prism::Species &obj) const
Hash method for species hashing is based on the hash of each subspecies the total mass the charge num...