Sunteți pe pagina 1din 9

INSTRUCTIONS

Part 1: worth 30% of the assignment marks


Suppose that atoms of type 1 decay to type 2, which, in turn, decay to stable atoms of type 3. The
decay constants of 1 and 2 are

and

t=0, N 1=0, N 2=N 3=0 . What are the values for

2 , respectively. Assume that at


N 1 ( t ) , N 2 ( t ) and

N 3 (t ) at any later time

t?

Part 2: worth 70% of the assignment marks


a) Simulate the process described in part 1 using Monte Carlo approach.
4
Use 1=1.0 10 decays /s
2=0.5 104 decays /s
5
And t MAX =1.5 10 s . Plot the simulation results

b) Estimate the accuracy of Monte Carlo simulation as a function of the number of initial
atoms

N0

used. As a measure of the accuracy, use the root mean square deviation of

the simulated data from the analytic solution found in part 1.

Solution
d N 1
=1 N 1 (1)
dt
d N2
= 1 N 1 2 N 2 (2)
dt
d N3
= 2 N 2 .(3)
dt
Since
N 1 ( t )=N 1 ( 0 ) e t (4)
1

Substituting 4 in 2
d N2
= 1 N 1 ( 0 ) . e t 2 N 2 (t)
dt
1

Adding

2 N 2 on both sides,

d N2
+ 2 N 2 (t )= 1 N 1 ( 0 ) e t
dt
1

Multiplying both sides by e

e t
2

d N2 t
+ e 2 N 2 ( t )= 1 N 1 ( 0 ) e t e t
dt
2

( 21 )t

2t

(5)
d N2 t

+ e 2 N 2 ( t ) = 1 N 1 ( 0 ) e
dt
2

e t
2

d N2 t
d
+ e + 2 N 2= ( e t N 2 ( t ) ) (6)
dt
dt
2

d
d
d
(u v )= ( u ) v+ ( v ) u
dt
dt
dt
Substitute 6 in 5
d t
( e N 2 (t ) )=1 N 1 ( 0 ) e( )t
dt
2

Integrate both sides

( dtd ( e t N 2 ( t ) )) dt = ( 1 N 1 ( 0 ) e( ) t ) dt
2

2
(
1 )t + B
t
1
e N 2 ( t ) + A=
1 N 1 ( 0 ) e
21
2

Where A,B are constants of integration

2
1) t+C
(
.(7)
1
e t N 2 ( t )=
N 1 ( 0 ) e
2 1
2

Since

N 2 ( 0 )=0

( 2 1)0+ C

e t 0= 1 N 1 ( 0 ) e
21
2

Hence

C=

1
N (0 )
2 1 1

Substitute value of C in (7)

1
N1 (0)
2 1
1
t
e N 2 ( t )=
N 1 ( 0 ) e
2 1
( 2 1) t
2

1
)t
N 1( 0) [e(
1 ]
2 1

N 2 ( t )=

1
)t
1
N 1 ( 0 ) [ e(
1 ] t
2 1
e
2

N 2 ( t )=

1 N 1 ( 0 ) ( )t
1
[e
1 ] ( e t )
21
2

1 N 1( 0) ( )t

[e
1 ] e
2 1
2

1 N 1 ( 0 ) ( ) t t t
[e
e e ]
2 1
2

N 2 ( t )=

For

N3

N 1 ( t )=N 1 ( 0 ) e t
1

N 2 ( t )=

1 N 1 ( 0 ) t t
[ e e ]
2 1
1

From equation 3
d N3
= 2 N 2 ( t )
dt
d N3
N 1 (0) t
= 2 1
[ e e
dt
21
1

Substituting the value of

N2(t )

d N3
1 N 1 ( 0 ) t t
1 N 1 ( 0 )
= 2
e e 2
dt
2 1
2 1
1

1 N 1 ( 0 ) t t
(e e )
21
1

Integrating with both sides with respect to time

( ddtN )dt = ( N ( 0) e
3

1 t

e t 2
2

1 N 1 ( 0 )
dt
21

d N3
N 1 ( 0 ) t
N 1(0)
dt = 2 1
e
dt e t 2 1
dt
dt
21
2 1

( )

) (

N 3 (t )=

N 1 ( 0 ) t 1
N 1 ( 0 ) t
1
2 1
e + 2 1
e
1
2 1
2
2 1
1

On simplifying, we get

1 N 1 ( 0 ) t
e
2 1
1 N 1 ( 0 )
N 3 ( t )=

1 ( 2 1) e

N 3 (t )=

2 t

N 1 ( 0 ) 2 e t
t
1 e
21
1
2

Matlab code for simulation


% Date: 27/8/2016
N0 = 1e5; % initial number of atoms

lambda1 = 0.0001; %decays/s


lambda2 = 0.00005;
dt = 100; % time step (in seconds)
M = 1500; % total number of time steps
t = 0:dt:(M-1)*dt; % time series
p1 = lambda1*dt; % probability of having a decay in the time dt
p2 = lambda2*dt;
% Define the array that will be populated with the number of atoms at each
% time step
N1 = zeros(M,1); N2 = zeros(M,1); N3 = zeros(M, 1);
N1(1) = N0;
tic
for j=2:M
n_decaysN1toN2 = nnz(rand(N1(j-1),1) <= p1);
n_decaysN2toN3 = nnz(rand(N2(j-1),1) <= p2);
N1(j) = N1(j-1) - n_decaysN1toN2; % number of type 1 atoms that are left
N2(j) = N2(j-1) + n_decaysN1toN2 - n_decaysN2toN3;
N3(j) = N3(j-1) + n_decaysN2toN3;
end
toc
plot(t, [N1, N2, N3]), box off
xlabel('Time');
ylabel('Decay');
legend({'N_1', 'N_2', 'N_3'})
legend boxoff

Figure 1: Resultant Figure

Root mean square can be given by

2
1
N 0RMS =
N0 |

|
N n=1

Using matlab, RMS can be extimated as

1.5065 .

Code
% root mean square
%values
lambda1 = 0.0001; %decays/s
lambda2 = 0.00005;
dt=100;
N0=1e5;
% Set parameters
M = 1500;
T = 100000;
p1 = 100;

p2 = 50;
% Initialize variables
BDist1 = zeros(M,1); % sample mean
BDist2 = zeros(M,1); % sample median
y = zeros(T,1);
% Set random-number generator
randn('state',1);
% Simulation step
for r = 1:M
numer = randn(T,1);
denom = sqrt(sum(randn(T,p2).^2,2));
z = numer./denom;
y = p1 + z;
BDist1(r) = mean(y);
BDist2(r) = median(y);
end
% Calculate sampling statistics
mse1 = mean((BDist1 - p1).^2);
mse2 = mean((BDist2 - p1).^2);
mse_r = mse2/mse1

S-ar putea să vă placă și