Пример #1
0
from hubbard import HubbardHamiltonian, sp2, plot, density
import sys
import numpy as np
import sisl

# Build sisl Geometry object
mol_file = '3-anthracene'
mol = sisl.get_sile(mol_file + '.XV').read_geometry()
mol.sc.set_nsc([1, 1, 1])
mol = mol.move(-mol.center(what='xyz'))

# 3NN tight-binding model
Hsp2 = sp2(mol, t1=2.7, t2=0.2, t3=.18)
H = HubbardHamiltonian(Hsp2)

# Output file to collect the energy difference between
# FM and AFM solutions
f = open('FM-AFM.dat', 'w')

mixer = sisl.mixing.PulayMixer(0.7, history=7)

for u in np.linspace(0.0, 4.0, 5):
    # We approach the solutions from above, starting at U=4eV
    H.U = 4.0 - u

    # AFM case first
    success = H.read_density(
        mol_file + '.nc')  # Try reading, if we already have density on file
    if not success:
        H.random_density()
        H.set_polarization([1, 6, 15])  # polarize lower zigzag edge
Пример #2
0
from hubbard import HubbardHamiltonian, sp2, ncsile
import sisl
import numpy as np

# Build sisl Geometry object only for a subset of atoms
molecule = sisl.get_sile('mol-ref/mol-ref.XV').read_geometry().sub([2,3,5])
molecule.sc.set_nsc([1, 1, 1])

# Build HubbardHamiltonian object
Hsp2 = sp2(molecule)
H = HubbardHamiltonian(Hsp2, U=3.5)
# Generate simple density
H.n = np.ones((2, H.sites))*0.5

print(f'1. Write and read densities under group {H.get_hash()} using the HubbardHamiltonian class\n')
# Write density in file
H.write_density('mol-ref/test.HU.nc', group=H.get_hash(), mode='w')
# Read density using the HubbardHamiltonian class
H.read_density('mol-ref/test.HU.nc', group=H.get_hash())

# Write another density in file under another group
print(f'2. Write another densities under another group\n')
H.n *= 2
H.write_density('mol-ref/test.HU.nc', group='group2', mode='a')


print('3. Read density, U and kT using ncsile from all groups')
fh = sisl.get_sile('mol-ref/test.HU.nc', mode='r')
for g in fh.groups:
    print('group: ', g)
    print('n:', fh.read_density(group=g))
Пример #3
0
from hubbard import HubbardHamiltonian, plot, sp2
import sys
import numpy as np
import sisl

# Build sisl Geometry object
mol = sisl.get_sile('junction-2-2.XV').read_geometry()
mol.sc.set_nsc([1, 1, 1])
mol = mol.move(-mol.center(what='xyz')).rotate(220, [0, 0, 1])
Hsp2 = sp2(mol)

# 3NN tight-binding model
H = HubbardHamiltonian(Hsp2, U=0)

# Plot Eigenspectrum
p = plot.Spectrum(H, ymax=0.12)
p.set_title(r'3NN, $U=%.2f$ eV' % H.U)
p.savefig('eigenspectrum_U%i.pdf' % (H.U * 100))

# Plot H**O and LUMO level wavefunctions for up- and down-electrons for U=3.5 eV
spin = ['up', 'dn']
N = H.q
for i in range(1):
    ev, evec = H.eigh(eigvals_only=False, spin=i)
# Use midgap as energy reference
midgap = H.find_midgap()
ev -= midgap
f = 1
v = evec[:, int(round(N[i])) - 1]
j = np.argmax(abs(v))
wf = f * v**2 * np.sign(v[j]) * np.sign(v)
Пример #4
0
from hubbard import HubbardHamiltonian, sp2, density, NEGF
import sisl

# Build sisl Geometry object
molecule = sisl.get_sile('mol-ref/mol-ref.XV').read_geometry()
molecule.sc.set_nsc([1, 1, 1])

print('1. Run one iteration with calc_n_insulator')
Hsp2 = sp2(molecule)
H = HubbardHamiltonian(Hsp2, U=3.5)
H.random_density()
dn = H.iterate(density.calc_n_insulator, mixer=sisl.mixing.LinearMixer())
print('   dn, Etot: ', dn, H.Etot, '\n')

print('2. Run one iteration with data from ncfile')
H.read_density('mol-ref/density.nc', group='3abe772')
dn = H.iterate(density.calc_n_insulator, mixer=sisl.mixing.LinearMixer())
etot = 1 * H.Etot
print('   dn, Etot: ', dn, etot, '\n')

