Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plasma phase #1190

Merged
merged 41 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ce2d4b1
[plasma] Add class PlasmaPhase with isotropic EEDF
BangShiuh Feb 5, 2022
b1e18cf
[plasma] add logic for user-specified EEDF
BangShiuh Feb 7, 2022
cd39a0f
[plasma] add get/setElectronEnergyDistrb
BangShiuh Feb 7, 2022
6adecff
[plasma] add test_set_electron_energy_distribution
BangShiuh Feb 7, 2022
1d0b23c
[plasma] calculate mean electron energy using trapezoidal rule
BangShiuh Feb 7, 2022
a50c151
[plasma] separate tests for isotropic-velocity and user-specified
BangShiuh Feb 7, 2022
fa280a4
[plasma] add documentation
BangShiuh Feb 8, 2022
91a18bd
[plasma] add _updateThermo()
BangShiuh Feb 11, 2022
4df1786
[plasma] change electron thermo model
BangShiuh Feb 11, 2022
8fd9f2f
[plasma] add test_mean_electron_energy
BangShiuh Feb 13, 2022
7afe591
add vscode to .gitignore
BangShiuh Feb 14, 2022
083fa41
[plasma] use LinSpaced for init grid
BangShiuh Feb 15, 2022
ce29b3b
[plasma] remove electron distrb method
BangShiuh Feb 19, 2022
2b99c93
[thermo] set Te = T when thermo=IdealGas
BangShiuh Feb 21, 2022
e2bb17c
[plasma] improve documentation
BangShiuh Feb 22, 2022
26dd1ad
[plasma] move plasma back to thermo folder
BangShiuh Feb 28, 2022
57451bf
[thermo] update handling of electron temperature
BangShiuh Feb 21, 2022
0f1bb62
[plasma] reduce line length
BangShiuh Mar 1, 2022
d255264
[plasma] move plasma back to thermo.pyx
BangShiuh Mar 1, 2022
a6b7d8f
[plasma] change electronEnergyGrid to Levels
BangShiuh Mar 1, 2022
12a112f
[plasma] move tests to test_thermo.py
BangShiuh Mar 1, 2022
9d1d6b2
[plasma] Add doxygen docs and move Python functions to ThermoPhase
BangShiuh Mar 5, 2022
ff4ad91
[plasma] use Eigen::Map
BangShiuh Mar 9, 2022
72619d3
[plasma] abbreviation of calculation (Boltzmann constant)
BangShiuh Mar 15, 2022
e17414b
[plasma] change name of updateIsotropicElectronEnergyDistribution
BangShiuh Mar 15, 2022
6c84297
[plasma] use addSpecies to find electron species index
BangShiuh Mar 20, 2022
16ef388
[plasma] add functions to manage isotropic shape factor
BangShiuh Mar 20, 2022
a4c998d
[plasma] use Eigen::ArrayXd for m_electronEnergyLevels
BangShiuh Mar 21, 2022
a14f7d0
[plasma] add key electron-energy-distribution-function
BangShiuh Mar 22, 2022
ff6a3ef
[plasma] add distribution type and input file parameters
BangShiuh Mar 22, 2022
09f48ed
[plasma] use raw pointer for get/set methods
BangShiuh Mar 22, 2022
4ade3d7
[plasma] add ThermoYamlRoundTrip test
BangShiuh Mar 24, 2022
7a7785c
[plasma] check for errors in electron energy levels and distribution
BangShiuh Apr 5, 2022
ce68a5f
[thermo] Add option of using Simpson's rule for EEDF
BangShiuh Apr 16, 2022
a3316f4
[plasma] add normalizeElectronEnergyDistribution
BangShiuh Apr 16, 2022
1c5a8f9
[plasma] add key normalize and fix get set parameters
BangShiuh Apr 17, 2022
2a3720c
[transport] fix electron species index initialization
BangShiuh Apr 17, 2022
033f9f1
[plasma] add test_add_multiple_electron_species
BangShiuh Apr 17, 2022
3d7d06e
[plasma] Add 'discretized' to function name
BangShiuh Apr 18, 2022
444a9ca
[plasma] Use a custom exception class for invalid methods
BangShiuh Apr 21, 2022
eaab899
[plasma] Add YAML docs
BangShiuh Apr 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interfaces/matlab/Contents.m
stage/
.sconsign.dblite
.sconf_temp
.vscode
cantera.conf*
config.log
*.lib
Expand Down
67 changes: 67 additions & 0 deletions doc/sphinx/yaml/phases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -822,3 +822,70 @@ A multi-species Redlich-Kwong phase as

