Example #1
0
def check(calc):
    wannier = Wannier(calc, nbands=6)
    wannier.localize()

    centers = wannier.get_centers()
    print centers
    expected = [[1.950, 2.376, 3.000], [1.950, 3.624, 3.000],
                [3.000, 3.000, 2.671], [3.000, 3.000, 3.329],
                [4.050, 2.376, 3.000], [4.050, 3.624, 3.000]]
    equal(13.7995, wannier.value, 0.016)
    for center in centers:
        i = 0
        while np.sum((expected[i] - center)**2) > 0.01:
            i += 1
            if i == len(expected):
                raise RuntimeError, 'Correct center not found'
    expected.pop(i)
Example #2
0
def check(calc):
    wannier = Wannier(calc, nbands=6)
    wannier.localize()

    centers = wannier.get_centers()
    print centers
    expected = [[1.950, 2.376, 3.000],
                [1.950, 3.624, 3.000],
                [3.000, 3.000, 2.671],
                [3.000, 3.000, 3.329],
                [4.050, 2.376, 3.000],
                [4.050, 3.624, 3.000]]
    equal(13.7995, wannier.value, 0.016)
    for center in centers:
        i = 0
        while np.sum((expected[i] - center)**2) > 0.01:
            i += 1
            if i == len(expected):
                raise RuntimeError, 'Correct center not found'
    expected.pop(i)
Example #3
0
from ase import Atoms
from ase.structure import molecule
from ase.visualize import view
from gpaw import GPAW
from gpaw.wannier import Wannier

calc = GPAW(nbands=5)
atoms = molecule('CO')
atoms.center(vacuum=3.)
atoms.set_calculator(calc)
atoms.get_potential_energy()

# Initialize the Wannier class
w = Wannier(calc)
w.localize()
centers = w.get_centers()
view(atoms + Atoms(symbols='X5', positions=centers))
Example #4
0
from ase import Atoms
from ase.io import write
from ase.visualize import view
from gpaw import restart
from gpaw.wannier import Wannier

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

h**o = calc.get_pseudo_wave_function(band=14)
write('h**o.cube', atoms, data=h**o)

# Initialize the Wannier class
w = Wannier(calc)
w.localize()
centers = w.get_centers()
view(atoms + Atoms(symbols='X15', positions=centers))

# Find the index of the center with the lowest y-coordinate:
nsigma = centers[:, 1].argmin()
sigma = w.get_function(calc, nsigma)

write('benzene.xyz', atoms)
write('sigma.cube', atoms, data=sigma)
Example #5
0
from ase import Atoms
from ase.io import write
from ase.visualize import view
from gpaw import restart
from gpaw.wannier import Wannier

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

h**o = calc.get_pseudo_wave_function(band=14)
write('h**o.cube', atoms, data=h**o)
write('h**o.plt', atoms, data=h**o)

# Initialize the Wannier class
w = Wannier(calc)
w.localize()
centers = w.get_centers()
view(atoms + Atoms(symbols='X15', positions=centers))

# Find the index of the center with the lowest y-coordinate:
nsigma = centers[:, 1].argmin()
sigma = w.get_function(calc, nsigma)

write('benzene.xyz', atoms)
write('sigma.cube', atoms, data=sigma)
write('sigma.plt', atoms, data=sigma)
Example #6
0
if 1:
    # GPAW calculator:
    calc = GPAW(nbands=natoms // 2 + 4,
                kpts=kpts,
                width=.1,
                spinpol=False,
                convergence={'eigenstates': 1e-7})
    atoms.set_calculator(calc)
    atoms.get_potential_energy()
    calc.write('hwire%s.gpw' % natoms, 'all')
else:
    calc = GPAW('hwire%s.gpw' % natoms, txt=None)

wannier = Wannier(
    numberofwannier=natoms,
    calculator=calc,
    occupationenergy=occupationenergy,
)
#                  initialwannier=[[[1.* i / natoms, .5, .5], [0,], .5]
#                                  for i in range(natoms)])

wannier.localize()
wannier.translate_all_wannier_functions_to_cell([1, 0, 0])

centers = wannier.get_centers()
for i in wannier.get_sorted_indices():
    center = centers[i]['pos']
    print center
    quotient = round(center[0] / hhbondlength)
    equal(hhbondlength * quotient - center[0], 0., 2e-3)
    equal(center[1], 4., 2e-3)
Example #7
0
if 1:
    # GPAW calculator:
    calc = GPAW(nbands=natoms // 2 + 4,
                      kpts=kpts,
                      width=.1,
                      spinpol=False,
                      convergence={'eigenstates': 1e-7})
    atoms.set_calculator(calc)
    atoms.get_potential_energy()
    calc.write('hwire%s.gpw' % natoms, 'all')
else:
    calc = GPAW('hwire%s.gpw' % natoms, txt=None)

wannier = Wannier(numberofwannier=natoms,
                  calculator=calc,
                  occupationenergy=occupationenergy,)
#                  initialwannier=[[[1.* i / natoms, .5, .5], [0,], .5]
#                                  for i in range(natoms)])

wannier.localize()
wannier.translate_all_wannier_functions_to_cell([1, 0, 0])

centers = wannier.get_centers()
for i in wannier.get_sorted_indices():
    center = centers[i]['pos']
    print center
    quotient = round(center[0] / hhbondlength)
    equal(hhbondlength*quotient - center[0], 0., 2e-3)
    equal(center[1], 4., 2e-3)
    equal(center[2], 4., 2e-3)