Skip to content

Commit cb52dcc

Browse files
authored
Merge pull request #20 from Imperial-CMTH/chern_number
Chern number
2 parents 192fdea + 0368952 commit cb52dcc

File tree

3 files changed

+379
-0
lines changed

3 files changed

+379
-0
lines changed

src/koala/chern_number.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from koala.lattice import Lattice
2+
import numpy as np
3+
import scipy.linalg as la
4+
5+
def crosshair_marker(lattice: Lattice, projector: np.ndarray, crosshair_position: np.ndarray):
6+
"""Generate the crosshair marker for a lattice and Hamiltonian
7+
8+
:param lattice: the lattice on which the Hamiltonian is placed
9+
:type lattice: Lattice
10+
:param projector: A projectro onto a set of occupied states
11+
:type projector: np.ndarray
12+
:param crosshair_position: the position of the crosshair in the bulk
13+
:type crosshair_position: np.ndarray
14+
:return: an array giving the marker value at every point in the system
15+
:rtype: np.ndarray
16+
"""
17+
18+
19+
positions = lattice.vertices.positions
20+
theta_x_vec = np.diag(1*(positions[:,0] < crosshair_position[0]))
21+
theta_y_vec = np.diag(1*(positions[:,1] < crosshair_position[1]))
22+
23+
crosshair_marker = 4*np.pi*np.diag(projector@theta_x_vec@projector@theta_y_vec@projector).imag
24+
25+
return crosshair_marker
26+
27+
28+
def chern_marker(lattice: Lattice, projector: np.ndarray):
29+
"""generate the Chern marker for the system
30+
31+
:param lattice: the lattice
32+
:type lattice: Lattice
33+
:param projector: a projector onto a set of occupied states
34+
:type projector: np.ndarray
35+
:return: the Chern marker value for each point in the system
36+
:rtype: np.ndarray
37+
"""
38+
39+
positions = lattice.vertices.positions
40+
X = np.diag(positions[:,0])
41+
Y = np.diag(positions[:,1])
42+
43+
chern_marker = 4*np.pi*np.diag(projector@X@projector@Y@projector).imag
44+
45+
return chern_marker

tests/test_chern_number.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from koala.pointsets import generate_random
2+
from koala.voronization import generate_lattice
3+
from koala.graph_color import color_lattice
4+
from koala.hamiltonian import generate_majorana_hamiltonian
5+
from numpy import linalg as la
6+
import numpy as np
7+
import matplotlib
8+
from koala import chern_number as cn
9+
10+
def test_chern_and_crosshair():
11+
# define the lattice system
12+
number_of_plaquettes = 50
13+
points = generate_random(number_of_plaquettes)
14+
lattice = generate_lattice(points)
15+
16+
# color the lattice
17+
coloring = color_lattice(lattice)
18+
19+
# parameters
20+
ujk = np.full(lattice.n_edges, 1)
21+
J = np.array([1,1,1])
22+
23+
# solve system
24+
H_maj = generate_majorana_hamiltonian(lattice, coloring, ujk, J)
25+
eigs, vecs = la.eigh (H_maj)
26+
lowest_diag = np.array([1]*(lattice.n_vertices//2) + [0]*(lattice.n_vertices//2) )
27+
P = vecs @ np.diag(lowest_diag) @ vecs.conj().T
28+
29+
# find crosshair / chern number
30+
crosshair_position = np.array([0.5,0.5])
31+
crosshair_marker = cn.crosshair_marker(lattice, P, crosshair_position)
32+
chern_marker = cn.chern_marker(lattice, P)

tutorial_notebooks/chern_number.ipynb

+302
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)