Solving PDEs with the FFT: Part 2

In the previous lecture, we explored how to solve the heat equation using the fast Fourier transform (FFT). Today, we’ll tackle two more equations: the one-way wave equation and the Burgers’ equation. These equations represent both linear and nonlinear wave behavior. So, let’s dive in and see how the FFT can help us solve them efficiently.

Solving PDEs with the FFT: Part 2
Solving PDEs with the FFT: Part 2

The One-Way Wave Equation

The one-way wave equation is described by the equation: Ut + C * Ux = 0. Here, U represents a wave that propagates from left to right at a constant speed C. To solve this equation, we can use the same approach as before. We’ll Fourier transform the variable U with respect to X and solve the equation in terms of U hat, a function of the spatial wave number K and time T.

To do this, we’ll utilize the relationship that states Ux, when Fourier transformed, becomes I Kappa U hat. So, by Fourier transforming the equation, we get U hat time derivative = -C I Kappa U hat. This becomes the right-hand side of our ordinary differential equation (ODE) integrator.

To solve the system of ODEs, we’ll use the OD45 function in MATLAB. We define the domain, Kappa variables, initial condition, and then apply OD45 to our vector field. The right-hand side of the wave equation is determined by locking the Kappa vector, wave speed C, and the frequency vector in the wave equation.

After solving the PDE, we’ll inverse Fourier transform the result to recover U as a function of space and time. Running the code and plotting the result, we observe that the FFT solution captures the behavior of the wave equation accurately.

Further reading:  Numerical Calculus: Introduction to Taylor Series

Waterfall plot of the wave equation

The Burgers’ Equation

Moving on to the Burgers’ equation, which is a nonlinear PDE defined as: Ut + U Ux = nu Uxx. This equation models the formation of shocks in fluid systems. If we ignore the diffusion term, the equation resembles the one-way wave equation, but with the wave speed proportional to the amplitude. Consequently, higher points in the wave move faster than lower points, causing them to stack up and form sharp shock waves.

To simulate this equation, we need to consider both the convection and diffusion terms. However, computing the product U * Ux in the Fourier domain results in a complicated convolution. Hence, we’ll solve the Burgers’ equation in the spatial domain. Similar to the previous example, we Fourier transform U to obtain U hat, calculate its first and second derivatives, and then inverse Fourier transform them to obtain Ux and Uxx in real space.

With these derivatives, we can build the right-hand side of the equation: -U Ux + nu Uxx. Again, we use the OD45 function to solve the system of ODEs. Plotting the result as a waterfall plot, we can observe the formation of shocks that are balanced by the diffusion term.

Waterfall plot of the Burgers' equation

Conclusion

In conclusion, we have demonstrated how the fast Fourier transform (FFT) can be effectively utilized to solve partial differential equations (PDEs). By mapping the PDEs into the Fourier domain, we can accurately approximate derivatives and efficiently solve the equations. This approach is suitable for both linear and nonlinear PDEs, enabling us to simulate wave behavior and capture the formation of shocks.

Further reading:  System Identification: Uncovering the Secrets of Dynamic Mode Decomposition with Control

If you’re interested in diving deeper into this topic, I encourage you to try solving the Navier-Stokes equations on a periodic domain using the same approach. By Fourier transforming in both X and Y dimensions, you can solve the equations and then inverse Fourier transform to obtain the results. Good luck with your exploration of PDEs and the FFT!

FAQs

  1. What is the advantage of using the FFT to solve PDEs?
    Using the FFT allows us to accurately approximate derivatives and efficiently solve PDEs. It simplifies the computation by working in the Fourier domain, where multiplication becomes equivalent to differentiation. This approach improves both accuracy and computational efficiency.

  2. Can we solve nonlinear PDEs using the FFT?
    Yes, we can solve nonlinear PDEs using the FFT. While we can’t directly use the FFT to compute the product of nonlinear terms, we can approximate the derivatives using the FFT. By solving the PDEs in the spatial domain and utilizing the FFT to approximate the derivatives, we can accurately simulate nonlinear behavior.

  3. How can I apply the FFT to solve other PDEs?
    The general approach involves mapping the PDEs into the Fourier domain, approximating the derivatives using the FFT, and then solving the resulting system of ODEs. Depending on the PDE’s characteristics, you may need to adapt the specific steps. Experimentation and practice will deepen your understanding and enable you to apply the technique to various PDEs.

  4. Are there other numerical methods for solving PDEs?
    Yes, there are various numerical methods for solving PDEs, such as finite difference, finite element, and spectral methods. Each method has its strengths and weaknesses, and the choice depends on the specific problem at hand. The FFT provides an efficient and accurate approach for solving PDEs with periodic boundary conditions.

Further reading:  Becoming an Azure Data Engineer: A Comprehensive Guide

Conclusion

In this article, we explored how to solve PDEs using the fast Fourier transform (FFT). By mapping PDEs into the Fourier domain, we can efficiently approximate derivatives and solve the equations accurately. We demonstrated the process by solving the one-way wave equation and the Burgers’ equation. Whether dealing with linear or nonlinear PDEs, the FFT is a powerful tool for analyzing and simulating wave behavior.

For more technology-related content and insightful analysis, visit Techal.

YouTube video
Solving PDEs with the FFT: Part 2