twpasolver.modes_rwa module#

Modes, frequency relations and rotating-wave-approximation (RWA) terms.

A ModeSet lists the modes of a coupled-mode-equation (CME) system, beyond pump, signal and idler (pump harmonics p2, conversion terms ps, signal/idler harmonics s2, …), and the relations fixing their frequencies. A relation such as ["i", "p-s"] sets a mode to a sum or difference of other modes, so every mode frequency is an integer combination of the independent tones (the modes no relation defines, any number of them). The RWA terms of a given order are the products of modes and conjugates whose combinations add up to a mode, found exactly on these integer vectors.

Examples

See Tutorial 4 (Tutorials) for standard and custom mode sets and RWA term analysis.

class twpasolver.modes_rwa.ModeSet(labels: Tuple[str, ...], relations: Tuple[Tuple[str, str], ...] = ())[source]#

Bases: object

Modes of a CME system and the frequency relations between them.

Parameters:
  • labels – Mode names; their order is the order of the CME amplitudes.

  • relations – [result, expression] pairs, e.g. ["i", "p-s"]; an expression is a sum or difference of mode names (repetitions allowed, "p+p-s"). A mode is defined by at most one relation; relations must not be cyclic.

Variables:
  • independent (Tuple[str, ...]) – Modes not defined by any relation (the independent tones).

  • matrix (numpy.ndarray) – Integer coefficients of every mode over independent, shape (n_modes, n_independent).

labels: Tuple[str, ...]#
relations: Tuple[Tuple[str, str], ...] = ()#
independent: Tuple[str, ...]#
matrix: ndarray#
classmethod basic(three_wave: bool = True) → ModeSet[source]#

Pump, signal and idler, with i = p - s (3WM) or i = 2p - s (4WM).

classmethod extended_3wm(n_pump_harmonics: int = 1, n_frequency_conversion: int = 1, n_signal_harmonics: int = 0, n_sideband_conversion: int = 0) → ModeSet[source]#

3WM pump, signal and idler with pump harmonics, conversion terms and sidebands.

Every signal order m gives the harmonic m s and its 3WM idler p - m s, labelled s{m} and i{m}, and their conversion chain n p + m s and (n + 1) p - m s, labelled p{n}s{m} and p{n}i{m} (m and n are left out when 1). Order m = 1 is the signal and idler themselves: s, i, ps, pi, p2s, …; order 2 gives s2 (2s), i2 (p - 2s), ps2 (p + 2s), pi2 (2p - 2s), …

The sidebands (m >= 2) are second or higher order in the signal: they leave the small-signal gain unchanged and matter in compression. The idler p - m s crosses 0 Hz at s = p / m, so keep the signals on one side of it (a mode below the frequency grid raises).

Parameters:
  • n_pump_harmonics – Number of pump harmonics (p2, p3, …).

  • n_frequency_conversion – Largest pump order n of the conversion chain of the signal and idler (ps/pi, p2s/p2i, …).

  • n_signal_harmonics – Number of sideband orders m = 2, 3, ... (s2/i2, s3/i3, …).

  • n_sideband_conversion – Largest pump order n of the conversion chain of every sideband order (ps2/pi2, p2s2/p2i2, …).

index(label: str) → int[source]#

Position of label among the modes.

frequencies(tones: Mapping[str, float | ndarray]) → ndarray[source]#

Frequencies of every mode, shape (n_modes, …), from the independent tones.

Parameters:

tones – Frequency of every independent mode, scalars or arrays that broadcast together; extra keys raise.

rwa_terms(power: int) → list[tuple[Any, ...]][source]#

RWA terms with power mode factors (2 for 3WM, 3 for 4WM).

Returns:

Tuples (mode_idx, combination, mode_name, rhs_terms, coefficient) sorted by mode_idx: the term prod(combination) drives mode mode_idx; indices in combination at or above the number of modes are conjugated modes; coefficient is 1 / prod(n_r!) over repeated factors.

dependents(label: str) → set[str][source]#

Modes whose relations depend, directly or not, on label.

expression(label: str) → str[source]#

Frequency of label over the independent tones, e.g. "p - s".

plot_relations(tones: Mapping[str, float] | None = None, figsize: Tuple[float, float] | None = None, node_size: int = 3000, font_size: int = 12, layout: str = 'hierarchical') → Figure[source]#

Plot the relations between modes as a directed graph.

Parameters:
  • tones – Independent tones; if given, nodes show the mode frequencies.

  • figsize – Figure size (width, height); None sizes it to the graph.

  • node_size – Size of mode nodes.

  • font_size – Font size for labels.

  • layout – Graph layout (‘hierarchical’, ‘circular’ or ‘spring’).

twpasolver.modes_rwa.as_mode_set(modes: str | ModeSet | Sequence[Any]) → ModeSet[source]#

A ModeSet from itself or the names "basic_3wm" / "basic_4wm".