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
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
1import sys
2from pathlib import Path
4from ase import Atoms
5from ase.parallel import parprint
7from .info import info
8from gpaw import GPAW, PW, setup_paths
9from gpaw.mpi import size
12class CLICommand:
13 """Test GPAW installation."""
15 @staticmethod
16 def add_arguments(parser):
17 pass
19 @staticmethod
20 def run(args):
21 info()
22 test()
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!
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
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".')