# Spectral averaging simple example

This page provides a simple example of the spectral averaging feature of frequency domain field monitors. This feature provides the most efficient method for calculating the average response over a range of frequencies.

Power monitors have three spectral averaging modes.

- Standard Fourier Transform (SFT), or no averaging. This is the default option, which calculates the response of the system at a particular set of frequencies.
- Partial Spectral Average (PSA). This option calculates the average response over a range of frequencies using a Lorentzian weighting function.
- Total Spectral Average (TSA). This option calculates the average response over the entire source spectrum.

The options can be selected in the Data to record tab of the monitor properties, as shown below.

In this example, we will calculate the reflection of an Air-Si-Ag-Air multi-layer stack in FDTD (a similar set up can be created in MODE' propagator). This is a useful test case because it has a complicated reflection spectrum. A screenshot of the structure is shown below. Please note that for this multilayer problem we have set the mesh refinement to "conformal variant 1" to take full advantage of the conformal meshing for both the Si and the Ag layer.

Without the spectral averaging functions (PSA and TSA), the only way to calculate an average spectral response is to measure the response at a large number of frequencies with the Standard Fourier Transform (SFT) option, then manually calculate the averages by post processing. The problem with this technique is that the simulation memory requirements can become impractically large when attempting to save a large number of frequencies.

In this example, we will calculate two values.

- Average reflection at 50 frequency points between 350-750HTz using a 10THz FWHM Lorentzian weighting function.
- Total average reflection between 350-750THz.

Both calculations will be done by two techniques.

- The built in PSA and TSA monitor options.
- The brute force technique of using a SFT monitor to measure the response at many frequencies (500). The average can then be manually calculated.

The following figure shows the memory requirements estimate of this simulation. Notice that the SFT monitor measuring 500 frequency points requires 66% of the memory, while the PSA monitor requires only 7% and the TSA requires 0.1%. In large 3D FDTD simulations, the memory savings from the PSA and TSA options can be very important.

## Standard fourier transform (SFT)

The Standard fourier transform (SFT) calculates the response of the system at a set of specific frequencies. The vast majority of simulation analysis uses the SFT mode of operation.

The following figure shows the reflectance as a function of frequency at 500 points between 350-750 THz.

For more details about how the SFT is calculated, see the Frequency domain normalization section of the Reference Guide.

## Partial spectral average (PSA)

The Partial spectral average (PSA) mode of operation allows the monitor to calculate the average response of the system over a range of frequencies. The weighting function is the product of the source spectrum and a lorentzian. The FWHM of the lorentzian can be specified in the monitor properties. In this example, it is 10THz.

The following figure shows the average reflectance as calculated by the PSA monitor (red) and the brute force technique (green). The two techniques give very similar results, although there are some differences at the minimum and maximum frequencies. The differences at these frequencies occur because the SFT data does not contain any data beyond the minimum or maximum frequencies. One other very important difference is that the brute force technique required 10 times more simulation memory.

The reflectance vs frequency as calculated by the SFT (blue) is shown for reference. The lorentzian weighting function (10 THz wide, centered at 530 THz) is also shown for reference.

NOTE: Discrepancies between PSA and brute force technique at the min and max frequencies

The brute force calculation does not include reflected power beyond the source limits (<350THz and >750THz), while the TSA monitor includes all frequencies in the integrals. If the frequency range of the standard fourier transform (SFT) monitor was increased, the agreement would improve.

## Total spectral average (TSA)

The Total spectral average (TSA) mode of operation allows the monitor to calculate the average response of the system using the source spectrum as a weighting function.

The following figure shows the average reflectance as calculated by the TSA monitor (red) and the brute force technique (green). The two techniques give very similar results. One very important difference is that the brute force technique required 500 times more simulation memory.

NOTE: Discrepancy between TSA and brute force technique

The brute force calculation does not include reflected power beyond the source limits (<350THz and >750THz), while the TSA monitor includes all frequencies in the integrals. If the frequency range of the standard fourier transform (SFT) monitor was increased, the agreement would improve.