Skip to main content

GraxPy

graxpy is an independent Python package for one-dimensional X-ray diffraction-grating simulations. Its public Python import is grax.

grax provides two selectable electromagnetic solver paths:

  • modal rigorous coupled-wave analysis (RCWA), inspired by RETICOLO v9;
  • the Nevière differential method.

Both solvers support the same grating, material, and workflow APIs. They share the Fourier/discretization infrastructure and differ in how they propagate the fields through a layer.

Documentation

Full user and API documentation is available at graxpy.readthedocs.io.

For local docs builds from this repository, use:

tools/build_docs.sh --html

Installation

graxpy supports Python 3.12 and 3.13 only.

python -m pip install graxpy

graxpy now supports local Henke-table material lookup for elemental string names such as "Si" and "Pt", with optional density overrides through grax.MaterialSpec. Existing DataFrame optical-constants inputs still work, and xrt-compatible material objects remain supported for now but emit a deprecation warning.

PyPI project page: https://pypi.org/project/graxpy/

For local editable installs:

python -m pip install -e .

Select a solver

RCWA is the default, so existing code continues to use it. Pass solver to choose the Nevière differential method instead:

import grax

grating = grax.LaminarGrating(
    period_lpermm=400,
    width_to_period_ratio=0.67,
    depth_nm=14.9,
    substrate_material="Si",
    layer_material="Pt",
    layer_thickness_nm=28.77,
)

common = dict(
    grating=grating,
    energy_ev=300.0,
    grazing_angle_deg=4.0,
    fourier_orders=30,
    polarization="p",
)

rcwa_result = grax.run_simulation(**common, solver="rcwa")
neviere_result = grax.run_simulation(**common, solver="neviere")

See the documentation's Choosing a solver tutorial and the runnable examples/simulation/neviere_solver/neviere_solver.py for guidance and integration options.

Local web app

Install the package and web extra, then start the local server.

From PyPI:

python -m pip install "graxpy[web]"
grax-web

From a local repository checkout:

python -m pip install -e ".[web]"
grax-web

The syntax graxpy.[web] is invalid. The extra must be attached directly to the package name: graxpy[web].

Then open http://127.0.0.1:5050. Use the home page to create and save gratings, then open the plot page to combine saved runs and select the diffraction orders to overlay.

grax-web now opens that local URL in your default browser automatically on startup.

Start on a different port when needed:

grax-web --port 8000

You can also override the bind address:

grax-web --host 0.0.0.0 --port 8000

When developing the web app locally, restart grax-web after changing run-state or UI logic so the browser sees the updated server behavior.

Local data is stored in .grax-web/ by default:

  • saved gratings: .grax-web/saved_gratings/
  • run results: .grax-web/runs/
  • combined plots: .grax-web/plots/
  • grating previews: .grax-web/previews/

Each saved run lives in .grax-web/runs/<run_id>/ and includes:

  • manifest.json
  • summary.csv
  • all_orders.csv
  • selected_efficiency.png

Use Plots to combine saved runs and choose which diffraction orders to overlay for each run. Use Manage runs to rename runs or bulk delete them.

Repository at a glance

  • src/grax/: core package source code
  • examples/: runnable examples
  • docs/: documentation sources

Attribution

The modal RCWA solver is inspired by RETICOLO v9. GraxPy is an independent implementation, not an official RETICOLO port or distribution; RETICOLO is not bundled with the public graxpy package.

License

Copyright (C) [2026] [Helmholtz-Berlin fur Materialen und Energie GmbH (HZB)]

Licensed under the European Union Public License (EUPL), Version 1.2.

You may not use this work except in compliance with the License.

A copy of the License is available at: https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12

Metadata

Release files for graxpy 0.5.2

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

Source distribution (sdist)

Source distribution for graxpy 0.5.2
File Size Uploaded
graxpy-0.5.2.tar.gz 864.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for graxpy 0.5.2
File Interpreter ABI Platform
graxpy-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 1.8 MB

Release files / graxpy-0.5.2.tar.gz

Download URL graxpy-0.5.2.tar.gz
Size 864.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0a13a94ecffa99a5e93b3d7e08f549cab707268d12f9fd5936f3eda0fb8bd150
BLAKE2b-256 checksum
How to use checksums
5a08bc76daff53df9e042f9bb6a5dd6ec585fa404cdf4ff6b6ba19110ddfbada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / graxpy-0.5.2-py3-none-any.whl

Download URL graxpy-0.5.2-py3-none-any.whl
Size 968.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32046e0ec0d294c638eda6b00d7187bd59ff1fc72cd02cde3afddf0a8cfd2c2e
BLAKE2b-256 checksum
How to use checksums
eec76f2808aea471b2afc9aa1ecfd6d8fa7dd685bdb0a4bd374c529fd1735413
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

0.5.4

2 release files

0.5.3

2 release files

This release

0.5.2 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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