Note
Go to the end to download the full example code.
NRP discharge with the adaptive PulsedPlasmaReactor#
A minimal (~5-lines) user API to solve a Pulsed Plasma. The reactor internally marches 0D2T deposition -> isentropic expansion -> isobaric cooling, switching models on physics-derived criteria. The user never names a sub-model; the 2-T deposition tier runs the native C++ CVODES + wave-circuit loop.
import time
from rizer.adaptive_models import PulsedPlasmaReactor
# --- the minimal API: construct, solve. -------------------------------------
reactor = PulsedPlasmaReactor.from_config(
"nrp.yaml",
mechanism="Goutier2025/CH4_to_C2H2",
qoi=("T", "P", "deposited_energy"),
tol=1e-2, # the ONE accuracy knob
)
t0 = time.perf_counter()
result = reactor.solve(t_end=1.0e-3)
wall = time.perf_counter() - t0
# --- what happened ----------------------------------------------------------
print(f"models : {result.active_model_log}")
print(f"switches : {[f'{t * 1e6:.3f} us' for t in result.switch_times]}")
print(f"T peak : {result.T.max():.0f} K")
print(f"P peak : {result.P.max() / 1e5:.2f} bar")
print(f"E_dep : {result.deposited_energy[-1] * 1e3:.2f} mJ")
print(f"wall : {wall:.1f} s ({result.t.size} output points)")
result.plot() # unified Tg/Te, P with active_model(t) annotations