Skip to main content

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

Project description

radioactivedecay

PyPI Python Version Latest Documentation Test Coverage

radioactivedecay is a Python package for radioactive decay calculations. It fully supports radionuclide decay chains, including those with branching decays or chains passing through metastable states. By default radioactivedecay uses the decay data from ICRP Publication 107, which covers 1252 radionuclides of 97 elements.

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 = rd.Inventory({'I-123': 1.0, 'Tc-99m': 2.0})
>>> inv = inv.decay(20.0, 'h')
>>> inv.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 123I and 2.0 Bq of 99mTc and decayed it for 20 hours. The decayed inventory contains 99Tc, which is the progeny of 99mTc, and 123Te and 123mTe, which are progeny of 123I.

Note that radioactivedecay does not require that you specify the activity units. This is because its calculations are agnostic of the activity units: units out are the same as units in. So this calculation could have also represented the decay of 1.0 Ci of 123I, 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 units of hours. Accepted time units 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 a Radionuclide class which can be used to fetch decay information for individual radionuclides.

>>> nuc = rd.Radionuclide('I-123')
>>> nuc.half_life('d')
13.27
>>> nuc.progeny()
['Te-123', 'Te-123m']
>>> nuc.branching_fractions()
[0.99996, 4.442e-05]
>>> nuc.decay_modes()
['EC', 'EC']

The half-life for 123I is thus 13.27 days. Its direct progeny are 123Te and 123mTe, with branching fractions 0.99996 and 4.442e-05 respectively. Both of the decay modes occur via electron capture (EC).

The default decay dataset in radioactivedecay is ICRP-107. Its data can be queried directly as follows:

>>> rd.DEFAULTDATA.dataset
'icrp107'
>>> rd.DEFAULTDATA.half_life('Cs-137', 'y')
30.1671
>>> rd.DEFAULTDATA.branching_fraction('Cs-137', 'Ba-137m')
0.94399
>>> rd.DEFAULTDATA.decay_mode('Cs-137', 'Ba-137m')
'β-'

High numerical precision decay calculations

radioactivedecay includes a high numerical precision mode for decay calculations employing SymPy arbitrary-precision routines. This can give more accurate results for decay chains containing both radionuclides with very long and very short half-lives. Access it using the decay_high_precision() method:

>>> inv = rd.Inventory({'U-238': 1.0})
>>> inv = inv.decay_high_precision(10.0, 'd')
>>> inv.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 decay chain differential equations using linear alegbra. It implements the method described in this paper: M Amaku, PR Pascholati & VR Vanin, Comp. Phys. Comm. 181, 21-23 (2010). It calls NumPy and SciPy for the standard double precision decay calculations, and SymPy for the high numerical precision decay 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 of decay calculations against the PyNE and Radiological Toolbox codes.

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.0.tar.gz (561.0 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.0-py3-none-any.whl (558.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: radioactivedecay-0.1.0.tar.gz
  • Upload date:
  • Size: 561.0 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.0.tar.gz
Algorithm Hash digest
SHA256 850aea58d822a4f4918bb13730ceebaccec6cbb48f035737aba820ff5efa54fd
MD5 d8a3114eb8a369a7a1d0caeb413672bf
BLAKE2b-256 92aa833e62b2af8c2de5e7720047414891d7a8f20743b944b2880e5f70de0382

See more details on using hashes here.

File details

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

File metadata

  • Download URL: radioactivedecay-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 558.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ea699405efe83920194a41f21411414a12e962ca68dd70e429dc24b7fbba81d
MD5 ae31d858e0e1c936ea47fff8b95b93e6
BLAKE2b-256 d34a1a634a86a500e74dd9d557386513c2f5e517b36bfd0fc5dda152403eda2b

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