Skip to content

flex_rf.tidy3d.ModeInterpSpec

Type: class Base(s): Tidy3dBaseModel

Specification for mode frequency interpolation.

Allows computing modes at a reduced set of frequencies and interpolating to obtain results at all requested frequencies. This can significantly reduce computational cost for broadband simulations where modes vary smoothly with frequency.

Requires frequency tracking to be enabled (mode_spec.sort_spec.track_freq must not be None) to ensure mode ordering is consistent across frequencies.

# Uniform sampling with linear interpolation
interp_spec = ModeInterpSpec(
method='linear',
sampling_spec=UniformSampling(num_points=10)
)
# Chebyshev sampling with polynomial interpolation
interp_spec = ModeInterpSpec.cheb(num_points=10)
# Custom sampling with cubic interpolation
custom_freqs = [1e14, 1.5e14, 2e14, 2.5e14]
interp_spec = ModeInterpSpec.custom(method='cubic', freqs=custom_freqs)
sampling_spec [UniformSampling | ChebSampling | CustomSampling]

Specification for frequency sampling points.

method [Literal['linear', 'cubic', 'poly']] = 'linear'

Method for interpolating mode data between computed frequencies. ‘linear’ uses linear interpolation (faster, requires 2+ points). ‘cubic’ uses cubic spline interpolation (smoother, more accurate, requires 4+ points). ‘poly’ uses polynomial interpolation with barycentric formula (optimal for Chebyshev nodes, requires 3+ points). For complex-valued data, real and imaginary parts are interpolated independently.

reduce_data [bool] = False

Applies only to ModeSolverData. If True, fields and quantities are only recorded at interpolation source frequency points. The data at requested frequencies can be obtained through interpolation. This can significantly reduce storage and computational costs for broadband simulations. Does not apply if the number of sampling points is greater than the number of monitor frequencies.

num_points [int]

Number of sampling points.

cheb(num_points: int, reduce_data: bool = False)

Create a ModeInterpSpec with Chebyshev node sampling and polynomial interpolation.

custom(freqs: FreqArray, method: Literal['linear', 'cubic', 'poly'] = 'linear', reduce_data: bool = False)

Create a ModeInterpSpec with custom frequency sampling.

sampling_points(freqs: FreqArray)

Compute frequency sampling points.

uniform(num_points: int, method: Literal['linear', 'cubic', 'poly'] = 'linear', reduce_data: bool = False)

Create a ModeInterpSpec with uniform frequency sampling.