rizer.cantera_ext
C++ Cantera 1-D plasma extension (custom Domain1D models and solvers)
Toggle main menu visibility
Loading...
Searching...
No Matches
ElectronReactions.cpp
Go to the documentation of this file.
1
#include "
kinetics/ElectronReactions.h
"
2
3
#include "
cantera/kinetics/Kinetics.h
"
4
#include "
cantera/kinetics/Reaction.h
"
5
6
#include <sstream>
7
#include <stdexcept>
8
#include <string>
9
10
namespace
rizer
11
{
12
13
// ------------------------------------------------------------------------------ //
14
// Free functions //
15
// ------------------------------------------------------------------------------ //
16
17
bool
equationHasElectron
(
const
std::string &equation,
18
const
std::string &electron)
19
{
20
std::string s = equation;
21
for
(
char
&ch : s)
22
{
23
if
(ch ==
'+'
|| ch ==
'='
|| ch ==
'<'
|| ch ==
'>'
)
24
ch =
' '
;
25
}
26
std::istringstream iss(s);
27
std::string token;
28
while
(iss >> token)
29
{
30
if
(token == electron)
31
return
true
;
32
}
33
return
false
;
34
}
35
36
ElectronReactionIndex
buildElectronReactionIndex
(
37
Cantera::Kinetics
&kinetics,
const
std::string &electron,
38
const
std::vector<double> &species_h0k, std::size_t n_species,
39
bool
reacting)
40
{
41
const
std::size_t n_reactions = kinetics.
nReactions
();
42
ElectronReactionIndex
index;
43
index.
is_electron_reaction
.assign(n_reactions, 0);
44
index.
threshold_energy
.assign(n_reactions, 0.0);
45
46
// Selected exactly as the Python reference selects them: the electron
47
// participates iff it appears in the equation. That covers
48
// two-temperature-plasma, three-body-two-temperature-plasma,
49
// reverse-two-temperature-plasma, Druyvesteyn and janev-* reactions,
50
// including the ones carrying a spectator electron.
51
for
(std::size_t i = 0; i < n_reactions; i++)
52
{
53
if
(
equationHasElectron
(kinetics.
reaction
(i)->equation(), electron))
54
{
55
index.
is_electron_reaction
[i] = 1;
56
index.
any_electron_reaction
=
true
;
57
}
58
}
59
60
if
(!(reacting && index.
any_electron_reaction
))
61
{
62
return
index;
63
}
64
65
// Fixed per-reaction threshold energy, eps_th_i = sum_k nu_ki H_k(0 K),
66
// from the caller's per-species formation enthalpies. Mirrors
67
// rizer.kinetics.electron_reactions.ElectronicReactionEnergetics.
68
if
(species_h0k.empty())
69
{
70
throw
std::invalid_argument(
71
"buildElectronReactionIndex: species_h0k is required (the "
72
"mechanism has an electron-impact reaction and chemistry is "
73
"live)."
);
74
}
75
if
(species_h0k.size() != n_species)
76
{
77
throw
std::invalid_argument(
78
"buildElectronReactionIndex: species_h0k has "
+
79
std::to_string(species_h0k.size()) +
" entries, expected "
+
80
std::to_string(n_species) +
"."
);
81
}
82
kinetics.
getReactionDelta
(
83
Cantera::span<const double>
(species_h0k.data(), n_species),
84
Cantera::span<double>
(index.
threshold_energy
.data(),
85
index.
threshold_energy
.size()));
86
return
index;
87
}
88
89
}
// namespace rizer
ElectronReactions.h
Which reactions of a mechanism the electron takes part in, and what each of them costs the electron p...
Kinetics.h
Reaction.h
Cantera::Kinetics
Cantera::Kinetics::reaction
shared_ptr< Reaction > reaction(size_t i)
Cantera::Kinetics::nReactions
size_t nReactions() const
Cantera::Kinetics::getReactionDelta
virtual void getReactionDelta(span< const double > property, span< double > deltaProperty) const
Cantera::span
rizer
Definition
ElectronReactions.cpp:11
rizer::buildElectronReactionIndex
ElectronReactionIndex buildElectronReactionIndex(Cantera::Kinetics &kinetics, const std::string &electron, const std::vector< double > &species_h0k, std::size_t n_species, bool reacting)
Build the index for one mechanism.
Definition
ElectronReactions.cpp:36
rizer::equationHasElectron
bool equationHasElectron(const std::string &equation, const std::string &electron)
Test whether the electron participates in a reaction equation as a standalone token.
Definition
ElectronReactions.cpp:17
rizer::ElectronReactionIndex
The per-reaction data the electron pool's inelastic power needs.
Definition
ElectronReactions.h:47
rizer::ElectronReactionIndex::any_electron_reaction
bool any_electron_reaction
Whether any reaction at all involves the electron [-].
Definition
ElectronReactions.h:57
rizer::ElectronReactionIndex::threshold_energy
std::vector< double > threshold_energy
Threshold energy [J/kmol], length nReactions(), zero where no electron takes part.
Definition
ElectronReactions.h:55
rizer::ElectronReactionIndex::is_electron_reaction
std::vector< char > is_electron_reaction
1 where the electron participates, 0 elsewhere, length nReactions().
Definition
ElectronReactions.h:51
rizer
cantera_ext
kinetics
ElectronReactions.cpp
Generated by
1.18.0