FDTD-Wave-Simulator

FDTD Wave Simulator

Overview

This is a numerical simulation application designed to model and visualize the propagation of a 2D scalar wave. It utilizes the Finite-Difference Time-Domain (FDTD) method to solve the wave equation on a discrete grid. The simulator allows for the observation of wave phenomena such as interference and reflection, with configurable boundary conditions and user-defined obstacles.

Live Demo

A live demo of the simulator is available at the following link:

FDTD Wave Simulator Demo

Physical Principles

The simulation is based on the 2D scalar wave equation:

∂²u/∂t² = c² * (∂²u/∂x² + ∂²u/∂y²)

Where:

This partial differential equation is solved numerically using the FDTD method. The continuous space and time are discretized into a grid. The wave amplitude U at a grid point (i, j) at the next time step t+dt is calculated from its current and past values, as well as the values of its neighbors, using the following central-difference update equation:

U(i, j, t+dt) = 2U(i, j, t) - U(i, j, t-dt) + (c*dt/dx)² * [U(i+1, j, t) + U(i-1, j, t) + U(i, j+1, t) + U(i, j-1, t) - 4*U(i, j, t)]

The stability of this numerical scheme is maintained by respecting the Courant-Friedrichs-Lewy (CFL) condition:

c * dt / dx ≤ 1/√2

Features

File Structure

FDTD-Wave-Simulator/
|-- templates/
|   |-- index.html
|-- static/
|   |-- style.css
|   |-- script.js
|-- app.py
|-- demo.html
|-- requirements.txt
|-- run.bat

Getting Started

To run the simulation application, follow these steps:

  1. Install Dependencies: Ensure all required dependencies are installed. You can typically do this by using the requirements.txt file with a package manager.

  2. Launch the Application: Execute the run.bat script. This will start the local server.

  3. Access the Simulator: Open a web browser and navigate to the address provided in the console (e.g., http://127.0.0.1:5000).

Usage

  1. Use the controls panel to set the desired simulation parameters (grid size, wave speed, boundary conditions, etc.).
  2. Use the drawing tools to place wave sources and obstacles on the canvas.
  3. Click the “Start Simulation” button to begin the computation.
  4. The visualization will update in real-time. You can pause, resume, or stop the simulation using the provided buttons.

License

This project is released under the MIT License. See the LICENSE file for details.