Skip to main content

multi_port_nr_solve_grouped

Function multi_port_nr_solve_grouped 

pub fn multi_port_nr_solve_grouped(
    n_nl: usize,
    s_nl: &[f64],
    known_a: &[f64],
    port_resistances: &[f64],
    device_groups: &[&dyn NlDeviceGroupIv],
    group_port_offsets: &[usize],
    v_guess: &mut [f64],
    max_iter: usize,
    tolerance: f64,
) -> Vec<f64>
Expand description

Multi-port Newton-Raphson solver for devices with cross-coupled I-V.

Generalizes multi_port_nr_solve() for devices where port currents depend on voltages at other ports of the same device. For example, a triode’s plate current depends on both Vpk and Vgk.

§Device groups

NL ports are organized into device groups. Each group is a multi-port NL device (e.g., a 3-port triode with grid and plate ports). The device provides a full Jacobian including cross-derivatives (∂i_plate/∂v_grid).

The global NL ports are laid out contiguously by group: [group0_port0, group0_port1, ..., group1_port0, ...]

§Residual equation

Same as multi_port_nr_solve():

F_i = known_a_i - v_i - R_i·i_i(v) + Σ_j S[i][j]·(v_j - R_j·i_j(v)) = 0

The difference is that i_j(v) now depends on voltages of ALL ports in device(j), not just v_j. The Jacobian includes cross-terms:

∂F_i/∂v_k = S[i][k] - δ_{ik}
          - R_i · ∂i_i/∂v_k                              (if k ∈ device(i))
          - Σ_j S[i][j] · R_j · ∂i_j/∂v_k               (j ∈ device(k))