opencl_fdfd/README.md

65 lines
2.3 KiB
Markdown
Raw Normal View History

2016-07-04 13:39:06 -07:00
# opencl_fdfd
2016-08-04 17:43:01 -07:00
**opencl_fdfd** is a 3D Finite Difference Frequency Domain (FDFD)
2016-08-04 20:19:04 -07:00
electromagnetic solver implemented in Python and OpenCL.
2016-08-04 20:36:30 -07:00
**Capabilities:**
2016-08-04 17:43:01 -07:00
* Arbitrary distributions of the following:
2020-07-03 13:46:38 -07:00
* Dielectric constant (`epsilon`)
* Magnetic permeabilty (`mu`)
* Perfect electric conductor (`PEC`)
* Perfect magnetic conductor (`PMC`)
2016-08-04 17:43:01 -07:00
* Variable-sized rectangular grids
* Stretched-coordinate PMLs (complex cell sizes allowed)
Currently, only periodic boundary conditions are included.
PEC/PMC boundaries can be implemented by drawing PEC/PMC cells near the edges.
Bloch boundary conditions are not included but wouldn't be very hard to add.
2020-07-03 13:46:38 -07:00
The default solver `opencl_fdfd.cg_solver(...)` located in main.py
2016-08-04 20:19:04 -07:00
implements the E-field wave operator directly (ie, as a list of OpenCL
instructions rather than a matrix). Additionally, there is a slower
2020-07-03 13:46:38 -07:00
(and slightly more versatile) solver in `csr.py` which attempts to solve
2016-08-04 20:19:04 -07:00
an arbitrary sparse matrix in compressed sparse row (CSR) format using
the same conjugate gradient method as the default solver. The CSR solver
is significantly slower, but can be very useful for testing alternative
formulations of the FDFD electromagnetic wave equation.
2016-08-04 17:43:01 -07:00
Currently, this solver only uses a single GPU or other OpenCL accelerator;
generalization to multiple GPUs should be pretty straightforward
(ie, just copy over edge values during the matrix multiplication step).
2016-08-04 20:14:17 -07:00
## Installation
2016-08-04 17:43:01 -07:00
**Dependencies:**
2020-07-03 13:48:24 -07:00
* python 3 (written and tested with 3.7)
2016-08-04 17:43:01 -07:00
* numpy
* pyopencl
* jinja2
2020-07-03 13:48:24 -07:00
* [meanas](https://mpxd.net/code/jan/meanas) (>=0.5)
2016-08-04 20:14:17 -07:00
Install with pip, via git:
```bash
2018-01-15 22:36:13 -08:00
pip install git+https://mpxd.net/code/jan/opencl_fdfd.git@release
2016-08-04 20:14:17 -07:00
```
## Use
2020-07-03 13:46:38 -07:00
See the documentation for `opencl_fdfd.cg_solver(...)`
2016-08-04 20:19:04 -07:00
(located in ```main.py```) for details about how to call the solver.
2016-08-04 22:28:31 -07:00
The FDFD arguments are identical to those in
2020-07-03 13:46:38 -07:00
`meanas.solvers.generic(...)`, and a few solver-specific
2016-08-04 22:28:31 -07:00
arguments are available.
2021-07-11 17:07:53 -07:00
2016-08-04 20:14:17 -07:00
An alternate (slower) FDFD solver and a general gpu-based sparse matrix
2020-07-03 13:46:38 -07:00
solver is available in `csr.py`. These aren't particularly
2016-08-04 20:19:04 -07:00
well-optimized, and something like
[MAGMA](http://icl.cs.utk.edu/magma/index.html) would probably be a
better choice if you absolutely need to solve arbitrary sparse matrices
2016-08-04 22:28:31 -07:00
and can tolerate writing and compiling C/C++ code. Still, they're
usually quite a bit faster than the scipy.linalg solvers.