def wan(calc):
    centers = [([0.125, 0.125, 0.125], 0, 1.5),
               ([0.125, 0.625, 0.125], 0, 1.5),
               ([0.125, 0.125, 0.625], 0, 1.5),
               ([0.625, 0.125, 0.125], 0, 1.5)]
    w = Wannier(4, calc,
                nbands=4,
                verbose=False,
                initialwannier=centers)
    w.localize()
    x = w.get_functional_value()
    centers = (w.get_centers(1) * k) % 1
    c = (centers - 0.125) * 2
    #print w.get_radii()  # broken! XXX
    assert abs(c.round() - c).max() < 0.03
    c = c.round().astype(int).tolist()
    c.sort()
    assert c == [[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0]]
    if 0:
        from ase.visualize import view
        from ase import Atoms
        watoms = calc.atoms + Atoms(symbols='X4',
                                    scaled_positions=centers,
                                    cell=calc.atoms.cell)
        view(watoms)
    return x
Exemple #2
0
def test_get_centers():
    # Rough test on the position of the Wannier functions' centers
    gpaw = pytest.importorskip('gpaw')
    calc = gpaw.GPAW(gpts=(32, 32, 32), nbands=4, txt=None)
    atoms = molecule('H2', calculator=calc)
    atoms.center(vacuum=3.)
    atoms.get_potential_energy()
    wanf = Wannier(nwannier=2, calc=calc, initialwannier='bloch')
    centers = wanf.get_centers()
    com = atoms.get_center_of_mass()
    assert np.abs(centers - [com, com]).max() < 1e-4
Exemple #3
0
 def _wan(gpts=(8, 8, 8),
          atoms=None,
          calc=None,
          nwannier=2,
          fixedstates=None,
          initialwannier='bloch',
          kpts=(1, 1, 1),
          file=None,
          rng=rng,
          full_calc=False,
          std_calc=True):
     if std_calc and calc is None and atoms is None:
         calc = std_calculator
     else:
         if calc is None:
             gpaw = pytest.importorskip('gpaw')
             calc = gpaw.GPAW(gpts=gpts,
                              nbands=nwannier,
                              kpts=kpts,
                              symmetry='off',
                              txt=None)
         if atoms is None and not full_calc:
             pbc = (np.array(kpts) > 1).any()
             atoms = molecule('H2', pbc=pbc)
             atoms.center(vacuum=3.)
         if not full_calc:
             atoms.calc = calc
             atoms.get_potential_energy()
     return Wannier(nwannier=nwannier,
                    fixedstates=fixedstates,
                    calc=calc,
                    initialwannier=initialwannier,
                    file=None,
                    rng=rng)
Exemple #4
0
def wan(calc):
    centers = [([0.125, 0.125, 0.125], 0, 1.5),
               ([0.125, 0.625, 0.125], 0, 1.5),
               ([0.125, 0.125, 0.625], 0, 1.5),
               ([0.625, 0.125, 0.125], 0, 1.5)]
    w = Wannier(4, calc,
                nbands=4,
                verbose=1,
                initialwannier=centers)
    w.localize()
    x = w.get_functional_value()
    centers = (w.get_centers(1) * k) % 1
    c = (centers - 0.125) * 2
    print(w.get_radii())  # broken! XXX
    assert abs(c.round() - c).max() < 0.03
    c = sorted(c.round().astype(int).tolist())
    assert c == [[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0]]
    if 0:
        from ase.visualize import view
        from ase import Atoms
        watoms = calc.atoms + Atoms(symbols='X4',
                                    scaled_positions=centers,
                                    cell=calc.atoms.cell)
        view(watoms)
    return x
Exemple #5
0
from ase.dft.wannier import Wannier
from gpaw import GPAW
from gpaw.mpi import world
calc = GPAW('Si-PBE.gpw', txt=None,
            parallel={'domain': world.size})
calc.wfs.ibz2bz(calc.atoms)
initial = [[(0.125, 0.125, 0.125), 0, 1.5],
           [(0.125, 0.625, 0.125), 0, 1.5],
           [(0.125, 0.125, 0.625), 0, 1.5],
           [(0.625, 0.125, 0.125), 0, 1.5]]
w = Wannier(4, calc,
            #fixedenergy=0.0,
            nbands=8,
            verbose=1,
            initialwannier=initial)
w.localize()
w.save('rotations.pckl')
from ase.dft.wannier import Wannier
from ase.units import Hartree
from ase.dft.kpoints import ibz_points, get_bandpath
from gpaw import GPAW
from gpaw.xc.tools import vxc
from gpaw.xc.hybridk import HybridXC

calc = GPAW('Si-PBE.gpw', txt=None)

pbe0 = HybridXC('PBE0', alpha=5.0)
de_skn = vxc(calc, pbe0) - vxc(calc, 'PBE')
de_kn = de_skn[0, calc.wfs.kd.bz2ibz_k]

calc.wfs.ibz2bz(calc.atoms)

w = Wannier(4, calc, 'rotations.pckl')

points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
kpts, x, X = get_bandpath([W, L, G, X, W, K], calc.atoms.cell)

epbe_kn = np.array([np.linalg.eigh(w.get_hamiltonian_kpoint(kpt))[0]
                    for kpt in kpts])

for kpt in calc.wfs.kpt_u:
    kpt.eps_n += de_kn[kpt.k] / Hartree