Coverage for gpaw/test/test_too_close.py: 100%

15 statements  

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

1"""Make sure we get an exception when an atom is too close to the boundary.""" 

2from ase import Atoms 

3from gpaw import GPAW 

4from gpaw.grid_descriptor import GridBoundsError 

5from gpaw.utilities import AtomsTooClose 

6import pytest 

7 

8 

9@pytest.mark.parametrize('mode', ['fd', 'pw']) 

10def test_too_close_to_boundary(mode, gpaw_new): 

11 if mode == 'pw' and not gpaw_new: 

12 return 

13 a = 4.0 

14 x = 0.1 

15 hydrogen = Atoms('H', [(x, x, x)], 

16 cell=(a, a, a), 

17 pbc=(1, 1, 0)) 

18 hydrogen.calc = GPAW(mode=mode) 

19 with pytest.raises((GridBoundsError, AtomsTooClose)): 

20 hydrogen.get_potential_energy()