Examples
Bundled Example Scripts
The repository includes several ready-to-run examples.
examples/example_li383_basic.pyMinimal end-to-end example: reads a bundled VMEC file, runs the transform on one surface, and generates a surfplot plus a dominant-mode plot.
Run it with:
python examples/example_li383_basic.py --no-show
examples/example_li383_jax_api_fast.pyDemonstrates the lower-level JAX API with precomputed constants and explicit
jax.jitcompilation.Run it with:
python examples/example_li383_jax_api_fast.py
examples/example_li383_autodiff_opt.pyShows how Boozer diagnostics can be embedded in a differentiable optimization loop.
examples/example_li383_jacobian_sensitivity.pyDemonstrates matrix-free sensitivities of
gmnc_bJacobian harmonics usingjax.value_and_grad,jax.jvp, andjax.vjp.examples/example_vmec_jax_pipeline.pyDemonstrates an in-memory pipeline from
vmec_jaxoutput tobooz_xform_jaxwithout writing intermediate files.examples/example_li383_wireframe.pyProduces a wireframe-style visualization from a transformed configuration.
examples/example_li383_resolution_scan.pyExplores how the output changes as
mbozandnbozare varied.
CLI Example
For a legacy-style CLI run, create an input file like:
16 16
'circular_tokamak'
2 8 14
and run:
booz_xform_jax in_booz.circular_tokamak F
If wout_circular_tokamak.nc is in the same directory, the command writes
boozmn_circular_tokamak.nc.
Python Example
from booz_xform_jax import Booz_xform
bx = Booz_xform()
bx.read_wout("wout_li383_1.4m.nc", flux=True)
bx.mboz = 16
bx.nboz = 16
bx.compute_surfs = [0, 10, 20]
bx.run()
print("Boozer I:", bx.Boozer_I)
print("First surface |B| coefficients:", bx.bmnc_b[:, 0][:10])
Using The Plot Helpers
from booz_xform_jax import Booz_xform, surfplot, modeplot
bx = Booz_xform()
bx.read_wout("wout_li383_1.4m.nc", flux=True)
bx.register_surfaces(0.5)
bx.run()
surfplot(bx, js=0, show=True)
modeplot(bx, nmodes=12, show=True)