Skip to content

Commit f2bcd83

Browse files
authored
Merge pull request #82 from noahsong-sdg/feature/readme-fix
update readme examples to match docs
2 parents 546df4d + 0521f3b commit f2bcd83

File tree

13 files changed

+91
-70
lines changed

13 files changed

+91
-70
lines changed

README.md

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,32 @@ julia> Pkg.add("TopologicalNumbers")
6262

6363
## Examples
6464

65-
### The Su-Schriffer-Heeger (SSH) model
65+
### The Su-Schrieffer-Heeger (SSH) model
6666

6767
Here's a simple example of the SSH Hamiltonian:
6868

6969
```julia
7070
julia> using TopologicalNumbers
71-
julia> function H₀(k, p)
71+
julia> function H₀(k, p) # SSH
72+
t₁ = 1
73+
t₂ = p
7274
[
73-
0 p[1]+p[2]*exp(-im * k)
74-
p[1]+p[2]*exp(im * k) 0
75+
0 t₁ + t₂*exp(-im * k)
76+
t₁ + t₂*exp(im * k) 0
7577
]
7678
end
7779
```
7880

81+
Or you can use our preset Hamiltonian function:
82+
83+
```julia
84+
julia> H₀ = SSH
85+
```
86+
7987
The band structure is computed as follows:
8088

8189
```julia
82-
julia> H(k) = H₀(k, (0.9, 1.0))
90+
julia> H(k) = H₀(k, 1.1)
8391
julia> showBand(H; value=false, disp=true)
8492
```
8593

@@ -134,30 +142,35 @@ julia> sol = calcPhaseDiagram(prob, param; plot=true)
134142
Hamiltonian of Haldane model is given by:
135143

136144
```julia
137-
julia> function H₀(k, p) # landau
138-
k1, k2 = k
139-
J = 1.0
140-
K = 1.0
141-
ϕ, M = p
142-
143-
h0 = 2K * cos(ϕ) * (cos(k1) + cos(k2) + cos(k1 + k2))
144-
hx = J * (1 + cos(k1) + cos(k2))
145-
hy = J * (-sin(k1) + sin(k2))
146-
hz = M - 2K * sin(ϕ) * (sin(k1) + sin(k2) - sin(k1 + k2))
147-
148-
s0 = [1 0; 0 1]
149-
sx = [0 1; 1 0]
150-
sy = [0 -im; im 0]
151-
sz = [1 0; 0 -1]
152-
153-
h0 .* s0 .+ hx .* sx .+ hy .* sy .+ hz .* sz
154-
end
145+
julia> function H₀(k, p) # Haldane
146+
k1, k2 = k
147+
t₁ = 1
148+
t₂, ϕ, m = p
149+
150+
h0 = 2t₂ * cos(ϕ) * (cos(k1) + cos(k2) + cos(k1 + k2))
151+
hx = t₁ * (1 + cos(k1) + cos(k2))
152+
hy = t₁ * (-sin(k1) + sin(k2))
153+
hz = m - 2t₂ * sin(ϕ) * (sin(k1) + sin(k2) - sin(k1 + k2))
154+
155+
s0 = [1 0; 0 1]
156+
sx = [0 1; 1 0]
157+
sy = [0 -im; im 0]
158+
sz = [1 0; 0 -1]
159+
160+
h0 .* s0 .+ hx .* sx .+ hy .* sy .+ hz .* sz
161+
end
162+
```
163+
164+
Or you can use our preset Hamiltonian function:
165+
166+
```julia
167+
julia> H₀ = Haldane
155168
```
156169

157170
The band structure is computed as follows:
158171

159172
```julia
160-
julia> H(k) = H₀(k, (π/3, 0.5))
173+
julia> H(k) = H₀(k, (1, π/3, 0.5))
161174
julia> showBand(H; value=false, disp=true)
162175
```
163176

@@ -220,31 +233,39 @@ julia> sol = calcPhaseDiagram(prob, param1, param2; plot=true)
220233
As an example of a two-dimensional topological insulator, the BHZ model is presented here:
221234

