Skip to main content

pydecay

PyPI version Python 3.10+ License: MIT

Radioactive decay mathematics for Python: analytical single-isotope decay, Bateman decay chains with a matrix-exponential stability guard, branching topologies, ICRP-107 nuclide data (1252+ isotopes), spectra access, and activity unit conversions.

Author: Daniel Deshmukh · github.com/DanielDeshmukh/pydecay

Install

pip install pydecay

Requires Python >= 3.10. Runtime dependencies: numpy, scipy, pint.

Quickstart

from pydecay import Nuclide, DecayChain, decayed_activity, remaining_fraction

# Single isotope: 1000 Bq of I-131 after one half-life -> 500 Bq
i131 = Nuclide.load("I-131")
a = decayed_activity(A0=1000.0, half_life=i131.half_life, time=i131.half_life)

# Dimensionless fraction after 5 half-lives -> 0.03125
f = remaining_fraction(half_life=i131.half_life, time=5 * i131.half_life)

# Linear chain (parent -> daughter -> stable), plain floats or pint
chain = DecayChain([0.693, 0.0], names=["parent", "stable"])
print(chain.at(t="1 days", n0={"parent": 1e6, "stable": 0.0}))

# Branching: 60% / 30% to two daughters, remainder untracked
b = DecayChain.branching(
    parent="P",
    branches={"D1": 0.6, "D2": 0.3},
    lambdas={"P": 0.7, "D1": 1e-5, "D2": 2e-5},
)

What is implemented

Area Detail Reference
Single isotope N(t)=N0*exp(-lambda*t), lambda=ln2/T_half, A=lambda*N Krane ch. 6; BIPM/NIST for units
Linear chains Bateman (1910) closed form when well-separated Bateman 1910
Stability guard scipy.linalg.expm on the generator matrix for degenerate lambda, branching, or nonzero daughter ICs spec fix option 2; Cetnar 2006 (deferred optimization)
Branching star topologies with fractions <= 1 (remainder = untracked sink) general linear ODE system
Data 1252+ ICRP-107 radionuclides + stable endpoints (default catalog) ICRP Publication 107
Spectra emissions / beta_spectrum (RAD/BET), lazy-loaded ICRP-107 RAD/BET files
Units seconds / atoms / Bq internally; Bq<->Ci and atoms<->grams at the boundary NIST SP 811; BIPM SI (N_A exact)

Verification

  • Worked examples (1000 Bq I-131 -> 500 Bq / 31.25 Bq) asserted against the bundled ICRP-107 half-lives in tests/test_known_values.py.
  • Bateman vs expm agreement to 1e-10; degenerate-lambda regression (0.6931 / 0.6932) must stay finite (tests/test_solver.py).
  • Differential cross-check against radioactivedecay (ICRP-107): report drift, fail past 1e-3 relative (tests/test_crosscheck.py).
  • IAEA 47-nuclide fixture retained as a differential oracle (tests/test_iaea_differential.py, REL_TOL_DATA = 1.5e-2).

Documentation

Full guide in docs/ (MkDocs: mkdocs serve). Architecture + solver dispatch diagrams: docs/architecture.md. Formula derivations with citations: docs/math.md.

Development

See CONTRIBUTING.md. Quality gates: pytest, ruff check src tests, mypy src, coverage >= 90%, mkdocs build --strict.

License

MIT — see LICENSE. Bundled ICRP-107 data is under LICENSE.ICRP-07 (educational / research / not-for-profit terms).

Release files for pydecay 0.2.0

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

Source distribution (sdist)

Source distribution for pydecay 0.2.0
File Size Uploaded
pydecay-0.2.0.tar.gz 4.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydecay 0.2.0
File Interpreter ABI Platform
pydecay-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 MB

Release files / pydecay-0.2.0.tar.gz

Download URL pydecay-0.2.0.tar.gz
Size 4.6 MB
Tags Source
SHA-256 checksum
How to use checksums
e09e7ca2c97bf1a6d20bf129b9d903e4f07f7359dcc32a5edd8025bf267c8fd9
BLAKE2b-256 checksum
How to use checksums
c9193a6683fd5aacb52a2d69497f0f7535053fe6d3d09fa9478dfad6f242f415
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pydecay-0.2.0-py3-none-any.whl

Download URL pydecay-0.2.0-py3-none-any.whl
Size 4.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2d16bf786995d2180e3d03a7db45393ae64701312945d869fb6b5febd5b141ad
BLAKE2b-256 checksum
How to use checksums
617003b8dfa37a7e0c99f6b893b7cb71c95c6b31a52ea0e10b77c8b4a5dd369d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.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