Percolation Theory

Installation¶

In [1]:
#Pkg.clone("https://github.com/goropikari/Percolation.jl")
using Percolation


Labeling¶

Square lattice¶

Nearest neighbor¶

In [2]:
N = 50; p = 0.6
sq = Square(N, p, "nn")
sq.lattice_config.lattice_sites

Out[2]:
50×50 Array{Int8,2}:
0  1  0  1  1  0  1  0  1  1  0  0  0  …  1  1  1  1  1  1  1  1  0  1  1  1
1  1  1  0  0  1  0  0  0  1  1  1  0     1  1  0  0  1  0  1  0  1  1  0  1
0  0  1  0  1  1  0  1  1  1  1  1  1     0  1  1  1  0  1  1  0  0  0  0  1
1  1  1  0  1  1  0  1  1  0  1  1  1     0  0  0  0  0  1  0  0  1  1  1  1
0  0  1  1  0  1  0  0  0  0  0  1  1     1  1  0  1  1  1  0  1  0  1  0  1
1  1  1  0  0  1  0  1  1  1  1  0  1  …  0  0  1  1  1  1  1  0  1  1  1  0
1  1  1  0  1  1  1  1  0  0  1  1  1     1  1  0  0  0  1  1  1  1  0  1  1
1  1  0  1  1  1  0  1  0  1  1  0  0     0  0  1  1  1  1  0  0  0  1  1  0
0  0  1  1  1  1  1  0  1  1  0  1  0     0  0  0  0  1  1  1  1  1  1  0  1
1  1  0  0  1  1  0  0  0  1  1  0  1     0  1  0  1  1  1  1  1  1  1  1  0
1  0  1  0  1  1  0  1  1  1  0  1  0  …  1  0  0  0  1  0  1  0  1  1  0  0
0  0  1  0  0  0  1  1  1  1  1  0  1     1  1  1  0  1  0  1  1  1  1  0  0
0  0  0  0  0  1  0  0  0  1  1  1  1     0  1  0  0  1  1  1  0  0  1  0  0
⋮              ⋮              ⋮        ⋱        ⋮              ⋮
1  1  1  0  1  0  1  0  1  1  0  1  1     0  1  1  1  1  1  1  1  0  1  0  0
0  1  1  1  1  1  1  0  0  0  1  1  0     0  1  0  0  0  1  1  0  0  0  1  0
0  1  0  1  0  1  0  1  1  1  1  0  1  …  1  0  0  0  1  0  0  1  1  1  0  1
0  0  1  0  0  0  0  1  1  0  1  1  1     1  0  0  1  0  0  0  1  1  1  1  1
1  1  1  1  1  0  1  0  1  0  1  0  1     0  0  0  1  1  1  0  1  1  1  0  1
0  1  0  0  0  0  0  0  0  0  1  1  0     1  0  1  0  1  0  0  0  1  1  0  1
1  1  1  0  1  0  0  1  1  1  1  0  0     1  1  1  1  1  0  1  1  0  0  0  1
1  1  1  1  1  0  1  1  0  0  0  0  1  …  1  0  1  0  1  0  1  0  1  0  1  0
0  1  1  1  1  1  0  1  1  1  0  1  1     1  0  0  0  0  1  1  0  1  1  1  0
0  1  1  0  0  1  1  1  0  0  0  1  1     0  1  1  0  0  0  1  1  0  0  0  0
0  1  1  1  0  1  0  0  0  1  0  0  1     1  1  0  0  1  1  1  0  1  1  0  1
1  0  1  1  0  0  1  0  0  1  0  1  0     1  0  0  1  1  1  1  0  1  0  1  1

By using label_components!, we can clasify clusters.

In [3]:
label_components!(sq)
sq.lattice_properties.labeled_lattice_sites

Out[3]:
50×50 Array{Int64,2}:
0  1  0  11  11   0  13  0  5   5  0  …  30  30  30  30  30   0  30  30  30
1  1  1   0   0   5   0  0  0   5  5      0  30   0  30   0  30  30   0  30
0  0  1   0   5   5   0  5  5   5  5     30   0  30  30   0   0   0   0  30
1  1  1   0   5   5   0  5  5   0  5      0   0  30   0   0  30  30  30  30
0  0  1   1   0   5   0  0  0   0  0     30  30  30   0  63   0  30   0  30
1  1  1   0   0   5   0  5  5   5  5  …  30  30  30  30   0  30  30  30   0
1  1  1   0   5   5   5  5  0   0  5      0   0  30  30  30  30   0  30  30
1  1  0   5   5   5   0  5  0   5  5     30  30  30   0   0   0  30  30   0
0  0  5   5   5   5   5  0  5   5  0      0  30  30  30  30  30  30   0  72
2  2  0   0   5   5   0  0  0   5  5     30  30  30  30  30  30  30  30   0
2  0  9   0   5   5   0  5  5   5  0  …   0  30   0  30   0  30  30   0   0
0  0  9   0   0   0   5  5  5   5  5      0  30   0  30  30  30  30   0   0
0  0  0   0   0  10   0  0  0   5  5      0  30  30  30   0   0  30   0   0
⋮                 ⋮                ⋮  ⋱                   ⋮
5  5  5   0   5   0   5  0  5   5  0     57  57  57  57  57   0  57   0   0
0  5  5   5   5   5   5  0  0   0  5      0   0  57  57   0   0   0  70   0
0  5  0   5   0   5   0  5  5   5  5  …   0  61   0   0  64  64  64   0  64
0  0  5   0   0   0   0  5  5   0  5      5   0   0   0  64  64  64  64  64
5  5  5   5   5   0  14  0  5   0  5      5   5   5   0  64  64  64   0  64
0  5  0   0   0   0   0  0  0   0  5      0   5   0   0   0  64  64   0  64
5  5  5   0   5   0   0  5  5   5  5      5   5   0  60  60   0   0   0  64
5  5  5   5   5   0   5  5  0   0  0  …   0   5   0  60   0  67   0  67   0
0  5  5   5   5   5   0  5  5   5  0      0   0  60  60   0  67  67  67   0
0  5  5   0   0   5   5  5  0   0  0      0   0   0  60  60   0   0   0   0
0  5  5   5   0   5   0  0  0  17  0      0  60  60  60   0  68  68   0  71
8  0  5   5   0   0  15  0  0  17  0     60  60  60  60   0  68   0  71  71

