.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/particle/radioactivity/plot_02_decay_chains.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_particle_radioactivity_plot_02_decay_chains.py: Bateman's equations for radioactive decay chains ===================================================== Real radioactive samples rarely decay in one step: uranium and thorium each head long chains of successive daughters. Bateman (1910) solved the resulting linear system in closed form, giving the population of the :math:`k`-th species in a chain :math:`N_1\to N_2\to\cdots\to N_n` as an explicit sum of exponentials in the decay constants :math:`\lambda_1,\ldots,\lambda_n`. This example builds a three-species chain with :func:`~physicskit.particle.decays.bateman_decay_chain`, watches the parent deplete while an intermediate daughter first rises and then falls (it has to be produced before it can decay away), and checks total population conservation at every instant. .. GENERATED FROM PYTHON SOURCE LINES 18-24 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.particle.decays import bateman_decay_chain from physicskit.particle.visualizers import animate_decay_chain_bars, plot_decay_chain .. GENERATED FROM PYTHON SOURCE LINES 25-31 A three-species chain: parent -> daughter -> stable granddaughter ------------------------------------------------------------------------ Decay constants chosen so the parent decays slower than the intermediate daughter, giving the daughter's population a clear rise-then-fall ("transient equilibrium") shape; the final species is stable (decay constant exactly 0). .. GENERATED FROM PYTHON SOURCE LINES 31-42 .. code-block:: Python N0 = 1000.0 decay_constants = [0.15, 0.6, 0.0] labels = ["Parent", "Daughter", "Stable granddaughter"] t = np.linspace(0.0, 30.0, 300) N = bateman_decay_chain(N0, decay_constants, t) fig1, ax1 = plot_decay_chain(t, N, labels=labels) ax1.set_title("A three-species decay chain") fig1.tight_layout() .. image-sg:: /api/gallery/particle/radioactivity/images/sphx_glr_plot_02_decay_chains_001.png :alt: A three-species decay chain :srcset: /api/gallery/particle/radioactivity/images/sphx_glr_plot_02_decay_chains_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-45 Total population is conserved (nothing but transformation) ------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-51 .. code-block:: Python total = N.sum(axis=0) print(f"N0 = {N0}") print(f"total population N1+N2+N3 at t=0: {total[0]:.6f}") print(f"total population N1+N2+N3 at t=30: {total[-1]:.6f} (should equal N0 -- decay only transforms species, it doesn't destroy atoms)") print(f"max deviation from N0 over the whole run: {np.max(np.abs(total - N0)):.2e}") .. rst-class:: sphx-glr-script-out .. code-block:: none N0 = 1000.0 total population N1+N2+N3 at t=0: 1000.000000 total population N1+N2+N3 at t=30: 1000.000000 (should equal N0 -- decay only transforms species, it doesn't destroy atoms) max deviation from N0 over the whole run: 4.55e-13 .. GENERATED FROM PYTHON SOURCE LINES 52-54 The daughter's rise-and-fall ----------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 54-62 .. code-block:: Python i_peak = np.argmax(N[1]) print(f"\ndaughter population peaks at t={t[i_peak]:.3f}, N2={N[1, i_peak]:.2f}") print("(it must first be produced by the parent's decay before it can decay away itself --") print(" a signature no single-species exponential can produce)") anim = animate_decay_chain_bars(t, N, labels=labels) plt.show() .. container:: sphx-glr-animation .. raw:: html .. rst-class:: sphx-glr-script-out .. code-block:: none daughter population peaks at t=3.110, N2=157.48 (it must first be produced by the parent's decay before it can decay away itself -- a signature no single-species exponential can produce) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 11.518 seconds) .. _sphx_glr_download_api_gallery_particle_radioactivity_plot_02_decay_chains.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_decay_chains.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_decay_chains.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_decay_chains.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_