## Using the Inverse Fast Fourier Transform to Reconstruct a Transient Signal

In this article, we will discuss how to use the inverse fast Fourier transform (IFFT) functionality in the COMSOL Multiphysics^{®} software and show how to reconstruct the time-domain response of an electrical system.

### Background

When simulating the response of a linear system to time-varying input signals, it is possible to model in the time domain or the frequency domain and to convert between them using the fast Fourier transform (FFT) and IFFT. Given a physical system and a time-domain input signal, it is possible to compute the response of the system over time. Alternatively, it is possible to take the FFT of the time signal and use that as input to a frequency-domain model of the system. Via the IFFT, this can be transformed back into the time domain. This article covers how to use the IFFT functionality.

### Converting from Frequency Domain to Time Domain

We start with a known signal that has already been converted from the time domain to the frequency domain via the FFT. We will use the IFFT to convert back to the time domain. Starting with the example developed in a previous article, where an FFT of a trapezoidal pulse is taken, the screenshot below shows the *Frequency to Time FFT* study step that will convert the frequency-domain data back to the time domain.

*Screenshot of the* Frequency to Time FFT *study step settings.*

The results of the IFFT are shown below. We have zoomed in to one section, making it possible to see the Gibb's phenomena.

*The results of taking an IFFT on the FFT of a trapezoidal pulse.*

It is also interesting to see how the IFFT reconstructs the signal in terms of the number of harmonics considered. We already know from looking at the FFT that only the odd harmonics carry significant information, and we would like to see what the IFFT looks like by considering only the lowest few harmonics in the IFFT. This is done by using the *Window function* capability, which can be used to operate on the frequency-domain data, where the frequency is the built-in variable, `freq`

. The screenshot below shows a Boolean expression being used (`freq<N*f1`

), which evaluates to zero or one. It filters out all signals greater than `N*f1`

, where `N`

is a positive integer parameter that is being swept over via the *Parametric Sweep* feature.

*Screenshot of the* Frequency to Time FFT *study step, with the window function being used. The* Parametric Sweep *is used to sweep over the number of harmonics used in the reconstruction.*

The results below show how including an increasing number of harmonics will improve the reconstruction of the original signal.

*The results of taking an IFFT on the FFT of a trapezoidal pulse, with increasing number of harmonics being considered.*

We now see how a signal can be converted from the time domain to the frequency domain and back again via the FFT and IFFT. Next, we will look at how the FFT of this signal can be combined with a model of a system to compute the transient response of a model via the IFFT.

### Using the IFFT to Reconstruct the Transient Response of a System

Here, we examine a system composed of a coaxial probe inserted into a metal cavity that is filled with a lossy dielectric, with relative permittivity of 50 and electric conductivity of 30 mS/m. The insulator within and surrounding the coax has a relative permittivity of 1.75 and electric conductivity of 1-e12 S/m. The outer conductor of the coax is electrically connected to the cavity walls, and the inner conductor is fed with a time-varying current source. This type of model can be solved with the transient *Electric Currents* interface since the magnetic fields are negligible.

*A model of a coaxial probe inside of a metallic cavity filled with a sample of lossy dielectric material.*

Solving this model for one period of the same trapezoidal pulse shown earlier, we can plot the voltage and current at the terminal as well as the losses within the sample. The response shows the typical behavior of a resistive–capacitive system.

*The terminal voltage (blue) and applied current (green) as computed in time.*

*The losses within the sample material computed over time.*

We want to reconstruct these results by instead solving the model in the frequency domain, followed by using the FFT of the excitation function that was computed earlier. Begin by solving the model in the frequency domain (using a unit excitation) over a set of harmonics. For this example, we solve for the first 100 harmonics. We then combine the frequency-domain response of the model with the FFT of this input signal via the *Window function* in the *Frequency to Time FFT* study, as shown in the screenshot below. The `withsol()`

operator is used to refer to the results of taking the FFT of the excitation function.

*Using the* Frequency to Time FFT *study to take an input study and an FFT as computed from a* Time to Frequency FFT *study.*

*Comparison of terminal voltage computed in the time domain (gray line) versus computed via frequency domain and IFFT (dashed blue line).*

*Comparison of losses computed in the time domain (gray line) versus computed via frequency domain and IFFT (dashed red line).*

The results show excellent agreement between the transient solution and the solution computed via the IFFT, using the first 100 harmonics.

It is also possible to reconstruct the signal with a smaller subset of nonuniformly spaced harmonics. To see why this is useful, look at the magnitude of the Fourier coefficients of the first 20 harmonics. Observe that all even harmonics are negligible and that the 5^{th} and 15^{th} harmonic are also negligible. It is thus justified to solve the frequency-domain model over only a much smaller and nonuniform frequency range.

*Magnitude of the Fourier coefficients of the first 20 harmonics of the trapezoidal pulse. Only some of these are significant.*

To solve the model, we solve a second *Frequency Domain* study over a fewer number of harmonics, which will take much less time. Within the *Frequency to Time FFT* study, we instead have to use the *Discrete Fourier transform* scaling option rather than the option for continuous scaling. The results show that the terminal voltage and losses in the sample still agree reasonably well.

*Using the* Frequency to Time FFT *study with a nonuniform set of frequency-domain results requires the discrete Fourier transform scaling.*

*The terminal voltage computed in the time domain (gray) versus computed via IFFT with only a few harmonics (blue).*

*The losses computed in the time domain (gray) versus computed via IFFT with only a few harmonics (red).*

### Extracting Time-Integrated Quantities

It is also useful to extract the total energy deposited into the sample per pulse. This data can be extracted directly from the *Time Dependent* study results by using the time integration operator:

`timeint(0, T1/2, intopSample(ec.Qh), 'nointerp')`

.
This expression integrates without interpolation over only one-half the period since we know already that the signal repeats over the second half of the period and that the integral over the entire period will be twice as much.

The same information can be extracted by combining the frequency-domain solution and the FFT of the input signal via the `withsol()`

operator. The energy dissipated within the sample material, for the N^{th} harmonic, can be computed via the expression

`withsol('sol2',0.5*intopSample(ec.Qh)*T1,setind(freq,N))*withsol('sol4',abs(comp1.u)^2,setind(freq,N+1))`

The parameter `N`

is a positive integer. The first `withsol`

operator within this expression uses the frequency-domain results with a factor of one-half applied to the losses for only one pulse, and the `setind`

argument sets the frequency index to the N^{th} harmonic. The scond `withsol`

operator uses the FFT results, and the `setind`

argument refers to the N+1 solution since the FFT dataset contains the DC solution.

It is possible to plot this data by introducing another *Global ODEs and DAEs* interface that stores the results of the above evaluation and to solve that within a study that sweeps over a number of harmonics. The results show that for this case over 75% of the dissipation of energy is in the 1^{st} harmonic; over 95% is in the 1^{st} and 3^{rd}; and over 99% is in the 1^{st}, 3^{rd}, 7^{th}, and 9^{th}. These observations of the system can be very useful when dealing with electromagnetic heating models.

*The fraction of the total dissipated energy in the system, summed over the first 20 harmonics.*

### Further Learning

You can open and review the model example shown throughout this article via the downloadable files on this page.

请提交与此页面相关的反馈，或点击此处联系技术支持。