1 Introduction to Computational Physics Autumn term 2017 402-0809-00L Tuesday 10.45 – 12.30 in HPT C 103 Exercises: Tuesday 8.45- 10.30 in HIT F21 Oral exams: end of January www.ifb.ethz.ch/education/IntroductionComPhys 2 Who is your teacher? Hans J. Herrmann [email protected]Institute of Building Materials (IfB) HIT G 23.1, Hönggerberg, ETH Zürich http://www.hans-herrmann.ethz.ch
58
Embed
Introduction to Computational Physics - ETH Z · 2017-11-06 · Introduction to Computational Physics Autumn term 2017 402-0809-00L ... Areas of computational physics • CFD (Computational
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
1 1 2 1 1 0mod , ..., : ( ... )n i i n i na a a x a x a x p
George Marsaglia (1968)For a congruential generator the
random numbers in an n-cube-test lie on
parallel n -1 dimensional hyperplanes.
1
11 0
at least one set
mod
, , , ..., :
...
n
nn
p c n a a
a c a c p
proof using:
31
n-cube-test
1
4
np
One can also show that for congruential RNG
the distance between the planes must be larger
than
and that the maximum number of planes is
1np
32
Lagged-Fibonacci RNG
• Initialization of b random bits xi
• Apply:
j jii xx 2mod)(
b,..,1Robert C. Tausworthe
33
Lagged Fibbonacci RNG
2modi i a i b i a i bx x x x x
20 i i k ix x x k b
Typically one uses, since it is easy to implement:
Theorem of A. Compagner (1992) :If (a,b) Zierler trinomial then sequence has
maximal period 2b – 1 and :
a < b
34
Zierler trinomials
(a, b)
(103, 250) (Kirkpatrick and Stoll, 1981)
(1689, 4187)
(54454, 132049) (J.R. Heringa et al., 1992)
(3037958, 6972592) (R.P.Brent et al., 2003)
ba xx 1 primitive on Z2[x]
(Neal Zierler, 1969)
35
Making 64-bit integers
..…
zi = (01101….101110)
zi+1 = (10001….010111)
zi+2 = (00101….111001)
zi+3 = (01011….011100)
zi+4 = (00011….011011)
.....
36
Tests for random numbers
• n-cube-test• Correlations should vanish• Average is 0.5• Average of each bit is 0.5• Check distribution• Spectral test: no peaks in Fourier transform• χ2 test: partial sums follow a Gaussian• Kolmogorov – Smirnov test
→ „Diehard battery“ of Marsaglia (1995)
37
Diehard battery• Birthday Spacings: Choose random points on a large interval. The spacings between the points should be Poisson
distributed.• Overlapping Permutations: Analyze sequences of five consecutive random numbers. The 120 possible orderings
should occur with statistically equal probability.• Ranks of matrices: Select some number of bits from some number of random numbers to form a matrix over
{0,1}, then determine the rank of the matrix. Count the ranks. • Monkey Tests: Treat sequences of some number of bits as "words". Count the overlapping words in a stream.
The number of "words" that don't appear should follow a known distribution.• Count the 1s: Count the 1 bits in each of either successive or chosen bytes. Convert the counts to "letters", and
count the occurrences of five-letter "words". • Parking Lot Test: Randomly place unit circles in a 100 x 100 square. If the circle overlaps an existing one, try
again. After 12,000 tries, the number of successfully "parked" circles should follow a normal distribution.• Minimum Distance Test: Randomly place 8,000 points in a 10,000 x 10,000 square, then find the minimum
distance between the pairs. The square of this distance should be exponentially distributed.• Random Spheres Test: Randomly choose 4,000 points in a cube of edge 1,000. Center a sphere on each point,
whose radius is the minimum distance to another point. The smallest sphere's volume should be exponentially distributed with a certain mean.
• The Squeeze Test: Multiply 231 by random floats on [0,1) until you reach 1. Repeat this 100,000 times. The number of floats needed to reach 1 should follow a certain distribution.
• Overlapping Sums Test: Generate a long sequence of random floats on [0,1). Add sequences of 100 consecutive floats. The sums should be normally distributed with characteristic mean and sigma.
• Runs Test: Generate a long sequence of random floats on [0,1). Count ascending and descending runs. The counts should follow a certain distribution.
• The Craps Test: Play 200,000 games of craps, counting the wins and the number of throws per game and check the distribution.
38
RN with other distributions
• Transformation method
• Rejection method
Poisson distribution
Gaussian distribution
(Box Muller, 1958)
39
Transformation method
1 0 1
0
if
otherwise
,( )
zP z
0 0
' ' ' ' ( ) ( )yz
P z dz P y dy
We want random numbers y distributed as P(y).
Start with homogeneously
distributed numbers z:
P(y)
y z 0 0
' ' ' '( ) ( )yz
z P z dz P y dy
40
Transformation method
( ) kyP y keexample:
generate Poisson distribution:
0
0
1
11
''
ln
[ ]y
ky y kykyz e
y zk
ke dy e
where z [0,1) are homogeneous random numbers.
This method only works if the integral can be
solved and the resulting function can be inverted.
41
Box –Muller (1958)
21
( )y
P y e
1
2
1 2
1 2
2 221 2
1 2 1 2
0 0
2 2 21 2
1 2
0 0 0 0
2 21 21 1
1 1
2
1
21 1arctan
( ) ( )
y y
y y r
y yr
y y r
y
y
y y
z z dy dy
dy dy rdrd
e e
e e
e e
0
21
'
'y y
z dye
Gaussian distribution:
cannot be solved in closed form.
trick:2 2 2
1 2
1
2
1 2
tan
dy dy rdrd
r y y
y
y
42
Box –Muller trick
2 21 2 2
1 11
2 1
1
22
2
ln
sintan
cos
y y z
y zz
y z
11 2
2
2 21 21
21
arctany y
yz z
ye
1 2 1
2 2 1
1 2
1 2
ln sin
ln cos
y z z
y z z
From two homogeneously distributed random
numbers z1 and z2 one gets two Gaussian
distributed random numbers y1 and y2 .
43
Sample two homogeneously
distributed random numbers
z1 , z2 [0,1). If the point
(Bz1, Az2) lies above the curve
P (y), i.e. P (Bz1) < Az2 then
reject the attempt, otherwise y = Bz1 is retained as a
random number which is distributed according to P (y).
P
Rejection method
Generate random numbers y [0, B] sampled
according to a distribution P (y) with P (y) < A.
44
Percolation
John M. Hammersley(1920 – 2004)
Broadbent and Hammersley
Proc. Cambridge Phil. Soc.
Vol. 53, p.629 (1957)
45
References to percolation
• D. Stauffer: „Introduction to Percolation Theory“ (Taylor and Francis, 1985)
• D. Stauffer and A. Aharony: „Introduction to Percolation Theory, Revised Second Edition“ (Taylor and Francis, 1992)
• M. Sahimi: „Applications of Percolation Theory“ (Taylor and Francis, 1994)
• G. Grimmett: „Percolation“ (Springer, 1989)
• B.Bollobas and O.Riordan: „Percolation“ (Cambridge Univ. Press, 2006)
46
Percolator
48
Applications of percolation
• Porous media (oil production, pollution of soils)
• Sol-gel transition• Mixtures of conductors and insulators• Forest fires• Propagation of epidemics or computer virus • Crash of stock markets (Sornette)• Landslide election victories (Galam)• Recognition of antigens by T-cells (Perelson)
• …
49
Gelatin formation
50
Sol -gel transition
Shear modulus G vanishes
and viscosity η diverges
at tg as function of time t.
η •
G ◦
tg
51
Percolation
bla
site percolation on square lattice
p is the probability to occupy a site.Neighboring occupied sites are „connected“
and belong to the same cluster.
52
Burning method
2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 34 4 4 4
4 4 4 4 45 5 5 5
5 5 5 5
6
6 6 67
7 7
7
8
8
89
9
9
HH et al (1984)
10 11 12 13
14 15 16
17 18
19
20
21
22
23
24
L = 16
shortest
path
ts = 24
p = 0.59
53
Probability to find a spanning cluster
pc = 0.592746…
54
Percolation thresholds pc
lattice site bondcubic (body-centered) 0.246 0.1803