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
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() dn = H.converge(density.calc_n_insulator, tol=1e-10, mixer=mixer) eAFM = H.Etot H.write_density('clar-goblet.nc') n_AFM = H.n.copy() if u == 3.5: p = plot.SpinPolarization(H, colorbar=True, vmax=0.4, vmin=-0.4) p.savefig('spin_pol_U%i_AFM.pdf' % (H.U * 1000)) # Now FM case H.q[0] += 1 # change to two more up-electrons than down H.q[1] -= 1 success = H.read_density( 'clar-goblet.nc') # Try reading, if we already have density on file if not success: H.random_density()
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) # First create NEGF object negf = NEGF(MFH_HC, [(MFH_elec, '-A'), (MFH_elec, '+A')], elec_indx) # Converge using Green's function method to obtain the densities dn = MFH_HC.converge(negf.calc_n_open, steps=1, mixer=sisl.mixing.PulayMixer(weight=.1), tol=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( 'fig3_type1.nc') # Try reading, if we already have density on file if not success: H.set_polarization([23]) mixer = sisl.mixing.PulayMixer(0.7, history=7) H.converge(density.calc_n_insulator, mixer=mixer) H.write_density('fig3_type1.nc') p = plot.SpinPolarization(H, ext_geom=mol, vmax=0.20) p.savefig('fig3_pol.pdf')
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: print('Total energy difference: %.4e eV' % (Etot0 - H.Etot)) # Eigenvalues are easy to check if np.allclose(ev1, ev0): print('Eigenvalue check passed') else: # Could be that up and down spins are interchanged print( 'Warning: Engenvalues for up-spins different. Checking down-spins instead' ) ev1, evec1 = H.eigh(eigvals_only=False, spin=1) if np.allclose(ev1, ev0):
# 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') # Find Fermi level of reservoirs and write to netcdf file Ef_elecs = MFH_elec.fermi_level(q=MFH_elec.q) MFH_elec.H.shift(-Ef_elecs) MFH_elec.H.write('MFH_elec.nc') # Build central region TB Hamiltonian HC = H_elec.tile(16, axis=0) HC = HC.remove([67, 68, 69, 72, 73, 74, 77, 78, 79, 82, 83, 84, 87, 88, 89]) HC.set_nsc([1, 1, 1])
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')
# 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') # Find Fermi level of reservoirs and write to netcdf file dist = sisl.get_distribution('fermi_dirac', smearing=kT) Ef_elecs = MFH_elec.H.fermi_level(MFH_elec.mp, q=MFH_elec.q, distribution=dist) MFH_elec.H.shift(-Ef_elecs) MFH_elec.H.write('MFH_elec.nc') # Central region is a repetition of the electrodes without PBC HC = H_elec.tile(10, axis=0)
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 Hsp2 = sp2(molecule, spin='unpolarized') H = HubbardHamiltonian(Hsp2, U=2.0)