Skip to main content

Raytrax

An ECRH ray tracer for fusion plasmas, built on JAX.

CI License: MIT Python ≥ 3.11 Documentation DOI

Raytrax simulates Electron Cyclotron Resonance Heating (ECRH) of magnetic confinement fusion plasmas. Powered by JAX, it features JIT-compiled ray tracing and automatic differentiation — making it well-suited for gradient-based beam optimization in fusion plant design.

Note: Raytrax is under active development, and the API may change before version 1.0. For current limitations see the docs.

Usage

Load a magnetic equilibrium, define plasma profiles, and trace a beam:

import jax.numpy as jnp
import raytrax
import vmecpp

vmec_wout = vmecpp.VmecWOut.from_wout_file("w7x.nc")
mag_conf = raytrax.MagneticConfiguration.from_vmec_wout(vmec_wout)

rho = jnp.linspace(0, 1, 200)
profiles = raytrax.RadialProfiles(
    rho=rho,
    electron_density=2.0 * (1 - rho**2),
    electron_temperature=3.0 * (1 - rho**2),
)
beam = raytrax.Beam(
    position=jnp.array([6.6, 0.0, 0.0]),
    direction=jnp.array([-0.985, 0.0, -0.174]),
    frequency=140e9,
    mode="O",
    power=1e6,
)

result = raytrax.trace(mag_conf, profiles, beam)

print(f"Optical depth τ     = {result.optical_depth:.3f}")
print(f"Absorbed fraction   = {result.absorbed_power_fraction:.1%}")
print(
    f"Deposition at ρ     = {result.deposition_rho_mean:.2f} ± {result.deposition_rho_std:.2f}"
)

Visualizations

Beam trace on a poloidal cross-section

ECRH beam trace on W7-X R-Z cross-section

3D visualization

Raytrax can render flux surfaces and beam trajectories in 3D using PyVista:

import pyvista as pv
from raytrax.plot.plot3d import plot_flux_surface_3d, plot_beam_profile_3d

plotter = pv.Plotter()
plot_flux_surface_3d(mag_conf, rho_value=1.0, plotter=plotter, opacity=0.25)
plot_beam_profile_3d(result.beam_profile, plotter=plotter, tube_radius=0.02)
plotter.export_html("scene.html")  # interactive standalone HTML
3D visualization of W7-X flux surface and ECRH beam

Try out a live interactive version in the docs.

Jupyter Notebooks

Quick-start notebooks are in the notebooks/ directory.

Installation

python -m pip install raytrax

See the documentation for a full getting-started guide, theory background, and API reference.

Citing Raytrax

If you use Raytrax in your research, please cite it via Zenodo: doi:10.5281/zenodo.18924104.

Acknowledgements

The development of Raytrax is a collaboration between Proxima Fusion and the Munich University of Applied Sciences (HM) and was partially supported by the German Federal Ministry of Research, Technology and Space (BMFTR) under grant FPP-MC (13F1001B).

Proxima Fusion      HM      BMFTR

License

Raytrax is released under the MIT License. See LICENSE.md for details.

Metadata

Release files for raytrax 0.6.0

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

Source distribution (sdist)

Source distribution for raytrax 0.6.0
File Size Uploaded
raytrax-0.6.0.tar.gz 599.2 kB Details

Built distribution (wheel)

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

Total release size: 659.8 kB

Release files / raytrax-0.6.0.tar.gz

Download URL raytrax-0.6.0.tar.gz
Size 599.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a4fdfb0102c3fb896986096dae5585a5ae4e67b4061d355dd6d8da30d354a7ac
BLAKE2b-256 checksum
How to use checksums
b9443079b155ecc1e95a423d933a7209224439ab49677ab6994829ad1f4a304a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

Release files / raytrax-0.6.0-py3-none-any.whl

Download URL raytrax-0.6.0-py3-none-any.whl
Size 60.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9374d35e7d2920d553bd6fe009c9f8de903e415c23dedfbb2753ed66f696ac21
BLAKE2b-256 checksum
How to use checksums
d9c53ae808c3b03baf8f51cd3572953f76aaf4f0de24054896210a94b2c3a7d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

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