def single_honeycomb(self, initbond=array([1., 0])):
        a = initbond
        r = rotate(pi / 3)
        b = zeros([6, 2])
        b[0] = a
        for i in xrange(1, 6):
            b[i] = r.dot(b[i - 1])
#        b = b - a
        return b
 def plot_lattice(self, magic_angle, color='black'):
     scalex, scaley = 10, 10
     a, b = self.alpha[:2], self.betha[:2]
     bond0 = self.single_honeycomb()
     r = rotate(magic_angle)
     for i in xrange(-scalex, scalex + 1):
         opointx = i * a
         for j in xrange(-scaley, scaley + 1):
             opointy = j * b
             opoint = opointx + opointy
             #                bond = opoint + bond0
             bond = (opoint + bond0).T
             bond = (r.dot(bond)).T
             self.plot_single_honeycomb(bond, color)
 def get_tba(self, k):
     alpha = self.alpha
     betha = self.betha
     mu, t1 = self.mu, self.t1
     angle = 2 * pi / 3
     alpha = alpha[:-1]
     betha = betha[:-1]
     delta1 = (alpha + betha) / 3
     delta2 = rotate(angle).dot(delta1)
     delta3 = -delta1 - delta2
     #print delta1,delta2,delta3
     phi1 = k.dot(delta1)
     phi2 = k.dot(delta2)
     phi3 = k.dot(delta3)
     xk = -t1 * (cos(phi1) + cos(phi2) + cos(phi3))
     yk = -t1 * (sin(phi1) + sin(phi2) + sin(phi3))
     #pdb.set_trace()
     hk = general_kron(xk, sigma1)
     hk = hk - general_kron(yk, sigma2)
     hk += -mu * sigma0
     return hk
    def get_TBG_model(self, kmesh, t2, tt1, tt2):
        hk = self.get_tba(kmesh)
        bondnnn = zeros([6, 2])
        bondnnn[0] = array([0, sqrt(3)])
        r_nnn = rotate(pi / 3)
        for i in xrange(1, 6):
            bondnnn[i] = r_nnn.dot(bondnnn[i - 1])
        bondnn = zeros([3, 2])
        bondnn[0] = (self.alpha + self.betha)[:-1] / 3
        r_nn = rotate(2 * pi / 3)
        for i in xrange(1, 3):
            bondnn[i] = r_nn.dot(bondnn[i - 1])

        isigma2 = 1j * sigma2
        sigmap = (sigma1 + isigma2) / 2.
        sigmam = sigmap.T.conj()

        warp_nnn = 0.
        fsign = array([1, -1, 1, -1, 1, -1.])
        for i in xrange(6):
            phi = kmesh.dot(bondnnn[i])
            warp_nnn = warp_nnn + general_kron(exp(1j * phi),
                                               sigma0) * fsign[i]
        warp_nnn = warp_nnn * tt2

        #        fsign = fsign*1j; hop_nnn = 0.
        #        for i in xrange(6):
        #            phi = kmesh.dot(bondnnn[i])
        #            hop_nnn = hop_nnn + general_kron(exp(1j*phi),sigma0)*fsign[i]
        #        hop_nnn *= tt1

        bondnnn = zeros([6, 2])
        bondnnn[0] = array([1., 0])
        for i in xrange(1, 6):
            bondnnn[i] = r_nnn.dot(bondnnn[i - 1])
        hop = 0.
        for i in xrange(6):
            phi = kmesh.dot(bondnnn[i])
            hop = hop + general_kron(exp(1j * phi), sigma0)
        hop *= t2

        hop_nn = 0.
        for i in xrange(3):
            bond = bondnn[i] * sqrt(3)
            xx = bond[0]**2
            yy = bond[1]**2
            xy = bond[0] * bond[1]
            sigma_orbital = array([[xx - yy, 2 * xy], [2 * xy, yy - xx]])
            phi = kmesh.dot(bondnn[i])
            hop_xy = general_kron(cos(phi), sigma1) - general_kron(
                sin(phi), sigma2)
            hop_nn = hop_nn + kron(sigma_orbital, hop_xy)
        hop_nn *= tt1

        Hk = 0.
        Hk = Hk + kron(sigma0, hk)
        Hk = Hk + kron(isigma2, warp_nnn)
        Hk = Hk + kron(sigma0, hop)
        #        Hk = Hk + kron(sigma0,hop_nnn)
        Hk = Hk + hop_nn
        #        pdb.set_trace()
        return Hk
 mu = -0
 t2 = 0.15
 tt1 = 0.
 tt2 = -0.02
 gph = graphen(mu, Nx, Ny)
 #    plt.subplot(122)
 #    plt.subplot(122)
 #    gph.get_dos(t2,tt1,tt2)
 alpha = gph.alpha
 betha = gph.betha
 kalpha, kbetha = gph.get_kvector(alpha, betha, Nx, Ny)
 kalpha *= Nx
 kbetha *= Ny
 Kpoint = gph.get_Kpoint(kalpha, kbetha)
 Mpoint = gph.get_Mpoint(kalpha, kbetha)
 Kp_point = rotate(pi / 3).dot(Kpoint)
 GKMG = gph.generate_loop(Kpoint, Mpoint, Kp_point)
 Hk = gph.get_TBG_model(GKMG, t2, tt1, tt2)
 Ek, Uk = linalg.eigh(Hk)
 plt.subplot(121)
 plt.plot([0, Ek.shape[0]], [-1.29, -1.29], linestyle='--', color='black')
 #    plt.plot([0,Ek.shape[0]],[-1.8,-1.8],linestyle = '--',color = 'black')
 #    plt.plot([0,Ek.shape[0]],[-1.65,-1.65],linestyle = '--',color = 'black')
 #    plt.plot([0,Ek.shape[0]],[1.4,1.4],linestyle = '--',color = 'black')
 #    plt.plot([0,Ek.shape[0]],[1.6,1.6],linestyle = '--',color = 'black')
 plt.plot(arange(Ek.shape[0]), Ek, linewidth=1.5)
 plt.yticks(size=16)
 plt.xticks([0, 500, 750, 750 + 250 * sqrt(3)],
            ['$\Gamma$', 'K', 'M', '$\Gamma$'],
            size=16)
 plt.ylabel('$\epsilon_k$', size=32)