print('3. Run one iteration with calc_n')
d = H.iterate(density.calc_n, mixer=sisl.mixing.LinearMixer())
e = H.Etot
print('   dn, dEtot: ', d - dn, e - etot, '\n')

# Write fdf-block
print('\n4. Write initspin to fdf-block')
H.write_initspin('test.fdf', mode='w')

import random
print('5. Run one iteration for spin-degenerate calculation')
Пример #5
0
from hubbard import HubbardHamiltonian, density, plot, sp2
import sys
import numpy as np
import sisl

# Build sisl Geometry object
mol = sisl.get_sile('junction-2-2.XV').read_geometry()
mol.sc.set_nsc([1, 1, 1])
# 3NN tight-binding model
Hsp2 = sp2(mol, t1=2.7, t2=0.2, t3=.18)

H = HubbardHamiltonian(Hsp2)

# Output file to collect the energy difference between
# FM and AFM solutions
f = open('FM-AFM.dat', 'w')

mixer = sisl.mixing.PulayMixer(0.7, history=7)
H.set_polarization([77], dn=[23])
for u in np.linspace(0.0, 1.4, 15):
    # We approach the solutions from above, starting at U=4eV
    H.U = 4.4 - u
    # AFM case first
    success = H.read_density(
        'fig_S15.nc')  # Try reading, if we already have density on file

    mixer.clear()
    dn = H.converge(density.calc_n_insulator, mixer=mixer, tol=1e-6)
    eAFM = H.Etot
    H.write_density('fig_S15.nc')
Пример #6
0
import sys
import matplotlib.pyplot as plt
from hubbard import HubbardHamiltonian, density, sp2, NEGF

# Set U and kT for the whole calculation
U = 3.
kT = 0.025

# Build zigzag GNR
ZGNR = sisl.geom.zgnr(2)

# and 3NN TB Hamiltonian
H_elec = sp2(ZGNR, t1=2.7, t2=0.2, t3=0.18)

# Hubbard Hamiltonian of elecs
MFH_elec = HubbardHamiltonian(H_elec, U=U, nkpt=[102, 1, 1], kT=kT)

# Start with random densities
MFH_elec.random_density()
# Converge Electrode Hamiltonians
dn = MFH_elec.converge(density.calc_n, mixer=sisl.mixing.PulayMixer(weight=.7, history=7), tol=1e-10)

# Central region is a repetition of the electrodes without PBC
HC = H_elec.tile(3, axis=0)
HC.set_nsc([1, 1, 1])

# Map electrodes in the device region
elec_indx = [range(len(H_elec)), range(len(HC.H)-len(H_elec), len(HC.H))]

# MFH object
MFH_HC = HubbardHamiltonian(HC.H, n=np.tile(MFH_elec.n, 3), U=U, kT=kT)
Пример #7
0
from hubbard import HubbardHamiltonian, sp2, density
import sisl

# Build sisl Geometry object
molecule = sisl.get_sile('mol-ref/mol-ref.XV').read_geometry()
molecule.sc.set_nsc([1, 1, 1])

print('1. Run one iteration with calc_n_insulator')
Hsp2 = sp2(molecule)
H = HubbardHamiltonian(Hsp2, U=3.5)
H.random_density()
dn = H.iterate(density.calc_n_insulator, mixer=sisl.mixing.LinearMixer())
print('   dn, Etot: ', dn, H.Etot, '\n')

print('2. Run one iteration with data from ncfile')
H.read_density('mol-ref/density.nc')
dn = H.iterate(density.calc_n_insulator, mixer=sisl.mixing.LinearMixer())
etot = 1 * H.Etot
print('   dn, Etot: ', dn, etot, '\n')

print('3. Run one iteration with calc_n')
d = H.iterate(density.calc_n, mixer=sisl.mixing.LinearMixer())
e = H.Etot
print('   dn, dEtot: ', d - dn, e - etot, '\n')

# Write new data structure
print('4. Write data in ncfile')
H.write_density('mol-ref/test.nc', mode='w')

# Write fdf-block
print('\n5. Write initspin to fdf-block')
Пример #8
0
import sisl

# Test all plot functionalities of hubbard module
# using a reference molecule (already converged)

# Build sisl Geometry object
molecule = sisl.get_sile('mol-ref/mol-ref.XV').read_geometry()
molecule.sc.set_nsc([1, 1, 1])
molecule = molecule.move(-molecule.center(what='xyz')).rotate(220, [0, 0, 1])
H_mol = sp2(molecule)

