Skip to content

Commit

Permalink
[plasma] fix the failed tests due to m_cs_interp
Browse files Browse the repository at this point in the history
  • Loading branch information
BangShiuh committed Nov 19, 2024
1 parent c4fba55 commit 72998bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
10 changes: 9 additions & 1 deletion include/cantera/thermo/PlasmaPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,20 @@ class PlasmaPhase: public IdealGasPhase

void initThermo() override;

//! Set electron energy levels.
//! Set electron energy levels, and update electron energy distribution.
//! @param levels The vector of electron energy levels (eV).
//! Length: #m_nPoints.
//! @param length The length of the @c levels.
void setElectronEnergyLevels(const double* levels, size_t length);

//! Set electron energy levels.
//! @param levels The vector of electron energy levels (eV).
//! Length: #m_nPoints.
//! @param length The length of the @c levels.
//! @param updateEnergyDist update electron energy distribution
void setElectronEnergyLevels(const double* levels, size_t length,
bool updateEnergyDist);

//! Get electron energy levels.
//! @param levels The vector of electron energy levels (eV). Length: #m_nPoints
void getElectronEnergyLevels(double* levels) const {
Expand Down
17 changes: 12 additions & 5 deletions src/thermo/PlasmaPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ PlasmaPhase::PlasmaPhase(const string& inputFile, const string& id_)

// initial electron temperature
setElectronTemperature(temperature());

// resize vectors
m_cs_interp.resize(m_nPoints);
}

void PlasmaPhase::updateElectronEnergyDistribution()
Expand Down Expand Up @@ -89,20 +92,26 @@ void PlasmaPhase::setMeanElectronEnergy(double energy) {
updateElectronEnergyDistribution();
}

void PlasmaPhase::setElectronEnergyLevels(const double* levels, size_t length)
void PlasmaPhase::setElectronEnergyLevels(const double* levels, size_t length,
bool updateEnergyDist)
{
m_nPoints = length;
m_electronEnergyLevels = Eigen::Map<const Eigen::ArrayXd>(levels, length);
checkElectronEnergyLevels();
electronEnergyLevelChanged();
updateElectronEnergyDistribution();
if (updateEnergyDist) updateElectronEnergyDistribution();
m_interp_cs.resize(m_nPoints);
// The cross sections are interpolated on the energy levels
if (nCollisions() > 0) {
updateInterpolatedCrossSections();
}
}

void PlasmaPhase::setElectronEnergyLevels(const double* levels, size_t length)
{
setElectronEnergyLevels(levels, length, true);
}

void PlasmaPhase::electronEnergyDistributionChanged()
{
m_distNum++;
Expand Down Expand Up @@ -151,9 +160,7 @@ void PlasmaPhase::setDiscretizedElectronEnergyDist(const double* levels,
size_t length)
{
m_distributionType = "discretized";
m_nPoints = length;
m_electronEnergyLevels =
Eigen::Map<const Eigen::ArrayXd>(levels, length);
setElectronEnergyLevels(levels, length, false);
m_electronEnergyDist =
Eigen::Map<const Eigen::ArrayXd>(dist, length);
checkElectronEnergyLevels();
Expand Down
2 changes: 1 addition & 1 deletion test/kinetics/kineticsFromYaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ TEST(Reaction, TwoTempPlasmaFromYaml)

TEST(Reaction, ElectronCollisionPlasmaFromYaml)
{
auto sol = newSolution("oxygen-plasma.yaml", "", "none");
auto sol = newSolution("oxygen-plasma.yaml", "discretized-electron-energy-plasma", "none");
AnyMap rxn = AnyMap::fromYamlString(
"{equation: O2 + E => E + O2,"
" type: electron-collision-plasma,"
Expand Down

0 comments on commit 72998bb

Please sign in to comment.