Zonghua Ouyang

Philadelphia, Pennsylvania | zo44@seas.upenn.edu | 480-875-9018


What is This Project About?

This program is aimmed to simulate electromagnetic waves in time domains using finite-difference time-domain (FDTD) algorithm. The videos below are generated by my program.

Video: A Gaussian Signal at the Center

Video: A Signal Reflecting in an Ellipse

Video: A Signal Refracting between 2 Substances


What Problems Did I Resolve in the Project?

Multithreading

Each frame relies on the last frame, so the frames must be calculated in order. However, within a frame, pixels are independent of each other, so it is possible to calculate multiple pixels at the same time.

The biggest problem with multithreading is that multiple threads can interfere with each other when they are trying to access the same memory location at the same time. To avoid this problem, I divided the image into 16 areas, and each thread is responsible for one area. Also, dispatch groups are used to make sure the calculation of the next frame starts after the calculation of the previous frame is completed.


Design and Implemented the FDTD Algorithm

This program is designed to be integrated into an iOS app, so I decided to implement the FDTD algorithm using Swift Language. The challenge of using Swift is that there is no code to reference. While there are some FDTD programs on GitHub, none of them are written in Swift. Thus, I need to understand this algorithm completely and write everything from the beginning.


How I Improved from This Project?