Coverage for gpaw/test/wannier/test_pe.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-12 00:18 +0000

1"""Poly-ethylene 1-d chain.""" 

2import pytest 

3import numpy as np 

4from ase.neighborlist import neighbor_list 

5 

6from gpaw import GPAW 

7from gpaw.wannier import calculate_overlaps 

8 

9 

10def check(atoms, rcut=0.8): 

11 """Make sure all Wannier function centers have two neighbors.""" 

12 atoms.wrap() 

13 i = neighbor_list('i', atoms, rcut) 

14 nneighbors = np.bincount(i) 

15 for symbol, nn in zip(atoms.symbols, nneighbors): 

16 if symbol == 'X': 

17 assert nn == 2 

18 

19 

20@pytest.mark.wannier 

21@pytest.mark.serial 

22def test_pe_w90(gpw_files, in_tmp_dir, wannier90): 

23 calc = GPAW(gpw_files['c2h4_pw_nosym']) 

24 o = calculate_overlaps(calc, n2=6, nwannier=6, 

25 projections={'C': 's', 'H': 's'}) 

26 w = o.localize_w90('pe') 

27 check(w.centers_as_atoms()) 

28 

29 

30@pytest.mark.wannier 

31@pytest.mark.serial 

32def test_pe_er(gpw_files): 

33 calc = GPAW(gpw_files['c6h12_pw']) 

34 o = calculate_overlaps(calc, n2=3 * 6, nwannier=18) 

35 w = o.localize_er() 

36 check(w.centers_as_atoms())