Beispiel #1
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
Beispiel #2
0
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
Beispiel #3
0
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()
Beispiel #4
0
                      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)
Beispiel #5
0
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
g = geometry.honeycomb_lattice()
g = g.supercell(1)
h = g.get_hamiltonian()  # create hamiltonian of the system
mf = scftypes.guess(h, mode="antiferro")
U = 3.0
from pygra import scftypes
from pygra import meanfield
hubbard = meanfield.hubbardscf
#hubbard = scftypes.hubbardscf
filling = 0.5
mf = meanfield.guess(h, mode="antiferro")
scf = hubbard(h,
              nk=10,
              U=U,
              filling=filling,
              mf=mf,
              solver="plain",
              maxerror=1e-8)
#scf = hubbard(h,nk=10,U=U,filling=filling,mf=scf.mf,solver="broyden1")
h = scf.hamiltonian  # get the Hamiltonian
#h.write_magnetization()
print(scf.identify_symmetry_breaking())
h.get_bands()  # calculate band structure
Beispiel #6
0

def fsc(r):
    return delta * np.cos(omega * np.pi * 2 * r[0])


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
Beispiel #7
0
# 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()
Beispiel #8
0
# zigzag ribbon
import numpy as np
from pygra import geometry
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")))
Beispiel #9
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
from pygra import groundstate
from pygra import meanfield
g = geometry.honeycomb_lattice()
h = g.get_hamiltonian(has_spin=False)  # create hamiltonian of the system
nk = 10
filling = 0.5

mf = meanfield.guess(h, "random")  # initialization
scf = meanfield.Vinteraction(h, mf=mf, V2=2.0, nk=nk, filling=filling, mix=0.1)
print(scf.identify_symmetry_breaking())
h = scf.hamiltonian  # get the Hamiltonian
print("Topological invariant", h.get_topological_invariant())
h.get_bands()  # calculate band structure
from pygra import topology
groundstate.hopping(h)
topology.write_berry(h)
Beispiel #10
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
from pygra import groundstate
from pygra import meanfield
g = geometry.honeycomb_lattice()
h = g.get_hamiltonian(has_spin=False)  # create hamiltonian of the system
nk = 10
filling = 0.5

mf = meanfield.guess(h, "Haldane")  # initialization
scf = meanfield.Vinteraction(h, mf=mf, V2=2.0, nk=nk, filling=filling, mix=0.1)
h = scf.hamiltonian  # get the Hamiltonian
h.get_bands()  # calculate band structure
from pygra import topology
groundstate.hopping(h)
topology.write_berry(h)
Beispiel #11
0
import numpy as np
from pygra import geometry
from pygra import scftypes
from pygra import meanfield
import os
g = geometry.honeycomb_lattice()
h0 = g.get_hamiltonian()  # create hamiltonian of the system
ds = []
Us = np.linspace(0.0, 10.0, 10)
f = open("DELTA_VS_T_VS_MU.OUT", "w")
h0.add_swave(0.0)
for U in Us:
    h = h0.copy()
    os.system("rm -rf *.pkl")
    #scf = scftypes.attractive_hubbard(h,nk=10,mix=0.9,mf=None,g=-2.0,T=t)
    mf = 10 * (meanfield.guess(h, "swave") + meanfield.guess(h, "CDW"))
    mf = meanfield.guess(h, "swave")  #+ meanfield.guess(h,"CDW"))
    mf = meanfield.guess(h, "random")  #+ meanfield.guess(h,"CDW"))
    scf = meanfield.hubbardscf(
        h,
        nk=10,
        mix=0.5,
        U=-U,
        mf=mf,
        filling=0.5,
        verbose=1,
        constrains=["no_charge"]  # this forces the system to ignore CDW
    )
    hscf = scf.hamiltonian
    #  rho = hscf.get_filling()
    d = np.abs(np.mean(hscf.extract("swave")))
Beispiel #12
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 meanfield
g = geometry.honeycomb_lattice()
h = g.get_hamiltonian()  # create hamiltonian of the system
h.add_swave(0.001)  # add swave
mf = meanfield.guess(h, mode="swave", fun=0.02)
scf = meanfield.hubbardscf(h, nk=5, mf=mf, U=-2.0, filling=0.7)
h = scf.hamiltonian
print("Delta", h.extract("swave"))
print("Onsite", h.extract("density"))
h.write_swave()
h.get_bands()
#scf.hamiltonian.get_bands(operator="electron")
Beispiel #13
0


# 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,"kekule")
#mf = None
scf = meanfield.Vinteraction(h,V1=6.0,mf=mf,
        V2=4.0,nk=nk,filling=filling,mix=0.3)
h = scf.hamiltonian # get the Hamiltonian
h.get_bands(operator="valley") # 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)





Beispiel #14
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
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
Beispiel #15
0
# if you wanted to modify the Hamiltonian, just put here your data
# h.geometry.r = rs # new positions
# h.geometry.r2xyz() # update
# h.geometry.a1 = a1 # first lattice vector
# h.geometry.a2 = a2 # second lattice vector
# h.intra = intra # your (spinless) intra cell hopping
# h.tx = tx # your (spinless) (1,0,0) hopping matrix
# h.ty = ty # your (spinless) (0,1,0) hopping matrix
# h.txy = txy # your (spinless) (1,1,0) hopping matrix
# h.txmy = txmy # your (spinless) (1,-1,0) hopping matrix

# now make the Hamiltonian spinful
h.turn_spinful()

# let us do now a mean field calculation
from pygra import meanfield

mf = meanfield.guess(h, "randomXY")  # random initial guess in XY plane
# if you want to restart a calculation, just uncomment the mf=None line
# that will force the code to pick the latest mean field from a file
#mf = None
scf = meanfield.hubbardscf(h,
                           U=6.0,
                           mf=mf,
                           verbose=1,
                           filling=0.5,
                           nk=6,
                           mix=0.5)  # perform SCF calculation
# this will write the magnetization to MAGNETISM.OUT
scf.hamiltonian.write_magnetization(nrep=2)  # write magnetization in a file
Beispiel #16
0
g = geometry.diamond_lattice()
g = films.geometry_film(g, nz=4)
#g = g.supercell(3)
ii = g.get_central()[0]
#print(ii)
#g = g.remove(i=ii)
g.write()
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"))
Beispiel #17
0
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)
Beispiel #18
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 meanfield

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 = 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, 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")  # save in a file

f.close()
Beispiel #19
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 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)
Beispiel #20
0
g = geometry.chain()
#g = g.supercell(2)
h = g.get_hamiltonian()  # create hamiltonian of the system

# 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("##########################################")