# 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() h = g.get_hamiltonian() # create hamiltonian of the system h.add_anti_kane_mele(0.1) mf = scftypes.guess(h, mode="random") # antiferro initialization # perform SCF with specialized routine for Hubbard U = 3.0 scf = scftypes.hubbardscf(h, nkp=10, filling=0.5, g=U, mix=0.9, mf=mf) scf.hamiltonian.get_bands(operator="sz")
# 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 scftypes g = geometry.honeycomb_zigzag_ribbon(10) # create geometry of a zigzag ribbon h = g.get_hamiltonian() # create hamiltonian of the system mf = scftypes.guess(h, "ferro", fun=lambda r: [0., 0., 1.]) scf = scftypes.hubbardscf(h, nkp=30, filling=0.5, mf=mf) h = scf.hamiltonian # get the Hamiltonian h.get_bands(operator="sz") # calculate band structure
is_multicell=False, mgenerator=specialhopping.twisted_matrix(ti=0.5, lambi=7.0)) h.turn_dense() #def ff(r): # return 0.2*r[2] #h.shift_fermi(ff) h.turn_spinful() h.turn_dense() h.add_sublattice_imbalance(0.5) h.add_kane_mele(0.03) #h.get_bands(num_bands=40) #exit() from pygra import meanfield mf = meanfield.guess(h, "antiferro", 0.1) g = 2.0 filling = 0.5 + 1. / h.intra.shape[0] # plus two electrons nk = 1 scf = scftypes.hubbardscf(h, nkp=nk, filling=filling, g=g, mix=0.9, mf=mf, maxite=1) #scf1 = scftypes.selfconsistency(h,nkp=nk,filling=0.5,g=g, # mix=0.9,mf=mf) scf.hamiltonian.get_bands(num_bands=40, operator="sz") #print(scf.total_energy-scf1.total_energy)
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 scf = scftypes.hubbardscf(h, nkp=5, filling=0.5, g=U, mix=0.5, mf=mf, collinear=True) e = scf.total_energy # get the energy of the system es.append(e) # store energy f.write(str(p) + " " + str(e) + "\n") # write in the file f.close() # close the file ## Plot the energies ## import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams.update({'font.size': 18}) matplotlib.rcParams['font.family'] = "Bitstream Vera Serif" fig = plt.figure()
# 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 islands from pygra import interactions from pygra import scftypes import numpy as np g = islands.get_geometry(name="honeycomb", n=40, nedges=3, rot=np.pi / 3, clean=False) # get an island g.write() exit() h = g.get_hamiltonian() # get the Hamiltonian scf = scftypes.hubbardscf(h, g=1.0, mag=[[0, 0, 1] for r in g.r]) scf.hamiltonian.get_bands()
# 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 scftypes import numpy as np # this spin calculates the spin stiffness of an interacting 1d chain g = geometry.chain() # chain geometry h0 = g.get_hamiltonian() # create hamiltonian of the system fo = open("STIFFNESS.OUT", "w") # open file for a in np.linspace(0., .2, 20): # loop over angles, in units of pi h = h0.copy() h.generate_spin_spiral(angle=a, vector=[0., 1., 0.]) scf = scftypes.hubbardscf(h, filling=0.1, nkp=100, g=2.5, silent=True, mag=[[0., 0., .1]], mix=0.9, maxerror=1e-4) fo.write(str(a) + " " + str(scf.total_energy) + "\n") # write print(a, scf.total_energy) fo.close()
# 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() h = g.get_hamiltonian() # create hamiltonian of the system U = 5.0 mf = scftypes.guess(h,mode="antiferro") # antiferro initialization # perform SCF with specialized routine for Hubbard # save = True will write the mean field in a file at every iteration scf = scftypes.hubbardscf(h,nkp=20,filling=0.5,g=U, mix=0.9,mf=mf,save=True,silent=True) # perform it again without giving a MF (it will be read from a file) # mf = None forces the code to read the mean field from a file scf = scftypes.hubbardscf(h,nkp=20,filling=0.5,g=U, mix=0.9,mf=None,save=True)
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 mfoff = scftypes.guess(h,mode="antiferro",fun = lambda x: [0.,0.,1.0]) # inplane antiferro initialization mfin = scftypes.guess(h,mode="antiferro",fun = lambda x: [1.0,0.,0.]) # compute the energies using collinear formalism with different # quantization axis. In this case, the collinear formalism # will enforce the magnetization in the z direction scfoff = scftypes.hubbardscf(hoff,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfoff,collinear=True) scfin = scftypes.hubbardscf(hin,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfoff,collinear=True) # alternatively, we can use a non-collinear formalism and go to the # ground state with using two different initializations # compute energies using non-collinear formalism but different initialization scfoff2 = scftypes.hubbardscf(h,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfoff,collinear=False) scfin2 = scftypes.hubbardscf(h,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfin,collinear=False) # Now compute energy differences e0 = scfoff.total_energy - scfin.total_energy e1 = scfoff2.total_energy - scfin2.total_energy # and store the energies es0.append(e0) # store energy es1.append(e1) # store energy
# 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 parallel parallel.cores = 7 from scipy.sparse import csc_matrix g = geometry.honeycomb_lattice() g.write() Us = np.linspace(0., 4., 10) # different Us #f = open("EVOLUTION.OUT","w") # file with the results h = g.get_hamiltonian() # create hamiltonian of the system mf = scftypes.guess(h, mode="antiferro") # antiferro initialization # perform SCF with specialized routine for Hubbard U = 3.0 scf = scftypes.hubbardscf(h, nkp=20, filling=0.5, g=U, mix=0.001, mf=mf)
from pygra import specialgeometry from pygra import scftypes g = specialgeometry.twisted_bilayer(8) #g = geometry.honeycomb_lattice() g.write() from pygra import specialhopping h = g.get_hamiltonian(is_sparse=True,has_spin=False,is_multicell=False, mgenerator=specialhopping.twisted_matrix(ti=0.5,lambi=7.0)) h.turn_dense() #def ff(r): # return 0.2*r[2] #h.shift_fermi(ff) h.turn_spinful() h.turn_dense() h.add_sublattice_imbalance(0.5) h.add_kane_mele(0.03) #h.get_bands(num_bands=40) #exit() from pygra import meanfield mf = meanfield.guess(h,"antiferro",0.1) g = 2.0 filling = 0.5 + 1./h.intra.shape[0] # plus two electrons nk = 1 scf = scftypes.hubbardscf(h,nkp=nk,filling=filling,g=g, mix=0.9,mf=mf,maxite=1) #scf1 = scftypes.selfconsistency(h,nkp=nk,filling=0.5,g=g, # mix=0.9,mf=mf) scf.hamiltonian.get_bands(num_bands=40,operator="sz") #print(scf.total_energy-scf1.total_energy)
# 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() h = g.get_hamiltonian() # create hamiltonian of the system U = 5.0 mf = scftypes.guess(h,mode="antiferro") # antiferro initialization # perform SCF with specialized routine for Hubbard # save = True will write the mean field in a file at every iteration scf = scftypes.hubbardscf(h,nkp=20,filling=0.5,g=U, mix=0.9,mf=mf,save=True,silent=True) # perform it again without giving a MF (it will be read from a file) # mf = None forces the code to read the mean field from a file scf = scftypes.hubbardscf(h,nkp=20,filling=0.5,g=U, mix=0.9,mf=None,save=True)
# 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() g.write() Us = np.linspace(0.,4.,10) # different Us f = open("EVOLUTION.OUT","w") # file with the results for U in Us: # loop over Us h = g.get_hamiltonian() # create hamiltonian of the system mf = scftypes.guess(h,mode="antiferro") # antiferro initialization # perform SCF with specialized routine for Hubbard scf = scftypes.hubbardscf(h,nkp=20,filling=0.5,g=U, mix=0.9,mf=mf) # alternatively use # scf = scftypes.selfconsistency(h,nkp=20,filling=0.5,g=U, # mix=0.9,mf=mf) h = scf.hamiltonian # get the Hamiltonian gap = h.get_gap() # compute the gap f.write(str(U)+" "+str(gap)+"\n") f.close()
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 mfoff = scftypes.guess(h,mode="antiferro",fun = lambda x: [0.,0.,1.0]) # inplane antiferro initialization mfin = scftypes.guess(h,mode="antiferro",fun = lambda x: [1.0,0.,0.]) # compute the energies using collinear formalism with different # quantization axis. In this case, the collinear formalism # will enforce the magnetization in the z direction scfoff = scftypes.hubbardscf(hoff,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfoff,collinear=True) scfin = scftypes.hubbardscf(hin,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfoff,collinear=True) # print(scfoff.total_energy) # print(scfin.total_energy) # exit() # alternatively, we can use a non-collinear formalism and go to the # ground state with using two different initializations # compute energies using non-collinear formalism but different initialization scfoff2 = scftypes.hubbardscf(h,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfoff,collinear=False) scfin2 = scftypes.hubbardscf(h,nkp=5,filling=0.5,g=U, mix=0.5,mf=mfin,collinear=False) # Now compute energy differences e0 = scfoff.total_energy - scfin.total_energy e1 = scfoff2.total_energy - scfin2.total_energy
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 scf = scftypes.hubbardscf(h,nkp=5,filling=0.5,g=U, mix=0.5,mf=mf,collinear=True) e = scf.total_energy # get the energy of the system es.append(e) # store energy f.write(str(p)+" "+str(e)+"\n") # write in the file f.close() # close the file ## Plot the energies ## import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams.update({'font.size': 18}) matplotlib.rcParams['font.family'] = "Bitstream Vera Serif" fig = plt.figure() fig.subplots_adjust(0.2,0.2) plt.plot(ps*180,es,marker="o",c="blue")