Labeled cluster is displayed by heatmap!

In [4]:
heatmap!(sq)

Out[4]:

Next nearest neighbor¶

If you want to simulate not only nearest neighbor but next nearest neighbor, specify 3rd argument as "nnn".

In [5]:
N = 100; p = 0.45
sq = Square(N, p, "nnn")
label_components!(sq)

In [6]:
heatmap!(sq)

Out[6]:

Triangular¶

In [7]:
N = 100; p = 0.45
tri = Triangular(N, p, "nnn")
label_components!(tri)
heatmap!(tri)

Out[7]:

Honeycomb¶

In [8]:
N = 100; p = 0.45
h = Honeycomb(N, p, "nnn")
label_components!(h)
heatmap!(h)

Out[8]:

Percolating probability¶

square lattice, nearest neighbor¶

In [9]:
linsize = 50
ps = 0.1
pinc = 0.025
pf = 1
nsample = 50
plot_percolation_prob("square", linsize, ps, pinc, pf, nsample)

Out[9]:

triangular lattice¶

In [10]:
linsize = 50
ps = 0
pinc = 0.025
pf = 1
nsample = 50
plot_percolation_prob("triangular", linsize, ps, pinc, pf, nsample)

Out[10]:

honeycomb lattice¶

In [11]:
linsize = 50
ps = 0
pinc = 0.025
pf = 1
nsample = 50
plot_percolation_prob("honeycomb", linsize, ps, pinc, pf, nsample)

Out[11]:

Cluster property¶

Following definition are based on Introduction To Percolation Theory: Revised Second Edition by Dietrich Stauffer and Ammon Aharony (ISBN-10: 0748402535).

Check percolation¶

If a cluster reaches 4 edge, the cluster is percolation cluster and the system is percolated.

In [12]:
N = 50; p = 0.6
sq = Square(N, p, "nn")
println(ispercolation!(sq))
heatmap!(sq)

true

Out[12]:

Cluster size¶

In [13]:
clustersize!(sq)

Out[13]:
64-element Array{Int64,1}:
1
0
1
16
39
55
1
2
8
3
6
13
1
⋮
1
3
2
42
16
4
1
3
2
5
2
2

Cluster size frequency¶

In [14]:
clustersizefreq!(sq)

Out[14]:
Dict{Int64,Int64} with 16 entries:
2   => 12
16  => 2
11  => 2
39  => 1
55  => 1
42  => 1
8   => 2
129 => 1
6   => 2
4   => 2
3   => 5
5   => 3
13  => 1
14  => 2
12  => 2
1   => 24

cluster number¶

Cluster Number $n_s$ is the probability that a occupied site belonging to s-cluster.

$n_s = \frac{\text{# of s-cluster in the lattice except for percolation cluster}}{L^2}$

By definition, occupied probability, $p$, is $p = \sum_s n_s s$

In [19]:
?clusternumber!

search: clusternumber!


Out[19]:

clusternumber!(latt::Lattice)

Cluster Number $n_s$ is the probability that a occupied site belonging to s-cluster. Formal definition of cluster number is defined by exclunding the percolation cluster. But in this calculation, it is included.

In [15]:
clusternumber!(sq)

Out[15]:
Dict{Int64,Float64} with 16 entries:
2   => 0.0048
16  => 0.0008
11  => 0.0008
39  => 0.0004
55  => 0.0004
42  => 0.0004
8   => 0.0008
129 => 0.0004
6   => 0.0008
4   => 0.0008
3   => 0.002
5   => 0.0012
13  => 0.0004
14  => 0.0008
12  => 0.0008
1   => 0.0096

average cluster size¶

Average cluster size $S$ is defined by $S = \frac{\sum_{s=1} s^2 n_s}{p}$.

In [16]:
average_clustersize!(sq)

Out[16]:
16.652000000000005

Strength¶

Strength $P(p)$ is the probability that an arbitrary site belongs to the percolating cluster.

$P(p) = \frac{\text{# of sites in percolating cluster with occupied probability$p$}}{L^2}$ where $L$ is the system linear size

In [17]:
strength!(sq)

Out[17]:
0.4064

linsize = 50