p = plot.BondHoppings(H_mol, annotate=False, off_diagonal_only=False, cmap_e='winter')
p.legend()
p.savefig('bondHoppings.pdf')

H = HubbardHamiltonian(H_mol, U=3.5)
H.read_density('mol-ref/density.nc')
H.iterate(density.calc_n_insulator)

p = plot.Charge(H, ext_geom=molecule, colorbar=True)
p.savefig('chg.pdf')

p = plot.ChargeDifference(H, ext_geom=molecule, colorbar=True)
p.savefig('chgdiff.pdf')

p = plot.SpinPolarization(H, ext_geom=molecule, colorbar=True, vmax=0.2)
p.annotate()
p.savefig('pol.pdf')

H.H.shift(-H.find_midgap())
ev, evec = H.eigh(eigvals_only=False, spin=0)
Пример #9
0
'''

# Set U and kT for the whole calculation
U = 2.0
kT = 0.025

# Build zigzag GNR
ZGNR = sisl.geom.zgnr(5)

# and 3NN TB Hamiltonian
H_elec = sp2(ZGNR, t1=2.7, t2=0.2, t3=0.18)

mixer = sisl.mixing.PulayMixer(0.6, history=7)

# Hubbard Hamiltonian of elecs
MFH_elec = HubbardHamiltonian(H_elec, U=U, nkpt=[102, 1, 1], kT=kT)
# Initial densities
success = MFH_elec.read_density('elec_density.nc')
if not success:
    # If no densities saved, start with random densities with maximized polarization at the edges
    MFH_elec.random_density()
    MFH_elec.set_polarization([0], dn=[9])

# Converge Electrode Hamiltonians
dn = MFH_elec.converge(density.calc_n, mixer=mixer)
# Write also densities for future calculations
MFH_elec.write_density('elec_density.nc')
# Plot spin polarization of electrodes
p = plot.SpinPolarization(MFH_elec, colorbar=True)
p.savefig('spin_elecs.pdf')
Пример #10
0
from hubbard import HubbardHamiltonian, density, sp2
import numpy as np
import sisl

# Test quantitatively that densities and eigenvalue spectrum are unchanged
# using a reference molecule (already converged)

# Build sisl Geometry object
molecule = sisl.get_sile('mol-ref/mol-ref.XV').read_geometry()
molecule.sc.set_nsc([1, 1, 1])

# Try reading from file
Hsp2 = sp2(molecule)
H = HubbardHamiltonian(Hsp2, U=3.5)
H.read_density('mol-ref/density.nc')
H.iterate(density.calc_n_insulator, mixer=sisl.mixing.LinearMixer())

# Determine reference values for the tests
ev0, evec0 = H.eigh(eigvals_only=False, spin=0)
Etot0 = 1 * H.Etot

mixer = sisl.mixing.PulayMixer(0.7, history=7)

for m in [density.calc_n_insulator, density.calc_n]:
    # Reset density and iterate
    H.random_density()
    mixer.clear()
    dn = H.converge(m, tol=1e-10, steps=10, mixer=mixer, print_info=True)
    ev1, evec1 = H.eigh(eigvals_only=False, spin=0)

    # Total energy check:
Пример #11
0
# using a reference molecule (already converged)

# Build sisl Geometry object
molecule = sisl.get_sile('mol-ref/mol-ref.XV').read_geometry()
molecule.sc.set_nsc([1, 1, 1])
molecule = molecule.move(-molecule.center(what='xyz')).rotate(220, [0, 0, 1])
H_mol = sp2(molecule)

p = plot.BondHoppings(H_mol,
                      annotate=False,
                      off_diagonal_only=False,
                      cmap_e='winter')
p.legend()
p.savefig('bondHoppings.pdf')

H = HubbardHamiltonian(H_mol, U=3.5)
H.read_density('mol-ref/density.nc')
H.iterate(density.calc_n_insulator)

p = plot.Charge(H, ext_geom=molecule, colorbar=True)
p.savefig('chg.pdf')

p = plot.ChargeDifference(H, ext_geom=molecule, colorbar=True)
p.savefig('chgdiff.pdf')

p = plot.SpinPolarization(H, ext_geom=molecule, colorbar=True, vmax=0.2)
p.annotate()
p.savefig('pol.pdf')

ev, evec = H.eigh(eigvals_only=False, spin=0)
p = plot.Wavefunction(H, 500 * evec[:, 10], ext_geom=molecule, colorbar=True)
Пример #12
0
import sisl
from hubbard import HubbardHamiltonian, sp2, density, plot
import numpy as np
import os

""" Script to benchmark the Generalized TB method of Ref. Phys. Rev. B 81, 245402 (2010) """

# Create geometry of the periodic (along x-axis) ribbon
agnr = sisl.geom.agnr(14)
zgnr = sisl.geom.zgnr(16)

lab = ['14-AGNR', '16-ZGNR']
mixer = sisl.mixing.PulayMixer(0.7, history=7)
for i, geom in enumerate([agnr, zgnr]):
    # Build TB Hamiltonian, one can use the parameters from the Ref.
    H0 = sp2(geom, t1=2.7, t2=0.2, t3=0.18, s1=0, s2=0, s3=0)

    # Find self-consistent solution with MFH
    H = HubbardHamiltonian(H0, U=2, nkpt=[100, 1, 1])
    # Start with random densities
    H.random_density()
    mixer.clear()
    dn = H.converge(density.calc_n, mixer=mixer, print_info=True)

    # Plot banstructure of Hubbard Hamiltonian
    p = plot.Bandstructure(H, ymax=3)
    p.savefig('%s_bands.pdf'%(lab[i]))
    print('\n')
Пример #13
0
'''

