Coverage for gpaw/test/ase_features/test_ase3k.py: 95%

20 statements  

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

1import pytest 

2from ase import Atoms 

3from ase.io import read 

4from ase.units import Ha 

5 

6from gpaw import GPAW 

7 

8 

9@pytest.mark.ci 

10def test_no_cell(): 

11 with pytest.raises(ValueError): 

12 H = Atoms('H', calculator=GPAW(mode='fd')) 

13 H.get_potential_energy() 

14 

15 

16@pytest.mark.parametrize('name', ['h2_pw', 'bcc_li_lcao']) 

17def test_read_txt(in_tmp_dir, gpw_files, name): 

18 gpw = gpw_files[name] 

19 calc = GPAW(gpw) 

20 e0 = calc.get_atoms().get_potential_energy() 

21 atoms = read(gpw.with_suffix('.txt')) 

22 e = atoms.get_potential_energy() 

23 assert e == pytest.approx(e0) 

24 if not calc.old: 

25 assert atoms.calc.energy_contributions['kinetic'] == pytest.approx( 

26 calc.dft.energies.kinetic * Ha)