Ejemplo n.º 1
0
 def test_1(self):
     g = geometry.honeycomb_lattice()
     g = g.supercell(2)
     k = np.random.random(3)
     h1 = geth(3,1,g).get_hk_gen()(k)
     h2 = geth(1,3,g).get_hk_gen()(k)
     diff = np.max(np.abs(h1-h2))
     print("Error = ",diff)
     passed = diff<error
     self.assertTrue(passed)
Ejemplo n.º 2
0
 def test_1(self):
     g = geometry.honeycomb_lattice()
     g = g.supercell(2)
     k = np.random.random(3)
     h1 = geth(3, 1, g).get_hk_gen()(k)
     h2 = geth(1, 3, g).get_hk_gen()(k)
     diff = np.max(np.abs(h1 - h2))
     print("Error = ", diff)
     passed = diff < error
     self.assertTrue(passed)
Ejemplo n.º 3
0
def func_to_parallelize(U):
    """Function to parallelize"""
    # all the variables must be internal!
    from pygra import geometry
    from pygra import meanfield
    g = geometry.honeycomb_lattice()
    h = g.get_hamiltonian() # create hamiltonian of the system
    mf = meanfield.guess(h,mode="antiferro") # antiferro initialization
    # perform SCF with specialized routine for Hubbard
    scf = meanfield.hubbardscf(h,nk=20,filling=0.5,U=U,verbose=1,
                  mix=0.9,mf=mf)
    # alternatively use
    h = scf.hamiltonian # get the Hamiltonian
    gap = h.get_gap() # compute the gap
    return gap
Ejemplo n.º 4
0
def get_bulk_green_function(h0, energy=0.0, eta=1e-3):
    """Function to compute the bulk Green's function"""
    from pygra import geometry
    from pygra import green
    g = geometry.honeycomb_lattice()
    h = g.get_hamiltonian()
    h.intra = np.matrix(h0.intra)
    h.tx = np.matrix(h0.tx)
    h.ty = np.matrix(h0.ty)
    h.txy = np.matrix(h0.txy)
    h.txmy = np.matrix(h0.txmy)
    h.is_multicell
    #gf,selfe = green.bloch_selfenergy(h,energy=energy,delta=eta,mode="full",nk=10)
    #  gf,selfe = green.bloch_selfenergy(h,energy=energy,delta=eta,mode="renormalization")
    gf, selfe = green.bloch_selfenergy(h,
                                       energy=energy,
                                       delta=eta,
                                       mode="adaptive")
    return gf  # return Green's function
Ejemplo n.º 5
0
# Add the root path of the pygra library
import os
import sys

sys.path.append(os.environ['PYGRAROOT'])

import numpy as np
from pygra import geometry
import os
from pygra import groundstate
from pygra.selfconsistency import densitydensity

g = geometry.honeycomb_lattice(3)
h = g.get_hamiltonian(has_spin=False)  # create hamiltonian of the system
nk = 3
filling = 0.5
g = 2.0  # interaction

V1s = np.linspace(0., 3.0, 10)
V2s = np.linspace(0., 3.0, 10)


#scf = scftypes.selfconsistency(h,nk=nk,filling=filling,g=g,mode="V")
def get_gap(V1, V2):
    os.system("rm -f MF.pkl")
    scf = densitydensity.Vinteraction(h, V1=V1, V2=V2, nk=nk, filling=filling)
    return scf.hamiltonian.get_gap()  # get the Hamiltonian


f = open("MAP.OUT", "w")
for V1 in V1s:
Ejemplo n.º 6
0
# Add the root path of the pygra library
import os ; import sys ; sys.path.append(os.environ['PYGRAROOT'])

# zigzag ribbon
import numpy as np
from pygra import geometry
from pygra import scftypes
from pygra import operators
from scipy.sparse import csc_matrix
g = geometry.chain()
g = geometry.honeycomb_lattice()
#g = geometry.kagome_lattice()
g = g.supercell(3)
h = g.get_hamiltonian() # create hamiltonian of the system
h = h.get_multicell()
h.remove_spin()
mf = np.random.random(h.intra.shape) -.5  
mf = np.matrix(mf)
mf = mf + mf.H
scf = scftypes.selfconsistency(h,nkp=1,filling=0.5,g=3.0,
              mix=0.9,mf=mf,mode="V")
h = scf.hamiltonian # get the Hamiltonian
h.get_bands() # calculate band structure
from pygra import groundstate
groundstate.hopping(h,nrep=3) # write three replicas
#spectrum.fermi_surface(h)
Ejemplo n.º 7
0
# Add the root path of the pygra library
import os ; import sys ; sys.path.append(os.environ['PYGRAROOT'])