# Set U and kT for the whole calculation
U = 2.0
kT = 0.025

# Build zigzag GNR
AGNR = sisl.geom.agnr(9)

# and 3NN TB Hamiltonian
H_elec = sp2(AGNR, t1=2.7, t2=0.2, t3=0.18)

mixer = sisl.mixing.PulayMixer(0.3, history=7)

# Hubbard Hamiltonian of elecs
MFH_elec = HubbardHamiltonian(H_elec, U=U, nkpt=[102, 1, 1], kT=0.025)
# Initial densities
success = MFH_elec.read_density('elec_density.nc')
if not success:
    # If no densities saved, start with random densities
    MFH_elec.random_density()

# Converge Electrode Hamiltonians
dn = MFH_elec.converge(density.calc_n, mixer=mixer)

# Write also densities for future calculations
MFH_elec.write_density('elec_density.nc')
# Plot spin polarization of electrodes
p = plot.SpinPolarization(MFH_elec, colorbar=True)
p.savefig('spin_elecs.pdf')
Пример #14
0
from hubbard import HubbardHamiltonian, plot, density, sp2
import sys
import numpy as np
import sisl

# Build sisl Geometry object
mol = sisl.get_sile('type1.xyz').read_geometry()
mol.sc.set_nsc([1, 1, 1])
mol = mol.move(-mol.center(what='xyz')).rotate(220, [0, 0, 1])
# 3NN tight-binding model
Hsp2 = sp2(mol, t1=2.7, t2=0.2, t3=.18)

H = HubbardHamiltonian(Hsp2)

# Plot the single-particle TB (U = 0.0) wavefunction (SO) for Type 1
H.U = 0.0
ev, evec = H.eigh(eigvals_only=False, spin=0)
N = H.q[0]
midgap = H.find_midgap()
ev -= midgap
f = 3800
v = evec[:, int(round(N)) - 1]
j = np.argmax(abs(v))
wf = f * v**2 * np.sign(v[j]) * np.sign(v)
p = plot.Wavefunction(H, wf)
p.set_title(r'$E = %.3f$ eV' % (ev[int(round(N)) - 1]))
p.savefig('Fig3_SOMO.pdf')

