Skip to main content

OpenCL FDFD solver

Project description

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.

Project details


Release history Release notifications | RSS feed

This version

0.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencl_fdfd-0.4.tar.gz (36.0 kB view details)

Uploaded Source

Built Distribution

opencl_fdfd-0.4-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

File details

Details for the file opencl_fdfd-0.4.tar.gz.

File metadata

  • Download URL: opencl_fdfd-0.4.tar.gz
  • Upload date:
  • Size: 36.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for opencl_fdfd-0.4.tar.gz
Algorithm Hash digest
SHA256 579ff3a0e902c537c98829f5b9c1fac763edd37c87fb1b078dc96540e7a19920
MD5 5672f409f75aa57575e2c7d657aac34c
BLAKE2b-256 a35a28dc5b48e2962d1489a3f9fb0e8d1ca3391ae05a3dfc567fd719d6b5cd51

See more details on using hashes here.

Provenance

File details

Details for the file opencl_fdfd-0.4-py3-none-any.whl.

File metadata

  • Download URL: opencl_fdfd-0.4-py3-none-any.whl
  • Upload date:
  • Size: 52.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for opencl_fdfd-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 48ae18e91b9bb1e6ebf12ffb7270de58175b63bd04e7807ae0961cfa10de9c8f
MD5 b7dd192ea582c704f211fbfffa77806d
BLAKE2b-256 14c5277b58d31630c9a4411ca5c0a36efa261c56e3d871ba97eddd6d11802a9d

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page