Metadata-Version: 2.2
Name: hpfem
Version: 0.5.1
Summary: Adaptive hp-FEM suite for nano-optics (time-harmonic Maxwell)
Keywords: finite elements,hp-FEM,Maxwell,nano-optics,photonics,Nedelec,adaptivity,PML,gratings,scatterometry,elasticity
Author: KF
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: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Scientific/Engineering :: Mathematics
Project-URL: Homepage, https://github.com/PhotonPower/hp-FEM
Project-URL: Documentation, https://photonpower.github.io/hp-FEM/
Project-URL: LLM reference, https://github.com/PhotonPower/hp-FEM/blob/main/python/hpfem/llm_reference.md
Project-URL: Changelog, https://github.com/PhotonPower/hp-FEM/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/PhotonPower/hp-FEM/issues
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: meshio; extra == "dev"
Requires-Dist: matplotlib; extra == "dev"
Requires-Dist: pyyaml; extra == "dev"
Requires-Dist: gmsh; extra == "dev"
Requires-Dist: emcee; extra == "dev"
Provides-Extra: meshing
Requires-Dist: gmsh; extra == "meshing"
Provides-Extra: yaml
Requires-Dist: pyyaml; extra == "yaml"
Provides-Extra: gui
Requires-Dist: streamlit>=1.30; extra == "gui"
Requires-Dist: gmsh; extra == "gui"
Requires-Dist: matplotlib; extra == "gui"
Requires-Dist: meshio; extra == "gui"
Requires-Dist: pyyaml; extra == "gui"
Provides-Extra: docs
Requires-Dist: mkdocs-material; extra == "docs"
Requires-Dist: pymdown-extensions; extra == "docs"
Provides-Extra: opt-bo
Requires-Dist: botorch>=0.10; extra == "opt-bo"
Provides-Extra: opt-mcmc
Requires-Dist: emcee>=3.1; extra == "opt-mcmc"
Description-Content-Type: text/markdown

# hp-FEM

[![CI](https://github.com/PhotonPower/hp-FEM/actions/workflows/ci.yml/badge.svg)](https://github.com/PhotonPower/hp-FEM/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/PhotonPower/hp-FEM/blob/main/LICENSE)
[![Docs](https://github.com/PhotonPower/hp-FEM/actions/workflows/docs.yml/badge.svg)](https://photonpower.github.io/hp-FEM/)

Adaptive **hp-finite-element** suite for nano-optics: time-harmonic Maxwell solvers with
high-order **Nédélec (edge) elements**, rigorous **a-posteriori error estimation**,
automatic **hp-refinement** and **perfectly matched layers**.

Target applications: scatterometry & EUV masks, metasurfaces, photovoltaics, integrated
photonics, VCSELs/LEDs, plasmonic sensors, quantum-dot emitters.

## Documentation
Theory, architecture, Python guide and API reference:
**<https://photonpower.github.io/hp-FEM/>** (built from `docs/` by MkDocs on every push to `main`).

## Status
Release **0.5.0**: milestones **M0–M20** are complete. Beyond the Maxwell core (mesh
infrastructure, Nédélec elements, scattering and waveguides, hp-adaptivity, solvers, Python API,
multiphysics) this covers validation against the literature, axisymmetric and conical solvers,
ports and sensitivities, optimisation and uncertainty quantification, dipole emitters in periodic
structures, anisotropic materials, and linear elasticity with eigenstrain. Open are the optional
MPI item and the full 3D ring resonator. See the
[roadmap](https://github.com/PhotonPower/hp-FEM/blob/main/docs/roadmap.md) and the
[changelog](https://github.com/PhotonPower/hp-FEM/blob/main/CHANGELOG.md).

## Installation
```bash
pip install hpfem            # binary wheels: Linux x86_64, Windows x86_64, macOS arm64 (>= 15)
pip install "hpfem[gui]"     # plus the Streamlit front end (hpfem-gui)
hpfem info                   # version, threads, solver backends
hpfem reference              # compact command reference of the Python API (for agents)
```
The wheels use the SparseLU direct solver (`hpfem info` shows the backends and OpenMP threads);
the MUMPS and cuDSS backends need a source build. Other platforms build from the sdist (C++20 compiler, CMake ≥ 3.25, Ninja).

## Quick start (development)
```bash
./scripts/setup-dev.sh                       # Ubuntu toolchain + pre-commit
cmake --preset release && cmake --build --preset release && ctest --preset release
pip install -e ".[dev]"                      # Python package from the source tree
pip install "hpfem[gui]" && hpfem-gui app.py # Streamlit front end with this interpreter
mkdocs serve                                 # documentation
```

## Repository
| Path | Content |
|---|---|
| `CLAUDE.md` | conventions, workflow, Definition of Done — read first |
| `include/hpfem`, `src` | C++20 core library |
| `python/` | pybind11 bindings + Python package |
| `tests/` | unit / convergence / regression tests (Catch2, pytest) |
| `docs/` | MkDocs site: theory, architecture, ADRs, roadmap |
| `examples/` | application examples |

## Dependencies
| Library | Purpose | How |
|---|---|---|
| Eigen 3.4 | dense/sparse linear algebra | system or FetchContent |
| fmt / spdlog | logging | FetchContent |
| nlohmann_json | configs, results | FetchContent |
| Spectra 1.2 | shift-invert Lanczos / Arnoldi eigensolvers (header-only) | FetchContent |
| Boost.Math 1.86 (standalone) | Bessel functions where the standard library lacks the C++17 special functions (libc++, Apple Clang); not used with libstdc++ / MSVC | FetchContent, only if needed |
| Catch2 v3 | C++ tests | FetchContent |
| pybind11 | Python bindings | FetchContent / pip |
| Gmsh | mesh generation (external tool) | system |
| OpenMP | parallel assembly and estimation (`HPFEM_ENABLE_OPENMP`, on by default) | compiler |
| MUMPS 5 (sequential, complex) | optional direct solver backend (`HPFEM_ENABLE_MUMPS`, preset `mumps`) | `cmake/FindMUMPS.cmake`: apt `libmumps-seq-dev libmumps-headers-dev`, MSYS2 `mingw-w64-ucrt-x86_64-mumps` |
| cuDSS 0.8 + CUDA 12/13 | optional GPU direct solver backend (`HPFEM_ENABLE_CUDA`); separate DLL `hpfem_gpu` built with nvcc, loaded at run time | `gpu/README.md` (not needed to build the library) |
| BoTorch | optional: multi-objective and multi-fidelity Bayesian optimisation (`hpfem.opt.pareto_optimize`, `multi_fidelity_optimize`; experimental) | pip extra `opt-bo` |
| emcee 3 | optional: MCMC sampling of the parameter posterior (`hpfem.opt.sample`); in the `dev` extra for the tests | pip extra `opt-mcmc` |
| PETSc/SLEPc, MPI | optional (later milestones) | `find_package`, CMake options |

## License
MIT — see [LICENSE](https://github.com/PhotonPower/hp-FEM/blob/main/LICENSE).
