from ase import *
from ase.dft import Wannier
from gpaw import restart

atoms, calc = restart('poly.gpw', txt=None)

# Make wannier functions using (one) extra degree of freedom
wan = Wannier(nwannier=6, calc=calc, fixedenergy=1.5)
wan.localize()
wan.save('poly.pickle')
wan.translate_all_to_cell((2, 0, 0))
for i in range(wan.nwannier):
    wan.write_cube(i, 'polyacetylene_%i.cube' % i)

# Print Kohn-Sham bandstructure
ef = calc.get_fermi_level()
f = open('KSbands.txt', 'w')
for k, kpt_c in enumerate(calc.get_ibz_k_points()):
    for eps in calc.get_eigenvalues(kpt=k):
        print >> f, kpt_c[0], eps - ef

# Print Wannier bandstructure
f = open('WANbands.txt', 'w')
for k in np.linspace(-.5, .5, 100):
    for eps in np.linalg.eigvalsh(wan.get_hamiltonian_kpoint([k, 0, 0])).real:
        print >> f, k, eps - ef
from gpaw import restart
from ase.dft import Wannier

atoms, calc = restart('benzene.gpw', txt=None)

# Make wannier functions of occupied space only
wan = Wannier(nwannier=15, calc=calc)
wan.localize()
for i in range(wan.nwannier):
    wan.write_cube(i, 'benzene15_%i.cube' % i)

# Make wannier functions using (three) extra degrees of freedom.
wan = Wannier(nwannier=18, calc=calc, fixedstates=15)
wan.localize()
wan.save('wan18.pickle')
for i in range(wan.nwannier):
    wan.write_cube(i, 'benzene18_%i.cube' % i)
import numpy as np
import matplotlib.pyplot as plt
from ase.dft import Wannier
from gpaw import restart

atoms, calc = restart('benzene.gpw', txt=None)
wan = Wannier(nwannier=18, calc=calc, fixedstates=15, file='wan18.pickle')

weight_n = np.sum(abs(wan.V_knw[0])**2, 1)
N = len(weight_n)
F = wan.fixedstates_k[0]
plt.figure(1, figsize=(12, 4))
plt.bar(range(1, N + 1), weight_n, width=0.65, bottom=0,
        color='k', edgecolor='k', linewidth=None,
        align='center', orientation='vertical')
plt.plot([F + 0.5, F + 0.5], [0, 1], 'k--')
plt.axis(xmin=0.32, xmax=N + 1.33, ymin=0, ymax=1)
plt.xlabel('Eigenstate')
plt.ylabel('Projection of wannier functions')
plt.savefig('spectral_weight.png')
plt.show()
Exemple #4
0
from ase.dft import Wannier
from gpaw import GPAW
from gpaw.test import equal

# Test of ase wannier using gpaw

calc = GPAW(gpts=(32, 32, 32), nbands=4)
atoms = molecule('H2', calculator=calc)
atoms.center(vacuum=3.)
e = atoms.get_potential_energy()
niter = calc.get_number_of_iterations()

pos = atoms.positions + np.array([[0, 0, .2339], [0, 0, -.2339]])
com = atoms.get_center_of_mass()

wan = Wannier(nwannier=2, calc=calc, initialwannier='bloch')
equal(wan.get_functional_value(), 2.964, 1e-3)
equal(np.linalg.norm(wan.get_centers() - [com, com]), 0, 1e-4)

wan = Wannier(nwannier=2, calc=calc, initialwannier='projectors')
equal(wan.get_functional_value(), 3.100, 2e-3)
equal(np.linalg.norm(wan.get_centers() - pos), 0, 1e-3)

wan = Wannier(nwannier=2, calc=calc, initialwannier=[[0, 0, .5], [1, 0, .5]])
equal(wan.get_functional_value(), 3.100, 2e-3)
equal(np.linalg.norm(wan.get_centers() - pos), 0, 1e-3)

wan.localize()
equal(wan.get_functional_value(), 3.100, 2e-3)
equal(np.linalg.norm(wan.get_centers() - pos), 0, 1e-3)
equal(np.linalg.norm(wan.get_radii() - 1.2393), 0, 2e-3)
Exemple #5
0
from ase.dft import Wannier
from gpaw import GPAW
from gpaw.test import equal

# Test of ase wannier using gpaw

calc = GPAW(gpts=(32, 32, 32), nbands=4)
atoms = molecule('H2', calculator=calc)
atoms.center(vacuum=3.)
e = atoms.get_potential_energy()
niter = calc.get_number_of_iterations()

pos = atoms.positions + np.array([[0, 0, .2339], [0, 0, -.2339]])
com = atoms.get_center_of_mass()

wan = Wannier(nwannier=2, calc=calc, initialwannier='bloch')
equal(wan.get_functional_value(), 2.964, 1e-3)
equal(np.linalg.norm(wan.get_centers() - [com, com]), 0, 1e-4)

wan = Wannier(nwannier=2, calc=calc, initialwannier='projectors')
equal(wan.get_functional_value(), 3.100, 1e-3)
equal(np.linalg.norm(wan.get_centers() - pos), 0, 1e-3)

wan = Wannier(nwannier=2, calc=calc, initialwannier=[[0, 0, .5], [1, 0, .5]])
equal(wan.get_functional_value(), 3.100, 1e-3)
equal(np.linalg.norm(wan.get_centers() - pos), 0, 1e-3)

wan.localize()
equal(wan.get_functional_value(), 3.100, 1e-3)
equal(np.linalg.norm(wan.get_centers() - pos), 0, 1e-3)
equal(np.linalg.norm(wan.get_radii() - 1.2393), 0, 1e-4)
import numpy as np

from ase.dft import Wannier
from gpaw import restart

atoms, calc = restart('poly.gpw', txt=None)

# Make wannier functions using (one) extra degree of freedom
wan = Wannier(nwannier=6, calc=calc, fixedenergy=1.5)
wan.localize()
wan.save('poly.pickle')
wan.translate_all_to_cell((2, 0, 0))
for i in range(wan.nwannier):
    wan.write_cube(i, 'polyacetylene_%i.cube' % i)

# Print Kohn-Sham bandstructure
ef = calc.get_fermi_level()
f = open('KSbands.txt', 'w')
for k, kpt_c in enumerate(calc.get_ibz_k_points()):
    for eps in calc.get_eigenvalues(kpt=k):
        print >> f, kpt_c[0], eps - ef

# Print Wannier bandstructure
f = open('WANbands.txt', 'w')
for k in np.linspace(-.5, .5, 100):
    for eps in np.linalg.eigvalsh(wan.get_hamiltonian_kpoint([k, 0, 0])).real:
        print >> f, k, eps - ef