rizer.electrical_model.circuit.stacked_coupling#

Exact monolithic coupling for scipy.integrate.solve_ivp-driven reactor/circuit pairs.

For a reactor whose own stepping is driven by scipy.integrate.solve_ivp (not a Cantera ReactorNet), the reactor’s state can be stacked together with the circuit’s own state and solved by a single combined right-hand side – exact, with no windowing or staleness at all, unlike DrivenCircuitAdapter.

Classes#

StackedReactorCircuit

Concatenate a reactor's state with a circuit's state and solve both together.

Module Contents#

class rizer.electrical_model.circuit.stacked_coupling.StackedReactorCircuit(reactor_initial_state: Callable[[], numpy.ndarray], reactor_plasma_resistance: Callable[[numpy.ndarray], float], reactor_compute_derivatives: Callable[[float, numpy.ndarray, float], numpy.ndarray], circuit: rizer.electrical_model.circuit.base_circuit.BaseCircuit)#

Concatenate a reactor’s state with a circuit’s state and solve both together.

Generalizes the pattern LowVoltageModel already hand-rolls (a fused [h, i] state, one scipy.integrate.solve_ivp call) via three small callables instead of a hard-coded stack – only usable for reactors already driven by scipy.integrate.solve_ivp; a Cantera ct.ReactorNet-driven reactor cannot have state stacked in from outside (use DrivenCircuitAdapter for those).

Parameters:
  • reactor_initial_state (Callable[[], numpy.ndarray]) – Returns the reactor’s own initial state vector.

  • reactor_plasma_resistance (Callable[[numpy.ndarray], float]) – Maps the reactor’s own state to the plasma resistance R_p.

  • reactor_compute_derivatives (Callable[[float, numpy.ndarray, float], numpy.ndarray]) – Maps (t, reactor_state, drive) to the reactor’s own state derivative, where drive is the current through the plasma (from the circuit’s state via current()).

  • circuit (BaseCircuit) – Externally-driven circuit supplying the plasma resistance’s counterpart current.

circuit#
solve(t_span: tuple[float, float], t_eval: numpy.ndarray | None = None, method: str = 'BDF', **kwargs) → Any#

Solve the coupled reactor/circuit system over t_span.

t_span and t_eval are kept separate (rather than inferring the integration span from t_eval’s own endpoints) so a caller can integrate from an absolute t=0 while only reporting the solution from some later t_eval[0] > 0 onward – e.g. LowVoltageModel, whose low-voltage phase can start at a nonzero absolute time continuing from an earlier NRP phase, while the circuit’s own time-dependent forcing (u_mes(t)) is still defined relative to t=0.

Parameters:
  • t_span (tuple of float, float) – Integration span (t0, tf) [s], passed to scipy.integrate.solve_ivp.

  • t_eval (numpy.ndarray or None, optional) – Time points at which to store the solution [s]. Default None (solver-chosen points).

  • method (str, optional) – Integrator passed to scipy.integrate.solve_ivp. Default “BDF”.

  • **kwargs – Additional arguments passed to scipy.integrate.solve_ivp.

Returns:

The solution object (scipy.integrate.OdeResult, a Bunch-like object) returned by scipy.integrate.solve_ivp. solution.y stacks the reactor’s state (first rows) above the circuit’s state (remaining rows), in that order.

Return type:

Any