Professional Documents
Culture Documents
T4.6 Montecarlo 3 KineticMC
T4.6 Montecarlo 3 KineticMC
Code
nuCreate = 100;
lMigrate = 500;
N=0; else
t=0; #migrate
endTime=1; select = ceil(rand*N);
while(t < endTime) if(rand < .5)
R(1) = nuCreate; x(select) = x(select) + 1;
R(2) = R(1) + N*lMigrate; else
t = t - log(rand)/R(2); x(select) = x(select) -1;
select = rand*R(2); end
if(select < R(1)) end
#create end
N=N+1;
x(N) = 0;
Solutions
Overall
The total number of particle should be bigger as time increases.
100
30 t=1
t=1 t=2
t=2 50
25
Number of particles
20 0
Position
15 -50
10
-100
5
-150
0 0 20 40 60 80 100 120 140 160 180 200
-15 -10 -5 0 5 10 15 Particle number
Length
Simulating “market”
The cellular shop
This is the story of a shop that sells cellular phones. Every day, the
owner of the shop is buying 20 new cellular phones and puts them
on sale on top of the existing ones, if any. Such owner has seen
that he manages to sell the fourth part of all the cellular phones he
has every day. The first day, he has no phones at all.
Conditions
We can simulate this with KMC. We will take t = 300 days.
Buying: a fixed average rate of 20 a day (i.e., one every 1/20
of a day)
Selling: a fourth part of the stock is sold every day in average.
(i.e., if there are 12 phones, 3 are sold, if there are 20, 5 are
sold, etc.)
Every phone costs the owner 70, and is sold at 75.
Simulation in Materials Engineering: Atomistic Modeling
More complicated KMC algorithms Changing the number of particles
Metropolis MC Applying KMC to “daily life” simulations
What to simulate
Code
Code (Cont.)
if(t>day)
fprintf(fid, "%f %d %d\n", t, A, money);
day = day+1;
daily=0;
end
end
fclose(fid);
Solutions
Expecting...
We expect to have loses the first days.
25000
Earnings
Number of phones in stock
20000
120
Realistic Simulation
Theoretical value 15000
100
10000
80 5000 2000
1000
60 0 0
-1000
-5000 -2000
40 -3000
-4000
-10000 -5000
20 -6000
-15000 0 10 20 30 40 50 60 70
0 0 50 100 150 200 250 300
0 50 100 150 200 250 300