# zigzag ribbon
from pygra import geometry
from pygra import topology
import numpy as np
from pygra import phasediagram
g = geometry.honeycomb_lattice() # create geometry of a chain
def getz2(x1,x2): 
  # calculate the Z2 invariant for certain Zeeman and Rashba
  h = g.get_hamiltonian(has_spin=True) # get the Hamiltonian, spinfull
  h.add_kane_mele(x1) # add SOC
  h.add_sublattice_imbalance(x2) # add mass
  z2 = topology.z2_invariant(h,nk=10,nt=10) # get the Z2
  print(x1,x2,z2)
  return z2
# now write the Phase diagram in a file
phasediagram.diagram2d(getz2,x=np.linspace(-.05,0.05,10,endpoint=True),y=np.linspace(-.1,.1,10,endpoint=True),nite=3)
Ejemplo n.º 8
0
# Add the root path of the pygra library
import os
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../src")

# zigzag ribbon
import numpy as np
from pygra import geometry
from pygra import scftypes
from pygra import operators
from scipy.sparse import csc_matrix

g = geometry.honeycomb_lattice()  # create a honeycomb lattice
h0 = g.get_hamiltonian()  # create hamiltonian of the system
h0.add_kane_mele(0.05)  # Add Kane-Mele SOC

ps = np.linspace(0., 1., 30)  # create different angles, from 0 to pi
es = []  # empty list for the total energies

f = open("ENERGY_VS_ANGLE.OUT", "w")  # file with the results
for p in ps:  # loop over angles
    h = h0.copy()  # copy Hamiltonian
    # the following will rotate the spin quantization axis in the
    # unit cell, so that we can fix the magnetization along one
    # direction and compute the magnetic anisotropy
    # the angle is given in units of pi, i.e. p=0.5 is 90 degrees
    h.global_spin_rotation(angle=p, vector=[1., 0., 0.])
    U = 3.0  # large U to get antiferromagnetism
    # antiferro initialization
    mf = scftypes.guess(h, mode="antiferro", fun=lambda x: 1.0)
    # perform SCF with specialized routine for collinear Hubbard
Ejemplo n.º 9
0
# Add the root path of the pygra library
import os
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../src")

import numpy as np
from pygra import geometry
g = geometry.honeycomb_lattice()  # geometry of a honeycomb lattice
h = g.get_hamiltonian(has_spin=True)  # create hamiltonian of the system
h.shift_fermi(3.0)  # bottom of the band
h.add_rashba(0.5)  # add Rashba SOC
h.add_zeeman([0., 0., 0.5])  # add a Zeeman field
h.add_swave(0.1)  # add s-wave superconductivity
c = h.get_chern(nk=20)  # compute Chern number
print()
print("########################")
print("Chern number = ", round(c, 2))
print("########################")
print()
h.get_bands(operator="sx")  # compute band structure
Ejemplo n.º 10
0
# Add the root path of the pygra library
import os ; import sys ; sys.path.append(os.environ['PYGRAROOT'])

# zigzag ribbon
import numpy as np
from pygra import geometry
from pygra import scftypes
from pygra import operators
from scipy.sparse import csc_matrix


g = geometry.honeycomb_lattice() # create a honeycomb lattice
h0 = g.get_hamiltonian() # create hamiltonian of the system



ps = np.linspace(0.,.1,5) # create the different KM couplings
es0 = [] # empty list for the total energies
es1 = [] # empty list for the total energies


f = open("ENERGY_VS_ANGLE.OUT","w") # file with the results
for p in ps: # loop over angles
  h = h0.copy() # copy Hamiltonian
  h.add_kane_mele(p) # Add Kane-Mele SOC
  hoff = h.copy()
  hin = h.copy()
  # Hamiltonian with in-plane quantization axis
  hin.global_spin_rotation(angle=0.5,vector=[1.,0.,0.])
  U = 3.0 # large U to get antiferromagnetism
  # offplane antiferro initialization
Ejemplo n.º 11
0
# Add the root path of the pygra library
import os ; import sys 
sys.path.append(os.path.dirname(os.path.realpath(__file__))+"/../../../src")





from pygra import geometry
from pygra import scftypes
import numpy as np
# create the hamiltonian
g = geometry.honeycomb_lattice() # triangular lattice geometry
#g = geometry.chain()
#g = g.supercell(2)
h = g.get_hamiltonian(has_spin=True) # create hamiltonian of the system
q = [1./3.,1./3.,0.]
q = [0.,0.,0.]
q = np.array(q) + 0.05
vector = [0.,0.,1.]
h.generate_spin_spiral(vector=[0.,0.,1.],qspiral=q,
        fractional=True)
h.add_zeeman([.0,0.2,0.0])
#h.add_zeeman([[.0,0.1,0.0],[0.,-0.1,0.]])
h.get_bands(operator="sz")