Skip to main content

TDCRPy

TDCRPy Logo

A Photo-Physical Stochastic Model for Liquid Scintillation Counting

License Python Version Status BIPM


📖 Overview

TDCRPy is a Python package developed and maintained by the BIPM (Bureau International des Poids et Mesures). It estimates detection efficiencies of liquid scintillation counters using the TDCR (Triple to Double Coincidence Ratio) or CIEMAT/NIST methods.

The calculation is based on a photo-physical stochastic Monte Carlo model, allowing users to address:

  • Complex decay schemes (beta spectra via BetaShape, gamma interactions via MCNP matrices).
  • Radionuclide mixtures with arbitrary activity fractions.
  • Ionisation quenching via the Birks model (electrons and alpha particles).
  • Prompt and delayed (triplet-triplet annihilation) fluorescence, giving a light yield that depends on the coincidence resolving time (delayedFluorescence, off by default, since v2.20.30).
  • Reverse micelle effects in cocktails used for aqueous samples — applied automatically, when an aqueous fraction is declared, to the nuclides measured to need it (micCorrAuto; the per-nuclide confinement bias was screened across the whole catalogue in micelleCatalogue.py, worst cases Ar-37 12.4 %, Ca-41 10.4 %, Fe-55 5.2 %).
  • Asymmetric PMT configurations (per-channel free parameters).
  • Full optical Monte Carlo transport (opticalTransport=True).
  • C/N (CIEMAT/NIST) 2-PMT efficiency curves.

Technical details are described in:


📦 Installation

TDCRPy requires Python ≥ 3.11 and a standard scientific environment.

pip install TDCRPy

To upgrade to the latest version:

pip install TDCRPy --upgrade

Run Tests

Verify the installation by running the unit tests:

python -m unittest tdcrpy.test.test_tdcrpy

🖥 Graphical interface

If you would rather not write a script, there is a window. It runs the model — efficiency at a given light yield, the light yield fitted to a measured TDCR (stochastic or analytical), the efficiency curve ε_D vs TDCR — and shows the data the model rests on: decay data, β spectra, stopping powers and the Birks quenching function. Every result can be exported as CSV and every curve is plotted in the window, ready to save as PNG, PDF or SVG (matplotlib is already a dependency, so there is nothing extra to install).

tdcrpy-gui            # or: python -m tdcrpy.gui

Setting it up on Windows

1 — Install Python 3.11 or newer, with tcl/tk. The window is built with tkinter, which ships with CPython but is an optional component of the python.org installer. Keep “tcl/tk and IDLE” ticked (it is on by default), and tick “Add python.exe to PATH” on the first screen. The Microsoft Store build of Python includes tkinter as well. Check it worked:

python -c "import tkinter; print(tkinter.TkVersion)"

A version number (8.6 or similar) means you are ready. ModuleNotFoundError: No module named 'tkinter' means Python was installed without tcl/tk — re-run the installer, choose Modify, and enable it. Nothing else needs installing: the interface adds no dependency of its own.

2 — Install TDCRPy. In a Command Prompt or PowerShell:

python -m pip install --upgrade TDCRPy

Using a virtual environment is recommended, because the interface writes the settings you choose into the package’s config.toml:

python -m venv %USERPROFILE%\tdcrpy-env
%USERPROFILE%\tdcrpy-env\Scripts\activate
python -m pip install TDCRPy

3 — Start it.

tdcrpy-gui

The first run takes longer than later ones — tens of seconds — because numba compiles the Monte-Carlo kernel. The window itself appears immediately; it fills the nuclide and cocktail lists once the library has loaded in the background.

If tdcrpy-gui is not recognised, the launcher was installed somewhere that is not on your PATH. This is normal for pip install --user. Either call it by its full path, or use the form that never depends on PATH:

python -m tdcrpy.gui

To find the launcher:

python -c "import sysconfig; print(sysconfig.get_path('scripts'))"

4 — Optional: a desktop shortcut. Right-click the desktop → New → Shortcut, and give it the full path to tdcrpy-gui.exe printed by the command above, for example:

