Ejemplo n.º 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)
Ejemplo n.º 2
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))
Ejemplo n.º 3
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)