Skip to main content

opencl_fdfd

opencl_fdfd is a 3D Finite Difference Frequency Domain (FDFD) electromagnetic solver implemented in Python and OpenCL.

Capabilities:

  • Arbitrary distributions of the following:
    • Dielectric constant (epsilon)
    • Magnetic permeabilty (mu)
    • Perfect electric conductor (PEC)
    • Perfect magnetic conductor (PMC)
  • 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.

The default solver opencl_fdfd.cg_solver(...) located in main.py implements the E-field wave operator directly (ie, as a list of OpenCL instructions rather than a matrix). Additionally, there is a slower (and slightly more versatile) solver in csr.py which attempts to solve 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.

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).

Installation

Dependencies:

  • python 3 (written and tested with 3.7)
  • numpy
  • pyopencl
  • jinja2
  • meanas (>=0.5)

Install with pip, via git:

pip install git+https://mpxd.net/code/jan/opencl_fdfd.git@release

Use

See the documentation for opencl_fdfd.cg_solver(...) (located in main.py) for details about how to call the solver. The FDFD arguments are identical to those in meanas.solvers.generic(...), and a few solver-specific arguments are available.

An alternate (slower) FDFD solver and a general gpu-based sparse matrix solver is available in csr.py. These aren't particularly well-optimized, and something like MAGMA would probably be a better choice if you absolutely need to solve arbitrary sparse matrices and can tolerate writing and compiling C/C++ code. Still, they're usually quite a bit faster than the scipy.linalg solvers.

Metadata

Release files for opencl-fdfd 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opencl-fdfd 0.4
File Size Uploaded
opencl_fdfd-0.4.tar.gz 36.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opencl-fdfd 0.4
File Interpreter ABI Platform
opencl_fdfd-0.4-py3-none-any.whl Python 3 none any Details

Total release size: 88.4 kB

Release files / opencl_fdfd-0.4.tar.gz

Download URL opencl_fdfd-0.4.tar.gz
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
579ff3a0e902c537c98829f5b9c1fac763edd37c87fb1b078dc96540e7a19920
BLAKE2b-256 checksum
How to use checksums
a35a28dc5b48e2962d1489a3f9fb0e8d1ca3391ae05a3dfc567fd719d6b5cd51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Release files / opencl_fdfd-0.4-py3-none-any.whl

Download URL opencl_fdfd-0.4-py3-none-any.whl
Size 52.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48ae18e91b9bb1e6ebf12ffb7270de58175b63bd04e7807ae0961cfa10de9c8f
BLAKE2b-256 checksum
How to use checksums
14c5277b58d31630c9a4411ca5c0a36efa261c56e3d871ba97eddd6d11802a9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Release history Release notifications | RSS feed

This release

0.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page