rizer.electrical_model.circuit.base_circuit#

Shared numerical infrastructure for electrical circuit models.

Circuits solved by this package come in two flavors:

  • Standalone, self-contained circuits (CLLRp_Circuit, CasteraCircuit) that own the plasma resistance as part of their own ODE state, solved end-to-end by their own solve method.

  • Externally-driven circuits, where the plasma resistance R_p is supplied from outside (a reactor), either through DrivenCircuitAdapter (windowed, for a Cantera-ReactorNet-driven reactor) or through StackedReactorCircuit (exact, for a scipy.integrate.solve_ivp-driven reactor).

BaseCircuit collects the interface both driven mechanisms need (initial_state(), current(), compute_derivatives_driven()), the windowed-solve helper used only by the adapter (solve_window()), shared power/energy diagnostic helpers, and shared helpers for the “any kind of resistance” standalone-mode input accepted by RLRp_Circuit, CLLRp_Circuit, and CasteraCircuit.

Classes#

ResistanceDerivativeModel

Structural interface for an ODE-based resistance model.

PlasmaVoltageCircuit

Structural interface for anything a reactor's electric_circuit= can be.

BaseCircuit

Abstract base class for electrical circuit models coupled to a plasma reactor.

Module Contents#

class rizer.electrical_model.circuit.base_circuit.ResistanceDerivativeModel#

Bases: Protocol

Structural interface for an ODE-based resistance model.

Any object with this method satisfies this Protocol – no inheritance from VariableResistorModel required. Used to accept “any kind of resistance” (see _validate_resistance_spec()) without narrowing standalone-mode circuits to that one class hierarchy.

compute_resistance_derivative(t: float, y: numpy.ndarray) → numpy.ndarray#

Return \(dR_p/dt\), given the current state y = [i_p, R_p].

Return type is numpy.ndarray, matching compute_resistance_derivative()’s actual annotation exactly (even though it is always scalar-valued at runtime) – a narrower -> float here would make every concrete VariableResistorModel subclass structurally fail this Protocol under mypy (return-type covariance), breaking make type-check for existing code.

class rizer.electrical_model.circuit.base_circuit.PlasmaVoltageCircuit#

Bases: Protocol

Structural interface for anything a reactor’s electric_circuit= can be.

Any object with this one method satisfies it – TransmissionLineResistiveCircuit, TransmissionLineRCLoadCircuit, DirectResistiveCircuit, DirectRCLoadCircuit, GeneratorVoltageCircuit, and a DrivenCircuitAdapter-wrapped circuit all qualify, without a shared base class – a reactive load or a bypassed source changes the solving strategy entirely, not just a parameter, so there is nothing else meaningful to make abstract here.

compute_plasma_voltage(t: float, R_p: float) → float#

Plasma terminal voltage at time t, given the plasma resistance R_p.

generator_voltage(t: float) → float#

Generator-side voltage at time t, before any cable/divider attenuation.

For GeneratorVoltageCircuit, which imposes the generator’s voltage directly with no cable/divider at all, this is the same value compute_plasma_voltage returns.

class rizer.electrical_model.circuit.base_circuit.BaseCircuit#

Bases: abc.ABC

Abstract base class for electrical circuit models coupled to a plasma reactor.

abstractmethod initial_state() → numpy.ndarray#

Return the initial value of the circuit’s own ODE state, in externally-driven mode.

Returns:

Initial state vector.

Return type:

numpy.ndarray

abstractmethod current(y: numpy.ndarray) → float#

Return the current flowing through the plasma, from the circuit’s own state y.

Only implemented by circuits whose plasma current is a pure function of their own state (needed by StackedReactorCircuit). Some circuits’ current also depends on the externally-supplied R_p or on t (e.g. RC_Rp_Circuit) and do not override this.

Parameters:

y (numpy.ndarray) – Circuit state vector, as returned by initial_state() or produced by compute_derivatives_driven().

Returns:

Current through the plasma, in Amperes.

Return type:

float

Raises:

NotImplementedError – If not overridden by the subclass.

abstractmethod compute_derivatives_driven(t: float, y: numpy.ndarray, R_p: float) → numpy.ndarray#

Time-derivative of the circuit’s own state, with the plasma resistance supplied externally.

Parameters:
  • t (float) – Time, in seconds.

  • y (numpy.ndarray) – Circuit state vector.

  • R_p (float) – Plasma resistance at time t, in Ohm.

Returns:

Time-derivative of the circuit state.

Return type:

numpy.ndarray

abstractmethod compute_derivatives(t: float, y: numpy.ndarray) → numpy.ndarray#

Time-derivative of the circuit’s own state, in standalone (self-contained) mode.

Only implemented by circuits that also own the plasma resistance as part of their own ODE state (used by their self-contained solve method) – CLLRp_Circuit and CasteraCircuit. Circuits that are only ever externally driven (e.g. RC_Rp_Circuit) do not override this.

Raises:

NotImplementedError – If not overridden by the subclass.

solve_window(time: numpy.ndarray, y0: numpy.ndarray, R_p: float, method: str = 'LSODA', dense_output: bool = True, **kwargs) → Any#

Solve the circuit over one window, with the plasma resistance frozen at R_p.

Used only by DrivenCircuitAdapter. Distinct from the self-contained solve method that CLLRp_Circuit and CasteraCircuit already define (no y0, builds its own initial state, returns a 4-tuple) – this method is never overridden and never collides with it.

Parameters:
  • time (numpy.ndarray) – Two-element array [t0, t1] spanning the window.

  • y0 (numpy.ndarray) – Circuit state at time[0].

  • R_p (float) – Plasma resistance, frozen over the window.

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

  • dense_output (bool, optional) – Whether to build a continuous interpolant (.sol). Default True.

  • **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.

Return type:

Any