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.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.1.0
File Size Uploaded
pydecay-0.1.0.tar.gz 733.8 kB Details

Built distribution (wheel)

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

Total release size: 751.3 kB

Release files / pydecay-0.1.0.tar.gz

Download URL pydecay-0.1.0.tar.gz
Size 733.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c3a96504bfaa93bd5f5b7fd3e2ef02487ad4a1a09979ccd6864879cc898c1af7
BLAKE2b-256 checksum
How to use checksums
14660a57a6711881b9c9703fa746a7df155f9c29070872b45f9a56f76a3f47c5
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.0-py3-none-any.whl

Download URL pydecay-0.1.0-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8824e03685a3baf451672a8f0371d515bce9b4133b585397b182b098c144685d
BLAKE2b-256 checksum
How to use checksums
77a174fab450981128bf77103428cb0f6fcd4799de04a83949553e9c29bfcd28
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

0.1.1

2 release files

This release

0.1.0 This release

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