Skip to main content

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:

  • The source strength of the source in particles per second can be specified with the strength_strength argument. This allows the tally results to be converted from the units of score per simulated particle to score per unit time (e.g seconds, hours, days etc).
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
  • The volume of the cell in cm3 can also be specified with the volume argument. This allows the tally result to be converted from the base units to base units per unit volume.
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

Release files for openmc-tally-unit-converter 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openmc-tally-unit-converter 0.3.1
File Size Uploaded
openmc_tally_unit_converter-0.3.1.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openmc-tally-unit-converter 0.3.1
File Interpreter ABI Platform
openmc_tally_unit_converter-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / openmc_tally_unit_converter-0.3.1.tar.gz

Download URL openmc_tally_unit_converter-0.3.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
55efb2001b3d271f133bf8e33cf6c6e3741b80c8aabb5bd5aaada27b0e5ef734
BLAKE2b-256 checksum
How to use checksums
2c3f90a979829b045d00bdd2654bf86ae88a9791a7fa04b8d6eb133e01fc810f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / openmc_tally_unit_converter-0.3.1-py3-none-any.whl

Download URL openmc_tally_unit_converter-0.3.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10f9d94fa4dddc1d9ab2cfcbe539e94b357eff4c54ed5f26efc2fcf46c7f7f7e
BLAKE2b-256 checksum
How to use checksums
c9568efd6f941f9a8f717510c20743726229cec68cb61aabbe8230810d202d63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page