rizer.models.nrp.isomass_2T_volume_reactor_cpp#
C++-backed two-temperature 0D plasma reactor driver.
A drop-in alternative to
Isomass2TVolumeReactor whose per-RHS
chemistry / 2T-energy / Joule / conductivity are evaluated natively in the
_plasma1d extension (Cantera MultiRate rate-constant caching + the C++
CollisionModel), while the NRP electric circuit stays in Python – the
validated, single-source-of-truth circuit; both are driven by
cantera.ReactorNet.
The state vector matches the Python reference: y = [Tg, Te, V, Y_0..Y_{K-1}].
Per RHS eval: sigma (C++) -> R_p -> V_p (Python circuit) -> E ->
dydt (C++). See rizer.models.nrp.isomass_2T_volume_reactor.Isomass2TVolumeReactor
for the physics; this class reproduces it with the heavy numerics moved to C++.
Classes#
Constant-mass 2T plasma reactor RHS with a native C++ core, on |
Functions#
|
Construct a native |
Module Contents#
- rizer.models.nrp.isomass_2T_volume_reactor_cpp.build_reactor0d(mech: str, phase: str, species_names: list[str], mtcf: list[rizer.transport.collision_frequency.MomentumTransferCollisionFrequencyModel], reacting: bool = True, gap: float = 0.0, Te_min: float = 300.0, Te_max: float = 100000.0, Te_n: int = 600, spitzer: bool = True, plasma: cantera.Solution | None = None) Any#
Construct a native
Reactor0Dfrom a momentum-transfer-model list.mtcfis the same per-species model list used byMixtureCollisionFrequencies(get_momentum_transfer_collision_frequencies_list); the per-species cross-section data / hard-sphere radius / ion charge are extracted from it so the C++ collision model is identical to the Python reference’s.- Parameters:
mech (
str) – Cantera mechanism (YAML) path.phase (
str) – Cantera mechanism (YAML) phase name (aPlasmaPhasewithe-).species_names (
listofstr) – Species names, in mechanism order. Only used to count species (nsp = len(species_names)); the C++ side re-reads the mechanism itself for the authoritative species order.mtcf (
listofMomentumTransferCollisionFrequencyModel) – Per-species momentum-transfer collision-frequency models, in species-index order (as built byrizer.transport.loaders.get_momentum_transfer_collision_frequencies_list()). Unpacked into the flat cross-section / hard-sphere-radius / ion-charge arrays the C++CollisionModelconstructor expects.reacting (
bool, optional) – Include finite-rate chemistry in the reactor’s RHS. Default True.gap (
float, optional) – Inter-electrode gap [m], used only by the reactor’s own diagnostics (not by the RHS physics, which is homogeneous/0D). Default 0.0.Te_min (
float, optional) – Electron-temperature bounds [K] of the log-spaced grid the C++CollisionModelprecomputes its per-species Maxwellian-averaged cross sections on. Defaults 300.0 and 1.0e5.Te_max (
float, optional) – Electron-temperature bounds [K] of the log-spaced grid the C++CollisionModelprecomputes its per-species Maxwellian-averaged cross sections on. Defaults 300.0 and 1.0e5.Te_n (
int, optional) – Number of points in that Te grid. Default 600.spitzer (
bool, optional) – Apply the Spitzer e-e correction to the electron-electron contribution of the collision model. Default True.plasma (
cantera.Solution, optional) – Already-loaded Solution formech/phase, reused (whenreacting) to computespecies_h0kinstead of loading a second copy of the mechanism. If None, one is loaded here. Ignored ifreactingis False.
- Returns:
Native two-temperature 0D reactor evaluator (persistent: rebuilds its rate/cross-section caches once at construction, then is queried once per RHS call from
Isomass2TVolumeReactor’sreplace_eval).- Return type:
rizer.cantera_ext._plasma1d.Reactor0D
- class rizer.models.nrp.isomass_2T_volume_reactor_cpp.Isomass2TVolumeReactor(plasma: cantera.Solution, mech: str, phase: str, mtcf: list[rizer.transport.collision_frequency.MomentumTransferCollisionFrequencyModel], mass: float, gap: float, electric_circuit: rizer.electrical_model.circuit.base_circuit.PlasmaVoltageCircuit, polytropic_index: float | str = np.inf, p_ext: float | str = 101325.0, reacting: bool = True, Te_n: int = 600, spitzer: bool = True, **kwargs)#
Bases:
cantera.ExtensibleReactorConstant-mass 2T plasma reactor RHS with a native C++ core, on
ct.ExtensibleReactor.Driven by
cantera.ReactorNet, using the same calling convention asIsomass2TVolumeReactor(the pure-Python variant).replace_evalis a single call intoself._r0d.rhs(...), plus the NRP-circuit voltage feedback that stays in Python. plasma/self.plasma is only used for the base class’s own bookkeeping and to seed the initial state (replace_get_state) – unlike the pure-Python reactor, Te is never read from or written to a Cantera phase object at all here; it travels purely as a plain float intoself._r0d.rhs(Tg, Te, ...).nu_eH/nu_ee/nu_eI/nu_eH_mass_weightedare read directly off the nativeReactor0D, using the same names asMixtureCollisionFrequencies’s methods.- Parameters:
plasma (
cantera.Solution) – Cantera plasma object, already set to the desired initial Tg/Te/composition – read once byreplace_get_stateto seed the ODE solver’s initial condition. Passed withclone=Falseand stored asself.plasmafor the same reason as the pure-Python reactor (seeIsomass2TVolumeReactor). Not otherwise used by the RHS itself – the nativeReactor0Dloads its own independent copy of the mechanism frommech/phase.mech (
str) – Cantera mechanism (YAML) path and phase name.phase (
str) – Cantera mechanism (YAML) path and phase name.mtcf (
listofMomentumTransferCollisionFrequencyModel) – Per-species momentum-transfer collision-frequency models; seebuild_reactor0d().mass (
float) – Mass of the plasma [kg]. Assumed constant.gap (
float) – Gap between the two electrodes [m].electric_circuit (
PlasmaVoltageCircuit) – Electric circuit object – any of TransmissionLineResistiveCircuit, TransmissionLineRCLoadCircuit, DirectResistiveCircuit, DirectRCLoadCircuit, GeneratorVoltageCircuit (seePlasmaVoltageCircuit).polytropic_index (
floatorstr, optional) – Polytropic index of the plasma expansion.np.inf(default) means constant volume."gamma"is not supported natively.p_ext (
floatorstr, optional) – External pressure [Pa], default 101325.0.reacting (
bool, optional) – Include finite-rate chemistry. Default True.Te_n (
int, optional) – Number of points in the collision model’s electron-temperature table. Default 600.spitzer (
bool, optional) – Apply the Spitzer e-e correction in the collision model. Default True.
- Raises:
ValueError – If
polytropic_index == "gamma", ifp_extis a string other than"atmospheric"/"atm", or if a numericp_extis not strictly positive.
- plasma#
- n_vars#
- species_names#
- plasma_mass#
- gap#
- polytropic_index#
- electric_circuit#
- plasma_resistance = 0.0#
Stored plasma resistance [Ohm], updated at the last RHS evaluation.
- plasma_voltage = 0.0#
Stored plasma voltage [V], updated at the last RHS evaluation.
- plasma_radius = 0.0#
Stored plasma radius [m] (from V = pi*r^2*gap), updated at the last RHS evaluation.
- P_elastic = 0.0#
Elastic electron-heavy exchange power [W/m^3], from the last RHS evaluation.
- P_inelastic = 0.0#
Inelastic electron-impact-reaction power [W/m^3], from the last RHS evaluation.
- P_chemical = 0.0#
Heavy-species chemical power [W/m^3], from the last RHS evaluation.
- P_chemical_e = 0.0#
Electron chemical power [W/m^3], from the last RHS evaluation.
- P_Joule = 0.0#
Joule heating power [W/m^3], from the last RHS evaluation.
- nu_eH = 0.0#
Electron-heavy momentum-transfer collision frequency [1/s], from the last RHS evaluation.
- nu_ee = 0.0#
Electron-electron collision frequency [1/s], from the last RHS evaluation.
- nu_eI = 0.0#
Electron-ion momentum-transfer collision frequency [1/s], from the last RHS evaluation.
- nu_eH_mass_weighted = 0.0#
sum_h nu_eh/m_h [1/kg/s] (Mitchner VIII-3.8, term 2), from the last RHS evaluation.
- volume#
- replace_get_state(y: numpy.ndarray) None#
Populate the state vector
y = [Tg, Te, V, Y_0, ..., Y_{K-1}].Reads the cache
replace_update_statemaintains, so this answers correctly whether it’s called before the first step (seeding the initial condition) or at any later time (a current-state query).
- replace_update_state(y: numpy.ndarray) None#
Cache the new state vector; the native RHS reads
ydirectly, no Cantera phase update needed.
- replace_eval(t: float, LHS: numpy.ndarray, RHS: numpy.ndarray) None#
Compute the RHS of the ODE system.
Geometry and conductivity come from the C++ reactor, the plasma voltage from the Python NRP circuit, and the resulting field is fed back into the C++ RHS.