tidy3d.FreqRange#

class FreqRange[source]#

Bases: Tidy3dBaseModel

Convenience class for handling frequency/wavelength conversion; it simplifies specification of frequency ranges and sample points for sources and monitors.

Parameters:
  • attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • freq0 (PositiveFloat) – [units = Hz]. Real-valued positive central frequency.

  • fwidth (PositiveFloat) – [units = Hz]. Real-valued positive width of the frequency range (bandwidth).

Notes

Depending on the context the user can define desired frequency range by specifying: - central frequency freq0 and frequency bandwidth fwidth; - frequency interval [fmin,``fmax``]; - central wavelength wvl0 and wavelength range wvl_width; - wavelength interval [wvl_min, wvl_max].

Example

>>> import tidy3d as td
>>> freq0  = 1e12
>>> fwidth = 1e11
>>> freq_range = td.FreqRange(freq0=freq0, fwidth=fwidth)
>>> central_freq = freq_range.freqs(num_points=1, spacing="uniform_freq")
>>> freqs = freq_range.freqs(num_points=11, spacing="uniform_wvl")
>>> source = freq_range.to_gaussian_pulse()

Attributes

fmax

Infer highest frequency fmax from central frequency freq0 and bandwidth fwidth.

fmin

Infer lowest frequency fmin from central frequency freq0 and bandwidth fwidth.

wvl0

Get central wavelength from central frequency and bandwidth.

attrs

Methods

check_half_fwidth_less_than_freq0(values)

freqs(num_points[, spacing])

method freqs() returns a numpy array of num_point frequencies uniformly sampled from the specified frequency range; if num_points == 1 method returns the central frequency freq0.

from_freq_interval(fmin, fmax)

method from_freq_interval() creates instance of class FreqRange from frequency interval defined by arguments fmin and fmax.

from_wvl(wvl0, wvl_width)

method from_wvl() updated instance of class FreqRange by reassigning new frequency- and wavelength-related parameters.

from_wvl_interval(wvl_min, wvl_max)

method from_wvl_interval() updated instance of class FreqRange by reassigning new frequency- and wavelength-related parameters.

to_gaussian_pulse(**kwargs)

to_gaussian_pulse(): Return a GaussianPulse instance based on this frequency range.

wvls(num_points[, spacing])

method wvls() returns a numpy array of num_points wavelengths uniformly sampled from the range of wavelengths; if num_points == 1 the method returns central wavelength wvl0.

Inherited Common Usage

freq0#
fwidth#
classmethod check_half_fwidth_less_than_freq0(values)[source]#
property fmin#

Infer lowest frequency fmin from central frequency freq0 and bandwidth fwidth.

property fmax#

Infer highest frequency fmax from central frequency freq0 and bandwidth fwidth.

property wvl0#

Get central wavelength from central frequency and bandwidth.

classmethod from_freq_interval(fmin, fmax)[source]#

method from_freq_interval() creates instance of class FreqRange from frequency interval defined by arguments fmin and fmax.

NB: central frequency never corresponds to central wavelength! freq0 = (fmin + fmax) / 2 implies that wvl0 != (wvl_min + wvl_max) / 2 and vise-versa.

Parameters:
  • fmin (float) – Lower bound of frequency of interest.

  • fmax (float) – Upper bound of frequency of interest.

Returns:

An instance of FreqRange defined by frequency interval [fmin, fmax].

Return type:

FreqRange

classmethod from_wvl(wvl0, wvl_width)[source]#

method from_wvl() updated instance of class FreqRange by reassigning new frequency- and wavelength-related parameters.

NB: central frequency never corresponds to central wavelength! wvl0 = (wvl_min + wvl_max) / 2 implies that freq0 != (fmin + fmax) / 2 and vise versa.

Parameters:
  • wvl0 (float) – Real-valued central wavelength.

  • wvl_width (float) – Real-valued wavelength range.

Returns:

An instance of FreqRange defined by central wavelength wvl0 and wavelength range wvl_width.

Return type:

FreqRange

classmethod from_wvl_interval(wvl_min, wvl_max)[source]#

method from_wvl_interval() updated instance of class FreqRange by reassigning new frequency- and wavelength-related parameters.

NB: central frequency never corresponds to central wavelength! wvl0 = (wvl_min + wvl_max) / 2 implies that freq0 != (fmin + fmax) / 2.

Parameters:
  • wvl_min (float) – The lowest wavelength of interest.

  • wvl_max (float) – The longest wavelength of interest.

Returns:

An instance of FreqRange defined by the wavelength interval [wvl_min, wvl_max].

Return type:

FreqRange

freqs(num_points, spacing='uniform_freq')[source]#

method freqs() returns a numpy array of num_point frequencies uniformly sampled from the specified frequency range; if num_points == 1 method returns the central frequency freq0.

Parameters:
  • num_points (int) – Number of frequency points in a frequency range of interest.

  • spacing (str = "uniform_freq") – Mode of frequency sampling. If spacing is set to uniform_freq, frequencies are sampled uniformly over the frequency interval. If set to uniform_wvl, frequencies correspond to uniformly sampled wavelengths over the wavelength interval. Frequencies are sorted in ascending order.

Returns:

a numpy array of uniformly distributed frequency samples in a frequency range of interest.

Return type:

np.ndarray

wvls(num_points, spacing='uniform_wvl')[source]#

method wvls() returns a numpy array of num_points wavelengths uniformly sampled from the range of wavelengths; if num_points == 1 the method returns central wavelength wvl0.

Parameters:
  • num_points (int) – Number of wavelength points in a range of wavelengths of interest.

  • spacing (str = "uniform_wvl") – Mode of wavelength sampling. If spacing is set to uniform_wvl, wavelengths are sampled uniformly over the wavelength interval. If set to uniform_freq, wavelengths correspond to uniformly sampled frequencies over the frequency interval. Wavelengths are sorted in ascending order.

Returns:

a numpy array of uniformly distributed wavelength samples in ascending order.

Return type:

np.ndarray

to_gaussian_pulse(**kwargs)[source]#

to_gaussian_pulse(): Return a GaussianPulse instance based on this frequency range.

This method constructs a GaussianPulse using GaussianPulse.from_frequency_range(fmin=self.fmin, fmax=self.fmax, **kwargs).

If you prefer to define the pulse using freq0 and fwidth directly, you should manually instantiate the GaussianPulse instead.

Parameters:

kwargs (dict) – Keyword arguments passed to GaussianPulse(), excluding freq0 & fwidth.

Returns:

A GaussianPulse that maximizes its amplitude in the frequency range [fmin, fmax].

Return type:

GaussianPulse

__hash__()#

Hash method.