222235
```julia
236+
julia> using LinearAlgebra
223237
julia> function H₀(k, p) # BHZ
224-
k1, k2 = k
225-
tₛₚ = 1
226-
t₁ = ϵ₁ = 2
227-
ϵ₂, t₂ = p
228-
229-
R0 = -t₁*(cos(k1) + cos(k2)) + ϵ₁/2
230-
R3 = 2tₛₚ*sin(k2)
231-
R4 = 2tₛₚ*sin(k1)
232-
R5 = -t₂*(cos(k1) + cos(k2)) + ϵ₂/2
233-
234-
s0 = [1 0; 0 1]
235-
sx = [0 1; 1 0]
236-
sy = [0 -im; im 0]
237-
sz = [1 0; 0 -1]
238-
239-
a0 = kron(s0, s0)
240-
a1 = kron(sx, sx)
241-
a2 = kron(sx, sy)
242-
a3 = kron(sx, sz)
243-
a4 = kron(sy, s0)
244-
a5 = kron(sz, s0)
245-
246-
R0 .* a0 .+ R3 .* a3 .+ R4 .* a4 .+ R5 .* a5
247-
end
238+
k1, k2 = k
239+
tₛₚ = 1
240+
t₁ = ϵ₁ = 1
241+
ϵ₂, t₂ = p
242+
243+
ϵ = -t₁*(cos(k1) + cos(k2)) + ϵ₁/2
244+
R1 = 0
245+
R2 = 0
246+
R3 = 2tₛₚ*sin(k2)
247+
R4 = 2tₛₚ*sin(k1)
248+
R0 = -t₂*(cos(k1) + cos(k2)) + ϵ₂/2
249+
250+
s0 = [1 0; 0 1]
251+
sx = [0 1; 1 0]
252+
sy = [0 -im; im 0]
253+
sz = [1 0; 0 -1]
254+
255+
I0 = Matrix{Int64}(I, 4, 4)
256+
a1 = kron(sz, sx)
257+
a2 = kron(sz, sy)
258+
a3 = kron(sz, sz)
259+
a4 = kron(sy, s0)
260+
a0 = kron(sx, s0)
261+
262+
ϵ .* I0 .+ R1 .* a1 .+ R2 .* a2 .+ R3 .* a3 .+ R4 .* a4 .+ R0 .* a0
263+
end
264+
```
265+
Alternatively, you can use our preset Hamiltonian:
266+
267+
```julia
268+
julia> H₀ = BHZ
248269
```
249270

250271
To calculate the dispersion, execute:
@@ -254,7 +275,7 @@ julia> H(k) = H₀(k, (2, 2))
254275
julia> showBand(H; value=false, disp=true)
255276
```
256277

257-
![Dispersion of BHZ model](https://github.com/KskAdch/TopologicalNumbers.jl/assets/139373570/de14907c-777f-4667-810b-54c10888dfa1)
278+
![Dispersion of BHZ model](./docs/src/2D/assets/Band_BHZ.png)
258279

259280

260281

@@ -272,7 +293,7 @@ The output is:
272293
Z2Solution{Vector{Int64}, Nothing, Int64}([1, 1], nothing, 0)
273294
```
274295

275-
The first argument `TopologicalNumber` in the named tuple is an vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
296+
The first argument `TopologicalNumber` in the named tuple is a vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
276297
The vector is arranged in order of bands, starting from the one with the lowest energy.
277298
The second argument `Total` stores the total of the $\mathbb{Z}_2$ numbers for each pair of two energy bands.
278299
`Total` is a quantity that should always return zero.
@@ -290,7 +311,7 @@ julia> sol = calcPhaseDiagram(prob, param; plot=true)
290311
(param = -2.0:0.004004004004004004:2.0, nums = [0 0; 0 0; ; 0 0; 0 0])
291312
```
292313

293-
![One-dimensional phase diagram of BHZ model](https://github.com/KskAdch/TopologicalNumbers.jl/assets/139373570/5d6d5364-68d0-4423-8ecf-49bf0538af63)
314+
![One-dimensional phase diagram of BHZ model](./docs/src/2D/assets/phase_diagram1D_BHZ.png)
294315

295316

296317
Also, two-dimensional phase diagram is given by:
@@ -304,7 +325,7 @@ julia> calcPhaseDiagram(prob, param1, param2; plot=true)
304325
```
305326

