Skip to main content

Convert Omega_h mesh files generated using TOMMS for TOKAMAKs to CSG format for OpenMC and Degas2.

Project description

Convert Omega_h Mesh to CSG Format

License GitHub Actions build status (Linux) Release

Efficiently convert Tokamak mesh of Omega_h (.osh) format to Constructive Solid Geometry (CSG). It supports creating CSG representation in

  1. Degas2's geometry.nc format
  2. OpenMC's geometry XML or a Python openmc.Universe object.

Installation

1. Pre-built Wheel

This is the recommended way to install this package. We provide a pre-built wheel (Kokkos with OpenMP backend) for Python. Follow these steps to install the latest version of readOH2csg using pip:

  1. On any Linux system, make sure you have Python (Version ≥ 3.11) installed. Go to the terminal and cd to the directory where you want to install the Python virtual environment.
python -m venv readoh2csg-env # or any name you prefer
source readoh2csg-env/bin/activate

[!TIP] Make sure that the Python version of the virtual environment is 3.11 or higher. You can check it by running python --version.

  1. Install dependencies:
pip install --extra-index-url https://shimwell.github.io/wheels openmc
pip install netCDF4==1.7.2
  1. Install readOH2csg:
pip install https://github.com/Fuad-HH/readOH2csg/releases/download/v0.0.1-alpha/omegah2csg-0.0.1-py3-none-any.whl omegah2csg

or

pip install -i https://test.pypi.org/simple/ omegah2csg
  1. Try running the CLI tool, and it should print the help message:
convert2degas2 --help

2. From Source

It depends on Omega_h. Omega_h has to be built with Kokkos and it supports any Kokkos backend.

Follow these steps to build and install readOH2csg from source:

  1. Make sure you have compilers (at least g++ or some alternative), Python (Version ≥ 3.11), and CMake available.
  2. Install Kokkos following the instructions in Kokkos Build Documentation. You can choose any backend supported. Here's an example for building with the OpenMP backend:
git clone --depth=2 --branch 4.7.02 https://github.com/kokkos/kokkos.git
cd kokkos
cmake -S . -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_CXX_COMPILER=g++ \
  -DBUILD_SHARED_LIBS=ON \
  -DKokkos_ENABLE_OPENMP=ON \
  -DCMAKE_INSTALL_PREFIX=<Kokkos_install_dir>

cmake --build build -j4 --target install
  1. Install Omega_h with Kokkos support:
git clone https://github.com/SCOREC/omega_h.git
cd omega_h
cmake -S . -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_CXX_COMPILER=g++ \
  -DBUILD_SHARED_LIBS=ON \
  -DOmega_h_USE_Kokkos=ON \
  -DKokkos_ROOT=<Kokkos_install_dir> \
  -DCMAKE_INSTALL_PREFIX=<Omega_h_install_dir>

cmake --build build -j4 --target install
  1. Now, install readOH2csg:
git clone https://github.com/Fuad-HH/readOH2csg.git --branch parallel
cd readOH2csg

# configure
cmake -S . -B build \
  -DOmega_h_ROOT=<Omega_h_install_dir> \
  -DKokkos_ROOT=<Kokkos_install_dir> \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=<readOH2csg_install_dir>

# build
cmake --build build -j4 --target install

[!WARNING] For now, only the Python API and CLI work. Please do not turn off the option for Python bindings. It is enabled by default.

  1. Create Python virtual environment and install dependencies as described in the Pre-built Wheel section.
  2. Install readOH2csg and run the CLI tool, and it should print the help message:
# from the source directory
python -m pip install .
convert2degas2 --help

Usage

Check an example case in tests/assets/simple_degas2_case/degas2-case. Please read the README.md file first for detailed instructions on how to run the example case.

To run an OpenMC example, running convert2openmc <mesh-name> will generate the geometry.xml file and, run the case following OpenMC Documentation.

[!TIP] If omegah2csg was installed with Kokkos OpenMP backend or using pip, try setting OpenMP environment variables for faster execution.

export OMP_PROC_BIND=spread && export OMP_PLACES=threads && export OMP_NUM_THREADS=<number of threads you want>

Documentation

More details on strategies, logic, and math are included in the doc/ directory.

Developer's Guide

For myself and future development, use the Developer's Guide to understand the code structure, design decisions, and how to contribute to this project.

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

omegah2csg-0.0.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

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

omegah2csg-0.0.1-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file omegah2csg-0.0.1.tar.gz.

File metadata

  • Download URL: omegah2csg-0.0.1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for omegah2csg-0.0.1.tar.gz
Algorithm Hash digest
SHA256 aae0ecf05d7a298564e664f05d6c29c61057dd5bb277de2be132d19b661d3848
MD5 9e6b88044dc0715a28be7fdd59578523
BLAKE2b-256 71333e6258dc46f2ae48e3adb2f1596676e21f2c7fdee11d7d73fde3bf442a0c

See more details on using hashes here.

File details

Details for the file omegah2csg-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: omegah2csg-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for omegah2csg-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 244a64c0ae5aae5c81669687776ea8e69308363b7764552d6c143cc9235f5c7e
MD5 6478d577f7ef84b44a4e7c948b894f47
BLAKE2b-256 689039f933d4f1888722e117493536f7eca21ee707d8a6867b525e61ee8966be

See more details on using hashes here.

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