Skip to main content

A Python package for radioactive decay calculations that supports 1252 radionuclides, decay chains, branching, and metastable states.

Project description

radioactivedecay

PyPI Python Version Latest Documentation Test Coverage

radioactivedecay is a Python package for radioactive decay calculations. It supports decay chains of radionuclides, metastable states and branching decays. By default it uses the decay data from ICRP Publication 107, which contains 1252 radionuclides of 97 elements.

It solves the radioactive decay differential equations analytically using NumPy and SciPy linear algebra routines. There is also a high numerical precision mode using SymPy routines which gives more accurate results for decay chains with orders of magnitude differences between radionuclide half-lives.

Installation

radioactivedecay requires Python 3.6+, NumPy and SciPy.

The easiest way to install radioactivedecay is via the Python Package Index using pip:

$ pip install radioactivedecay

Usage

Decay calculations

Create an Inventory of radionuclides and decay it as follows:

>>> import radioactivedecay as rd
>>> inv_t0 = rd.Inventory({'I-123': 1.0, 'Tc-99m': 2.0})
>>> inv_t1 = inv_t0.decay(20.0, 'h')
>>> inv_t1.contents
{'I-123': 0.35180331802323694,
 'Tc-99': 5.852125859801924e-09,
 'Tc-99m': 0.19957172182663926,
 'Te-123': 1.6353735405592892e-18,
 'Te-123m': 1.3312369019952352e-07}

Here we created an inventory of 1.0 Bq of I-123 and 2.0 Bq of Tc-99m and decayed it for 20 hours. The decayed inventory contains Tc-99, which is the progeny of Tc-99m, and Te-123 and Te-123m, which are progeny of I-123.

Note the Inventory constructor did not require specification of activity units. This is because in radioactivedecay, units out are the same as units in, by default. So the above calculation could have represented the decay of 1.0 Ci of I-123, or 1.0 dpm, or 1.0 kBq, etc.

In the example we supplied 'h' as an argument to the decay() method to specify the decay time period (20.0) had a time unit of hours. Acceptable time units for the program include 'ms', 's', 'm', 'h', 'd', 'y' etc. Note seconds ('s') is the default if no time unit is supplied to decay().

Radionuclides can be specified in three equivalent ways in radioactivedecay. The strings

  • 'Rn-222', 'Rn222' or '222Rn',
  • 'Ir-192n', 'Ir192n' or '192nIr'

are all equivalent ways of specifying 222Rn and 192nIr to the program.

Fetching decay data

radioactivedecay includes methods to fetch decay data for the radionuclides in an inventory:

>>> inv_t0.half_lives('h')
{'I-123': 13.27, 'Tc-99m': 6.015}
>>> inv_t0.progeny()
{'I-123': ['Te-123', 'Te-123m'], 'Tc-99m': ['Tc-99', 'Ru-99']}
>>> inv_t0.branching_fractions()
{'I-123': [0.99996, 4.442e-05], 'Tc-99m': [0.99996, 3.7e-05]}
>>> inv_t0.decay_modes()
{'I-123': ['EC', 'EC'], 'Tc-99m': ['IT', 'β-']}

The Radionuclide class can be used to fetch decay information for individual radionuclides, e.g. for Rn-222:

>>> nuc = rd.Radionuclide('Ra-226')
>>> nuc.half_life('d')
3.8235
>>> nuc.progeny()
['Po-218']
>>> nuc.branching_fractions()
[1.0]
>>> nuc.decay_modes()
['α']

The half-life for Rn-222 is 3.8235 days. Its direct progeny is Po-218, created from an α decay.

High numerical precision decay calculations

radioactivedecay includes a high numerical precision mode which gives more accurate results for decay chains containing long and short lived radionuclides together. It employs SymPy arbitrary-precision numerical routines. Access it with the decay_high_precision() method:

>>> inv_t0 = rd.Inventory({'U-238': 1.0})
>>> inv_t1 = inv_t0.decay_high_precision(10.0, 'd')
>>> inv_t1.contents
{'At-218': 1.4511675857141352e-25,
'Bi-210': 1.8093327888942224e-26,
'Bi-214': 7.09819414496093e-22,
'Hg-206': 1.9873081129046843e-33,
'Pa-234': 0.00038581180879502017,
'Pa-234m': 0.24992285949158477,
'Pb-210': 1.0508864357335218e-25,
'Pb-214': 7.163682655782086e-22,
'Po-210': 1.171277829871092e-28,
'Po-214': 7.096704966148592e-22,
'Po-218': 7.255923469955255e-22,
'Ra-226': 2.6127168262000313e-21,
'Rn-218': 1.4511671865210924e-28,
'Rn-222': 7.266530698712501e-22,
'Th-230': 8.690585458641225e-16,
'Th-234': 0.2499481473619856,
'Tl-206': 2.579902288672889e-32,
'Tl-210': 1.4897029111914831e-25,
'U-234': 1.0119788393651999e-08,
'U-238': 0.9999999999957525}

How radioactivedecay works

radioactivedecay calculates an analytical solution to the radioactive decay differential equations using linear algebra operations. It implements the method described in this paper: M Amaku, PR Pascholati & VR Vanin, Comp. Phys. Comm. 181, 21-23 (2010). See the theory docpage for more details.

It uses NumPy and SciPy routines for standard double-precision floating-point computations, and SymPy for high numerical precision calculations.

By default radioactivedecay uses decay data from ICRP Publication 107 (2008).

The notebooks folder in the GitHub repository contains Jupyter Notebooks for creating the decay datasets that are read in by radioactivedecay, e.g. ICRP 107. It also contains some comparisons against decay calculations made with PyNE and Radiological Toolbox.

Tests

From the base directory run:

$ python -m unittest discover

License

radioactivedecay is open source software released under the MIT License. The ICRP-107 decay data is copyright 2008 A. Endo and K.F. Eckerman. See LICENSE for details.

Contributing

Contributors are welcome to fix bugs, add new features or make feature requests. Please open a pull request or a new issue on the GitHub repository.

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

radioactivedecay-0.1.1.tar.gz (561.1 kB view details)

Uploaded Source

Built Distribution

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

radioactivedecay-0.1.1-py3-none-any.whl (558.6 kB view details)

Uploaded Python 3

File details

Details for the file radioactivedecay-0.1.1.tar.gz.

File metadata

  • Download URL: radioactivedecay-0.1.1.tar.gz
  • Upload date:
  • Size: 561.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for radioactivedecay-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a576b97362fb97523d47b7f1d6ed24e4fc1aaf269773ba4b1bd0e05ef4d01a90
MD5 91a8aaaf0a336e3211a4b4ba9772ce79
BLAKE2b-256 83eacf015191d39e9920a0a427eee4fb511b2a2dbe51c1d866efc07c58721113

See more details on using hashes here.

File details

Details for the file radioactivedecay-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: radioactivedecay-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 558.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for radioactivedecay-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f9329b0ceaf9984c602b564459682005fc20ca273fe21ce5d003a2070135449
MD5 a8821a1652f6882bdba5e395a676c495
BLAKE2b-256 d17f5a670a6bf73e265d63e2489777f5a5b4ce7d42113193a4705c85ae43765c

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