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')
# 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) p = plot.Wavefunction(H, 500 * evec[:, 10], ext_geom=molecule, colorbar=True)
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')