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, IAEA-sourced nuclide data, 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 47 nuclides with per-record source + fetch date IAEA Live Chart of Nuclides
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 IAEA 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).

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.

Release files for pydecay 0.1.1

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.1.1
File Size Uploaded
pydecay-0.1.1.tar.gz 179.1 kB Details

Built distribution (wheel)

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

Total release size: 196.8 kB

Release files / pydecay-0.1.1.tar.gz

Download URL pydecay-0.1.1.tar.gz
Size 179.1 kB
Tags Source
SHA-256 checksum
How to use checksums
14fe919e62d602a8c17a67c5bb59091af4e78c8e55a933e658d11f80c9c8b919
BLAKE2b-256 checksum
How to use checksums
392634739274148eeaf55ea28893683be73b28fc12afa532d9420098b2bb351c
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.1.1-py3-none-any.whl

Download URL pydecay-0.1.1-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60e28dc3e49a8afbf7fe3a0c2a24896cdfdb9ab02431b170f611d0fc0c140825
BLAKE2b-256 checksum
How to use checksums
1f4b6810499605b9b6fb5c23a0269c003a013c7a33a390001a5541a0cd887fc3
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

0.2.0

2 release files

This release

0.1.1 This release

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