radioactivedecay

radioactivedecay: A Python package for radioactive decay calculations - Published in JOSS (2022)

https://github.com/radioactivedecay/radioactivedecay

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 11 DOI reference(s) in README
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    1 of 5 committers (20.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.7%) to scientific vocabulary

Keywords

decay decay-chains medical-physics nuclear-physics pypi-package python radioactive-decay-calculations radioactivity radiochemistry radioisotopes radionuclides

Scientific Fields

Mathematics Computer Science - 65% confidence
Sociology Social Sciences - 64% confidence
Last synced: 4 months ago · JSON representation

Repository

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

Basic Info
Statistics
  • Stars: 102
  • Watchers: 11
  • Forks: 30
  • Open Issues: 6
  • Releases: 47
Topics
decay decay-chains medical-physics nuclear-physics pypi-package python radioactive-decay-calculations radioactivity radiochemistry radioisotopes radionuclides
Created over 5 years ago · Last pushed 11 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.md

radioactivedecay logo


PyPI Conda Python Version Latest Documentation Tests Tests Coverage Code Style: Black DOI Downloads

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, and atomic mass data from the Atomic Mass Data Center.

The code solves the radioactive decay differential equations analytically using NumPy and SciPy linear algebra routines. There is also a high numerical precision calculation mode employing SymPy routines. This gives more accurate results for decay chains containing radionuclides with orders of magnitude differences between the half-lives.

This is free-to-use open source software. It was created for engineers, technicians and researchers who work with radioactivity, and for educational use.

Installation

radioactivedecay requires Python 3.9+. Install radioactivedecay from the Python Package Index using pip:

console $ pip install radioactivedecay

or from conda-forge:

console $ conda install -c conda-forge radioactivedecay

Either command will attempt to install the dependencies (Matplotlib, NetworkX, NumPy, Pandas, SciPy, Setuptools & SymPy) if they are not already present in the environment.

Usage

Decay calculations

Create an Inventory of radionuclides and decay it as follows:

```pycon

import radioactivedecay as rd Mo99t0 = rd.Inventory({'Mo-99': 2.0}, 'Bq') Mo99t1 = Mo99t0.decay(20.0, 'h') Mo99t1.activities('Bq') {'Mo-99': 1.6207863893776937, 'Ru-99': 0.0, 'Tc-99': 9.05304236308454e-09, 'Tc-99m': 1.3719829376710406} ```

An Inventory of 2.0 Bq of Mo-99 was decayed for 20 hours, producing the radioactive progeny Tc-99m and Tc-99, and the stable nuclide Ru-99.

We supplied 'h' as an argument to decay() to specify the decay time period had units of hours. Supported time units include 'μs', 'ms', 's', 'm', 'h', 'd', 'y' etc. Note seconds ('s') is the default if no unit is supplied to decay().

Use cumulative_decays() to calculate the total number of atoms of each radionuclide that decay over the decay time period:

```pycon

Mo99t0.cumulativedecays(20.0, 'h') {'Mo-99': 129870.3165339939, 'Tc-99m': 71074.31925850797, 'Tc-99': 0.0002724635511147602} ```

Radionuclides can be specified in four equivalent ways in radioactivedecay: three variations of nuclide strings or by canonical ids. For example, the following are equivalent ways of specifying 222Rn and 192nIr:

  • 'Rn-222', 'Rn222', '222Rn', 862220000,
  • 'Ir-192n', 'Ir192n', '192nIr', 771920002.

Inventories can be created by supplying activity ('Bq', 'Ci', 'dpm'...), mass ('g', 'kg'...), mole ('mol', 'kmol'...) units, or numbers of nuclei ('num') to the Inventory() constructor. Use the methods activities(), masses(), moles(), numbers(), activity_fractions(), mass_fractions() and mole_fractions() to obtain the contents of the inventory in different formats:

