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#
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
LowVoltageModelalready 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 Canteract.ReactorNet-driven reactor cannot have state stacked in from outside (useDrivenCircuitAdapterfor 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 resistanceR_p.reactor_compute_derivatives (
Callable[[float,numpy.ndarray,float],numpy.ndarray]) – Maps(t, reactor_state, drive)to the reactor’s own state derivative, wheredriveis the current through the plasma (from the circuit’s state viacurrent()).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_spanand t_eval are kept separate (rather than inferring the integration span from t_eval’s own endpoints) so a caller can integrate from an absolutet=0while only reporting the solution from some latert_eval[0] > 0onward – 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 tot=0.- Parameters:
t_span (
tupleoffloat,float) – Integration span(t0, tf)[s], passed to scipy.integrate.solve_ivp.t_eval (
numpy.ndarrayorNone, 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.ystacks the reactor’s state (first rows) above the circuit’s state (remaining rows), in that order.- Return type:
Any