Skip to main content

An ECRH ray tracer based on JAX

Project description

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 in early development. Expect API changes and incomplete validation. For details 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raytrax-0.4.0.tar.gz (587.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raytrax-0.4.0-py3-none-any.whl (57.5 kB view details)

Uploaded Python 3

File details

Details for the file raytrax-0.4.0.tar.gz.

File metadata

  • Download URL: raytrax-0.4.0.tar.gz
  • Upload date:
  • Size: 587.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for raytrax-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4add08bf497710141cb00a55f85eeb31c8feecec43f3341c35cef4b428bd2948
MD5 3f39c029280c291ab1e2a86e9764d0c8
BLAKE2b-256 42558ca32520038001f618a5e3f47cc5cac82c7823246c2e44f51643bababbb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for raytrax-0.4.0.tar.gz:

Publisher: publish.yml on proximafusion/raytrax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file raytrax-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: raytrax-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 57.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for raytrax-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3886cdbcba4508585544b9a5362432e5f071641ba96b6c085ae1d18f2d02d960
MD5 627249ad0eabdef1f86817ca99c63726
BLAKE2b-256 7eb60cf0aaabb75b1e7c654ebd066858c5f38903966d49b8af996241b3b66152

See more details on using hashes here.

Provenance

The following attestation bundles were made for raytrax-0.4.0-py3-none-any.whl:

Publisher: publish.yml on proximafusion/raytrax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page