C:\Users\<you>\tdcrpy-env\Scripts\tdcrpy-gui.exe

tdcrpy-gui.exe is a windowed launcher, so it opens no console behind the interface. If you prefer a batch file — useful for a shared instrument PC, where it can activate the environment first — use pythonw.exe rather than python.exe, or a console window will stay open for as long as the interface does:

@echo off
call "%USERPROFILE%\tdcrpy-env\Scripts\activate"
start "" pythonw -m tdcrpy.gui

Troubleshooting

What you see What it means
No module named 'tkinter' Python installed without tcl/tk. Re-run the installer → Modify → enable “tcl/tk and IDLE”.
'tdcrpy-gui' is not recognized The Scripts directory is not on PATH. Use python -m tdcrpy.gui, or the full path.
A console window sits behind the interface You launched it with python. Use tdcrpy-gui or pythonw -m tdcrpy.gui.
Nuclide and cocktail lists stay empty The background enquiry failed; the log pane shows why. Usually a broken install — check python -c "import tdcrpy".
crashed (code …) in the status bar A fault inside the Monte-Carlo kernel, not a problem with your inputs. Re-running usually succeeds.
Results differ slightly between identical runs Expected: the model is a Monte Carlo. Raise Number of decays N; the reported uncertainties scale as 1/√N.

The window is laid out like a desktop application:

