# 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: print('Total energy difference: %.4e eV' % (Etot0 - H.Etot)) # Eigenvalues are easy to check
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) p.savefig('wf.pdf') p = plot.Spectrum(H) p.savefig('spectrum.pdf') p = plot.DOSmap(H) p.savefig('2Ddos_map.pdf') p = plot.PDOS(H, np.linspace(-0.2, 0.2, 101)) p.savefig('total_dos.pdf') p = plot.PDOS(H, np.linspace(-0.2, 0.2, 101), sites=[60]) p.savefig('pdos_energy_resolved.pdf')
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) dn = H.converge(density.calc_n_insulator, mixer=sisl.mixing.LinearMixer(), tol=1e-7) print('Unpolarized calculation:') print('dn: {}, Etot: {}'.format(dn, H.Etot)) ev = H.eigh() - H.find_midgap()