7#include <boost/math/special_functions/gamma.hpp>
28 throw CanteraError(
"PlasmaPhase::updateElectronEnergyDistribution",
29 "Invalid for discretized electron energy distribution.");
41 throw CanteraError(
"PlasmaPhase::normalizeElectronEnergyDistribution",
42 "The norm is negative. This might be caused by bad "
43 "electron energy distribution");
50 if (
type ==
"discretized" ||
51 type ==
"isotropic") {
54 throw CanteraError(
"PlasmaPhase::setElectronEnergyDistributionType",
55 "Unknown type for electron energy distribution.");
62 double x = m_isotropicShapeFactor;
63 double gamma1 = boost::math::tgamma(3.0 / 2.0 * x);
64 double gamma2 = boost::math::tgamma(5.0 / 2.0 * x);
65 double c1 = x * std::pow(gamma2, 1.5) / std::pow(gamma1, 2.5);
66 double c2 = x * std::pow(gamma2 / gamma1, x);
109 throw CanteraError(
"PlasmaPhase::checkElectronEnergyLevels",
110 "Values of electron energy levels need to be positive and "
111 "monotonically increasing.");
120 throw CanteraError(
"PlasmaPhase::checkElectronEnergyDistribution",
121 "Values of electron energy distribution cannot be negative.");
124 warn_user(
"PlasmaPhase::checkElectronEnergyDistribution",
125 "The value of the last element of electron energy distribution exceed 0.01. "
126 "This indicates that the value of electron energy level is not high enough "
127 "to contain the isotropic distribution at mean electron energy of "
139 Eigen::Map<const Eigen::ArrayXd>(levels, length);
141 Eigen::Map<const Eigen::ArrayXd>(dist, length);
158 Eigen::Map<const Eigen::ArrayXd>(dist, length);
178 m_isotropicShapeFactor = x;
189 eedf[
"energy-levels"] = levels;
191 eedf[
"shape-factor"] = m_isotropicShapeFactor;
196 eedf[
"distribution"] = dist;
199 phaseNode[
"electron-energy-distribution"] = std::move(eedf);
205 if (phaseNode.
hasKey(
"electron-energy-distribution")) {
206 const AnyMap eedf = phaseNode[
"electron-energy-distribution"].as<
AnyMap>();
209 if (eedf.
hasKey(
"shape-factor")) {
213 "isotropic type requires shape-factor key.");
215 if (eedf.
hasKey(
"mean-electron-energy")) {
216 double energy = eedf.
convert(
"mean-electron-energy",
"eV");
220 "isotropic type requires electron-temperature key.");
222 if (eedf.
hasKey(
"energy-levels")) {
224 eedf[
"energy-levels"].asVector<double>().size());
228 if (!eedf.
hasKey(
"energy-levels")) {
230 "Cannot find key energy-levels.");
232 if (!eedf.
hasKey(
"distribution")) {
234 "Cannot find key distribution.");
236 if (eedf.
hasKey(
"normalize")) {
240 eedf[
"distribution"].asVector<double>().data(),
241 eedf[
"energy-levels"].asVector<double>().size());
251 if (spec->composition.find(
"E") != spec->composition.end() &&
252 spec->composition.size() == 1 &&
253 spec->composition[
"E"] == 1) {
258 "Cannot add species, {}. "
259 "Only one electron species is allowed.", spec->name);
271 "No electron species found.");
285 if (cached.
state1 != tempNow || cached.
state2 != electronTempNow) {
289 cached.
state2 = electronTempNow;
332 for (
size_t k = 0; k <
m_kk; k++) {
333 ubar[k] =
RT() * (_h[k] - 1.0);
336 ubar[k] =
RTe() * (_h[k] - 1.0);
344 mu[k] += (
RTe() -
RT()) * log(xx);
358 copy(_s.begin(), _s.end(), sr);
360 for (
size_t k = 0; k <
m_kk; k++) {
372 copy(gibbsrt.begin(), gibbsrt.end(), grt);
374 for (
size_t k = 0; k <
m_kk; k++) {
Header file for class PlasmaPhase.
Declaration for class Cantera::Species.
A map of string keys to values whose type can vary at runtime.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
double convert(const string &key, const string &units) const
Convert the item stored by the given key to the units specified in units.
Base class for exceptions thrown by Cantera classes.
const vector< double > & entropy_R_ref() const
Returns a reference to the dimensionless reference state Entropy vector.
double enthalpy_mole() const override
Return the Molar enthalpy. Units: J/kmol.
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
double pressure() const override
Pressure.
vector< double > m_g0_RT
Temporary storage for dimensionless reference state Gibbs energies.
vector< double > m_h0_RT
Temporary storage for dimensionless reference state enthalpies.
void getGibbs_ref(double *g) const override
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
void getStandardChemPotentials(double *mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
const vector< double > & gibbs_RT_ref() const
Returns a reference to the dimensionless reference state Gibbs free energy vector.
void getStandardVolumes_ref(double *vol) const override
Get the molar volumes of the species reference states at the current T and P_ref of the solution.
virtual void updateThermo() const
Update the species reference state thermodynamic functions.
vector< double > m_s0_R
Temporary storage for dimensionless reference state entropies.
vector< double > m_cp0_R
Temporary storage for dimensionless reference state heat capacities.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
const vector< double > & enthalpy_RT_ref() const
Returns a reference to the dimensionless reference state enthalpy vector.
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.
double temperature() const
Temperature (K).
double moleFraction(size_t k) const
Return the mole fraction of a single species.
void checkElectronEnergyDistribution() const
Check the electron energy distribution.
double meanElectronEnergy() const
Mean electron energy [eV].
double enthalpy_mole() const override
Return the Molar enthalpy. Units: J/kmol.
size_t m_nPoints
Number of points of electron energy levels.
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
void normalizeElectronEnergyDistribution()
Electron energy distribution norm.
void getStandardChemPotentials(double *muStar) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void updateThermo() const override
Update the species reference state thermodynamic functions.
void setElectronTemperature(double Te) override
Set the internally stored electron temperature of the phase (K).
void electronEnergyLevelChanged()
When electron energy level changed, plasma properties such as electron-collision reaction rates need ...
int m_levelNum
Electron energy level change variable.
void electronEnergyDistributionChanged()
When electron energy distribution changed, plasma properties such as electron-collision reaction rate...
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void getGibbs_ref(double *g) const override
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
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 getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
string type() const override
String indicating the thermodynamic model implemented.
void checkElectronEnergyLevels() const
Check the electron energy levels.
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
void updateElectronTemperatureFromEnergyDist()
Update electron temperature (K) From energy distribution.
string m_distributionType
Electron energy distribution type.
void getStandardVolumes_ref(double *vol) const override
Get the molar volumes of the species reference states at the current T and P_ref of the solution.
void updateElectronEnergyDistribution()
Update electron energy distribution.
string m_quadratureMethod
Numerical quadrature method for electron energy distribution.
PlasmaPhase(const string &inputFile="", const string &id="")
Construct and initialize a PlasmaPhase object directly from an input file.
double m_electronTemp
Electron temperature [K].
double RTe() const
Return the Gas Constant multiplied by the current electron temperature.
void setElectronEnergyLevels(const double *levels, size_t length)
Set electron energy levels.
void getGibbs_RT(double *grt) const override
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
bool m_do_normalizeElectronEnergyDist
Flag of normalizing electron energy distribution.
void getPartialMolarIntEnergies(double *ubar) const override
Return an array of partial molar internal energies for the species in the mixture.
void setIsotropicElectronEnergyDistribution()
Set isotropic electron energy distribution.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap()) override
Set equation of state parameters from an AnyMap phase description.
void setMeanElectronEnergy(double energy)
Set mean electron energy [eV].
size_t m_electronSpeciesIndex
Index of electron species.
void setElectronEnergyDistributionType(const string &type)
Set electron energy distribution type.
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
virtual double electronPressure() const
Electron pressure.
double electronTemperature() const override
Electron Temperature (K)
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...
int m_distNum
Electron energy distribution change variable.
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 ...
double RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
void initThermoFile(const string &inputFile, const string &id)
Initialize a ThermoPhase object using an input file.
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
virtual double refPressure() const
Returns the reference pressure in Pa.
CachedScalar getScalar(int id)
Get a reference to a CachedValue object representing a scalar (double) 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 and logging,...
double numericalQuadrature(const string &method, const Eigen::ArrayXd &f, const Eigen::ArrayXd &x)
Numerical integration of a function.
const double Boltzmann
Boltzmann constant [J/K].
const double GasConstant
Universal Gas Constant [J/kmol/K].
const double ElectronCharge
Elementary charge [C].
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const double SmallNumber
smallest number to compare to zero.
A cached property value and the state at which it was evaluated.
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...