```pycon

H3t0 = rd.Inventory({'H-3': 3.0}, 'g') H3t1 = H3t0.decay(12.32, 'y') H3t1.masses('g') {'H-3': 1.5, 'He-3': 1.4999900734297729} H3t1.massfractions() {'H-3': 0.5000016544338455, 'He-3': 0.4999983455661545}

C14t0 = rd.Inventory({'C-14': 3.2E24}, 'num') C14t1 = C14t0.decay(3000, 'y') C14t1.moles('mol') {'C-14': 3.6894551567795797, 'N-14': 1.6242698581767292} C14t1.molefractions() {'C-14': 0.6943255713073281, 'N-14': 0.3056744286926719} ```

Plotting decay graphs

Use the plot() method to graph of the decay of an inventory over time:

```pycon

Mo99_t0.plot(20, 'd', yunits='Bq') ```

Mo-99 decay graph

The graph shows the decay of Mo-99 over 20 days, leading to the ingrowth of Tc-99m and a trace quantity of Tc-99. The activity of Ru-99 is strictly zero as it is the stable nuclide at the end of the decay chain. Graphs are drawn using Matplotlib.

Fetching decay data

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

```pycon

nuc = rd.Nuclide('Rn-222') nuc.halflife('s') 330350.4 nuc.halflife('readable') '3.8235 d' nuc.progeny() ['Po-218'] nuc.branchingfractions() [1.0] nuc.decaymodes() ['α'] nuc.Z # proton number 86 nuc.A # nucleon number 222 nuc.atomic_mass # atomic mass in g/mol 222.01757601699998 ```

There are similar inventory methods for fetching decay data:

```pycon

Mo99t1.halflives('readable') {'Mo-99': '65.94 h', 'Ru-99': 'stable', 'Tc-99': '0.2111 My', 'Tc-99m': '6.015 h'} Mo99t1.progeny() {'Mo-99': ['Tc-99m', 'Tc-99'], 'Ru-99': [], 'Tc-99': ['Ru-99'], 'Tc-99m': ['Tc-99', 'Ru-99']} Mo99t1.branchingfractions() {'Mo-99': [0.8773, 0.1227], 'Ru-99': [], 'Tc-99': [1.0], 'Tc-99m': [0.99996, 3.7e-05]} Mo99t1.decay_modes() {'Mo-99': ['β-', 'β-'], 'Ru-99': [], 'Tc-99': ['β-'], 'Tc-99m': ['IT', 'β-']} ```

Decay chain diagrams

The Nuclide class includes a plot() method for drawing decay chain diagrams:

```pycon

nuc = rd.Nuclide('Mo-99') nuc.plot() ```

Mo-99 decay chain

These diagrams are drawn using NetworkX and Matplotlib.

High numerical precision decay calculations

radioactivedecay includes an InventoryHP class for high numerical precision calculations. This class can give more reliable decay calculation results for chains containing long- and short-lived radionuclides:

