7#include <boost/math/special_functions/gamma.hpp>
15 : m_isotropicShapeFactor(2.0)
17 , m_electronSpeciesIndex(
npos)
18 , m_distributionType(
"isotropic")
19 , m_quadratureMethod(
"simpson")
20 , m_do_normalizeElectronEnergyDist(true)
34 throw CanteraError(
"PlasmaPhase::updateElectronEnergyDistribution",
35 "Invalid for discretized electron energy distribution.");
46 throw CanteraError(
"PlasmaPhase::normalizeElectronEnergyDistribution",
47 "The norm is negative. This might be caused by bad "
48 "electron energy distribution");
55 if (
type ==
"discretized" ||
56 type ==
"isotropic") {
59 throw CanteraError(
"PlasmaPhase::setElectronEnergyDistributionType",
60 "Unknown type for electron energy distribution.");
67 double x = m_isotropicShapeFactor;
68 double gamma1 = boost::math::tgamma(3.0 / 2.0 * x);
69 double gamma2 = boost::math::tgamma(5.0 / 2.0 * x);
70 double c1 = x * std::pow(gamma2, 1.5) / std::pow(gamma1, 2.5);
71 double c2 = x * std::pow(gamma2 / gamma1, x);
103 throw CanteraError(
"PlasmaPhase::checkElectronEnergyLevels",
104 "Values of electron energy levels need to be positive and "
105 "monotonically increasing.");
114 throw CanteraError(
"PlasmaPhase::checkElectronEnergyDistribution",
115 "Values of electron energy distribution cannot be negative.");
118 warn_user(
"PlasmaPhase::checkElectronEnergyDistribution",
119 "The value of the last element of electron energy distribution exceed 0.01. "
120 "This indicates that the value of electron energy level is not high enough "
121 "to contain the isotropic distribution at mean electron energy of "
133 Eigen::Map<const Eigen::ArrayXd>(levels, length);
135 Eigen::Map<const Eigen::ArrayXd>(dist, length);
154 m_isotropicShapeFactor = x;
165 eedf[
"energy-levels"] = levels;
167 eedf[
"shape-factor"] = m_isotropicShapeFactor;
172 eedf[
"distribution"] = dist;
175 phaseNode[
"electron-energy-distribution"] = std::move(eedf);
181 if (phaseNode.
hasKey(
"electron-energy-distribution")) {
182 const AnyMap eedf = phaseNode[
"electron-energy-distribution"].as<
AnyMap>();
185 if (eedf.
hasKey(
"shape-factor")) {
189 "isotropic type requires shape-factor key.");
191 if (eedf.
hasKey(
"mean-electron-energy")) {
192 double energy = eedf.
convert(
"mean-electron-energy",
"eV");
196 "isotropic type requires electron-temperature key.");
198 if (eedf.
hasKey(
"energy-levels")) {
200 eedf[
"energy-levels"].asVector<double>().size());
204 if (!eedf.
hasKey(
"energy-levels")) {
206 "Cannot find key energy-levels.");
208 if (!eedf.
hasKey(
"distribution")) {
210 "Cannot find key distribution.");
212 if (eedf.
hasKey(
"normalize")) {
216 eedf[
"distribution"].asVector<double>().data(),
217 eedf[
"energy-levels"].asVector<double>().size());
227 if (spec->composition.find(
"E") != spec->composition.end() &&
228 spec->composition.size() == 1 &&
229 spec->composition[
"E"] == 1) {
234 "Cannot add species, {}. "
235 "Only one electron species is allowed.", spec->name);
247 "No electron species found.");
261 if (cached.
state1 != tempNow || cached.
state2 != electronTempNow) {
265 cached.
state2 = electronTempNow;
Header file for class PlasmaPhase.
Declaration for class Cantera::Species.
A map of string keys to values whose type can vary at runtime.
double convert(const std::string &key, const std::string &units) const
Convert the item stored by the given key to the units specified in units.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Base class for exceptions thrown by Cantera classes.
vector_fp m_g0_RT
Temporary storage for dimensionless reference state Gibbs energies.
vector_fp m_cp0_R
Temporary storage for dimensionless reference state heat capacities.
virtual bool addSpecies(shared_ptr< Species > spec)
vector_fp m_h0_RT
Temporary storage for dimensionless reference state enthalpies.
vector_fp m_s0_R
Temporary storage for dimensionless reference state entropies.
virtual void updateThermo() const
virtual void update_single(size_t k, double T, double *cp_R, double *h_RT, double *s_R) const
Get reference-state properties for a single species.
ValueCache m_cache
Cached for saved calculations within each ThermoPhase.
size_t m_kk
Number of species in the phase.
doublereal temperature() const
Temperature (K).
void checkElectronEnergyDistribution() const
Check the electron energy distribution.
double meanElectronEnergy() const
Mean electron energy [eV].
size_t m_nPoints
Number of points of electron energy levels.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap())
Set equation of state parameters from an AnyMap phase description.
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
void normalizeElectronEnergyDistribution()
Electron energy distribution norm.
std::string m_quadratureMethod
Numerical quadrature method for electron energy distribution.
virtual void setElectronTemperature(double Te)
Set the internally stored electron temperature of the phase (K).
PlasmaPhase(const std::string &inputFile="", const std::string &id="")
Construct and initialize a PlasmaPhase object directly from an input file.
Eigen::ArrayXd m_electronEnergyDist
Normalized electron energy distribution vector [-] Length: m_nPoints.
Eigen::ArrayXd m_electronEnergyLevels
electron energy levels [ev]. Length: m_nPoints
void setDiscretizedElectronEnergyDist(const double *levels, const double *distrb, size_t length)
Set discretized electron energy distribution.
void checkElectronEnergyLevels() const
Check the electron energy levels.
void updateElectronTemperatureFromEnergyDist()
Update electron temperature (K) From energy distribution.
void setElectronEnergyDistributionType(const std::string &type)
Set electron energy distribution type.
void updateElectronEnergyDistribution()
Update electron energy distribution.
virtual double electronTemperature() const
Electron Temperature (K)
virtual void updateThermo() const
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
double m_electronTemp
Electron temperature [K].
void setElectronEnergyLevels(const double *levels, size_t length)
Set electron energy levels.
bool m_do_normalizeElectronEnergyDist
Flag of normalizing electron energy distribution.
virtual std::string type() const
String indicating the thermodynamic model implemented.
std::string m_distributionType
Electron energy distribution type.
void setIsotropicElectronEnergyDistribution()
Set isotropic electron energy distribution.
void setMeanElectronEnergy(double energy)
Set mean electron energy [eV].
size_t m_electronSpeciesIndex
Index of electron species.
void setIsotropicShapeFactor(double x)
Set the shape factor of isotropic electron energy distribution.
void enableNormalizeElectronEnergyDist(bool enable)
Set flag of automatically normalize electron energy distribution Flag: m_do_normalizeElectronEnergyDi...
void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
CachedScalar getScalar(int id)
Get a reference to a CachedValue object representing a scalar (doublereal) with the given id.
int getId()
Get a unique id for a cached value.
Header for a file containing miscellaneous numerical functions.
This file contains definitions for utility functions and text for modules, inputfiles,...
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const double Boltzmann
Boltzmann constant [J/K].
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
double numericalQuadrature(const std::string &method, const Eigen::ArrayXd &f, const Eigen::ArrayXd &x)
Numerical integration of a function.
const double ElectronCharge
Elementary charge [C].
void warn_user(const std::string &method, const std::string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
double state2
Value of the second state variable for the state at which value was evaluated, for example density or...
double state1
Value of the first state variable for the state at which value was evaluated, for example temperature...