Cantera  3.1.0a4
Loading...
Searching...
No Matches
ElectronCollisionPlasmaRate.cpp
Go to the documentation of this file.
1//! @file ElectronCollisionPlasmaRate.cpp
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
10
11namespace Cantera
12{
13
14ElectronCollisionPlasmaData::ElectronCollisionPlasmaData()
15{
16 energyLevels.assign(1, 0.0);
17 distribution.assign(1, 0.0);
18}
19
21{
22 const PlasmaPhase& pp = dynamic_cast<const PlasmaPhase&>(phase);
23
24 // The distribution number dictates whether the rate should be updated.
25 // Three scenarios involving changes of the distribution number:
26 // 1. Change of the electron energy levels
27 // 2. Change of the electron energy distribution
28 // 3. Combined changes of one and two
30 return false;
31 }
32
33 // Update distribution
37
38 // Update energy levels
39 levelChanged = pp.levelNumber() != m_level_number;
40 if (levelChanged) {
44 }
45
46 return true;
47}
48
50{
51 ReactionRate::setParameters(node, rate_units);
52 if (!node.hasKey("energy-levels") && !node.hasKey("cross-sections")) {
53 return;
54 }
55 if (node.hasKey("energy-levels")) {
56 m_energyLevels = node["energy-levels"].asVector<double>();
57 }
58 if (node.hasKey("cross-sections")) {
59 m_crossSections = node["cross-sections"].asVector<double>();
60 }
61 if (m_energyLevels.size() != m_crossSections.size()) {
62 throw CanteraError("ElectronCollisionPlasmaRate::setParameters",
63 "Energy levels and cross section must have the same length.");
64 }
65}
66
68 node["type"] = type();
69 node["energy-levels"] = m_energyLevels;
70 node["cross-sections"] = m_crossSections;
71}
72
74 const ElectronCollisionPlasmaData& shared_data)
75{
76 // Interpolate cross-sections data to the energy levels of
77 // the electron energy distribution function
78 if (shared_data.levelChanged) {
80 for (double level : shared_data.energyLevels) {
83 }
84 }
85
86 // Map cross sections to Eigen::ArrayXd
87 auto cs_array = Eigen::Map<const Eigen::ArrayXd>(
89 );
90
91 // Map energyLevels in Eigen::ArrayXd
92 auto eps = Eigen::Map<const Eigen::ArrayXd>(
93 shared_data.energyLevels.data(), shared_data.energyLevels.size()
94 );
95
96 // Map energyLevels in Eigen::ArrayXd
97 auto distribution = Eigen::Map<const Eigen::ArrayXd>(
98 shared_data.distribution.data(), shared_data.distribution.size()
99 );
100
101 // unit in kmol/m3/s
102 return 0.5 * pow(2.0 * ElectronCharge / ElectronMass, 0.5) * Avogadro *
103 simpson(distribution.cwiseProduct(cs_array), eps.pow(2.0));
104}
105
107{
108 // ElectronCollisionPlasmaReaction is for a non-equilibrium plasma, and the reverse rate
109 // cannot be calculated from the conventional thermochemistry.
110 // @todo implement the reversible rate for non-equilibrium plasma
111 if (rxn.reversible) {
112 throw InputFileError("ElectronCollisionPlasmaRate::setContext", rxn.input,
113 "ElectronCollisionPlasmaRate does not support reversible reactions");
114 }
115
116 // get electron species name
117 string electronName;
118 if (kin.thermo().type() == "plasma") {
119 electronName = dynamic_cast<const PlasmaPhase&>(kin.thermo()).electronSpeciesName();
120 } else {
121 throw CanteraError("ElectronCollisionPlasmaRate::setContext",
122 "ElectronCollisionPlasmaRate requires plasma phase");
123 }
124
125 // Number of reactants needs to be two
126 if (rxn.reactants.size() != 2) {
127 throw InputFileError("ElectronCollisionPlasmaRate::setContext", rxn.input,
128 "ElectronCollisionPlasmaRate requires exactly two reactants");
129 }
130
131 // Must have only one electron
132 // @todo add electron-electron collision rate
133 if (rxn.reactants.at(electronName) != 1) {
134 throw InputFileError("ElectronCollisionPlasmaRate::setContext", rxn.input,
135 "ElectronCollisionPlasmaRate requires one and only one electron");
136 }
137}
138
139}
Header for plasma reaction rates parameterized by electron collision cross section and electron energ...
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1477
Base class for exceptions thrown by Cantera classes.
vector< double > m_crossSectionsInterpolated
collision cross sections [m2] after interpolation
virtual void setContext(const Reaction &rxn, const Kinetics &kin) override
Set context of reaction rate evaluation.
vector< double > m_crossSections
collision cross sections [m2] at m_energyLevels
virtual void getParameters(AnyMap &node) const override
Get parameters.
vector< double > m_energyLevels
electron energy levels [eV]
virtual void setParameters(const AnyMap &node, const UnitStack &units) override
Set parameters.
virtual const std::string type() const override
String identifying reaction rate specialization.
double evalFromStruct(const ElectronCollisionPlasmaData &shared_data)
Evaluate reaction rate.
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition AnyMap.h:749
Public interface for kinetics managers.
Definition Kinetics.h:125
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
Definition Kinetics.h:242
Base class for a phase with plasma properties.
Definition PlasmaPhase.h:58
int distributionNumber() const
Return the distribution Number m_distNum.
int levelNumber() const
Return the electron energy level Number m_levelNum.
size_t nElectronEnergyLevels() const
Number of electron levels.
void getElectronEnergyDistribution(double *distrb) const
Get electron energy distribution.
void getElectronEnergyLevels(double *levels) const
Get electron energy levels.
Definition PlasmaPhase.h:88
virtual void setParameters(const AnyMap &node, const UnitStack &units)
Set parameters.
Abstract base class which stores data about a reaction and its rate parameterization so that it can b...
Definition Reaction.h:25
bool reversible
True if the current reaction is reversible. False otherwise.
Definition Reaction.h:126
Composition reactants
Reactant species and stoichiometric coefficients.
Definition Reaction.h:111
AnyMap input
Input data used for specific models.
Definition Reaction.h:139
Base class for a phase with thermodynamic properties.
string type() const override
String indicating the thermodynamic model implemented.
Header for a file containing miscellaneous numerical functions.
double linearInterp(double x, const vector< double > &xpts, const vector< double > &fpts)
Linearly interpolate a function defined on a discrete grid.
Definition funcs.cpp:13
double simpson(const Eigen::ArrayXd &f, const Eigen::ArrayXd &x)
Numerical integration of a function using Simpson's rule with flexibility of taking odd and even numb...
Definition funcs.cpp:87
const double Avogadro
Avogadro's Number [number/kmol].
Definition ct_defs.h:81
const double ElectronCharge
Elementary charge [C].
Definition ct_defs.h:90
const double ElectronMass
Electron Mass [kg].
Definition ct_defs.h:111
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
Data container holding shared data specific to ElectronCollisionPlasmaRate.
vector< double > energyLevels
electron energy levels
virtual bool update(const ThermoPhase &phase, const Kinetics &kin) override
Update data container based on thermodynamic phase state.
vector< double > distribution
electron energy distribution
int m_level_number
integer that is incremented when electron energy level changes
int m_dist_number
integer that is incremented when electron energy distribution changes
Unit aggregation utility.
Definition Units.h:105