# Plot MFH spin polarization for U = 3.5 eV
H.U = 3.5
success = H.read_density(
Пример #15
0
from hubbard import HubbardHamiltonian, sp2
import numpy as np
import sisl

for w in range(1, 25, 2):
    g = sisl.geom.agnr(w)
    H0 = sp2(g)
    H = HubbardHamiltonian(H0, U=0)
    zak = H.get_Zak_phase()
    print(f'width={w:3}, zak={zak:7.3f}')

# SSH model, topological cell
g = sisl.Geometry([[0, 0, 0], [0, 1.65, 0]],
                  sisl.Atom(6, 1.001),
                  sc=[10, 3, 10])
g.set_nsc([1, 3, 1])
H0 = sp2(g)
H = HubbardHamiltonian(H0, U=0)
zak = H.get_Zak_phase(axis=1)
print(f'SSH topo : zak={zak:7.3f}')

# SSH model, trivial cell
g = sisl.Geometry([[0, 0, 0], [0, 1.42, 0]],
                  sisl.Atom(6, 1.001),
                  sc=[10, 3, 10])
g.set_nsc([1, 3, 1])
H0 = sp2(g)
H = HubbardHamiltonian(H0, U=0)
zak = H.get_Zak_phase(axis=1)
print(f'SSH triv : zak={zak:7.3f}')
Пример #16
0
import sisl
from sisl import geom, Atom
import numpy as np
import os
from hubbard import HubbardHamiltonian, sp2, density, plot

W = 7
bond = 1.42

# single-orbital
g = geom.zgnr(W)
TBHam = sp2(g, t1=2.7, t2=0, t3=0)
HH = HubbardHamiltonian(TBHam, U=3, nkpt=[100, 1, 1])
HH.set_polarization([0], dn=[-1])
HH.converge(density.calc_n, print_info=True, tol=1e-10, steps=3)
n_single = HH.n * 1

# Start bands-plot, the single-orbital case will be plotted in black
p = plot.Bandstructure(HH, c='k')


class OrbitalU(sisl.Orbital):
    __slots__ = ('U', )

    def __init__(self, *args, U=0., **kwargs):
        super().__init__(*args, **kwargs)
        self.U = U

    def copy(self, *args, **kwargs):
        copy = super().copy(*args, **kwargs)
        copy.U = self.U
Пример #17
0
import sys
import matplotlib.pyplot as plt
from hubbard import HubbardHamiltonian, density, sp2, NEGF

# Set U and kT for the whole calculation
U = 3.
kT = 0.025

# Build zigzag GNR
ZGNR = sisl.geom.zgnr(2)

# and 3NN TB Hamiltonian
H_elec = sp2(ZGNR, t1=2.7, t2=0.2, t3=0.18)

# Hubbard Hamiltonian of elecs
MFH_elec = HubbardHamiltonian(H_elec, U=U, nkpt=[102, 1, 1], kT=kT)

# Initialize spin densities
MFH_elec.set_polarization([0], dn=[-1])  # Ensure we break symmetry
# Converge Electrode Hamiltonians
dn = MFH_elec.converge(density.calc_n,
                       mixer=sisl.mixing.PulayMixer(weight=.7, history=7),
                       tol=1e-10)

# Central region is a repetition of the electrodes without PBC
HC = H_elec.tile(3, axis=0)
HC.set_nsc([1, 1, 1])

# Map electrodes in the device region
elec_indx = [range(len(H_elec)), range(len(HC.H) - len(H_elec), len(HC.H))]
Пример #18
0
from hubbard import HubbardHamiltonian, density, sp2, plot
import sys
import numpy as np
import sisl

# Build sisl Geometry object
mol = sisl.get_sile('clar-goblet.xyz').read_geometry()
mol.sc.set_nsc([1, 1, 1])
mol = mol.move(-mol.center(what='xyz'))

# 3NN tight-binding model
Hsp2 = sp2(mol, t1=2.7, t2=0.2, t3=.18, dim=2)
H = HubbardHamiltonian(Hsp2)
H.random_density()
H.set_polarization(up=[6], dn=[28])
n_AFM = H.n

f = open('FM-AFM.dat', 'w')

mixer = sisl.mixing.PulayMixer(0.7, history=7)

for u in np.arange(5, 0, -0.25):
    # We approach the solutions for different U values
    H.U = u
    mixer.clear()

    # AFM case first
    success = H.read_density(
        'clar-goblet.nc')  # Try reading, if we already have density on file
    if not success:
        H.n = n_AFM.copy()
Пример #19
0
from hubbard import HubbardHamiltonian, sp2, density, plot
import numpy as np
import sisl
"""
For this system we get an open-shell solution for U>3 eV
This test obtaines the closed-shell solution for U=2 eV for both a spin-polarized and unpolarized situation
"""

# Build sisl Geometry object
molecule = sisl.get_sile('mol-ref/mol-ref.XV').read_geometry()
molecule.sc.set_nsc([1, 1, 1])

Hsp2 = sp2(molecule)

H = HubbardHamiltonian(Hsp2, U=2.0)
H.set_polarization([36], [77])
dn = H.converge(density.calc_n_insulator,
                mixer=sisl.mixing.LinearMixer(),
                tol=1e-7)
print('Closed-shell spin-polarized calculation:')
print('dn: {}, Etot: {}\n'.format(dn, H.Etot))

p = plot.Plot()
for i in range(2):
    ev = H.eigh(spin=i) - H.find_midgap()
    ev = ev[abs(ev) < 2]
    p.axes.plot(ev,
                np.zeros_like(ev), ['or', 'xg'][i],
                label=[r'$\sigma=\uparrow$', r'$\sigma=\downarrow$'][i])

# Compute same system with spin degeneracy