twpasolver.analysis.results module#

Results of the gain and phase-matching analyses.

class twpasolver.analysis.results.GainResult(model: str, unit: str, signal_freqs: ~numpy.ndarray, pump_freq: float, x: ~numpy.ndarray, mode_labels: list[str], signal_mode: str, pump_mode: str, I_fwd: ~numpy.ndarray, I_bwd: ~numpy.ndarray, a_in: ~numpy.ndarray, a_out: ~numpy.ndarray, b_in: ~numpy.ndarray, b_out: ~numpy.ndarray, gain_db: ~numpy.ndarray, gain_db_12: ~numpy.ndarray, gain_db_11: ~numpy.ndarray, gain_db_22: ~numpy.ndarray, converged: ~numpy.ndarray, diagnostics: dict[str, typing.Any] = <factory>, history: dict[str, typing.Any] = <factory>)[source]#

Bases: _Saveable

Result of TWPAnalysis.gain(); the same fields for every model.

Frequencies are in unit, positions in unit cells, currents in A.

Variables:
  • model (str) – Gain model, "simple" or "bloch".

  • unit (str) – Frequency unit.

  • signal_freqs (numpy.ndarray) – Signal frequencies, shape (n_freq,).

  • pump_freq (float) – Pump frequency.

  • x (numpy.ndarray) – Positions along the device, shape (n_x,).

  • mode_labels (list[str]) – Mode names, in the order of the mode axis.

  • pump_mode (signal_mode,) – Names of the signal and pump modes.

  • I_bwd (I_fwd,) – Forward and backward mode currents inside the device, shape (n_freq, n_modes, n_x); I_bwd is zero for simple.

  • a_out (a_in,) – Currents incident from the external lines at x=0 and x=L, shape (n_freq, n_modes).

  • b_out (b_in,) – Currents going out into the external lines at x=0 and x=L (b_in is NaN for simple, which does not model it).

  • gain_db_22 (gain_db, gain_db_12, gain_db_11,) – Signal S21, S12, S11 and S22 in dB, shape (n_freq,); NaN where the reference input is zero. With inputs at both ends the outputs contain the response to both.

  • converged (numpy.ndarray) – Points whose solution converged (bloch) or reached the end of the device (simple), shape (n_freq,).

  • diagnostics (dict[str, Any]) – Solver tables (bloch: Bloch tables, edge-basis flags, residuals). The forward-backward residual is the largest change of any mode between passes relative to that mode’s largest forward plus backward envelope; nearly empty backward envelopes dominate it, so 1e-3 to 1e-1 is common while the gains are stable.

  • history (dict[str, Any]) – With BlochSolverConfig(save_all_passes=True), every pass: I_fwd, I_bwd, b_in, b_out and the four gains with a leading pass axis of length passes; NaN after the last pass a point ran (diagnostics["passes_used"]). Otherwise empty.

model: str#
unit: str#
signal_freqs: ndarray#
pump_freq: float#
x: ndarray#
mode_labels: list[str]#
signal_mode: str#
pump_mode: str#
I_fwd: ndarray#
I_bwd: ndarray#
a_in: ndarray#
a_out: ndarray#
b_in: ndarray#
b_out: ndarray#
gain_db: ndarray#
gain_db_12: ndarray#
gain_db_11: ndarray#
gain_db_22: ndarray#
converged: ndarray#
diagnostics: dict[str, Any]#
history: dict[str, Any]#
mode(label: str) → int[source]#

Index of mode label on the mode axis.

bandwidth(gain_reduction: float = 3) → dict[str, Any][source]#

Compound bandwidth of gain_db within gain_reduction dB of its maximum.

Returns bandwidth_edges (start and end of every contiguous band), total_bw, max_gain, reduced_gain, mean_gain (over the band) and bw_freqs.

plot(**kwargs) → Axes[source]#

Plot gain_db versus signal frequency.

plot_currents(backward: bool = False, **kwargs) → Axes[source]#

Plot the mode currents along the device, averaged over frequency.

class twpasolver.analysis.results.PhaseMatchingResult(unit: str, process: str, mixing: str, signal_mode: str, pump_mode: str, idler_mode: str, signal_freqs: ndarray, pump_freqs: ndarray, delta: ndarray, relative: bool, optimal_pump_freq: float, f_triplets: ndarray, k_triplets: ndarray)[source]#

Bases: _Saveable

Result of TWPAnalysis.phase_matching().

Variables:
  • unit (str) – Frequency unit.

  • mixing (process,) – Process ("PA", "FCU", "FCD") and mixing ("3WM", "4WM").

  • idler_mode (signal_mode, pump_mode,) – Mode names.

  • pump_freqs (signal_freqs,) – Grids, shapes (n_signal,) and (n_pump,).

  • delta (numpy.ndarray) – Phase mismatch per unit cell (relative to the signal k if relative), shape (n_signal, n_pump); NaN for pumps in a stopband.

  • relative (bool) – Whether delta is divided by the signal wavenumber.

  • optimal_pump_freq (float) – Pump with the smallest mean |delta|; NaN if none.

  • k_triplets (f_triplets,) – Pump, signal and idler frequencies and (length-weighted) wavenumbers for every pump and signal, shape (n_pump * n_signal, 3).

unit: str#
process: str#
mixing: str#
signal_mode: str#
pump_mode: str#
idler_mode: str#
signal_freqs: ndarray#
pump_freqs: ndarray#
delta: ndarray#
relative: bool#
optimal_pump_freq: float#
f_triplets: ndarray#
k_triplets: ndarray#
plot(**kwargs) → Axes[source]#

Plot delta over pump and signal frequency.