This release is a pre-release and may not be stable for production use.
solwa 0.3.0rc1
- License: LGPL
Differentiable Rigorous Coupled-Wave Analysis (RCWA) package based on PyTorch
Features
solwa (solar + rcwa) is a PyTorch implementation of rigorous coupled-wave analysis (RCWA) based on torcwa https://github.com/kch3782/torcwa
-
GPU-accelerated simulation on CUDA, with CPU support
-
Automatic differentiation through simulations, material properties, and geometry for gradient-based optimization
-
Li Fourier factorization for improved convergence, with the Laurent rule also available
-
Geometry tools for common shapes and Boolean operations, including unions, intersections, and differences
-
Wavelength-dependent refractive-index data with differentiable interpolation
-
Scattering parameters, diffraction angles, electromagnetic field maps, and Poynting vector / power-flux calculations
-
Optional layer offloading to reduce GPU memory use in multilayer simulations
-
Units: Lorentz-Heaviside units
-
Speed of light: 1
-
Permittivity and permeability of vacuum: both 1
-
-
Notation: exp(-jωt)
Installation
Install from PyPI using pip:
pip install solwa
For the latest nightly build of main, use pip install --pre solwa.
Alternatively, install from source by cloning this repository and running:
pip install .
PyTorch ≥ 2.10 is recommended for improved CUDA performance (see PR: https://github.com/pytorch/pytorch/pull/166715)
Material Handling
You can load dispersive materials from n/k tables with:
import solwa
silicon = solwa.materials.Material("Materials_data/aSiH.txt")
silicon_lossless = solwa.materials.Material("Materials_data/aSiH.txt", lossless=True)
When lossless=True, the extinction coefficient k is forced to zero while
keeping the tabulated real refractive index n.
significant changes from the original torcwa
- Constants are loaded from standard libraries instead of defining them again in the code.
- Major cleanup of the code structure for better readability and maintainability.
- Better error handling and messages.
- Li Fourier factorization, with the Laurent rule available as an option.
- Poynting-vector and power-flux calculations, including integration over selected areas.
solwa Examples
-
Example 0: Fresnel equation
-
Example 1: Simulation with rectangular meta-atom
Normal incidence / Parametric sweep on wavelength / View electromagnetic field -
Example 1-1: Simulation with stacked meta-atom
Normal incidence / View electromagnetic field -
Example 2: Simulation with square meta-atom
Oblique incidence / View electromagnetic field -
Example 3: Simulation with rectangular meta-atom
Normal incidence / Parametric sweep on geometric parameters -
Example 4: Gradient calculation of cylindrical meta-atom
Differentiation of transmittance with respect to radius -
Example 5: Shape optimization
Maximize anisotropy -
Example 6: Topology optimization
Maximize 1st order diffraction -
Example 7: Layer-by-layer absorption Calculate absorbed power in each layer using Poynting flux
Acknowledgements
The fundamental implementation, including mathematical formulation, was implemented in the torcwa package by Changhyun Kim and Byoungho Lee.
This solwa package is a modified version of torcwa for better usability. It will be continuously updated to include more features and improvements.
If this package is useful for your research, please cite the following paper:
@article{
title = {TORCWA: GPU-accelerated Fourier modal method and gradient-based optimization for metasurface design},
journal = {Computer Physics Communications},
volume = {282},
pages = {108552},
year = {2023},
doi = {https://doi.org/10.1016/j.cpc.2022.108552},
author = {Changhyun Kim and Byoungho Lee},
}
Work on the solwa package is supported by the ERC Consolidator Grant (No. 101125948, PHASE).
Furthermore, the authors acknowledge support by the state of Baden-Württemberg through bwHPC through providing computational resources.
The work on the original torcwa was supported by the National Research Foundation of Korea (NRF) grant funded by the Korea government (MSIT) (No. 2020R1A2B5B02002730) and Samsung Electronics Co., Ltd (IO201214-08164-01).
GPU continuous integration
SOLWA can run its physics tests on a fresh Nebius GPU VM through GitHub Actions.
To run them on a pull request, add the gpu-ci label; they start after the CPU
tests pass.
See GPU CI setup and recovery for the two secrets,
project/subnet configuration, the gpu-ci PR label, manual runs, and automatic
cleanup.
Metadata
Release files for solwa 0.3.0rc2.dev202611140835
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| solwa-0.3.0rc2.dev202611140835.tar.gz | 40.1 kB | With provenance | Details for solwa-0.3.0rc2.dev202611140835.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| solwa-0.3.0rc2.dev202611140835-py3-none-any.whl | Python 3 | none | any | Details for solwa-0.3.0rc2.dev202611140835-py3-none-any.whl |
Total release size: 69.5 kB
Release files / solwa-0.3.0rc2.dev202611140835.tar.gz
| Download URL | solwa-0.3.0rc2.dev202611140835.tar.gz |
|---|---|
| Size | 40.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd8afb7f1af78576728b001deb4fbb87a1cb01b06e471efc29e12b31399e677c
|
|
BLAKE2b-256 checksum How to use checksums |
8522d4bc46389c3277a266842241d286c5e5ab5680248f523d5e7c21ac033386
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / solwa-0.3.0rc2.dev202611140835-py3-none-any.whl
| Download URL | solwa-0.3.0rc2.dev202611140835-py3-none-any.whl |
|---|---|
| Size | 29.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05818871316e8ab9634276b98f46c480fa33f1d9ac8d322fe61fcf1a94571764
|
|
BLAKE2b-256 checksum How to use checksums |
ac3429e5b70a2c2f11f05db593dd07cd7e80589a3fc61fde1636640f3929a93a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for solwa 0.3.0rc2.dev202611140835
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for solwa-0.3.0rc2.dev202611140835.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.