Пример #1
0
 def test_NC(self):
     g = geometry.square_lattice()
     h = g.get_hamiltonian()
     mf = scftypes.guess(h,mode="antiferro",fun=0.0001)
     scf0 = scftypes.selfconsistency(h,mf=mf,nkp=5,filling=0.5,
             mode="Hubbard",silent=True)
     scf1 = scftypes.selfconsistency(h,mf=mf,nkp=5,filling=0.5,
             mode="Hubbard collinear",silent=True)
     passed = scf0.total_energy - scf1.total_energy
     passed = abs(passed)<error
     self.assertTrue(passed)
Пример #2
0
 def test_NC(self):
     g = geometry.square_lattice()
     h = g.get_hamiltonian()
     mf = scftypes.guess(h, mode="antiferro", fun=0.0001)
     scf0 = scftypes.selfconsistency(h,
                                     mf=mf,
                                     nkp=5,
                                     filling=0.5,
                                     mode="Hubbard",
                                     silent=True)
     scf1 = scftypes.selfconsistency(h,
                                     mf=mf,
                                     nkp=5,
                                     filling=0.5,
                                     mode="Hubbard collinear",
                                     silent=True)
     passed = scf0.total_energy - scf1.total_energy
     passed = abs(passed) < error
     self.assertTrue(passed)
Пример #3
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 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()
Пример #4
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()
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")
Пример #5
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 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
Пример #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
g = geometry.honeycomb_lattice()
h = g.get_hamiltonian()  # create hamiltonian of the system
h = h.get_multicell()
h.shift_fermi(0.6)
h.add_swave(0.0)
mf = scftypes.guess(h, mode="swave", fun=0.02)
mode = {"U": -2}
from pygra import algebra
algebra.accelerate = True
scf = scftypes.selfconsistency(h, nkp=5, mix=0.9, mf=None, mode=mode)

h = scf.hamiltonian
print(h.extract("swave"))
h.write_swave()
#scf.hamiltonian.get_bands(operator="electron")
Пример #7
0
import os ; import sys ; sys.path.append(os.environ['PYGRAROOT'])

from pygra import geometry
from pygra import scftypes
import numpy as np
# create the hamiltonian
g = geometry.triangular_lattice() # triangular lattice geometry
h0 = g.get_hamiltonian(has_spin=True) # create hamiltonian of the system
###################

# perform the SCF calculation
mf = scftypes.guess(h0,"ferro",fun=[1.,0.,0.]) # in-plane guess
scf = scftypes.selfconsistency(h0,filling=0.5,nkp=20,g=10.0,
           mf=mf,mix=0.8,maxerror=1e-6)
hscf = scf.hamiltonian # save the selfconsistent Hamiltonian
hscf.get_bands(operator="sz") # compute the SCF bandstructure
#########################

# Now compute energies for different rotations
# mesh of quvectors for the spin spiral
qs = np.linspace(-1,1,20) # loop over qvectors
fo = open("STIFFNESS.OUT","w") # open file
for qx in qs: # loop over qx
  for qy in qs: # loop over qy
    # Compute the energy by rotating the previous ground state
    ############################
    h = hscf.copy() # copy SCF Hamiltonian
    # create the qvector of the rotation
    # get the vector in natural units (assume input is in the real BZ)
    q = h.geometry.reciprocal2natural([qx,qy,0.]) 
Пример #8
0
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
    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 ##
Пример #9
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 scipy.sparse import csc_matrix
g = geometry.honeycomb_lattice()
h = g.get_hamiltonian() # create hamiltonian of the system
mf = scftypes.guess(h,mode="antiferro")
U = 3.0
scf = scftypes.selfconsistency(h,nkp=10,filling=0.5,g=U,
              mix=0.9,mf=mf,mode="U")
h = scf.hamiltonian # get the Hamiltonian
h.write_magnetization()
h.get_bands() # calculate band structure
Пример #10
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 scftypes
from pygra import operators
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.selfconsistency(h,nkp=30,filling=0.5,mf=mf,
             mode="Hubbard collinear")
h = scf.hamiltonian # get the Hamiltonian
h.get_bands(operator=operators.get_sz(h)) # calculate band structure
Пример #11
0
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
  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,
Пример #12
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()
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)


Пример #13
0
from pygra import geometry
from pygra import scftypes
import numpy as np
# create the hamiltonian
g = geometry.triangular_lattice() # triangular lattice geometry
h0 = g.get_hamiltonian(has_spin=True) # create hamiltonian of the system
###################

# perform the SCF calculation
mf = scftypes.guess(h0,"ferro",fun=[1.,0.,0.]) # in-plane guess
scf = scftypes.selfconsistency(h0,filling=0.5,nkp=20,g=10.0,
           mf=mf,mix=0.8,maxerror=1e-6)
hscf = scf.hamiltonian # save the selfconsistent Hamiltonian
hscf.get_bands(operator="sz") # compute the SCF bandstructure
#########################

# Now compute energies for different rotations
# mesh of quvectors for the spin spiral
qs = np.linspace(-1,1,20) # loop over qvectors
fo = open("STIFFNESS.OUT","w") # open file
for qx in qs: # loop over qx
  for qy in qs: # loop over qy
    # Compute the energy by rotating the previous ground state
    ############################
    h = hscf.copy() # copy SCF Hamiltonian
    # create the qvector of the rotation
    # get the vector in natural units (assume input is in the real BZ)
    q = h.geometry.reciprocal2natural([qx,qy,0.]) 
    # This is the direction around which we rotate the magnetization
    vector = [0.,0.,1.]
    # rotate the Hamiltonian
Пример #14
0
#ps = [0.1]
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
  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
Пример #15
0
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
  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"
Пример #16
0
import numpy as np
from pygra import geometry
from pygra import scftypes
from pygra import operators
from scipy.sparse import csc_matrix
from pygra import parallel

#parallel.cores = 4
g = geometry.triangular_lattice()
#g = geometry.bichain()
g = g.supercell(6)
#g = geometry.triangular_lattice()
#g = g.supercell(3)
h = g.get_hamiltonian(has_spin=True)  # create hamiltonian of the system
h = h.get_multicell()
mf = scftypes.guess(h, mode="ferro", fun=1.0)


def vfun(r):
    if r < 1e-2: return 0.0
    else: return 2.0 * np.exp(-r)


scf = scftypes.selfconsistency(h,
                               nkp=10,
                               filling=0.5,
                               g=3.0,
                               mix=0.9,
                               mf=mf,
                               mode="fastCoulomb",
                               vfun=vfun)