FDTD Simulation

Electromagnetic Wave Propagation

Interactive 2D Finite-Difference Time-Domain simulation with Convolutional Perfectly Matched Layer (CPML) boundary conditions. Explore electromagnetic wave propagation in real time with an updated, high-contrast palette.

Live Field Intensity
0.0 fps
Compute 0.00 msGrid 200×200 · Source (100, 100) · On

Project

FDTD Electromagnetic Simulation

About

This is an interactive web-based implementation of a Finite-Difference Time-Domain (FDTD) electromagnetic simulation. Originally developed in Python for a bachelor's thesis in physics, this TypeScript port brings the simulation to the browser with real-time visualization and interactive controls.

The simulation uses Convolutional Perfectly Matched Layer (CPML) boundary conditions to accurately model wave propagation without unwanted reflections, making it suitable for studying electromagnetic phenomena in various materials and geometries.

Features

  • CPML (Convolutional Perfectly Matched Layer) boundary conditions
  • Real-time 2D field visualization
  • Interactive parameter controls
  • Gaussian pulse source injection
  • Performance-optimized Web Worker architecture
  • Multiple field visualization modes (Ex, Ey, Hz, magnitude)
  • Real-time performance metrics

Original Python Implementation

The original Python implementation includes additional features such as multiple PML types (BPML, CPML), comprehensive benchmarking tools, and extensive visualization capabilities using matplotlib. It was designed as a complete research tool for electromagnetic simulation.

View on GitHub

Technology Stack

TypeScriptReactNext.jsWeb WorkersCanvas APIWebAssembly-ready

Ported from Python (NumPy, SciPy, Matplotlib) to TypeScript for web deployment

Education

Understanding FDTD

What is FDTD?

The Finite-Difference Time-Domain (FDTD) method is a numerical technique for solving Maxwell's equations, which govern electromagnetic wave propagation. Instead of solving these equations analytically (which is often impossible for complex geometries), FDTD discretizes both space and time, approximating derivatives with finite differences.

This allows us to simulate how electromagnetic waves propagate through arbitrary materials and structures, making it invaluable for antenna design, optical device simulation, and understanding wave interactions with matter.

Maxwell's Equations

FDTD solves the time-dependent form of Maxwell's equations:

× E = -∂B/∂t
× H = ∂D/∂t + J
· D = ρ
· B = 0

Where E is the electric field, H is the magnetic field, D is the electric displacement, and B is the magnetic flux density.

How FDTD Works

  1. Discretization: The simulation space is divided into a grid of cells. Each cell stores the electric and magnetic field values.
  2. Time-stepping: Fields are updated in alternating steps. First, the electric field is updated based on the curl of the magnetic field, then the magnetic field is updated based on the curl of the electric field.
  3. Source injection: A source (like a Gaussian pulse) is injected at a specific location, creating waves that propagate through the grid.
  4. Boundary conditions: Perfectly Matched Layers (PML) absorb waves at the boundaries, preventing reflections that would contaminate the simulation.

CPML (Convolutional PML)

This simulation uses Convolutional Perfectly Matched Layer (CPML) boundary conditions. CPML is an advanced form of PML that provides better absorption of waves at oblique angles compared to the original Berenger PML.

CPML works by introducing artificial conductivity that increases gradually from the interior to the boundary. This creates a "sponge" that absorbs incoming waves without reflecting them back into the simulation domain. The convolutional approach uses auxiliary fields to handle the frequency-dependent nature of the absorption, making it more effective than simpler PML implementations.

Applications

  • Antenna design and optimization
  • Optical device simulation (waveguides, filters, resonators)
  • Electromagnetic compatibility analysis
  • Radar cross-section calculations
  • Metamaterial and photonic crystal research
  • Microwave circuit design

About This Implementation

This interactive simulation is a TypeScript/JavaScript port of a Python FDTD implementation originally developed for a bachelor's thesis in physics. The original implementation featured multiple PML types (BPML, CPML), comprehensive benchmarking, and extensive visualization capabilities. This web version brings the simulation to the browser, allowing real-time interaction and exploration of electromagnetic wave propagation.