Coverage for gpaw/cli/test.py: 42%

33 statements  

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

1import sys 

2from pathlib import Path 

3 

4from ase import Atoms 

5from ase.parallel import parprint 

6 

7from .info import info 

8from gpaw import GPAW, PW, setup_paths 

9from gpaw.mpi import size 

10 

11 

12class CLICommand: 

13 """Test GPAW installation.""" 

14 

15 @staticmethod 

16 def add_arguments(parser): 

17 pass 

18 

19 @staticmethod 

20 def run(args): 

21 info() 

22 test() 

23 

24 

25def test(): 

26 for path in setup_paths: 

27 if Path(path).is_dir(): 

28 break 

29 else: 

30 print("""Could not find any atomic PAW-data or pseudopotentials! 

31 

32You need to set the GPAW_SETUP_PATH environment variable to point to 

33the directories where PAW dataset and basis files are stored. See 

34https://gpaw.readthedocs.io/install.html#install-paw-datasets 

35for details.""", file=sys.stderr) 

36 return 

37 

38 parprint(f'Doing a test calculation (cores: {size}): ... ', 

39 end='', flush=True) 

40 a = 2.5 

41 d = 0.9 

42 chain = Atoms('H', cell=[a, a, d], pbc=(False, False, True)) 

43 chain.center() 

44 chain.calc = GPAW(mode=PW(200), 

45 kpts=(1, 1, 8), 

46 txt='test.txt') 

47 chain.get_forces() 

48 chain.get_stress() 

49 parprint('Done') 

50 if size == 1: 

51 print() 

52 print('Test parallel calculation with "gpaw -P 4 test".')