Trait NlDeviceGroupIv
pub trait NlDeviceGroupIv {
// Required methods
fn n_ports(&self) -> usize;
fn eval(&self, v: &[f64], currents: &mut [f64], jacobian: &mut [f64]);
fn v_clamp_port(&self, port: usize) -> (f64, f64);
// Provided method
fn limit_port_voltage(&self, _port: usize, v_new: f64, _v_old: f64) -> f64 { ... }
}Expand description
Trait for multi-port nonlinear WDF devices with internally coupled I-V.
Used for 3-terminal devices (triodes, FETs) where the current at one port depends on the voltage at another port of the same device. For example, a triode’s plate current depends on both plate-cathode and grid-cathode voltages.
Each device group owns N ports. The grouped NR solver uses the full N×N device Jacobian (including cross-derivatives) when building the system Jacobian.
Required Methods§
fn eval(&self, v: &[f64], currents: &mut [f64], jacobian: &mut [f64])
fn eval(&self, v: &[f64], currents: &mut [f64], jacobian: &mut [f64])
Evaluate currents and full Jacobian for all ports.
Given port voltages v[0..n], writes:
currents[i]= current at port ijacobian[i * n + j]= ∂i_i/∂v_j (row-major, n×n)
Buffers are pre-allocated by the caller (length n and n*n).
fn v_clamp_port(&self, port: usize) -> (f64, f64)
fn v_clamp_port(&self, port: usize) -> (f64, f64)
Voltage clamp bounds for a specific port.
Provided Methods§
fn limit_port_voltage(&self, _port: usize, v_new: f64, _v_old: f64) -> f64
fn limit_port_voltage(&self, _port: usize, v_new: f64, _v_old: f64) -> f64
SPICE-style junction voltage limiting (pnjlim) hook.
Given a proposed new voltage v_new for port and the previous
iterate v_old, return a limited voltage that bounds the per-iteration
change across a forward-biased exponential junction so exp() cannot
blow up between Newton iterates. The default is a no-op (identity) —
only devices with exponential junctions (e.g. a BJT Vbe port) override
this.
This is applied inside the grouped-NR line search at every trial
point, so it must be a pure, side-effect-free function of
(port, v_new, v_old).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl NlDeviceGroupIv for BjtTwoPort
impl NlDeviceGroupIv for EbersMollTwoPort
impl NlDeviceGroupIv for NlDeviceKind
Implement NlDeviceGroupIv for NlDeviceKind, treating each as a 1-port group. This allows SinglePort(NlDeviceKind) in NlDeviceGroupKind to delegate through as_group_iv() in mixed-device collapsed stages.