Coverage for gpaw/test/fileio/test_wfs_io.py: 100%

18 statements  

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

1import pytest 

2from ase import Atoms 

3from ase.units import Hartree 

4 

5from gpaw import GPAW 

6 

7 

8@pytest.mark.old_gpaw_only 

9def test_fileio_wfs_io(in_tmp_dir): 

10 h2 = Atoms('H2', [(0, 0, 0), (0, 0, 1)]) 

11 h2.center(vacuum=2.0) 

12 calc = GPAW(mode='fd', nbands=2, convergence={'eigenstates': 1e-3}) 

13 h2.calc = calc 

14 h2.get_potential_energy() 

15 r0 = calc.wfs.eigensolver.error * Hartree**2 / 2 

16 assert r0 < 1e-3 

17 calc.write('h2', 'all') 

18 

19 # refine the restart file containing the wfs 

20 calc = GPAW('h2', convergence={'eigenstates': 1e-5}) 

21 calc.get_atoms().get_potential_energy() 

22 r1 = calc.wfs.eigensolver.error * Hartree**2 / 2 

23 assert r1 < 1e-5