2016-05-30 22:43:14 -07:00
|
|
|
# opencl_fdtd
|
2016-03-30 15:00:00 -07:00
|
|
|
|
2016-05-30 22:43:14 -07:00
|
|
|
**opencl_fdtd** is a python application for running 3D time-domain
|
2016-04-13 04:01:45 -07:00
|
|
|
electromagnetic simulations on parallel compute hardware (mainly GPUs).
|
2016-03-30 15:00:00 -07:00
|
|
|
|
|
|
|
**Performance** highly depends on what hardware you have available:
|
|
|
|
* A 395x345x73 cell simulation (~10 million points, 8-cell absorbing boundaries)
|
2017-03-29 01:09:21 -07:00
|
|
|
runs at around 91 iterations/sec. on my AMD RX480.
|
|
|
|
* On an Nvidia GTX 580, it runs at 66 iterations/sec
|
|
|
|
* On my laptop (Nvidia 940M) the same simulation achieves ~12 iterations/sec.
|
2016-03-30 15:00:00 -07:00
|
|
|
* An L3 photonic crystal cavity ringdown simulation (1550nm source, 40nm
|
2017-03-29 01:09:21 -07:00
|
|
|
discretization, 8000 steps) takes about 3 minutes on my laptop.
|
2016-03-30 15:00:00 -07:00
|
|
|
|
|
|
|
**Capabilities** are currently pretty minimal:
|
|
|
|
* Absorbing boundaries (CPML)
|
2017-03-29 01:09:21 -07:00
|
|
|
* Perfect electrical conductors (PECs; to use set epsilon to inf)
|
2016-05-30 22:41:06 -07:00
|
|
|
* Anisotropic media (eps_xx, eps_yy, eps_zz, mu_xx, ...)
|
2016-03-30 15:00:00 -07:00
|
|
|
* Direct access to fields (eg., you can trivially add a soft or hard
|
2017-03-29 01:09:21 -07:00
|
|
|
current source with just sim.E[ind] += sin(f0 * t), or save any portion
|
2016-03-30 15:00:00 -07:00
|
|
|
of a field to a file)
|
|
|
|
|
2017-03-29 01:09:21 -07:00
|
|
|
|
2016-03-30 15:00:00 -07:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
**Requirements:**
|
|
|
|
* python 3 (written and tested with 3.5)
|
|
|
|
* numpy
|
|
|
|
* pyopencl
|
2017-03-29 01:09:21 -07:00
|
|
|
* jinja2
|
2018-01-15 22:36:40 -08:00
|
|
|
* [fdfd_tools](https://mpxd.net/code/jan/fdfd_tools)
|
2017-08-24 11:28:03 -07:00
|
|
|
|
|
|
|
Optional (used for examples):
|
2017-03-29 01:09:21 -07:00
|
|
|
* dill (for file output)
|
2018-01-15 22:36:40 -08:00
|
|
|
* [gridlock](https://mpxd.net/code/jan/gridlock)
|
|
|
|
* [masque](https://mpxd.net/code/jan/masque)
|
2016-03-30 15:00:00 -07:00
|
|
|
|
2016-04-13 04:01:45 -07:00
|
|
|
To get the code, just clone this repository:
|
2016-04-13 04:00:08 -07:00
|
|
|
```bash
|
2018-01-15 22:36:40 -08:00
|
|
|
git clone https://mpxd.net/code/jan/opencl_fdtd.git
|
2016-04-13 04:00:08 -07:00
|
|
|
```
|
|
|
|
|
2016-03-30 15:00:00 -07:00
|
|
|
You can install the requirements and their dependencies easily with
|
|
|
|
```bash
|
2016-04-13 04:00:27 -07:00
|
|
|
pip install -r requirements.txt
|
2016-03-30 15:06:10 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
## Running
|
|
|
|
The root directory contains ``fdtd.py``, which sets up and runs a sample simulation
|
|
|
|
(cavity ringdown).
|
|
|
|
|
|
|
|
```bash
|
|
|
|
python3 fdtd.py
|
2016-04-13 04:00:08 -07:00
|
|
|
```
|