Skip to content

Commit

Permalink
Merge pull request #20 from Imperial-CMTH/chern_number
Browse files Browse the repository at this point in the history
Chern number
  • Loading branch information
dpreuo authored Jul 28, 2022
2 parents 192fdea + 0368952 commit cb52dcc
Show file tree
Hide file tree
Showing 3 changed files with 379 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/koala/chern_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from koala.lattice import Lattice
import numpy as np
import scipy.linalg as la

def crosshair_marker(lattice: Lattice, projector: np.ndarray, crosshair_position: np.ndarray):
"""Generate the crosshair marker for a lattice and Hamiltonian
:param lattice: the lattice on which the Hamiltonian is placed
:type lattice: Lattice
:param projector: A projectro onto a set of occupied states
:type projector: np.ndarray
:param crosshair_position: the position of the crosshair in the bulk
:type crosshair_position: np.ndarray
:return: an array giving the marker value at every point in the system
:rtype: np.ndarray
"""


positions = lattice.vertices.positions
theta_x_vec = np.diag(1*(positions[:,0] < crosshair_position[0]))
theta_y_vec = np.diag(1*(positions[:,1] < crosshair_position[1]))

crosshair_marker = 4*np.pi*np.diag(projector@theta_x_vec@projector@theta_y_vec@projector).imag

return crosshair_marker


def chern_marker(lattice: Lattice, projector: np.ndarray):
"""generate the Chern marker for the system
:param lattice: the lattice
:type lattice: Lattice
:param projector: a projector onto a set of occupied states
:type projector: np.ndarray
:return: the Chern marker value for each point in the system
:rtype: np.ndarray
"""

positions = lattice.vertices.positions
X = np.diag(positions[:,0])
Y = np.diag(positions[:,1])

chern_marker = 4*np.pi*np.diag(projector@X@projector@Y@projector).imag

return chern_marker
32 changes: 32 additions & 0 deletions tests/test_chern_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from koala.pointsets import generate_random
from koala.voronization import generate_lattice
from koala.graph_color import color_lattice
from koala.hamiltonian import generate_majorana_hamiltonian
from numpy import linalg as la
import numpy as np
import matplotlib
from koala import chern_number as cn

def test_chern_and_crosshair():
# define the lattice system
number_of_plaquettes = 50
points = generate_random(number_of_plaquettes)
lattice = generate_lattice(points)

# color the lattice
coloring = color_lattice(lattice)

# parameters
ujk = np.full(lattice.n_edges, 1)
J = np.array([1,1,1])

# solve system
H_maj = generate_majorana_hamiltonian(lattice, coloring, ujk, J)
eigs, vecs = la.eigh (H_maj)
lowest_diag = np.array([1]*(lattice.n_vertices//2) + [0]*(lattice.n_vertices//2) )
P = vecs @ np.diag(lowest_diag) @ vecs.conj().T

# find crosshair / chern number
crosshair_position = np.array([0.5,0.5])
crosshair_marker = cn.crosshair_marker(lattice, P, crosshair_position)
chern_marker = cn.chern_marker(lattice, P)
302 changes: 302 additions & 0 deletions tutorial_notebooks/chern_number.ipynb

Large diffs are not rendered by default.

0 comments on commit cb52dcc

Please sign in to comment.