fusion-energy / openmc_tally_unit_converter

A Python package that finds and converts OpenMC tally units.
MIT License
5 stars 2 forks source link
conversion convert normalization openmc units

N|Python

CI with install

PyPI

This Python package aims to help convert OpenMC tallies to user specified units.

Installation

pip install openmc_tally_unit_converter

Usage

OpenMC tally results are save into a statepoint h5 file without units.

This package ascertains the base units of common tallies by inspecting their tally filters and scores.

The following worked example is for a heating tally. Other supported tallies are heating-local, flux, effective dose and damage-energy (used to find DPA) tallies are also supported.

import openmc_tally_unit_converter as otuc
import openmc

# loads up tally from an openmc statepoint output file
statepoint = openmc.StatePoint(filepath="statepoint.2.h5")
my_tally = statepoint.get_tally(name="my_cell_heating_tally")

# gets the base units of the tally
tally = otuc.process_tally(tally=my_tally)
print(tally)
>>> 218559.22320927 electron_volt / source_particle

The package then allows users to scale the base tally units to different units. For example the package can easily convert cm to meters or electron volts to joules.

converted_tally = otuc.process_tally(
    tally=my_tally,
    required_units = "joules / source_particle"
)

print(converted_tally)
>>> 3.50170481e-14 Joules / source_particle

Additional inputs can be applied to normalize the the tallies and convert the units further:

converted_tally = otuc.process_tally(
    tally=my_tally,
    source_strength=1e20,  # input units for this argument are particles per second
    required_units = "joules / minute"
)

print(converted_tally)
>>> 2.10102288e+08 joules / source_particle
converted_tally = otuc.process_tally(
    tally=my_tally,
    source_strength=13458.3,  # input units for this argument are particles per second
    volume=12,  # input units are in cm3
    required_units = "joules / second / meter **3"
)

print(converted_tally)
>>> 3.92724948e-05 Joules / meter ** 3 / second

:point_right: Further examples