13Cantera::shared_ptr<Cantera::Solution>
14loadMechanism(
const std::string& mech,
const std::string& phase)
22 : m_sol(loadMechanism(cfg.mech, cfg.phase))
25 auto thermo = m_sol->thermo();
26 const std::size_t nsp = thermo->nSpecies();
30 m_ie = thermo->speciesIndex(
"e-");
32 throw std::invalid_argument(
"Plasma0DReactor: mechanism has no 'e-' species.");
35 std::vector<double> wt(thermo->molecularWeights().begin(),
36 thermo->molecularWeights().end());
37 std::vector<CollisionModel::SpeciesSpec> specs = cfg.
specs;
39 for (std::size_t k = 0; k < nsp; k++) {
40 specs[k].molar_mass = wt[k] * 1.0e-3;
41 specs[k].is_electron = (k == m_ie);
54 m_rhs = std::make_unique<ReactorRHS>(m_sol, std::move(rc));
59 std::vector<std::string> names(m_rhs->nSpecies());
60 for (std::size_t k = 0; k < names.size(); k++) names[k] = m_rhs->speciesName(k);
65 double mass,
double p_ext,
double polytropic_index,
70 const double rho = mass / V;
75 double dTg = 0.0, dTe = 0.0, lhsTg = 1.0, lhsTe = 1.0;
78 m_rhs->rates(Tg, Te, Y, rho, E, dTg, dTe, dydt + 3, lhsTg, lhsTe, &m_diag);
81 if (std::isfinite(polytropic_index) && polytropic_index > 0.0 && m_gap > 0.0) {
85 auto thermo = m_rhs->solution()->thermo();
86 const double P = thermo->pressure();
87 const double Xe = thermo->moleFraction(m_ie);
90 const double p_e = Xe * P;
93 const double Tg_c = std::max(Tg, 200.0);
94 const double Te_c = std::max(Te, 200.0);
101 const double Tmean = (1.0 - Xe) * Tg_c + Xe * Te_c;
102 const double cp = thermo->cp_mass();
103 const double cv = thermo->cv_mass();
105 const double gamma = (cv > 0.0) ? cp / cv : 1.4;
106 const double M = thermo->meanMolecularWeight() * 1.0e-3;
116 const double radius = std::sqrt(V / (m_gap *
units::pi));
117 const double c_sound = std::sqrt(gamma *
units::R * Tmean / M);
118 const double tau = radius / c_sound;
126 const double dp_dt = -(P - p_ext) / tau;
127 dV = -1.0 / polytropic_index * (V / P) * dp_dt;
129 if (std::isfinite(dV)) {
130 dTe -= (p_e * dV / V) / lhsTe;
131 dTg -= ((P - p_e) * dV / V) / lhsTg;
Composition-resolved electron-heavy momentum-transfer collision model.
std::vector< std::string > speciesNames() const
void rhs(double Tg, double Te, double V, const double *Y, double E, double mass, double p_ext, double polytropic_index, double *dydt) const
Full 0D RHS.
Plasma0DReactor(const Config &cfg)
Construct from a mechanism/phase and collision-model configuration.
shared_ptr< Solution > newSolution(const string &infile, const string &name="", const string &transport="default", const vector< shared_ptr< Solution > > &adjacent={})
constexpr double R
Ideal gas constant [J/(mol K)].
constexpr double pi
pi (matches numpy's np.pi used in units.py).
void registerPlasmaRates()
Register the custom plasma reaction rates with Cantera's ReactionRateFactory.
bool spitzer
Use Spitzer (Coulomb) conductivity contribution when true.
std::size_t Te_n
Number of points in the tabulated Te grid [-].
double Te_max
Upper bound of the tabulated electron-temperature grid [K].
bool reacting
If false, disables chemistry source terms in the RHS.
std::vector< CollisionModel::SpeciesSpec > specs
Per-species cross-section model (cross-section data / radius / ion Z).
std::vector< double > species_h0k
Per-species standard enthalpy of formation at 0 K [J/kmol]; forwarded to ReactorRHS::Config::species_...
double Te_min
Lower bound of the tabulated electron-temperature grid [K].
bool reacting
Include finite-rate chemistry source terms (true) or freeze composition (false) [-].
CollisionModel collision
Composition-resolved sigma/nu_E (preferred).
std::vector< double > species_h0k
Per-species standard enthalpy of formation at 0 K [J/kmol], length nSpecies(), in mechanism species-i...
Physical constants and unit conversions, in SI by default.