tidy3d.plugins.resonance.ResonanceFinder#

class ResonanceFinder[source]#

Bases: Tidy3dBaseModel

Tool that extracts resonance information from a time series of the form shown below. The resonance information consists of frequency \(f\), decay rate \(\alpha\), Q factor \(Q = \pi |f|/\alpha\), amplitude \(a\), and phase \(\phi\).

Parameters:
  • freq_window (Attribute: freq_window) –

    Type

    Tuple[float, float]

    Default

    Units

    Hz

    Description

    Window [fmin, fmax] for the initial frequencies. The resonance finder is initialized with an even grid of frequencies between fmin and fmax. The resonance finder then iteratively optimizes and prunes these frequencies. Note that frequencies outside this window may be returned. A narrow frequency window that only contains a few resonances may give enhanced accuracy compared to a broad frequency window with many resonances.

  • init_num_freqs (Attribute: init_num_freqs) –

    Type

    PositiveInt

    Default

    = 200

    Description

    Number of frequencies with which the resonance finder is initialized. The resonance finder then iteratively optimizes and prunes these frequencies. The number of frequencies returned will be less than init_num_freqs. Making this larger can find more resonances, while making it smaller can speed up the resonance finder.

  • rcond (Attribute: rcond) –

    Type

    NonNegativeFloat

    Default

    = 0.0001

    Description

    Cutoff for eigenvalues, relative to the largest eigenvalue. The resonance finder solves a generalized eigenvalue problem of the form \(Ax = \lambda B x\). If B has small eigenvalues, this is poorly conditioned, so we eliminate eigenvalues of B less than rcond times the largest eigenvalue. Making this closer to zero will typically return more resonances.

Note

\[f(t) = \sum_k a_k e^{i \phi_k} e^{-2 \pi i f_k t - \alpha_k t}\]

Note

We use the algorithm described in

Vladimir A. Mandelshtam and Howard S. Taylor, β€œHarmonic inversion of time signals and its applications,” J. Chem. Phys. 107, 6756 (1997).

Example

>>> import numpy as np
>>> from tidy3d.plugins.resonance import ResonanceFinder
>>> t = np.linspace(0, 10000, 10000)
>>> f1 = 2*np.pi*0.1 - 1j*0.002
>>> f2 = 2*np.pi*0.2 - 1j*0.0005
>>> sig = 2*np.exp(-1j*f1*t) + 3*1j*np.exp(-1j*f2*t)
>>> resfinder = ResonanceFinder(freq_window=(0.05, 0.25))
>>> resdata = resfinder.run_raw_signal(signal=sig, time_step=1)
>>> resdata.to_dataframe()

Attributes

Methods

run(signals)

Finds resonances in a FieldTimeData or a Tuple of such.

run_raw_signal(signal,Β time_step)

Finds resonances in a time series.

run_scalar_field_time(signal)

Finds resonances in a ScalarFieldTimeDataArray.

freq_window#
init_num_freqs#
rcond#
run(signals)[source]#

Finds resonances in a FieldTimeData or a Tuple of such. The time coordinates must be uniformly spaced, and the spacing must be the same across all supplied data. The resonance finder runs on the sum of the Ex, Ey, and Ez fields of all the supplied data, unless no electric fields are present at all, in which case it runs on the sum of the Hx, Hy, and Hz fields. Note that the signal should start after the sources have turned off.

Parameters:

signals (FieldTimeData) – Data to search for resonances

Returns:

Dataset containing the decay rate, Q, amplitude, phase, and estimation error of the resonances as a function of frequency. Modes with low Q, small amplitude, or high estimation error are likely to be spurious.

Return type:

xr.Dataset

run_scalar_field_time(signal)[source]#

Finds resonances in a ScalarFieldTimeDataArray. The time coordinates must be uniformly spaced to use the resonance finder; the time step is calculated automatically. Note that the signal should start after the sources have turned off.

Parameters:

signal (ScalarFieldTimeDataArray) – Time series to search for resonances

Returns:

Dataset containing the decay rate, Q, amplitude, phase, and estimation error of the resonances as a function of frequency. Modes with low Q, small amplitude, or high estimation error are likely to be spurious.

Return type:

xr.Dataset

run_raw_signal(signal, time_step)[source]#

Finds resonances in a time series. Note that the signal should start after the sources have turned off.

Parameters:
  • signal (List[complex]) – One-dimensional array holding the complex-valued time series data to search for resonances.

  • time_step (float) – Time step / sampling rate of the data (in seconds).

Returns:

Dataset containing the decay rate, Q, amplitude, phase, and estimation error of the resonances as a function of frequency. Modes with low Q, small amplitude, or high estimation error are likely to be spurious.

Return type:

xr.Dataset

__hash__()#

Hash method.