306327

307-
![Two-dimensional phase diagram of BHZ model](https://github.com/KskAdch/TopologicalNumbers.jl/assets/139373570/802eedbe-c893-44b4-8267-d80e1745415a)
328+
![Two-dimensional phase diagram of BHZ model](./docs/src/2D/assets/phase_diagram2D_BHZ.png)
308329

309330

310331

docs/src/1D/Kitaev-Chain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The output is:
4242
BPSolution{Vector{Int64}, Int64}([1, 1], 0)
4343
```
4444

45-
The first argument `TopologicalNumber` in the named tuple is an vector that stores the winding number for each band.
45+
The first argument `TopologicalNumber` in the named tuple is a vector that stores the winding number for each band.
4646
The vector is arranged in order of bands, starting from the one with the lowest energy.
4747
The second argument `Total` stores the total of the winding numbers for each band (mod 2).
4848
`Total` is a quantity that should always return zero.

docs/src/1D/SSH.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The Su-Schriffer-Heeger (SSH) model
1+
# The Su-Schrieffer-Heeger (SSH) model
22

33
Here's a simple example of the SSH Hamiltonian:
44

@@ -17,7 +17,7 @@ julia> function H₀(k, p)
1717
You can also use our preset Hamiltonian function `SSH` to define the same Hamiltonian matrix as follows:
1818

1919
```julia
20-
julia> H₀(k, p) = SSH(k, p)
20+
julia> H₀ = SSH
2121
```
2222

2323
The band structure is computed as follows:

docs/src/2D/BHZ.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ julia> using LinearAlgebra
77
julia> function H₀(k, p) # BHZ
88
k1, k2 = k
99
tₛₚ = 1
10-
t₁ = ϵ₁ = 2
10+
t₁ = ϵ₁ = 1
1111
ϵ₂, t₂ = p
1212

1313
ϵ = -t₁*(cos(k1) + cos(k2)) + ϵ₁/2
@@ -35,7 +35,7 @@ end
3535
You can also use our preset Hamiltonian function `BHZ` to define the same Hamiltonian matrix as follows:
3636

3737
```julia
38-
julia> H₀(k, p) = BHZ(k, p)
38+
julia> H₀ = BHZ
3939
```
4040

4141
To calculate the dispersion, execute:
@@ -45,7 +45,7 @@ julia> H(k) = H₀(k, (2, 2))
4545
julia> showBand(H; value=false, disp=true)
4646
```
4747

48-
![Dispersion of BHZ model](https://github.com/KskAdch/TopologicalNumbers.jl/assets/139373570/de14907c-777f-4667-810b-54c10888dfa1)
48+
![Dispersion of BHZ model](./assets/Band_BHZ.png)
4949

5050

5151
Next, we can compute the $\mathbb{Z}_2$ numbers using `Z2Problem`:
@@ -62,7 +62,7 @@ The output is:
6262
Z2Solution{Vector{Int64}, Nothing, Int64}([1, 1], nothing, 0)
6363
```
6464

65-
The first argument `TopologicalNumber` in the named tuple is an vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
65+
The first argument `TopologicalNumber` in the named tuple is a vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
6666
The vector is arranged in order of bands, starting from the lower energy.
6767
The second argument `Total` stores the total of the $\mathbb{Z}_2$ numbers for Energy bands below and above some filling condition (mod2).
6868
`Total` is a quantity that should always return zero.
@@ -91,7 +91,7 @@ julia> sol = calcPhaseDiagram(prob, param; plot=true)
9191
(param = -2.0:0.004004004004004004:2.0, nums = [0 0; 0 0; ; 0 0; 0 0])
9292
```
9393

94-
![One-dimensional phase diagram of BHZ model](https://github.com/KskAdch/TopologicalNumbers.jl/assets/139373570/5d6d5364-68d0-4423-8ecf-49bf0538af63)
94+
![One-dimensional phase diagram of BHZ model](./assets/phase_diagram1D_BHZ.png)
9595

9696

9797
Also, two-dimensional phase diagram is given by:
@@ -105,4 +105,4 @@ julia> calcPhaseDiagram(prob, param1, param2; plot=true)
105105
```
106106

107107

108-
![Two-dimensional phase diagram of BHZ model](https://github.com/KskAdch/TopologicalNumbers.jl/assets/139373570/802eedbe-c893-44b4-8267-d80e1745415a)
108+
![Two-dimensional phase diagram of BHZ model](./assets/phase_diagram2D_BHZ.png)

docs/src/2D/Haldane.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ julia> function H₀(k, p) # Haldane
2424
You can also use our preset Hamiltonian function `Haldane` to define the same Hamiltonian matrix as follows:
2525

2626
```julia
27-
julia> H₀(k, p) = Haldane(k, p)
27+
julia> H₀ = Haldane
2828
```
2929

3030
The band structure is computed as follows:
@@ -51,7 +51,7 @@ The output is:
5151
FCSolution{Vector{Int64}, Int64}([1, -1], 0)
5252
```
5353

54-
The first argument `TopologicalNumber` in the named tuple is an vector that stores the first Chern number for each band.
54+
The first argument `TopologicalNumber` in the named tuple is a vector that stores the first Chern number for each band.
5555
The vector is arranged in order of bands, starting from the one with the lowest energy.
5656
The second argument `Total` stores the total of the first Chern numbers for each band.
5757
`Total` is a quantity that should always return zero.

docs/src/2D/Kane-Mele.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The output is:
5757
Z2Solution{Vector{Int64}, Nothing, Int64}([1, 1], nothing, 0)
5858
```
5959

60-
The first argument `TopologicalNumber` in the named tuple is an vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
60+
The first argument `TopologicalNumber` in the named tuple is a vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
6161
The vector is arranged in order of bands, starting from the lower energy.
6262
The second argument `Total` stores the total of the $\mathbb{Z}_2$ numbers for Energy bands below and above some filling condition (mod2).
6363
`Total` is a quantity that should always return zero.

docs/src/2D/Kitaev-Honeycomb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The output is:
4949
FCSolution{Vector{Int64}, Int64}([-1, 1], 0)
5050
```
5151

52-
The first argument `TopologicalNumber` in the named tuple is an vector that stores the first Chern number for each band.
52+
The first argument `TopologicalNumber` in the named tuple is a vector that stores the first Chern number for each band.
5353
The vector is arranged in order of bands, starting from the one with the lowest energy.
5454
The second argument `Total` stores the total of the first Chern numbers for each band.
5555
`Total` is a quantity that should always return zero.

docs/src/2D/Thouless.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The output is:
5656
Z2Solution{Vector{Int64}, Nothing, Int64}([1, 1], nothing, 0)
5757
```
5858

59-
The first argument `TopologicalNumber` in the named tuple is an vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
59+
The first argument `TopologicalNumber` in the named tuple is a vector that stores the $\mathbb{Z}_2$ number for Energy bands below and above some filling condition that you selected in the options (the default is the half-filling).
6060
The vector is arranged in order of bands, starting from the lower energy.
6161
The second argument `Total` stores the total of the $\mathbb{Z}_2$ numbers for Energy bands below and above some filling condition (mod2).
6262
`Total` is a quantity that should always return zero.

docs/src/2D/assets/Band_BHZ.png

50.2 KB
Loading
11 KB
Loading

0 commit comments

Comments
 (0)