```pycon

U238t0 = rd.InventoryHP({'U-238': 1.0}) U238t1 = U238t0.decay(10.0, 'd') U238t1.activities() {'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-206': 0.0, '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 decay calculations (double-precision floating-point operations), and SymPy for arbitrary numerical precision calculations.

By default radioactivedecay uses decay data from ICRP Publication 107 (2008) and atomic mass data from the Atomic Mass Data Center (AMDC - AME2020 and Nubase2020 evaluations).

The datasets repo contains Jupyter Notebooks for creating decay datasets that can be used by radioactivedecay, e.g. ICRP 107.

The comparisons repo contains some checks of radioactivedecay against PyNE and Radiological Toolbox.

Tests

From the base directory run:

console $ python -m unittest discover

License

radioactivedecay is open source software released under the MIT License. See LICENSE file for details.

The default decay data used by radioactivedecay (ICRP-107) is copyright 2008 A. Endo and K.F. Eckerman and distributed under a separate license. The default atomic mass data is from AMDC (license).

Citation

If you find this package useful for your research, please consider citing the paper on radioactivedecay published in the Journal of Open Source Software:

Alex Malins & Thom Lemoine, radioactivedecay: A Python package for radioactive decay calculations. Journal of Open Source Software, 7 (71), 3318 (2022). DOI: 10.21105/joss.03318.

Contributing

Contributors are welcome to fix bugs, add new features or make feature requests. Please open an Issue, Pull Request or new Discussions thread at GitHub repository.

Please read the contribution guidelines.

Owner

  • Name: radioactivedecay
  • Login: radioactivedecay
  • Kind: organization
  • Email: radioactivedecay@alexmalinsREMOVETHIS.com

Radioactive decay calcuations in Python

GitHub Events

Total
  • Create event: 3
  • Release event: 2
  • Issues event: 7
  • Watch event: 18
  • Delete event: 3
  • Issue comment event: 32
  • Push event: 9
  • Pull request review event: 10
  • Pull request review comment event: 12
  • Pull request event: 7
  • Fork event: 9
Last Year
  • Create event: 3
  • Release event: 2
  • Issues event: 7
  • Watch event: 18
  • Delete event: 3
  • Issue comment event: 32
  • Push event: 9
  • Pull request review event: 10
  • Pull request review comment event: 12
  • Pull request event: 7
  • Fork event: 9

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 311
  • Total Committers: 5
  • Avg Commits per committer: 62.2
  • Development Distribution Score (DDS): 0.17
Past Year
  • Commits: 28
  • Committers: 2
  • Avg Commits per committer: 14.0
  • Development Distribution Score (DDS): 0.036
Top Committers
Name Email Commits
Alex Malins g****b@a****m 258
Thom Lemoine l****m@w****u 36
Ian Cullen i****n@g****m 15
Bernardo Gameiro 3****0 1
Alberto 4****3 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 21
  • Total pull requests: 89
  • Average time to close issues: 21 days
  • Average time to close pull requests: 1 day
  • Total issue authors: 16
  • Total pull request authors: 6
  • Average comments per issue: 2.9
  • Average comments per pull request: 0.85
  • Merged pull requests: 87
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 5
  • Pull requests: 8
  • Average time to close issues: 1 day
  • Average time to close pull requests: 3 days
  • Issue authors: 4
  • Pull request authors: 3
  • Average comments per issue: 1.2
  • Average comments per pull request: 2.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • danieldjewell (3)
  • alexmalins (2)
  • BishopWolf (2)
  • munkm (2)
  • exaos (1)
  • radioactivedecay-github (1)
  • atharva-2001 (1)
  • lemointm (1)
  • shenbo (1)
  • JWingUtk (1)
  • jvavrek (1)
  • shyamd (1)
  • tabaker99 (1)
  • Cs137 (1)
  • snuetzmann (1)
Pull Request Authors
  • alexmalins (82)
  • lemointm (6)
  • php1ic (3)
  • tristan-gardner (2)
  • alberto743 (2)
  • BGameiro2000 (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 7,638 last-month
  • Total dependent packages: 2
    (may contain duplicates)
  • Total dependent repositories: 3
    (may contain duplicates)
  • Total versions: 66
  • Total maintainers: 1
pypi.org: radioactivedecay

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

  • Versions: 48
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 7,638 Last month
Rankings
Dependent packages count: 4.8%
Downloads: 6.2%
Stargazers count: 8.2%
Forks count: 9.8%
Average: 10.1%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 4 months ago
conda-forge.org: radioactivedecay

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

  • Versions: 18
  • Dependent Packages: 1
  • Dependent Repositories: 2
Rankings
Dependent repos count: 20.3%
Dependent packages count: 29.0%
Average: 33.3%
Stargazers count: 38.8%
Forks count: 45.0%
Last synced: 4 months ago

Dependencies

requirements.txt pypi
  • importlib_resources *
  • matplotlib *
  • networkx *
  • numpy *
  • scipy *
  • setuptools *
  • sympy *
requirements_dev.txt pypi
  • black * development
  • coverage * development
requirements_docs.txt pypi
  • sphinx *
  • sphinx-rtd-theme *
.github/workflows/1_tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/2_coverage.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v2 composite
.github/workflows/3_code_formatting.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • isort/isort-action master composite
  • psf/black stable composite
.github/workflows/4_docs_build.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/5_docs_deploy.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/6_pypi_release.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
pyproject.toml pypi
setup.py pypi