11.1 Introduction 349
11.1.4Radioactive Decay
Radioactive decay is among one of the classical examples of Monte-Carlo simulations. Assume
that at the timet= 0 we haveN( 0 )nuclei of typeXwhich can decay radioactively. At a
timet> 0 we are left withN(t)nuclei. With a transition probabilityω, which expresses the
probability that the system will make a transition to another state during a time step of one
second, we have the following first-order differential equation
dN(t) =−ωN(t)dt,
whose solution is
N(t) =N( 0 )e−ωt,
where we have defined the mean lifetimeτofXas
τ=^1
ω
If a nucleusXdecays to a daugther nucleusYwhich also can decay, we get the following
coupled equations
dNX(t)
dt
=−ωXNX(t),
and
dNY(t)
dt
=−ωYNY(t)+ωXNX(t).
The program example in the next subsection illustrates how we can simulate such the decay
process of one type of nuclei through a Monte Carlo sampling procedure.
11.1.5Program Example for Radioactive Decay
The program is split in four tasks, a main program with various declarations,
http://folk.uio.no/mhjensen/compphys/programs/chapter11/cpp/program3.cpp
// Radioactive decay of nuclei
#include
#include
#include
#include"lib.h"
using namespacestd;
ofstream ofile;
// Function to read in data from screen
voidinitialise(int&,int&,int&,double& ) ;
// The Mc sampling for nuclear decay
voidmc_sampling(int,int,int,double,int);
// prints to screen the results of the calculations
voidoutput(int,int,int);
intmain(intargc,charargv[])
{
charoutfilename;
intinitial_n_particles, max_time, number_cycles;
doubledecay_probability;
int*ncumulative;
// Read in output file, abort if there are too few command-line arguments
if( argc <= 1 ){
cout <<"Bad Usage: "<< argv[0] <<