Struct RTypeAdaptor
pub struct RTypeAdaptor {
pub num_ports: usize,
pub port_resistance: f64,
/* private fields */
}Expand description
R-type adaptor for arbitrary N-port topologies in WDF.
Handles non-series/parallel circuit topologies that cannot be decomposed into binary adaptor trees. Examples include:
- 3-winding transformers
- Bridged-T and twin-T networks
- Bassman/Marshall tone stacks
- Op-amp feedback networks
The scattering matrix S is computed at compile time from the circuit’s MNA (Modified Nodal Analysis) system using element stamps.
Reference: Werner, Smith, Abel (2015) “Wave Digital Filter Adaptors for Arbitrary Topologies and Multiport Linear Elements”
Scattering equation: b = S · a
One port (typically the last) is adapted to be reflection-free (S_nn = 0).
Fields§
§num_ports: usizeNumber of ports (children + 1 for parent)
port_resistance: f64Port resistance seen from parent (adapted port)
Implementations§
§impl RTypeAdaptor
impl RTypeAdaptor
pub fn new(
scattering_matrix: Vec<f64>,
port_resistances: &[f64],
) -> RTypeAdaptor
pub fn new( scattering_matrix: Vec<f64>, port_resistances: &[f64], ) -> RTypeAdaptor
Create an R-type adaptor from a pre-computed scattering matrix.
scattering_matrix— NxN matrix in row-major orderport_resistances— resistance for each port (last is adapted)
The last port is the “parent” port facing the root, and should be adapted (S[n-1][n-1] ≈ 0).
pub fn three_winding_transformer(
n12: f64,
n13: f64,
r_sec1: f64,
r_sec2: f64,
) -> RTypeAdaptor
pub fn three_winding_transformer( n12: f64, n13: f64, r_sec1: f64, r_sec2: f64, ) -> RTypeAdaptor
Create an R-type adaptor for an ideal 3-winding transformer.
n12— turns ratio primary:secondary₁ (e.g., 4.0 for 4:1)n13— turns ratio primary:secondary₂ (e.g., 9.5 for 9.5:1)r_sec1— port resistance of secondary₁ subtreer_sec2— port resistance of secondary₂ subtree
The primary (port 3) is adapted (reflection-free).
pub fn from_mna(
num_ports: usize,
mna_system: MnaSystem,
port_resistances: &[f64],
) -> RTypeAdaptor
pub fn from_mna( num_ports: usize, mna_system: MnaSystem, port_resistances: &[f64], ) -> RTypeAdaptor
Create from MNA element stamps (general method).
This implements the Werner DAFx-15 algorithm for deriving scattering matrices from arbitrary linear circuits.
num_ports— number of WDF portsmna_stamps— element stamps defining the internal circuitport_resistances— resistance at each port
The last port is adapted to be reflection-free.
pub fn scatter_up(&mut self, b_children: &[f64]) -> f64
pub fn scatter_up(&mut self, b_children: &[f64]) -> f64
scatter_up: collect child reflected waves, produce parent reflected wave.
Children send b₁, b₂, …, b_{n-1}. We compute b_n (to parent). Uses power-normalized S̅ internally for bounded intermediate products.
pub fn scatter_up_gain(&self, child_gains: &[f64]) -> f64
pub fn scatter_up_gain(&self, child_gains: &[f64]) -> f64
Linear gain from child reflected-wave gains to the parent reflected
wave. This mirrors scatter_up without mutating cached child waves.
pub fn scatter_down(&self, a_parent: f64) -> Vec<f64>
pub fn scatter_down(&self, a_parent: f64) -> Vec<f64>
scatter_down: given parent incident wave, produce child incident waves.
Parent sends a_n. We compute a₁, a₂, …, a_{n-1} for children. Uses power-normalized S̅ internally for bounded intermediate products.
pub fn scatter_down_parent_gains(&self) -> Vec<f64>
pub fn scatter_down_parent_gains(&self) -> Vec<f64>
Linear gains from parent incident wave to child incident waves. This is
the a_parent part of scatter_down; cached child waves are constants.
pub fn scatter_all(&self, b_all: &[f64]) -> Vec<f64>
pub fn scatter_all(&self, b_all: &[f64]) -> Vec<f64>
Perform full N×N scatter: a = S · b_all using power-normalized waves.
Equivalent to standard scattering but uses S̅ (power-normalized) internally. Since S̅ entries are bounded [-1,1] for passive networks, intermediate products cannot overflow even with extreme port resistance ratios (e.g., 0.1Ω cap vs 10kΩ NL port).
pub fn scatter_all_into(&self, b_all: &[f64], a_out: &mut [f64])
pub fn scatter_all_into(&self, b_all: &[f64], a_out: &mut [f64])
Like scatter_all, but writes into a pre-allocated output buffer
to avoid per-sample heap allocation.
pub fn set_child_waves(&mut self, b_children: &[f64])
pub fn set_child_waves(&mut self, b_children: &[f64])
Manually set the cached child reflected waves.
After a multi-NL NR solve determines the correct b values for all
ports, call this to update the cached state so that a subsequent
scatter_down produces correct incident waves for passive children.
pub fn reset(&mut self)
pub fn reset(&mut self)
Reset state.
pub fn power_scattering(&self) -> &[f64]
pub fn power_scattering(&self) -> &[f64]
Return the power-normalized scattering matrix S̅ (row-major).
S̅[i][j] = S[i][j] · √(R_j / R_i). For passive networks all entries
are bounded [-1, 1].
pub fn port_resistances(&self) -> Vec<f64>
pub fn port_resistances(&self) -> Vec<f64>
Port resistances in port order (last entry is the adapted parent port).
Reconstructed from √R_i values stored internally as R_i = (√R_i)².
pub fn scattering_matrix(&self) -> Vec<f64>
pub fn scattering_matrix(&self) -> Vec<f64>
Reconstruct the standard (non-power-normalized) scattering matrix
S[i][j] (row-major, num_ports × num_ports).
Inverse of the power normalization applied in RTypeAdaptor::new:
S̅[i][j] = S[i][j]·√(R_j/R_i) ⇒ S[i][j] = S̅[i][j]·√(R_i/R_j)
= power_scattering[i][j]·sqrt_r[i]·inv_sqrt_r[j].
This is the same matrix MultiNlScattering::from_full_matrix slices, so
the port ordering is [NL, passive, (vcc?), adapted] with the adapted
port last. Used by the stiff-cap fold to retain the passive rows that
the NL-only sub-blocks discard.
Trait Implementations§
§impl Clone for RTypeAdaptor
impl Clone for RTypeAdaptor
§fn clone(&self) -> RTypeAdaptor
fn clone(&self) -> RTypeAdaptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more