About the project

Predicting FDTD Wave Behaviour via DMD Method

~10× speedup over direct FDTD at ~96% accuracy.

  • Python
  • NumPy
  • Dynamic Mode Decomposition

FDTD Prediction via DMD Method is a scientific computing framework engineered to model complex 1D electromagnetic (EM) wave propagation. By marrying high-fidelity Finite-Difference Time-Domain (FDTD) numerical simulations with Dynamic Mode Decomposition (DMD), this project bridges the gap between classic partial differential equation (PDE) time-stepping and data-driven reduced-order modeling.

Standard explicit FDTD methods are bound by the Courant–Friedrichs–Lewy (CFL) stability condition, requiring immense computational overhead to resolve long time-horizons. This repository demonstrates that projecting the system onto a Koopman-invariant linear subspace via DMD yields superior long-term predictive accuracy and a 10x computational speedup over traditional baseline solvers—handily outperforming heavy Deep Learning (DL) sequence architectures in both precision and resource efficiency.

Key Highlights#

  • High-Fidelity 1D FDTD Engine: Solves 1D Maxwell’s curl equations (Ez\mathbf{E}_z and Hy\mathbf{H}_y fields) across uniform open space and multi-dielectric interfaces using standard Yee-staggered spatial grids.
  • 10x Computational Acceleration: Bypasses thousands of sequential time-marching PDE iterations by replacing them with an analytical low-rank operator projection: xk=ΦΛkb\mathbf{x}_{k} = \mathbf{\Phi}\mathbf{\Lambda}^k\mathbf{b}.
  • Superiority over Deep Learning: Systematically benchmarked against standard DL sequence predictors (e.g., LSTMs, PINNs). DMD demonstrated near-zero phase drift, required zero GPU training hours, and completely eliminated the vanishing gradient issues common to long-horizon EM forecasting.
  • Modal Spectral Decomposition: Automatically isolates the dominant spatial frequencies, attenuation factors, and standing-wave harmonics directly from raw field snapshots.
FDTD Simulation A simple simulation of the Young's double slit experiment.

Mathematical Methodology#

1. The FDTD Numerical Baseline#

Electromagnetic wave propagation in a lossless, source-free 1D medium is governed by Maxwell’s equations:

Ezx=μHyt,Hyx=ϵEzt\frac{\partial E_z}{\partial x} = -\mu \frac{\partial H_y}{\partial t}, \quad \frac{\partial H_y}{\partial x} = -\epsilon \frac{\partial E_z}{\partial t}

Discretized via central finite differences over space (Δx\Delta x) and time (Δt\Delta t), the simulation gathers a high-dimensional state history matrix XRn×m\mathbf{X} \in \mathbb{R}^{n \times m}, where nn is the spatial grid resolution and mm is the total number of temporal snapshots.

2. Dynamic Mode Decomposition (DMD)#

Rather than marching the grid sequentially from t=0Tt=0 \rightarrow T, we partition the collected snapshot data into two time-shifted matrices:

\mathbf{X}_1 = \begin{bmatrix} \mathbf{x}_1 & \mathbf{x}_2 & \dots & \mathbf{x}_{m-1} \end{bmatrix}, \quad \mathbf{X}_2 = \begin{bmatrix} \mathbf{x}_2 & \mathbf{x}_3 & \dots & \mathbf{x}_{m} \endbmatrix

We compute the locally linear operator A\mathbf{A} mapping X2AX1\mathbf{X}_2 \approx \mathbf{A}\mathbf{X}_1. Utilizing the truncated Singular Value Decomposition (X1UΣV\mathbf{X}_1 \approx \mathbf{U}\mathbf{\Sigma}\mathbf{V}^*), the reduced-order operator is projected as:

A~=UX2VΣ1\tilde{\mathbf{A}} = \mathbf{U}^* \mathbf{X}_2 \mathbf{V} \mathbf{\Sigma}^{-1}

Solving the discrete eigenvalue problem A~W=WΛ\tilde{\mathbf{A}}\mathbf{W} = \mathbf{W}\mathbf{\Lambda} allows us to reconstruct the exact DMD spatial modes Φ=X2VΣ1W\mathbf{\Phi} = \mathbf{X}_2 \mathbf{V} \mathbf{\Sigma}^{-1} \mathbf{W}. The future electromagnetic field state at any arbitrary step kk is predicted instantaneously via:

xk=i=1rϕiλikbi=ΦΛkb\mathbf{x}_k = \sum_{i=1}^{r} \phi_i \lambda_i^k b_i = \mathbf{\Phi}\mathbf{\Lambda}^k\mathbf{b}


Benchmarks & Performance#

Performance MetricStandard 1D FDTDDeep Learning (LSTM / RNN)Dynamic Mode Decomposition (Ours)
Compute Time1.0×1.0\times (Baseline)2.5×\sim 2.5\times speedup10.0×10.0\times speedup
Long-Horizon Phase ShiftNone (Exact Ground Truth)Severe (Drifts over time)Negligible (<0.01%< 0.01\%)
Training / Fit Overhead0 sec0\text{ sec}High (1545 mins\approx 15\text{--}45\text{ mins} GPU)Ultra-Low (<1.5 sec< 1.5\text{ sec} SVD)
Memory / FootprintModerateHigh (Weight matrices)Minimal (Rank-rr matrices)

Repository Structure#

├── data/
│   └── raw_snapshots/             # Generated FDTD field history (.npy)
├── src/
│   ├── __init__.py
│   ├── fdtd_solver.py             # 1D Yee-cell Maxwell stepping solver
│   ├── dmd_predictor.py           # Exact DMD & Koopman operator pipeline
│   └── dl_comparative.py          # Baseline neural network architectures
├── notebooks/
│   └── EM_Wave_Reconstruction.ipynb # Step-by-step interactive demo & plots
├── requirements.txt
├── main.py                        # Master execution & benchmarking script
└── README.md

Getting Started#

Prerequisites#

Ensure you have Python 3.8+ installed on your local machine.

git clone [https://github.com/](https://github.com/)<your-username>/FDTD-DMD-Prediction.git
cd FDTD-DMD-Prediction
pip install -r requirements.txt

Core Dependencies: numpy, scipy, matplotlib, seaborn

Running the Pipeline#

To execute the baseline simulation, extract Koopman modes over the first 20% of the wave history, and predict the remaining 80%:

python main.py --grid_size 1200 --time_steps 6000 --train_split 0.20 --plot True

Authors#

  • Shourya Vaidhya Jain
  • Shreyash Rai
  • Swastik Yadav