Professional Documents
Culture Documents
I. IMPLEMENTATION, PROCEEDINGS, AND we can compute the mean square distance hR2 i given by:
THEORY
K
1 X 2
The code has been implemented according to the in- hR2 i = R (N ) (3)
K n=1 (K)
structions provided by Landau et al. [1]. We choose
random values ∆x0 and ∆y 0 using the library random for
√
Python. Also notice that each step is normalized in this In my simulations I chose N = 100 steps for K = N =
way: 10 trials. This can be seen in CheckingTheory.py for
the 2D case, and in CheckingTheory3D.py for the 3D
∆x0 ∆y 0 ∆z 0 one.
∆x = , ∆y = , ∆z =
L L L 3. The theoretical arguments can be tested considering
p the previous mathematical background. Also, to validate
where, L = ∆x0 2 + ∆y 0 2 + ∆z 0 2 the theoretical results, I compute a selection of the values
that should accomplish the next condition:
Considering this, I developed some calculations in order
to visualize the walk produced by the algorithm, and to
check if some theoretical considerations are accomplished h∆xi ∆xj6=i i h∆xi ∆yj i
∼ ∼0 (4)
when running the program. The Python libraries mat- R2 R2
plotlib, and math were used too.
1. First of all, it is possible to develop the code for one In addition, if we consider the 3D case, we have to also
trial and N steps, then one can generalize to obtain a K analyse when:
number of trials. In my simulations, five trials were de-
veloped at first considering a random seed a = 1729, and h∆xi ∆zj i h∆yi ∆zj i h∆zi ∆zj6=i i
N = 1000 to see the patterns of each path. The imple- ∼ ∼ ∼0 (5)
R2 R2 R2
mentation of the code is written in the file VariousTri-
als.py for the 2D case, and in VariousTrials3D.py for To compute these kind of expected values one can make
the 3D case. It is important to consider that the radial calculations with the use of multiple f or loop. This is
distance R from the origin is given by: also analysed in the files CheckingTheory.py (2D) and
√ CheckingTheory3D.py (3D) for K trials. The analysis
R = Nr (1) for just one trial is done in CheckingTheory2.py (2D)
and in CheckingTheory3Dp2.py .
where r is the root-mean-square step size. Also, it is ex- p
4. Finally,
√ one can make a plot of R = hR2 (N )i with
pected that after a long walk, the average vector distance
will be: respect to N . According to theory, we would expect to
obtain approximately a relation of direct proportionality,
hRi = hxii + hyij + hzik ∼ 0 (2) or in other words a straight line. In my work I make the
plot for a single trial. This can be seen in the files Check-
2. Also, a run for K = 10 trials was developed so that ingTheory2.py (2D) and CheckingTheory3Dp2.py
(3D).
Additional comment: One can even make √ a plot for
the RK ’s (the R of each trial) in relation to N and still
∗ Electronic address: jorge.vega@yachaytech.edu.ec obtain interesting results, i.e. a straight line.
2
II. RESULTS AND DISCUSSION printed (in the 2D case), and 5 lists (in the 3D case)
respectively. Therefore, observing the results it is possi-
1. When doing the plots for some trials, it can be ble to affirm that (4) and (5) are correct, and also the
observed according to figure. (1) that the vector endpoint algorithms work as expected.
√
is distributed uniformly in all quadrants. It means that
p
4. The plot R = hR2 (N )i with respect to N is
the distribution of the trials are around the origin. nicely obtained for N = 300 steps in 2D and√3D. Evi-
dently there is a direct proportion of R and N . This
can be seen in figure (3) and figure (4)
√
FIG. 3: Plot of R (the radial distance) in relation to the N
for N = 300 steps for the 2D case. This is done in Check-
ingTheory2.py. The plotted points form almost a perfect
straight line. Very little variations appear at the beginning if
that zone is zoomed. The random seed is set to a = 0
[1] Rubin Landau, Manuel Páez, and Cristian Bordeianu. WILEY-VCH Verlag GmbH Co. KGaA, USA, 2015.
Computational Physics. Problem Solving with Computers.