Skip to main content

A package to post-treat OpenMC's `depletion_results.h5` files.

Project description

A class for reading OpenMC depletion_results.h5 files.

Installation

PostOMC is available on PyPI:

pip install postomc

This installs the postomc python package as well as the pomc command line script.

API Usage

PostMC revolves around the DepletionResults which can be instantiated from a depletion_results.h5 file:

from postomc import DepletionResults
res = DepletionResults("path/to/depletion_results.h5")

The get the isotopic composition over time simply call the DepletionResults like a function, and provide the desired unit as argument:

res("g/cm**3")

If your result file contains only a single medium, this returns a Pandas dataframe with nuclide names as row index and timestamps as columns:

          0.0           1.0           2.0           3.0
H1        0.0  8.546804e-11  1.710615e-10  2.561159e-10
H2        0.0  9.163202e-17  3.674525e-16  8.276545e-16
H3        0.0  7.819664e-26  6.288458e-25  2.128727e-24
H4        0.0  0.000000e+00  0.000000e+00  0.000000e+00
H5        0.0  0.000000e+00  0.000000e+00  0.000000e+00
...       ...           ...           ...           ...
Ds271_m1  0.0  0.000000e+00  0.000000e+00  0.000000e+00
Ds272     0.0  0.000000e+00  0.000000e+00  0.000000e+00
Ds273     0.0  0.000000e+00  0.000000e+00  0.000000e+00
Ds279_m1  0.0  0.000000e+00  0.000000e+00  0.000000e+00
Rg272     0.0  0.000000e+00  0.000000e+00  0.000000e+00

[3820 rows x 4 columns]

If your result file contains multiples media, it will return a dictionnary mapping medium id to results dataframes. If you want to look at derived quantities like decay heat of activity, you'll need to provide an OpenMC decay chain to get decay constant and energy release values:

from postomc import DepletionResults
res = DepletionResults("path/to/depletion_results.h5", chain="path/to/chain.xml")
res("W")
res("W/cm**3")
res("Bq")
res("Bq/cm**3")

You can also set the time unit to whatever you prefer:

res("W", time_unit="s")

PostOMC uses pint for unit management so any unit from the default pint definition file is valid as long as it is homogeneous to mass, number of atoms, power, activity, or the volumic counterparts.

We also define the atom unit as an alias for the count unit so you can do:

res("atom/beer_barrel", time_unit="fortnight")

Sometimes you may want to get information like total mass of a certain element, regardless of isotope. You can facilitate this treatment by providing the multiindex=True argument to the call, this will result in dataframes using multiindex.

          0.0           1.0           2.0           3.0
Z  A   I
H  1   0  0.0  0.000000e+00  0.000000e+00  0.000000e+00
   2   0  0.0  0.000000e+00  0.000000e+00  0.000000e+00
   3   0  0.0  4.284350e-12  3.445411e-11  1.166318e-10
   4   0  0.0  0.000000e+00  0.000000e+00  0.000000e+00
   5   0  0.0  0.000000e+00  0.000000e+00  0.000000e+00
...       ...           ...           ...           ...
Ds 271 1  0.0  0.000000e+00  0.000000e+00  0.000000e+00
   272 0  0.0  0.000000e+00  0.000000e+00  0.000000e+00
   273 0  0.0  0.000000e+00  0.000000e+00  0.000000e+00
   279 1  0.0  0.000000e+00  0.000000e+00  0.000000e+00
Rg 272 0  0.0  0.000000e+00  0.000000e+00  0.000000e+00

[3820 rows x 4 columns]

In addition to isotopic composition, you can retrieve:

  • Reaction rates in $\mathrm{reaction}/s$ with DepletionResults.rr(time_unit="s")
  • $k_\mathrm{eff}$ using DepletionResults.keffs(time_unit="s")
  • Reactivity using DepletionResults.rhos(time_unit="s")

Time units are always "day" by default.

CLI Usage

Installing PostOMC also provides the pomc CLI command:

Usage: pomc [OPTIONS]

Options:
  -f, --file TEXT         Path to the depletion_results.h5 file.
  -s, --split-nuclides    Wether to create a nuclide indexed table or an
                          (Element, A, I) indexed table.
  -u, --unit TEXT         The desired unit.  [default: g/cm**3]
  -t, --time-unit TEXT    The desired time unit.  [default: d]
  -o, --output TEXT       Path to the output file.
  -c, --chain TEXT        Path to a depletion chain file.
  -m, --material INTEGER  Id of the desired material
  --help                  Show this message and exit.

The CLI allows you to convert results files to CSV, Excel, on print their content in the console as a formatted dataframe.

For instance to creating an Excel file in with a tab for each medium:

pomc -f path/to/depletion_results.h5 -o mass.xlsx -u "g/cm**3"

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

postomc-0.3.0.tar.gz (975.9 kB view details)

Uploaded Source

Built Distribution

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

postomc-0.3.0-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

Details for the file postomc-0.3.0.tar.gz.

File metadata

  • Download URL: postomc-0.3.0.tar.gz
  • Upload date:
  • Size: 975.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for postomc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 bd144e4e7919fdb3f5cdaf0c813c68a4d25e0407a58abd9d642e6da4dc15bbc9
MD5 791eb2bde73def8ed9cbddafea88826b
BLAKE2b-256 e55de2b9f23c073ef6c649b1d51fa6fa27e5f51b53fbb2fd7af1c996caaed1d6

See more details on using hashes here.

File details

Details for the file postomc-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: postomc-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for postomc-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b4f441e7c70bb028322e50520d5e2f2a9847c28c7b872f979d83cfd3c3d7be8
MD5 8e892b6154f4bd19dd3b4a7f11718aa4
BLAKE2b-256 bf17d58e0cc299426cde2e2eb707a675bdc8a3c84a63e15135ef89519719c09d

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