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#

Isomass2TVolumeReactor

Constant-mass 2T plasma reactor RHS with a native C++ core, on ct.ExtensibleReactor.

Functions#

build_reactor0d(→ Any)

Construct a native Reactor0D from a momentum-transfer-model list.

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 Reactor0D from a momentum-transfer-model list.

mtcf is the same per-species model list used by MixtureCollisionFrequencies (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 (a PlasmaPhase with e-).

  • species_names (list of str) – 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 (list of MomentumTransferCollisionFrequencyModel) – Per-species momentum-transfer collision-frequency models, in species-index order (as built by rizer.transport.loaders.get_momentum_transfer_collision_frequencies_list()). Unpacked into the flat cross-section / hard-sphere-radius / ion-charge arrays the C++ CollisionModel constructor 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++ CollisionModel precomputes 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++ CollisionModel precomputes 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 for mech/phase, reused (when reacting) to compute species_h0k instead of loading a second copy of the mechanism. If None, one is loaded here. Ignored if reacting is 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’s replace_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.ExtensibleReactor

Constant-mass 2T plasma reactor RHS with a native C++ core, on ct.ExtensibleReactor.

Driven by cantera.ReactorNet, using the same calling convention as Isomass2TVolumeReactor (the pure-Python variant). replace_eval is a single call into self._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 into self._r0d.rhs(Tg, Te, ...). nu_eH/nu_ee/nu_eI/nu_eH_mass_weighted are read directly off the native Reactor0D, using the same names as MixtureCollisionFrequencies’s methods.

Parameters:
  • plasma (cantera.Solution) – Cantera plasma object, already set to the desired initial Tg/Te/composition – read once by replace_get_state to seed the ODE solver’s initial condition. Passed with clone=False and stored as self.plasma for the same reason as the pure-Python reactor (see Isomass2TVolumeReactor). Not otherwise used by the RHS itself – the native Reactor0D loads its own independent copy of the mechanism from mech/phase.

  • mech (str) – Cantera mechanism (YAML) path and phase name.

  • phase (str) – Cantera mechanism (YAML) path and phase name.

  • mtcf (list of MomentumTransferCollisionFrequencyModel) – Per-species momentum-transfer collision-frequency models; see build_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 (see PlasmaVoltageCircuit).

  • polytropic_index (float or str, optional) – Polytropic index of the plasma expansion. np.inf (default) means constant volume. "gamma" is not supported natively.

  • p_ext (float or str, 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", if p_ext is a string other than "atmospheric"/"atm", or if a numeric p_ext is not strictly positive.

plasma#
n_vars#
species_names#
plasma_mass#
gap#
p_ext: float#
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_state maintains, 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 y directly, 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.

replace_component_name(i: int) → str#

Name the state-vector components for component_name/component_index.

replace_component_index(name: str) → int | None#

Symmetric with replace_component_name.