Coverage for gpaw/test/symmetry/test_fractional_translations.py: 100%

21 statements  

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

1from ase.spacegroup import crystal 

2from gpaw import GPAW 

3from gpaw import PW 

4import pytest 

5 

6 

7def test_symmetry_fractional_translations(in_tmp_dir): 

8 'sishovite' 

9 # no 136 - tetragonal 

10 

11 a = 4.233944 

12 c = 2.693264 

13 p0 = (0, 0, 0) 

14 p1 = (0.306866, 0.306866, 0.0) 

15 

16 atoms = crystal(['Si', 'O'], basis=[p0, p1], 

17 spacegroup=136, cellpar=[a, a, c, 90, 90, 90]) 

18 

19 # with fractional translation 

20 calc = GPAW(mode=PW(), 

21 xc='LDA', 

22 kpts=(3, 3, 3), 

23 nbands=28, 

24 symmetry={'symmorphic': False}, 

25 gpts=(18, 18, 12), 

26 eigensolver='rmm-diis', 

27 txt='with.txt') 

28 

29 atoms.calc = calc 

30 energy_fractrans = atoms.get_potential_energy() 

31 

32 assert len(calc.wfs.kd.ibzk_kc) == 6 

33 assert len(calc.wfs.kd.symmetry.op_scc) == 16 

34 

35 # without fractional translations 

36 calc = GPAW(mode=PW(), 

37 xc='LDA', 

38 kpts=(3, 3, 3), 

39 nbands=28, 

40 gpts=(18, 18, 12), 

41 eigensolver='rmm-diis', 

42 txt='without.txt') 

43 

44 atoms.calc = calc 

45 energy_no_fractrans = atoms.get_potential_energy() 

46 

47 assert len(calc.wfs.kd.ibzk_kc) == 8 

48 assert len(calc.wfs.kd.symmetry.op_scc) == 8 

49 

50 assert energy_fractrans == pytest.approx(energy_no_fractrans, abs=1e-5)