Skip to main content

A Python package for BOOZ_XFORM output to GKV input

Project description

BZX - Boozer to GKV Coordinate Transformations


BZX is a Python package that transforms BOOZ_XFORM Boozer coordinate metrics into GKV field-aligned coordinates, enabling gyrokinetic analysis of VMEC equilibria.

Installation

To install from PyPI:

pip install bzx

Or install the latest development version from GitHub:

pip install git+https://github.com/GKV-developers/bzx.git

If your environment has any problems with installation, you can copy the single source script file bzx.py from the src/bzx/ directory and use it.

Usage

(i) Basic usage: Convert to GKV input file using BZX

Prepare VMEC equilibrium output (e.g. wout.nc) and its BOOZ_XFORM output (e.g. boozmn.nc).

from bzx import bzx

# Define transformation parameters
Ntheta_gkv = 1   # N_theta value in GKV
nrho = 11        # Radial grid points
ntht = 64        # Poloidal grid points
nzeta = 0        # Toroidal grid points (nzeta=0 corresponds to output GKV field-aligned coordinates)
alpha_fix = 0.0  # Field-line label: alpha = zeta - q*theta (not used for nzeta > 0)

# Run BZX transformation
bzx(Ntheta_gkv, nrho, ntht, nzeta, alpha_fix, 
    fname_boozmn="boozmn.nc", fname_wout="wout.nc", 
    output_file="./metric_boozer.bin.dat")
  • Reads VMEC output file (wout.nc) and BOOZ_XFORM output file (boozmn.nc). NetCDF format is recommended, but Binary format is also acceptable.
  • Converts them into field-aligned data and saves the result as GKV input binary file (metric_boozer.bin.dat).
  • Note: some BOOZ_XFORM versions (e.g. the Python package booz_xform==0.0.9) write phi_b = 0 into boozmn.nc. BZX detects this automatically and recovers the edge toroidal flux from the phi variable of wout.nc (a NetCDF wout is required in this case), printing a warning to stdout and log_BZX.dat.

(ii) Example of workflow: From VMEC to GKV via BOOZ_XFORM and BZX

The script examples/run_vmecpp_boozxform_bzx.ipynb demonstrats how to use BZX, starting from generating an equilibrium.

(iii) As a command line tool

After installation, you can use BZX directly as a CLI tool in a terminal, e.g.,

python -m bzx --Ntheta_gkv 1 --nrho 11 --ntht 64 \
              --nzeta 0 --alpha_fix 0.0 \
              --fname_boozmn "boozmn.nc" --fname_wout "wout.nc" \
              --output_file "./metric_boozer.bin.dat"

All arguments of bzx function is specified by keyword arguments. See also help.

python -m bzx --help

Dependencies

BZX requires the following Python packages:

  • numpy, scipy, xarray
  • (Optional) matplotlib for visualization in examples/
  • (Optional) booz_xform for examples/run_vmecpp_boozxform_bzx.py
  • (Optional) vmecpp for examples/run_vmecpp_boozxform_bzx.py

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Developed by Shinya Maeyama (maeyama.shinya@nifs.ac.jp)

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

bzx-0.1.3.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

bzx-0.1.3-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file bzx-0.1.3.tar.gz.

File metadata

  • Download URL: bzx-0.1.3.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bzx-0.1.3.tar.gz
Algorithm Hash digest
SHA256 54d50666d6f81024c20a5f012ee8729bdfabfbfa6a09ede6e4901a497b54821c
MD5 c2d5b226ebb04def270a7a574731f863
BLAKE2b-256 c424e4f1bd23a08f946926c5a6c27fbf562da45f195fed1977c070fd0e8fc055

See more details on using hashes here.

Provenance

The following attestation bundles were made for bzx-0.1.3.tar.gz:

Publisher: publish-to-pypi.yml on GKV-developers/bzx

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

File details

Details for the file bzx-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: bzx-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bzx-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c54862943b1cc4674a8e92981ee7bd3caa3a475d5e53290cf8c6ec3f268ed695
MD5 565e776cf804a60638e209ba29beaadb
BLAKE2b-256 dafa9e7b59fd15209060290680f72e2bc2ff1aa1d8a70558bc36659457a1f9e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bzx-0.1.3-py3-none-any.whl:

Publisher: publish-to-pypi.yml on GKV-developers/bzx

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