def get(U): """Perform a selfconsistent calculation""" print(U) h = g.get_hamiltonian() # create hamiltonian of the system mf = meanfield.guess(h,mode="ferro") # ferro initialization # perform SCF with specialized routine for Hubbard fU = lambda r: U*fimpurity(r) # Hubbard for the site scf = meanfield.Vinteraction(h,nk=20, filling=0.5, # set at half filling U=fU, # spatially dependent U mix = 0.9, # quite agressive mixing mf=mf, # initial guess constrains=["no_charge"] # ignore chemical potential renorm ) h = scf.hamiltonian # selfconsistent Hamiltonian return h.compute_vev("sz")[0] # magnetization of the Hubbard site
def get(): h = g.get_hamiltonian() # create hamiltonian of the system m = np.random.random(3) - 0.5 m = m / np.sqrt(m.dot(m)) # random magnetic field h.add_zeeman(m) nk = 30 filling = 0.25 h.turn_nambu() mf = meanfield.guess(h, "random") scf = meanfield.Vinteraction(h, V1=-2.0, nk=nk, filling=filling, mf=mf, constrains=["no_charge"], verbose=0) h = scf.hamiltonian # get the Hamiltonian h.check() print(scf.identify_symmetry_breaking()) d = np.round(h.get_average_dvector(), 3) print("d-vector", d, np.sum(d)) return h.get_gap()
# 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 meanfield g = geometry.honeycomb_lattice() g = g.supercell(1) h = g.get_hamiltonian() # create hamiltonian of the system U = 3.0 filling = 0.5 mf = meanfield.guess(h, mode="random") scf = meanfield.Vinteraction(h, nk=10, U=U, filling=filling, mf=mf, constrains=["no_charge"]) h = scf.hamiltonian # get the Hamiltonian h.get_bands() # calculate band structure
# 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 from pygra import films from pygra import meanfield g = geometry.honeycomb_lattice() g = g.supercell(3) h = g.get_hamiltonian() h.turn_nambu() mf = meanfield.guess(h,"random") scf = meanfield.Vinteraction(h,V1=-2.0,V2=-1.0,mf=mf, nk=20,filling=0.5,mix=0.6, compute_normal=True, compute_dd=False, compute_anomalous=True) h = scf.hamiltonian h.write_anomalous_hopping() print(scf.identify_symmetry_breaking()) h.get_bands(operator="sz")
# 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 scipy.sparse import csc_matrix from pygra import meanfield g = geometry.honeycomb_lattice() h = g.get_hamiltonian() # create hamiltonian of the system h.add_swave(0.0) U = -2.0 #hubbard = scftypes.hubbardscf mf = meanfield.guess(h, mode="random") scf = meanfield.Vinteraction(h, nk=4, U=U, filling=0.7, mf=mf, compute_anomalous=True, compute_dd=False) h = scf.hamiltonian # get the Hamiltonian h.get_bands(operator="electron") # calculate band structure
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../src") import numpy as np from pygra import specialgeometry from pygra.specialhopping import twisted_matrix from pygra import meanfield from pygra import groundstate from pygra import geometry g = specialgeometry.twisted_bilayer(4) g = geometry.honeycomb_lattice() g = g.supercell(3) h = g.get_hamiltonian(is_sparse=True, has_spin=False, is_multicell=False, mgenerator=twisted_matrix(ti=0.0, lambi=7.0)) mf = meanfield.guess(h, "dimerization") scf = meanfield.Vinteraction(h, nk=1, filling=0.5, V1=2.0, V2=1.0, mix=0.3, mf=mf) h = scf.hamiltonian # get the Hamiltonian groundstate.hopping( h, nrep=1, skip=lambda r1, r2: r1[2] * r2[2] < 0) # write three replicas h.get_bands() # calculate band structure h.write_onsite()
# Add the root path of the pygra library import os import sys sys.path.append(os.environ['PYGRAROOT']) from pygra import islands import numpy as np g = islands.get_geometry(name="honeycomb", n=3, nedges=3, rot=0.0) # get an island # maximum distance to the origin h = g.get_hamiltonian(has_spin=True) # get the Hamiltonian from pygra import meanfield g.write() mf = meanfield.guess(h, mode="ferro") scf = meanfield.Vinteraction(h, filling=0.5, U=3.0, V1=1.0, mf=mf, maxerror=1e-9) scf.hamiltonian.write_hopping(spin_imbalance=True) scf.hamiltonian.write_magnetization() #scf.hamiltonian.get_bands()
from pygra import scftypes from pygra import meanfield import os g = geometry.honeycomb_lattice() h = g.get_hamiltonian() # create hamiltonian of the system ds = [] Us = np.linspace(0.0, 10.0, 10) h.add_swave(0.0) os.system("rm -rf *.pkl") U = 2.0 # SC and CDW guess mf = 10 * (meanfield.guess(h, "swave") + meanfield.guess(h, "CDW")) scf = meanfield.Vinteraction( h, nk=10, mix=0.5, U=-U, mf=mf, filling=0.45, verbose=1, V1=0.25, # first neighbor repulsion # constrains=["no_charge"] # this forces the system to ignore CDW # constrains=["no_SC"] # this forces the system to ignore SC ) hscf = scf.hamiltonian hscf.get_bands(operator="electron", nk=4000) print("CDW order", np.abs(hscf.extract("CDW"))) print("SC order", np.abs(hscf.extract("swave"))) print("Gap", np.abs(hscf.get_gap()))
# 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 from pygra import meanfield g = geometry.square_lattice() # square lattice h = g.get_hamiltonian() # create hamiltonian of the system h.add_swave(0.0) # activate a BdG Hamiltonian mf = meanfield.guess(h, mode="random") scf = meanfield.Vinteraction( h, nk=10, # number of k-points U=-0.2, # interaction strength for the onsite interaction filling=0.5, # filling of the system mf=mf, # initial guess (ranodm should be ok) mix=0.8, # mixing of the SCF verbose=1, # this prints some info of the SCF constrains=["no_normal_term"] # ignore normal terms of the SCF ) h = scf.hamiltonian # get the selfconsistent Hamiltonian print(scf.identify_symmetry_breaking()) h.get_bands(operator="electron") # calculate band structure
# 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 scipy.sparse import csc_matrix from pygra import meanfield g = geometry.honeycomb_lattice() #g = geometry.kagome_lattice() filling = 0.5 nk = 10 h = g.get_hamiltonian(has_spin=True) # create hamiltonian of the system scf = meanfield.Vinteraction(h, U=0.0, V1=4.0, nk=nk, filling=filling, mf="random") from pygra import scftypes print("Symmetry breaking", scf.identify_symmetry_breaking()) scf.hamiltonian.get_bands() # get the Hamiltonian
h = g.get_hamiltonian() #h.add_kekule(.1) #h.add_sublattice_imbalance(lambda r: 0.6*np.sign(r[2])) h.add_antiferromagnetism(lambda r: 0.8 * np.sign(r[2])) #h.add_antiferromagnetism(lambda r: 0.8*(r[2]>0)) #h.add_swave(lambda r: 0.8*(r[2]<0)) #h.add_swave(0.0) mf = meanfield.guess(h, "kanemele") #mf = meanfield.guess(h,"random") h.add_kane_mele(0.01) mf = None scf = meanfield.Vinteraction(h, V1=3.0, U=0.0, mf=mf, V2=3.0, V3=0.0, nk=20, filling=0.5, mix=0.2, compute_dd=False) mix0 = h.extract("spin_mixing") print("Mixing in original Hamiltonian", h.extract("spin_mixing")) h = scf.hamiltonian print("Mixing in new Hamiltonian", h.extract("spin_mixing")) mix1 = h.extract("spin_mixing") print("Enhancement of the spin mixing", mix1 / mix0) #h.add_rashba(.1) #h.add_antiferromagnetism(lambda r: 0.6*(r[2]>0)) #h.add_swave(lambda r: 0.6*(r[2]<0)) #print(h.extract("swave")) print("Density", h.extract("density"))
# 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 scipy.sparse import csc_matrix from pygra import meanfield g = geometry.honeycomb_lattice() #g = geometry.kagome_lattice() g = g.supercell(1) filling = 0.5 nk = 10 h = g.get_hamiltonian(has_spin=False) # create hamiltonian of the system #scf = scftypes.selfconsistency(h,nk=nk,filling=filling,g=g,mode="V") scf = meanfield.Vinteraction(h, V2=1.0, nk=nk, filling=filling) from pygra import scftypes #scf = meanfield.hubbardscf(h,U=2.6,nk=nk,filling=filling) #scf = scftypes.hubbardscf(h,U=2.6,nk=nk,filling=filling) 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)
def faf(r): return maf * np.sin(omega * np.pi * 2 * r[0]) h.add_antiferromagnetism(faf) h.add_swave(fsc) mf = meanfield.guess(h, "random") mf = None scf = meanfield.Vinteraction(h, V1=1.0, mf=mf, filling=0.5, mix=0.1, compute_normal=True, compute_dd=False, compute_anomalous=True) hscf = scf.hamiltonian (inds, es) = h.get_bands() (indsscf, esscf) = hscf.get_bands() import matplotlib.pyplot as plt plt.scatter(range(len(es)), es, c="red", label="Non-interacting") plt.scatter(range(len(esscf)), esscf, c="blue", label="Interacting") plt.legend()
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../src") import numpy as np from pygra import geometry from pygra import meanfield g = geometry.triangular_lattice() # square lattice h = g.get_hamiltonian() # create hamiltonian of the system h.add_zeeman([0., 0., 6.0]) # add exchange to promote triplet h.add_swave(0.0) # activate a BdG Hamiltonian mf = meanfield.guess(h, mode="random") scf = meanfield.Vinteraction(h, nk=20, V1=-2.0, filling=0.2, mf=mf, constrains=["no_normal_term"], mix=0.8, verbose=1) hscf = scf.hamiltonian # SCF Hamiltonian # now extract only the anomalous part h0 = hscf.copy() h0.remove_nambu() # remove SC (and Nambu as side effect) h0.add_swave(0.0) # restore Nambu basis print("SCF symmetry breaking", scf.identify_symmetry_breaking()) ha = hscf - h0 # this yields a Hamiltonian only with anomalous term ha.get_bands() # band structure of only the anomalous term
# 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 from pygra import groundstate from pygra import topology g = geometry.honeycomb_lattice() h = g.get_hamiltonian(has_spin=True) # create hamiltonian of the system nk = 10 filling = 0.5 from pygra import meanfield #scf = scftypes.selfconsistency(h,nk=nk,filling=filling,g=g,mode="V") h.add_zeeman([0.,0.,1.0]) mf = meanfield.guess(h,"dimerization") mf = None scf = meanfield.Vinteraction(h,V1=0.5,V2=0.5,nk=nk,filling=filling, mf=mf,mix=0.2) h = scf.hamiltonian # get the Hamiltonian h.get_bands(operator="sz") # calculate band structure groundstate.hopping(h) topology.write_berry(h) h.write_onsite()
# 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 scipy.sparse import csc_matrix from pygra import meanfield g = geometry.honeycomb_lattice() h = g.get_hamiltonian() # create hamiltonian of the system h.add_swave(0.0) U = -2.0 #hubbard = scftypes.hubbardscf mf = meanfield.guess(h,mode="random") scf = meanfield.Vinteraction(h,nk=4,U=U,filling=0.7,mf=mf, constrains = ["no_normal_term"]) h = scf.hamiltonian # get the Hamiltonian print(scf.identify_symmetry_breaking()) h.get_bands(operator="electron") # calculate band structure
# 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 from pygra import groundstate from pygra import meanfield from scipy.sparse import csc_matrix g = geometry.chain() g = g.supercell(4) h = g.get_hamiltonian(has_spin=False) # create hamiltonian of the system nk = 10 filling = 0.5 mf = meanfield.guess(h, "dimerization") scf = meanfield.Vinteraction(h, V1=2.0, nk=nk, filling=filling, mf=mf) h = scf.hamiltonian # get the Hamiltonian h.get_bands() # calculate band structure from pygra import topology groundstate.hopping(h) print(np.round(h.intra, 3).real)
# We will take a ferromagnetic triangular lattice, whose # superconducting state is a p-wave superfluid state with # odd superconductivity h.add_zeeman([0., 0., 20.0]) # add ferromagnetism h.turn_nambu() # setup a Nambu hamiltonian # the interaction terms are controlled by U, V1 and V2 # U is the onsite Hubbard interaction # V1 is the first neighbor charge-charge interaction # V2 is the second neighbor charge-charge interaction mf = meanfield.guess(h, "random") # random intialization scf = meanfield.Vinteraction(h, U=0.0, V1=-6.0, V2=0.0, nk=20, filling=0.2, mf=mf, mix=0.3) from pygra import scftypes print("##########################################") print("Symmetry breaking created by interactions") print(scf.identify_symmetry_breaking()) print("##########################################") # now extract the Hamiltonian and compute the bands h = scf.hamiltonian # get the Hamiltonian h.get_bands(operator="electron") # calculate band structure
# 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 scipy.sparse import csc_matrix from pygra import meanfield g = geometry.honeycomb_lattice() nk = 10 h = g.get_hamiltonian(has_spin=True) # create hamiltonian of the system filling = 0.7 # filling of the system h.turn_nambu() # setup nambu degree of freedom mf = meanfield.guess(h,"random") scf = meanfield.Vinteraction(h,U=-3.0,V1=0.0,nk=nk,filling=filling,mf=mf, verbose=1) # perform the SCF calculation from pygra import scftypes print("Symmetry breaking",scf.identify_symmetry_breaking()) scf.hamiltonian.get_bands(operator="electron",nk=2000) # get the Hamiltonian
def faf(r): return maf * np.sin(omega * np.pi * 2 * r[0]) h.add_antiferromagnetism(faf) h.add_swave(fsc) mf = None filling = 0.5 h.set_filling(filling) mf = meanfield.guess(h, "random") scf = meanfield.Vinteraction(h, V1=-2.0, mf=mf, filling=filling, mix=0.1, verbose=1, constrains=["no_normal_term"]) print(scf.identify_symmetry_breaking()) hscf = scf.hamiltonian (inds, es) = h.get_bands() (indsscf, esscf) = hscf.get_bands() import matplotlib.pyplot as plt plt.scatter(range(len(es)), es, c="red", label="Non-interacting") plt.scatter(range(len(esscf)), esscf, c="blue", label="Interacting")
from pygra import films from pygra import meanfield g = geometry.diamond_lattice() g = films.geometry_film(g, nz=4) #g = g.supercell(3) h = g.get_hamiltonian() #h.add_antiferromagnetism(lambda r: 0.6*(r[2]>0)) #h.add_swave(lambda r: 0.6*(r[2]<0)) h.add_antiferromagnetism(lambda r: 0.8 * np.sign(r[2])) #h.add_swave(lambda r: 0.2*r[2]>0.0) #h.add_swave(0.0) mf = meanfield.guess(h, "random") #h.add_kane_mele(0.04) #mf = None scf = meanfield.Vinteraction(h, V1=3.0, U=0.0, mf=mf, V2=3.0, V3=0.0, nk=6, filling=0.5, mix=0.3, compute_normal=True, compute_dd=False, compute_anomalous=False) h = scf.hamiltonian print(scf.identify_symmetry_breaking()) h.get_bands(operator="sz")
# 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 scipy.sparse import csc_matrix from pygra import meanfield g = geometry.honeycomb_lattice_C6() g = geometry.honeycomb_lattice() g = g.supercell(3) filling = 0.5 nk = 10 h = g.get_hamiltonian(has_spin=False) # create hamiltonian of the system #scf = scftypes.selfconsistency(h,nk=nk,filling=filling,g=g,mode="V") mf = meanfield.guess(h,"dimerization") scf = meanfield.Vinteraction(h,V1=4.0,mf=mf, V2=2.0,nk=nk,filling=filling,mix=0.3) h = scf.hamiltonian # get the Hamiltonian h.get_bands() # calculate band structure from pygra import groundstate groundstate.hopping(h,nrep=3) # write three replicas h.write_onsite(nrep=3) # write three replicas #spectrum.fermi_surface(h)
# 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,meanfield g = geometry.chain() ns = 2 # make a supercell g = g.supercell(ns) h = g.get_hamiltonian() # create hamiltonian of the system J = np.random.random(3) - 0.5 ; J = J/np.sqrt(J.dot(J)) # random vector h.add_zeeman(J) # add magnetization in a random direction h.setup_nambu_spinor() # tell the code to account for potential SC scf = meanfield.Vinteraction(h,V1=-1.0,nk=10,filling=1./3.,mf="random", verbose=1 # to print how the scf progresses ) h = scf.hamiltonian # get the selfconssitent Hamiltonian # write selfconsistent magnetization in MAGNETISM.OUT scf.hamiltonian.write_magnetization(nrep=2) # write non-unitarity of the d-vector in NON_UNITARITY_MAP.OUT scf.hamiltonian.write_non_unitarity(nrep=2)