<jupyter_start><jupyter_text>Radioactivity part 2, decay dynamics Recall simple radioactive decay\begin{align}        N_i(t) &= \mbox{number of isotopes i adjusted for decay [atoms]}\\        N_i(0)&= \mbox{initial condition [atoms]}\\        \lambda &= \mbox{decay constant} [s^{-1}]\\        \tau_{1/2} &= \mbox{half-life [s]} \\       \frac{dN_i(t)}{dt} &=-\lambda N_i(t)\\         N_i(t) &= N_i(0)e^{-\lambda t}\\        \tau_{1/2}&=\frac{ln(2)}{\lambda}  \\\end{align} And radioactive decay with production\begin{align}\frac{dN(t)}{dt} &= -\mbox{rate of decay} + \mbox{rate of production}\\\implies N(t) &= N_0 e^{-\lambda t} + \int_0^t dt'Q(t')e^{-\lambda (t-t')}\\\end{align}If the production rate is constant $(Q(t)=Q_0)$, this simplifies:\begin{align}N(t) &= N_0 e^{-\lambda t} + \frac{Q_0}{\lambda}\left[1-e^{-\lambda t}\right]\\\end{align}The average (or mean) life of a radionuclide is<jupyter_code>import math
def n_decay(t, n_initial=100, lam=0.4):
    """This function describes the decay of an isotope"""
    return n_initial*math.exp(-lam*t)


# This code plots the decay of an isotope
import numpy as np
y = np.arange(26.0)
x = np.arange(26.0)
for t in range(0,26):
    x[t] = t
    y[t] = n_decay(t)
    
# creates a figure and axes with matplotlib
fig, ax = plt.subplots()
scatter = plt.scatter(x, y, color='blue', s=y*20, alpha=0.4)    
ax.plot(x, y, color='red')    

# adds labels to the plot
ax.set_ylabel('N_i(t)')
ax.set_xlabel('Time')
ax.set_title('N_i')

# adds tooltips
import mpld3
labels = ['{0}% remaining'.format(i) for i in y]
tooltip = mpld3.plugins.PointLabelTooltip(scatter, labels=labels)
mpld3.plugins.connect(fig, tooltip)

mpld3.display()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19075482738443533, 'fraction_numerical': 0.022235225277940317, 'mean_word_length': 3.8857142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '244282', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 677, 'n_tokens_neox': 654, 'n_words': 159, 'path': '10.05-radioactivity/01-radioactivity.ipynb', 'repo_name': 'npre247/npre247', 'size': '1709'}