rizer.adaptive_models.composite#

Generic adaptive composite reactor: the time-integration loop.

AdaptiveCompositeReactor is the reusable core of every adaptive reactor in rizer: a plain time-marching loop (solve()) that advances the currently active stage and delegates every switching decision — which model applies now, blend weight, hand-off bookkeeping — to ModelSelector. The loop itself never inspects why a switch happened; it only reacts to the HandoffStep the selector returns. Which model is active at any instant is decided by live physical conditions (SwitchRule), not by a position in a fixed sequence — see allowed_models for restricting the graph to a subset of models for a given run (testing, model comparisons).

Concrete reactors subclass this base — PulsedPlasmaReactor (one pulse: isochoric deposition → isentropic expansion → isobaric cooling), and whatever comes next. A subclass supplies the stages, the switch rules, the initial state and (optionally) a macro-grid policy; everything else — blending, conservation-checked seams, result assembly — is inherited.

Attributes#

Classes#

AdaptiveResult

Unified trajectory of an adaptive composite solve.

AdaptiveCompositeReactor

Base class of every adaptive (self-switching) composite reactor.

Module Contents#

rizer.adaptive_models.composite.logger#
class rizer.adaptive_models.composite.AdaptiveResult#

Bases: rizer.models.nrp.engineering_model.base.TimeSeriesState

Unified trajectory of an adaptive composite solve.

Extends TimeSeriesState (t, T, P, plot) with the plasma fields and the model provenance. T is the unified temperature (Tg; equal to the single temperature after any 2-T stage).

Tg: numpy.ndarray#
Te: numpy.ndarray#
V: numpy.ndarray#
R: numpy.ndarray#
E: numpy.ndarray#
Y: numpy.ndarray#
deposited_energy: numpy.ndarray#
species_names: list[str] = []#
stage_trace: list[str] = []#
active_model_log: list[str] = []#
switch_times: list[float] = []#
plot(show: bool = True)#

Plot T/Te and P vs time with the model switches annotated.

class rizer.adaptive_models.composite.AdaptiveCompositeReactor(plasma: cantera.Solution, collision_freq: rizer.transport.mixture_law.MixtureCollisionFrequencies, stages: list[rizer.adaptive_models.models_list.BasePhysicalModel], rules: list[rizer.adaptive_models.selector.SwitchRule], qoi: rizer.adaptive_models.contract.QoISet = ('T', 'P', 'deposited_energy'), tol: float = 0.01, allowed_models: set[str] | None = None)#

Base class of every adaptive (self-switching) composite reactor.

Subclasses build the ladder and call this constructor; users interact with the concrete reactor’s from_config and solve() only.

Parameters:
  • plasma (cantera.Solution) – The shared Cantera plasma Solution every stage reads and writes.

  • collision_freq (MixtureCollisionFrequencies) – Collision-frequency wrapper around plasma (the modeling-error estimator’s elastic-exchange and conductivity closures).

  • stages (list of BasePhysicalModel) – The ladder’s stage solvers. stages[0] seeds the trajectory; which model is active thereafter is decided by live conditions, not position (see SwitchRule/ ModelSelector).

  • rules (list of SwitchRule) – All ladder edges (unordered; several may share the same outgoing — whichever fires wins).

  • qoi (tuple of str) – Quantities of interest driving the goal-oriented switching.

  • tol (float) – The single accuracy knob [-].

  • allowed_models (set of str, optional) – Restrict the graph to just these stage names (and the edges between them) for this run — for testing a single model in isolation, or comparing runs across model combinations. None (default): every stage/edge the subclass registered is available. The seed stage (stages[0]) must itself be in allowed_models when given. A stage left with no outgoing edges after filtering is a valid configuration (it simply never switches away), not an error.

plasma#
qoi = ('T', 'P', 'deposited_energy')#
tol#
final_state() → rizer.adaptive_models.state.PlasmaState#

Canonical state of whichever stage is active when solve returns.

solve(t_end: float) → AdaptiveResult#

March the ladder to t_end and return the unified trajectory.

The mutation decision (which edge, blend weight, hand-off/rebound bookkeeping) is entirely internal to advance() — this loop only advances the active stage and reacts to the HandoffStep it returns.