The parameters for each species are contained in the corresponding species
entries.

.. _sec-yaml-plasma-phase:

``plasma-phase``
----------------

A phase for plasma. This phase handles plasma properties such as the electron
energy distribution and electron temperature with different models as
`described here <https://cantera.org/documentation/dev/doxygen/html/d5/dd7/classCantera_1_1PlasmaPhase.html#details>`__.


Additional fields:

``electron-energy-distribution``
A mapping with the following fields:

``type``
String specifying the type of the electron energy distribution to be used.
Supported model strings are:

- `isotropic`
- `discretized`

``shape-factor``
A constant in the isotropic distribution, which is shown as x in the
detailed description of this class. The value needs to be a positive
number. This field is only used with `isotropic`. Defaults to 2.0.

``mean-electron-energy``
Mean electron energy of the isotropic distribution. The default sets
the electron temperature equal gas temperature and uses the
corresponding electron energy as mean electron energy. This field
is only used with `isotropic`.

``energy-levels``
A list of values specifying the electron energy levels. The default
uses 1001 equal spaced points from 0 to 1 eV.

``distribution``
A list of values specifying the discretized electron energy distribution.
This field is only used with `discretized`.

``normalize``
A flag specifying whether normalizing the discretized electron energy
distribution or not. This field is only used with `discretized`.
Defaults to ``true``.

Example::

- name: isotropic-electron-energy-plasma
thermo: plasma
kinetics: gas
transport: Ion
electron-energy-distribution:
type: isotropic
shape-factor: 2.0
mean-electron-energy: 1.0 eV
energy-levels: [0.0, 0.1, 1.0, 10.0]
- name: discretized-electron-energy-plasma
thermo: plasma
kinetics: gas
transport: Ion
electron-energy-distribution:
type: discretized
energy-levels: [0.0, 0.1, 1.0, 10.0]
distribution: [0.0, 0.2, 0.7, 0.01]
normalize: False
41 changes: 40 additions & 1 deletion include/cantera/numerics/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define CT_FUNCS_H

#include "cantera/base/ct_defs.h"
#include "cantera/numerics/eigen_sparse.h"
speth marked this conversation as resolved.
Show resolved Hide resolved

namespace Cantera
{
Expand All @@ -28,6 +29,44 @@ namespace Cantera
*/
doublereal linearInterp(doublereal x, const vector_fp& xpts,
const vector_fp& fpts);
}

//! Numerical integration of a function using the trapezoidal rule.
/*!
* Vector x contanins a monotonic sequence of grid points, and
* Vector f contains function values defined at these points.
* The size of x and f must be the same.
*
* @param f vector of function value
* @param x vector of function coordinate
*/
double trapezoidal(const Eigen::ArrayXd& f, const Eigen::ArrayXd& x);

//! Numerical integration of a function using Simpson's rule
//! with flexibility of taking odd and even number of points.
//! For even number, Simpson's rule is used for the first
//! N-2 intervals with a trapezoidal rule on the last interval.
/*!
* Vector x contanins a monotonic sequence of grid points, and
* Vector f contains function values defined at these points.
* The size of x and f must be the same.
*
* @param f vector of function value
* @param x vector of function coordinate
*/
double simpson(const Eigen::ArrayXd& f, const Eigen::ArrayXd& x);

