예제 #1
0
파일: scf.py 프로젝트: joselado/pygra
 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
파일: main.py 프로젝트: restart668/pygra
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)
예제 #4
0
파일: main.py 프로젝트: joselado/pygra
# 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)
예제 #5
0
# maximum distance to the origin
rmax = np.sqrt(np.max([ri.dot(ri) for ri in g.r]))
def fhop(r1,r2):
  """Function to calculate the hopping, it will create different hoppings
  for different atoms. The hopping becomes smaller the further the atom
  is from the origin"""
  tmax = 1.0 # minimum hopping
  tmin = 0.7 # maximum hopping
  dr = r1-r2 # vector between the two sites
  drmod = np.sqrt(dr.dot(dr)) # distance
  rm = (r1+r2)/2. # average position
  rmmod = np.sqrt(rm.dot(rm)) # value of the average position
  if 0.9<drmod<1.1: # if first neighbor
    lamb = rmmod/rmax # ratio between 0 and 1
    return tmax*(1.-lamb) + tmin*lamb
  else: return 0.0
fhop = None
h = g.get_hamiltonian(fun=fhop,has_spin=True) # get the Hamiltonian
h.add_zeeman([0.,.4,0.])
g.write()
mf = scftypes.guess(h,mode="antiferro")
scf = scftypes.selfconsistency(h,filling=0.5,g=1.0,
                mix=0.9,mf=mf,mode="U")
#scf.hamiltonian.get_bands()






예제 #6
0
파일: main.py 프로젝트: woal777/pygra
# 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
파일: main.py 프로젝트: woal777/pygra
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
파일: main.py 프로젝트: joselado/pygra
# 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
예제 #9
0
파일: main.py 프로젝트: joselado/pygra
# 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
예제 #10
0
파일: main.py 프로젝트: joselado/pygra
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
예제 #11
0
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)
h = scf.hamiltonian
h.get_bands(operator="sz")
#print(h.extract("density"))