twpasolver.cmes.bloch module#
Linear Bloch-mode tables for the coupled mode equations in the Bloch basis.
The standard CMEs treat the periodically loaded line as a homogeneous medium:
the supercell only provides the Bloch propagation constant, while the
nonlinear coupling of mode n is scaled by its propagation constant
(-gamma_n in the kernel). In the Bloch basis the amplitudes are the
boundary currents of the forward Bloch modes, and the coupling becomes
dA_n/dx ∋ -(2j omega_n / W_n) * c_q * <L_j phi^-_{n,j} prod_r phi_{p_r,j}>,
where
W_n = Zb^+_n + Zb^-_nis the reciprocity invariant <psi^+, psi^-> (the mode power normalization,2 Re Zbfor a lossless line),phi^±_{n,j}is the periodic part of the current of the forward/backward Bloch mode through the series nonlinear inductorjof the supercell, normalized to unit current at the supercell boundary,<...>is the sum over the nonlinear inductors divided by the number of unit cells per supercell (xis measured in unit cells).
For a homogeneous lumped ladder phi = 1 and -2j omega L / W equals
-gamma * tanh(gamma/2) / (gamma/2), which tends to the standard -gamma
far below the ladder cutoff.
This module provides the linear ingredients: Bloch impedances, W and the
intracell current profiles of a supercell (bloch_mode_tables()), the
fixed (“edge”) basis for modes close to a stopband edge
(edge_basis_tables() and the edge search), and the per-process weights
of the stopband guard (process_weights()). The forward-backward solver is in
twpasolver.cmes.bloch_fb. Supported unit cells are those whose
nonlinearity is a lumped series inductance (LCLfBaseCell,
StubBaseCell), or any cell defining a bloch_nl_elements() method (see
series_nl_elements()).
Time convention is the package one: exp(+j omega t), forward waves ~ exp(-gamma x) with gamma = alpha + j k.
- twpasolver.cmes.bloch.series_nl_elements(cell: Any) list[tuple[int, float]][source]#
Return the series nonlinear inductors of a unit cell.
Each element is
(port, L): the nonlinear inductanceLcarries the current of the cell’s input (PORT_IN) or output (PORT_OUT) port. Custom cells can define abloch_nl_elements()method returning the same list to be supported. The package cells scaleLby theirnl_scale.
- twpasolver.cmes.bloch.expand_unit_cells(array: TwoPortArray) list[tuple[Any, int]][source]#
Expand one period (supercell) of
arrayinto ordered runs(cell, count).The top-level repetition
array.Nis not applied (it is the number of supercells); nestedTwoPortArrayinstances are expanded recursively.
- twpasolver.cmes.bloch.bloch_wavenumber(twpa: TwoPortArray, freqs_hz: ndarray[Any, dtype[float64]], T: ndarray, Z0: complex) ndarray[source]#
Bloch wavenumber
k dper supercell of the forward mode, by winding.The forward mode is the eigenvector of the supercell ABCD
Tcarrying power along +x (Re Zb > 0) in a passband and decaying along +x (|lambda| > 1) in a stopband. Its forward-wave amplitudea = V + Z0 Iis carried from x = d back to x = 0 element by element (series/shunt steps of every unit cell) andk dis the accumulated phase ofa. Unlike unwrappingarg lambdaalong the frequency grid this does not depend on the grid, givesknear 0 above a notch andk < 0in a left-handed band. The result is snapped toarg lambdamodulo 2 pi.
- twpasolver.cmes.bloch.bloch_mode_tables(twpa: TwoPortArray, freqs_hz: ndarray[Any, dtype[float64]], gamma_ref: ndarray[Any, dtype[complex128]]) dict[str, Any][source]#
Compute Bloch impedances, W and intracell current profiles of a supercell.
- Parameters:
twpa (TwoPortArray) – Non-segmented device; one period is
twpa.cells.freqs_hz ((F,) float) – Frequencies in Hz (mode frequencies, flattened).
gamma_ref ((F,) complex) – Per-unit-cell propagation constant
alpha + j kused by the CME kernel. It selects the forward eigenvalue and the branch ofk.
- Returns:
Zb_plus,Zb_minus,W: (F,) complex.phi_plus,phi_minus: (F, n_nl) complex, periodic profiles of the forward/backward mode current through each nonlinear inductor.L_nl: (n_nl,) nonlinear inductances.n_cells: unit cells per supercell.positions: (n_nl,) position of each nonlinear inductor inside the supercell, in unit cells (the reference used forphi).gamma_exact: (F,) complex, per-unit-cell gamma from the eigenvalue.eig_residual: (F,) float,|I_M * lambda - 1|after propagating the forward mode through one supercell (should be ~machine precision).split: (F,) float,|sinh(gamma d)| = |lambda+ - lambda-| / 2, the normalisation-free splitting of the two Bloch modes (0 at every band edge, the exceptional point of the supercell matrix).
- Return type:
- twpasolver.cmes.bloch.lossless_copy(model: Any) Any[source]#
Deep copy of a device model with every loss tangent
deltaset to zero.
- twpasolver.cmes.bloch.supercell_matrix(twpa: TwoPortArray, freqs_hz: ndarray[Any, dtype[float64]]) ndarray[source]#
ABCD matrix of one supercell, shape (F, 2, 2).
- twpasolver.cmes.bloch.logm_unimodular_2x2(Q: ndarray) ndarray[source]#
Principal logarithm of 2x2 matrices with unit determinant, shape (…, 2, 2).
log Q = (phi / sinh phi) (Q - cosh(phi) I)withcosh phi = tr(Q)/2, regular at the exceptional pointQ - Inilpotent (log Q = Q - I). Valid for Q close to the identity (|phi|well below pi).
- twpasolver.cmes.bloch.passband_mask(h: ndarray) ndarray[source]#
Passband points of a scan of the half trace
h = tr T / 2.|h| < 1, except that runs of points with|h| >= 1whose excess never reachesSTOPBAND_TOL(bands touching at a folding point, rounding) are counted as passband.
- twpasolver.cmes.bloch.in_stopband(twpa_ll: TwoPortArray, f_hz: ndarray[Any, dtype[float64]]) ndarray[source]#
True where
|tr T / 2| > 1 + STOPBAND_TOLfor the (lossless) supercell.
- twpasolver.cmes.bloch.gap_ahead(twpa_ll: TwoPortArray, f_hz: ndarray[Any, dtype[float64]], n_sample: int = 16) ndarray[source]#
Whether a stopband starts close to each frequency, toward increasing
|tr T / 2|.Next to a real edge
|h|(h = tr T / 2) crosses 1 almost linearly; at a zone-folding point it only touches 1 (1 - c (f - f0)^2).|h|is sampled fromfto three times the distance at which its linear extrapolation reaches 1: past a real edge it exceeds1 + STOPBAND_TOL, past a folding point it falls back. Two supercell evaluations for all frequencies, so the edge search can skip the folding points.
- twpasolver.cmes.bloch.edge_reference_frequency(twpa_ll: TwoPortArray, f_hz: float, e_ref: float, span_hz: float = 500000000.0, n_scan: int = 2001, max_span_hz: float = 8000000000.0) tuple[float, float, int][source]#
Reference frequency of the fixed basis of a mode near a stopband edge.
Finds the band edge of the lossless supercell closest to
f_hz(|tr T / 2| = 1) and, on its passband side, the frequency where the splitting|sinh(gamma d)| = sqrt(1 - (tr T / 2)^2)equalse_ref.- Returns:
f_ref, f_edge (float) – Reference and edge frequencies (Hz).
parity (int) –
(-1)^m = sign(tr T / 2)at the edge.
- twpasolver.cmes.bloch.stopband_edges(twpa_ll: TwoPortArray, f_hz: ndarray[Any, dtype[float64]], e_ref: float, span_hz: float = 1000000000.0, step_hz: float = 500000.0) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]#
Stopband edges of a lossless supercell near a set of frequencies.
Scans
|tr T / 2|on a grid of stepstep_hzover the union of the intervalsf +- span_hzand refines every edge,|tr T / 2| = 1, and its reference frequency on the passband side, where the splitting equalse_ref, asedge_reference_frequency()does for a single frequency.- Returns:
f_edge, f_ref ((E,) float) – Edge and reference frequencies (Hz), sorted by edge;
f_refis NaN when the passband next to the edge does not reache_refwithin the scanned block.parity ((E,) int) –
(-1)^m = sign(tr T / 2)at the edge.
- twpasolver.cmes.bloch.edge_basis_tables(twpa: TwoPortArray, twpa_ll: TwoPortArray, f_hz: ndarray[Any, dtype[float64]], f_ref_hz: ndarray[Any, dtype[float64]], m_edge: ndarray) dict[str, Any][source]#
Fixed-basis tables of modes close to a stopband edge.
- Parameters:
twpa (TwoPortArray) – Lossy device and its lossless copy (same supercell).
twpa_ll (TwoPortArray) – Lossy device and its lossless copy (same supercell).
f_hz ((F,) float) – Actual mode frequencies.
f_ref_hz ((F,) float) – Reference frequencies (passband side, see
edge_reference_frequency()).m_edge ((F,) int) – Edge index,
kappa_e d = m pi.
- Returns:
Zb_plus,Zb_minus: (F,) lossless Bloch impedances atf_ref(the fixed boundary vectors(Zb+, 1),(-Zb-, 1)).W: (F,) real,Zb+ + Zb-(positive).phi_plus,phi_minus: (F, n_nl) periodic profiles of the fixed vectors propagated through the lossy cells atf, with the edge phaseexp(+-j kappa_e pos).K,K_lossless: (F, 2, 2) per-unit-cell linear generator of(c+, c-)from the lossy / lossless supercell atf.kappa_e: (F,) edge wavenumber per unit cell.ham_defect: (F,)||K^dag S + S K|| / ||K||of the lossless K,S = diag(1, -1); zero to rounding (flux conservation).
- Return type:
- twpasolver.cmes.bloch.reactive_angle_deg(W: ndarray) ndarray[source]#
Reactive angle of the Bloch normalisation,
arcsin(|Im W| / |W|)in degrees.0 for a power-carrying travelling Bloch mode (
Wreal in every lossless passband, for any supercell reference plane), 90 for a purely evanescent mode inside a lossless stopband. Unlikearg Zbit does not depend on the supercell boundary chosen for asymmetric cells.
- twpasolver.cmes.bloch.process_weights(relations: ndarray, mode_weights: ndarray) ndarray[source]#
Weight of every relation row: product of the weights of all its modes.
All rows describing the same physical process (one per participating mode, and every direction / reciprocal-vector variant in the FB model) contain the same multiset of modes, so they receive the same real factor and the Manley-Rowe cancellation between them is preserved exactly.