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

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.

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.0.2.tar.gz (575.2 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.0.2-py3-none-any.whl (53.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for raytrax-0.0.2.tar.gz
Algorithm Hash digest
SHA256 036ba40332baef82392c8e2962b3eb99702240d2a8b6d32336d58973af93721c
MD5 b1857fc9a4410e91732a20f3344b408d
BLAKE2b-256 8d76b4aa746f41bd7c0b9af14572cba20e78ac04a4c5264fd4ad03ff90b885cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for raytrax-0.0.2.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.0.2-py3-none-any.whl.

File metadata

  • Download URL: raytrax-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 53.9 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.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 128b3c2c4f707da3aca272c48058cbbc0ef12577c482dd74d480acf7ad38b52c
MD5 6bf881312ca56f579081f9cbba67ab85
BLAKE2b-256 59456ca5d463ad2db217ca03ec8c4e9e6c0cdce07285c7b125abff9ab15a5f0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for raytrax-0.0.2-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