//! Numerical integration of a function.
/*!
* Vector x contanins a monotonic sequence of grid points, and
* Vector f contains function values defined at these points.
* The size of x and f must be the same.
*
* @param method method name
* @param f vector of function value
* @param x vector of function coordinate
*/
double numericalQuadrature(const std::string& method,
const Eigen::ArrayXd& f,
const Eigen::ArrayXd& x);
}
#endif
15 changes: 7 additions & 8 deletions include/cantera/thermo/IdealGasPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Cantera
* This class is optimized for speed of execution. All calls to thermodynamic
* functions first call internal routines (aka #enthalpy_RT_ref()) which return
* references the reference state thermodynamics functions. Within these
* internal reference state functions, the function #_updateThermo() is called,
* internal reference state functions, the function #updateThermo() is called,
* that first checks to see whether the temperature has changed. If it has, it
* updates the internal reference state thermo functions by calling the
* MultiSpeciesThermo object.
Expand Down Expand Up @@ -548,7 +548,7 @@ class IdealGasPhase: public ThermoPhase
* state thermo functions.
*/
const vector_fp& enthalpy_RT_ref() const {
_updateThermo();
updateThermo();
return m_h0_RT;
}

Expand All @@ -558,7 +558,7 @@ class IdealGasPhase: public ThermoPhase
* state thermo functions.
*/
const vector_fp& gibbs_RT_ref() const {
_updateThermo();
updateThermo();
return m_g0_RT;
}

Expand All @@ -568,7 +568,7 @@ class IdealGasPhase: public ThermoPhase
* state thermo functions.
*/
const vector_fp& entropy_R_ref() const {
_updateThermo();
updateThermo();
return m_s0_R;
}

Expand All @@ -578,7 +578,7 @@ class IdealGasPhase: public ThermoPhase
* state thermo functions.
*/
const vector_fp& cp_R_ref() const {
_updateThermo();
updateThermo();
return m_cp0_R;
}

Expand Down Expand Up @@ -612,8 +612,7 @@ class IdealGasPhase: public ThermoPhase
//! Temporary array containing internally calculated partial pressures
mutable vector_fp m_pp;

private:
//! Update the species reference state thermodynamic functions
//! @internal Update the species reference state thermodynamic functions
/*!
* This method is called each time a thermodynamic property is requested,
* to check whether the internal species properties within the object
Expand All @@ -625,7 +624,7 @@ class IdealGasPhase: public ThermoPhase
* concentration dependent information at the time the setMoleFractions()
* (or equivalent) call is made.
*/
void _updateThermo() const;
virtual void updateThermo() const;
};

}
Expand Down
19 changes: 6 additions & 13 deletions include/cantera/thermo/Phase.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ class Phase

//! Electron Temperature (K)
//! @return The electron temperature of the phase
double electronTemperature() const {
return m_electronTemp;
virtual double electronTemperature() const {
return m_temp;
}

//! Return the thermodynamic pressure (Pa).
Expand Down Expand Up @@ -716,7 +716,7 @@ class Phase

//! Set the internally stored temperature of the phase (K).
//! @param temp Temperature in Kelvin
virtual void setTemperature(const doublereal temp) {
virtual void setTemperature(double temp) {
if (temp > 0) {
m_temp = temp;
} else {
Expand All @@ -727,13 +727,9 @@ class Phase

//! Set the internally stored electron temperature of the phase (K).
//! @param etemp Electron temperature in Kelvin
virtual void setElectronTemperature(const double etemp) {
if (etemp > 0) {
m_electronTemp = etemp;
} else {
throw CanteraError("Phase::setElectronTemperature",
"electron temperature must be positive. Te = {}", etemp);
}
virtual void setElectronTemperature(double etemp) {
throw NotImplementedError("Phase::setElectronTemperature",
"Not implemented for thermo model '{}'", type());
}

//! @}
Expand Down Expand Up @@ -985,9 +981,6 @@ class Phase

doublereal m_temp; //!< Temperature (K). This is an independent variable

//! Electron Temperature (K).
double m_electronTemp;

//! Density (kg m-3). This is an independent variable except in the case
//! of incompressible phases, where it has to be changed using the
//! assignDensity() method. For compressible substances, the pressure is
Expand Down
Loading