Area What it holds
Calculations (sidebar) Efficiency at a given L · Fit L to a TDCR (stochastic or analytical) · Efficiency curve ε_D vs TDCR
Data & plots (sidebar) Decay data — branches, γ rays and conversion electrons per decay, as read from PenNuc · β spectrum — any transition in the BetaShape archive · Stopping power — electrons (one model, or all six side by side) or α particles (ASTAR) · Ionisation quenching — Q(E) and Q/E for one or several kB
Input tabs Source, Data & plots, Scintillator, Micelles, Delayed fluorescence, Counter
Results Table (with uncertainties), Plot (zoom, pan, save) and Log (the model's own messages, including the reverse-micelle advisories)
Help menu Online documentation, example notebooks, the reference paper, the BIPM technical report, issue tracker, licence and About

Export CSV… writes the table at full precision, UTF-8 so a spreadsheet shows β and γ correctly, preceded by # lines recording the TDCRPy version, the calculation and every setting used (pandas.read_csv(path, comment='#') skips them). Save plot… writes PNG, PDF or SVG at 300 dpi. F5 runs, Esc cancels, Ctrl+S exports.

Two things worth knowing:

  • Running writes your settings to the package config.toml, which scripts and notebooks share. The window snapshots that file when it opens, and Undo my config changes puts it back; Restore shipped defaults replaces it with configDefault.toml.
  • Each calculation runs in a separate process, so the window stays responsive, Cancel is immediate, and a native crash in the Monte-Carlo kernel is reported rather than taking the interface with it.

The interface needs no extra dependency — tkinter ships with CPython — and the nuclide list, cocktail list and defaults are read from the installed library, never duplicated in the GUI.

⚡ Quick Start

Estimate detection efficiencies for Co-60 using the full stochastic model.

import tdcrpy

L    = 1.2      # free parameter (photons keV⁻¹)
Rad  = "Co-60"  # radionuclide
pmf  = "1"      # activity fraction (100 %)
N    = 10000    # Monte Carlo trials (≥ 10 000 recommended)
kB   = 1.0e-5   # Birks constant (cm keV⁻¹)
V    = 10       # scintillator volume (mL)

result = tdcrpy.TDCRPy.TDCRPy(L, Rad, pmf, N, kB, V)

print(f"eff_S = {result[0]:.4f} ± {result[1]:.4f}")   # single events
print(f"eff_D = {result[2]:.4f} ± {result[3]:.4f}")   # double coincidences
print(f"eff_T = {result[4]:.4f} ± {result[5]:.4f}")   # triple coincidences

Find L from a Measured TDCR Ratio

TD = 0.9776   # measured T/D ratio
result = tdcrpy.TDCRPy.eff(TD, Rad, pmf, kB, V)

print(f"L = {result[0]:.4f} photons/keV")
print(f"eff_T = {result[6]:.4f} ± {result[7]:.4f}")

🛠 Advanced Features

Asymmetric PMT Configuration

Pass a 3-tuple for the free parameter to model per-channel asymmetry:

L = (1.1, 1.3, 1.2)   # (L_A, L_B, L_C) in photons keV⁻¹
result = tdcrpy.TDCRPy.TDCRPy(L, "Co-60", "1", N, kB, V)

print(f"eff_AB = {result[6]:.4f}")   # A–B double coincidences
print(f"eff_BC = {result[8]:.4f}")
print(f"eff_AC = {result[10]:.4f}")

Radionuclide Mixtures

Provide comma-separated nuclides and their relative activity fractions:

result = tdcrpy.TDCRPy.TDCRPy(L, "Co-60, H-3", "0.8, 0.2", N, kB, V)

Analytical Model (Pure Beta Emitters)

A faster, deterministic alternative for pure β⁻ nuclides:

# Returns (L0, L_opt, eff_S, eff_D, eff_T)
result = tdcrpy.TDCRPy.effA(TD, "H-3", "1", kB, V)

print(f"L0 = {result[0]:.4f} photons/keV")
print(f"eff_T = {result[4]:.4f}")

Full Optical Monte Carlo Transport

Enable stochastic photon-transport for each event: photons are sampled from a Poisson distribution, distributed equally among PMTs, and converted to photoelectrons via Binomial draws (quantum efficiency):

result = tdcrpy.TDCRPy.TDCRPy(L, Rad, pmf, N, kB, V, opticalTransport=True)

C/N Efficiency Curve

Compute the CIEMAT/NIST efficiency curve — detection efficiency as a function of the free parameter L for a 2-PMT coincidence system:

import numpy as np
import matplotlib.pyplot as plt
import tdcrpy.TDCR_model_lib as tl

rad = "H-3"
kB  = 1e-5   # Birks constant (cm keV⁻¹)
V   = 10     # volume (mL)
ne  = 1000   # quenching integration bins

L_vec = np.linspace(1, 20, 80)
eff_D = np.array([tl.modelAnalyticalCN(L, rad, kB, V, ne)[2] for L in L_vec])

plt.plot(L_vec, eff_D)
plt.xlabel("L (photons keV⁻¹)")
plt.ylabel("eff_D (double coincidence)")
plt.title(f"C/N efficiency curve — {rad}")
plt.grid(True)
plt.show()

To find L from a measured C/N counting ratio CN (counts_D / counts_S):

from scipy.optimize import brentq

CN_meas = 0.62   # measured D/S ratio

def residual(L):
    eA, eB, eD = tl.modelAnalyticalCN(L, rad, kB, V, ne)
    return eD / ((eA + eB) / 2) - CN_meas

L0 = brentq(residual, 0.5, 30)
_, _, eff_D = tl.modelAnalyticalCN(L0, rad, kB, V, ne)
print(f"L = {L0:.3f} photons/keV,  eff_D = {eff_D:.5f}")

⚙️ Configuration & Physics

Display the current physics settings:

import tdcrpy as td
td.TDCR_model_lib.readParameters(disp=True)

Configuration Reference

Parameter Setter Default Unit Description
Electron bins modifynE_electron(n) 1000 — Integration bins for electron quenching
Alpha bins modifynE_alpha(n) 1000 — Integration bins for alpha quenching
Stopping power modifysp_model(m) tan_xia — Low-energy model (tan_xia, joy_luo, …)
Birks parameter modifyChou_param(k) 0 cm²/MeV² Chou bimolecular quenching constant
Density modifyDensity(ρ) 0.98 g/cm³ Scintillator density (Ultima Gold)
Mean Z / A modifyZ(z), modifyA(a) 3.25 / 5.94 — Effective atomic/mass number
Cocktail modifyLScocktail(name, fAq) Ultima Gold — LS cocktail + aqueous fraction
Micelle correction modifyMicCorr(b) False — Force the reverse-micelle correction on for every nuclide
Micelle auto-activation modifyMicCorrAuto(b) True — Apply it by itself to electron-capture nuclides when fAq > 0, warning once per nuclide
Bias threshold modifyMicCorrBiasThreshold(b) 0.01 % Measured confinement bias above which a nuclide self-activates (Micelle/micelleBias.csv)
EC threshold modifyMicCorrECThreshold(p) 0.01 — Fallback gate, for a nuclide absent from the bias table
Micelle diameter modifyDiam_micelle(d) 4 nm Mean micelle diameter (Bergeron 2012)
Micelle dispersion modifySigma_micelle(s) 0 nm Size spread; 0 = monodisperse
Delayed fluorescence modifyDelayedFluorescence(b) False — Prompt + delayed (TTA) light-yield model; makes the light yield depend on the coincidence window
Prompt decay time modifyTau_prompt(t) 3.0 ns τ_p — a measured cocktail constant, never fitted
Delayed capture time modifyTau_delayed(t) 85 ns τ_d — 85 (Ultima Gold family), 138 (toluene); re-derived by modifyLScocktail
Delayed amplitude modifyEta_delayed(e) 0.03 — η — 0.03 (Ultima Gold family), 0.05 (toluene)
TTA kinetics modifyTTAkinetics(k_q, gamma, A_c) 5e6, 1e-11, 1e-13 s⁻¹, cm³s⁻¹, cm² Constants behind S_a = 1666.7 keV/cm
Quantum efficiency modifyEffQ(q) 0.25,0.25,0.25 — PMT quantum efficiencies (A, B, C)
Optical transport modifyOpticalTransport(b) False — Enable full optical MC transport
Resolving time modifyTau(τ) 50 ns Coincidence resolving time
Dead time modifyDeadTime(t) 30 µs Extended dead time
Measurement time modifyMeasTime(T) 60 min Measurement duration

📓 Notebooks

Notebooks are organised in subfolders by topic under notebooks/.

Getting started — notebooks/getting_started/

Notebook Description
tuturial.ipynb End-to-end tutorial: fixed-L efficiencies, TDCR fitting (symmetric and asymmetric), radionuclide mixtures, full optical MC transport
changeParameters.ipynb Configuration: how to modify every physics parameter (quenching bins, stopping power model, cocktail, PMT efficiencies, dead time…)

Detection models — notebooks/models/

Notebook Description
analyticalModel.ipynb Analytical model (effA): fast beta-spectrum-based efficiency for pure β emitters; symmetric and asymmetric PMT configurations
CNmethod.ipynb CIEMAT/NIST (C/N) method: 2-PMT coincidence efficiency curve using modelAnalyticalCN; L-fitting from measured C/N ratio
cerenkovModel.ipynb Čerenkov counting model: Frank-Tamm-based efficiency for high-energy beta emitters
cerenkovY90.ipynb Čerenkov model, worked example (Y-90): threshold physics, Frank-Tamm photon yield, efficiency vs L, fitting L from a measured TDCR (symmetric and 3-PMT), optical parameters, and ⁹⁰Sr/⁹⁰Y discrimination
opticalTransport.ipynb Optical MC transport: comparison of semi-analytical vs full photon-transport model (opticalTransport=True) for H-3, Fe-55, Co-60

Nuclide case studies — notebooks/nuclides/

Notebook Description
H-3.ipynb Tritium (H-3): low-energy pure β; analytical and stochastic efficiency, micelle correction effect
Co-60.ipynb Co-60: γ-emitter with complex decay; analytical approximation vs full stochastic model
Fe-55.ipynb Fe-55: electron-capture nuclide producing Mn K-α X-rays and Auger electrons
Sr-90_Y-90.ipynb Sr-90/Y-90 mixture: secular equilibrium of two pure β emitters (0.546 and 2.28 MeV endpoints)
Zr-93.ipynb Zr-93: β/EC branching ratio nuclide with X-ray emission

Physics sub-models — notebooks/physics/

Notebook Description
quenchingModel.ipynb Birks quenching: quenched energy vs initial energy for electrons and α particles as a function of kB
stoppingPower.ipynb Stopping power models: comparison of tan_xia, joy_luo, ashley and other models for electrons
readBetaSpectrum.ipynb Beta spectra: reading and visualising deposited-energy spectra from BetaShape + MCNP calculations
interaction.ipynb Radiation–matter interactions: photon and electron energy deposition via MCNP response matrices
micelleEffects.ipynb Micellar quenching: stochastic reverse-micelle model (micCorr); microscopic energy-retention factor and its impact on efficiency for H-3, Fe-55, Ni-63, C-14, Tc-99, at fixed L and with eff() TDCR calibration

Advanced — notebooks/advanced/

Notebook Description
mixture.ipynb Radionuclide mixtures: efficiency of arbitrary multi-component samples with activity fractions
efficiencyCuve.ipynb TDCR efficiency curve: eff_D and eff_T vs light yield L for a series of kB values
distrubutionTDCR.ipynb TDCR distribution: histogram of per-event efficiency values over MC trials; statistical characterisation
cocktailComposition.ipynb Cocktail composition: effect of aqueous fraction (H₂O / HCl) on detection efficiency for H-3 and Sr-90
cocktailResponse.ipynb Cocktail comparison: eff_D for 12 commercial LS cocktails × 6 nuclides (H-3, C-14, Fe-55, Cr-51, Co-60, Cd-109)

Sensitivity — notebooks/sensitivity/

Notebook Description
parameterSensitivity.ipynb Parameter sensitivity study: sweeps every tunable model parameter (L, kB, PMT quantum efficiency, cocktail composition, stopping-power model, quenching numerics, micelle correction, counting-chain parameters, optical transport, MC convergence) around its nominal value for H-3 and Sr-90, with a summary tornado chart

Validation — notebooks/validation/

Notebook Description
functional_validation.ipynb Cross-version validation: compare two TDCRPy versions side-by-side for H-3, Fe-55, Co-60, Sr-90, Cd-109 across analytical and stochastic models; configurable VERSION_REF / VERSION_NEW

📚 Citation

If you use TDCRPy in your work, please cite:

R. Coulon, J. Hu — TDCRPy: A Python package for TDCR measurements
Applied Radiation and Isotopes (2024)
DOI: 10.1016/j.apradiso.2024.111518


⚖️ License

This project is licensed under the MIT License.
Copyright © BIPM (Bureau International des Poids et Mesures).

Metadata

Release files for TDCRPy 2.20.36

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

Source distribution (sdist)

Source distribution for TDCRPy 2.20.36
File Size Uploaded Provenance Actions
tdcrpy-2.20.36.tar.gz 23.8 MB With provenance Details for tdcrpy-2.20.36.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for TDCRPy 2.20.36
File Interpreter ABI Platform Actions
tdcrpy-2.20.36-py3-none-any.whl Python 3 none any Details for tdcrpy-2.20.36-py3-none-any.whl

Total release size: 47.5 MB

Release files / tdcrpy-2.20.36.tar.gz

Download URL tdcrpy-2.20.36.tar.gz
Size 23.8 MB
Tags Source
SHA-256 checksum
How to use checksums
d35cefc7936a79a8de60f9b68990cf9b54ca25eaf75965e9281a442f7d570619
BLAKE2b-256 checksum
How to use checksums
3e012acdf6b6091599011c67e421c19b0152f82e1340b784a9e256964f9126f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tdcrpy-2.20.36-py3-none-any.whl

Download URL tdcrpy-2.20.36-py3-none-any.whl
Size 23.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
58f92848f4c9bb26c02f94ec73105290546ddce732367783a1320658c66fc2d1
BLAKE2b-256 checksum
How to use checksums
99474ad88001e3958e0a8b7806a1775236486ba95ae18091780e2147537ff548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for TDCRPy 2.20.36

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tdcrpy-2.20.36.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.20.36 This release

2 release files Full provenance

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