Metadata-Version: 2.1
Name: fouriergrating
Version: 0.20.0
Summary: Fourier modal method for 1D/2D gratings: differential method (implicit Runge-Kutta) and RCWA
License: MIT License
         
         Copyright (c) 2026 KF
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: C++
Classifier: Topic :: Scientific/Engineering :: Physics
Project-URL: Repository, https://github.com/PhotonPower/FourierGrating
Requires-Python: >=3.10
Requires-Dist: numpy>=1.23
Provides-Extra: pandas
Requires-Dist: pandas>=1.5; extra == "pandas"
Provides-Extra: materials
Requires-Dist: pyyaml>=6; extra == "materials"
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: pandas>=1.5; extra == "test"
Requires-Dist: pyyaml>=6; extra == "test"
Description-Content-Type: text/markdown

# FourierGrating

Löser für die Beugung elektromagnetischer Wellen an periodischen Strukturen nach der
**Fourier-Modal-Methode (FMM)** in zwei Ausprägungen:

* **Differentialmethode** – numerische Integration der Propagationsgleichung `dF/dy = M(y) F`
  mit einem **impliziten Runge–Kutta-Verfahren** (Gauß–Legendre, optional Radau IIA),
  stabilisiert durch die S-Matrix,
* **RCWA** – Scheibenzerlegung mit Eigenmoden je Scheibe.

Beide nutzen die schnelle Fourierfaktorisierung (FFF, Normalenvektor-Methode) nach
Nevière/Popov, *Light Propagation in Periodic Media* (2003), mit den in `docs/book_errata.md`
dokumentierten Korrekturen.

| | isotrop | anisotrop (voller ε-Tensor) |
|---|---|---|
| **1D** (eine Fouriertransformation) | M2–M4 | M5 |
| **2D** (zwei Fouriertransformationen) | M7 | M8 |
| **Nahfeld** (horizontaler + vertikaler Schnitt) | M6 (1D), M9 (2D) | M6, M9 |
| **CUDA** (RTX 6000 Ada, sm_89) | M10 | M10 |

> **Status (v0.20):** M0–M19, M22 und M23 umgesetzt, M20 teilweise: 1D und 2D, isotrop und anisotrop, RK und RCWA, Nahfeld, CUDA-Backend,
> Scans/Sweeps, Anwenderhandbuch (`docs/user_guide.md`), Python-Paket `fouriergrating` (`docs/python.md`), gekrümmte Querschnitte (`contour2d`), CAD-Slicer für STEP-Dateien in 1D und 2D (`docs/cad.md`), Parallelisierung einzelner Rechnungen und GPU-residente Ketten (`docs/benchmarks.md`), wählbare Genauigkeit fp64/mixed/fp32, Koordinatentransformation/ASR für Metalle und isolierte Strukturen mit PML, Streufeldformulierung und Modenanregung (`docs/config_format.md`), Gradienten über die diskrete Adjungierte mit PyTorch-/JAX-Adaptern (`docs/python.md`), dispersive Materialien (Sellmeier, Cauchy, Drude–Lorentz, Tabellen; `docs/config_format.md`), kompakte Referenz für Sprachmodell-Agenten im Wheel (`fg.llm_reference()`). Wheels, sdist und das Handbuch als PDF stehen an den [GitHub-Releases](https://github.com/PhotonPower/FourierGrating/releases). Offen auf dem Zielsystem: GPU-Abnahme (M10) und die
> quantitative V10-Konvergenzstudie (siehe `docs/roadmap.md`).

## Dokumentation

| Dokument | Inhalt |
|---|---|
| [`docs/handbuch/`](docs/handbuch/) | **Benutzerhandbuch** (LaTeX, ausführlich): Grundlagen, Konfiguration, alle Schichttypen, Löserwahl, Konvergenz, Nahfeld, Python, GUI, Rezepte, Fehlersuche; PDF mit `scripts/build_docs.sh` |
| [`docs/user_guide.md`](docs/user_guide.md) | **Anwenderhandbuch**: Installation, Konfiguration, Löserwahl, Scans, Nahfeld, Laufzeiten |
| [`docs/cad.md`](docs/cad.md) | CAD-Slicer: STEP → Schichten, Konfiguration, Geometrieprüfung |
| [`docs/python.md`](docs/python.md) | Python-Anbindung: Installation (Wheels, CUDA), API, Tests |
| [`python/fouriergrating/LLM_REFERENCE.md`](python/fouriergrating/LLM_REFERENCE.md) | Kompakte Referenz für Sprachmodell-Agenten (englisch), im Wheel enthalten: `python -m fouriergrating` bzw. `fg.llm_reference()` |
| [`docs/benchmarks.md`](docs/benchmarks.md) | Laufzeiten CPU/GPU (`fgbench`) |
| [`docs/implementation_plan/main.pdf`](docs/implementation_plan/main.pdf) | **Verbindliche Spezifikation**: alle Formeln mit Herleitungen, Algorithmen, Tests, Meilensteine (LaTeX-Quelle daneben) |
| [`AGENTS.md`](AGENTS.md) | Arbeitsregeln für KI-Agenten und Entwickler |
| [`docs/architecture.md`](docs/architecture.md) | Module, Datenfluss, Schnittstellen |
| [`docs/roadmap.md`](docs/roadmap.md) | Meilensteine M0–M19 mit Abnahmekriterien und Status |
| [`docs/validation.md`](docs/validation.md) | Referenzfälle mit Sollwerten |
| [`docs/conventions.md`](docs/conventions.md) | Zeitkonvention, normierte Einheiten, Koordinaten, Indizes |
| [`docs/config_format.md`](docs/config_format.md) | JSON-Eingabeformat |
| [`docs/build_almalinux10.md`](docs/build_almalinux10.md) | Installation auf AlmaLinux 10 mit CUDA |
| [`docs/build_windows.md`](docs/build_windows.md) | Installation auf Windows (MSVC 2022 für Wheels und CUDA; MSYS2/MinGW-w64 für die Entwicklung) |
| [`docs/book_errata.md`](docs/book_errata.md) | Fehler im Buch, die die Implementierung betreffen |

## Schnellstart

```bash
# AlmaLinux 10: Abhängigkeiten (einmalig, siehe docs/build_almalinux10.md)
sudo ./scripts/setup_almalinux10.sh            # --with-cuda für das CUDA-Toolkit

cmake --preset cpu-release                      # oder cuda-release
cmake --build --preset cpu-release
ctest --preset cpu-release

./build/cpu-release/apps/fgsolve --info
./build/cpu-release/apps/fgsolve examples/v3_lamellar_dielectric.json   # schreibt out/v3/efficiencies.csv
```

Plan als PDF neu erzeugen: `./scripts/build_docs.sh`.

## Verzeichnisse

```
include/fg/   öffentliche Header (core, fourier, geometry, physics, smatrix, solvers, field, linalg, io)
src/          Implementierungen, src/cuda/ CUDA-Backend (cuBLAS/cuSOLVER)
apps/         Kommandozeilenprogramme fgsolve (Rechnung), fgbench (Benchmarks)
tests/        GoogleTest-Unit-Tests, Validierungsfälle
examples/     JSON-Konfigurationen der Referenzfälle
scripts/      Setup, Doku-Build, Plot-Skripte (plot_efficiencies.py, plot_nearfield.py)
docs/         Spezifikation und Begleitdokumente
```

## Lizenz

MIT, siehe [`LICENSE`](LICENSE). Der CAD-Slicer (`FG_ENABLE_NURBFORGE`, Python-Wheels) bindet
[Nurbforge](https://github.com/PhotonPower/Nurbforge) ein (MIT).
