Skip to content

Interactive 2D electromagnetic simulation environment with the FDTD method using pygame

License

Notifications You must be signed in to change notification settings

milanofthe/Interactive_2D_FDTD

Repository files navigation

Interactive 2D FDTD Simulator

Interactive 2D electromagnetic simulation environment for educational purposes. There are multiple options for boundary conditions and sources.

Menu

An interactive main menu and sub menues makes navigation easy

Boundary Conditions

Currently supported are dirichlet and periodic boundary conditions and unidirectional perfectly matched layer (PML). The BC can be indicvidually selected for the left-right and top-bottom boundaries.

Simulation

The simulator uses the 2D finite difference time domain (FDTD) method and simulates the TE-mode (could be easily extended to compute the TM-mode also). Runs at half pixel resolution internally and is upscaled 2x (default) for display.

Sources

The sources can be placed in realtime by pressing the left mouse button at the desired location. Currently only gaussian pulse and sinnusoidal sources are implemented as soft sources. Source frequency can be set in the respective menu. "Spacebar" pauses the simulation and pressing "R" resets it (removes the sources).

Material Editor

A small editor is included, where shapes such as rectangles, circles and polygons (triangles) can be arbitrarily spaced within the problem space. Permittivity and Permeabiliyty can be set before placement. Backspace in the editor menu removes the latest material placed. Also Materials can be imported from image files as bitmap, but the path to the file and the material properties have to be specified in the configuration file.

GPU

GPU acceleration is supported via numbas cuda jit compiler. Also runs fine on CPU when the simulation grid still fits in the cache.

Demo

2D_FDTD_DEMO.mp4

About

Interactive 2D electromagnetic simulation environment with the FDTD method using pygame

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages