Coverage for gpaw/fulldiag.py: 53%
19 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
1from gpaw import GPAW
4def fulldiag(filename, bands=None, scalapack=1):
5 """Set up full H and S matrices and find all or some eigenvectors/values.
7 calc: str
8 Filename of gpw-file.
9 bands: int
10 Number of bands to calculate. Defaults to all.
11 scalapack: int
12 Number of cores to use for ScaLapack. Default is one.
13 dry_run: bool
14 Don't do actual calculation.
16 """
17 name, ext = filename.rsplit('.', 1)
18 assert ext == 'gpw'
19 calc = GPAW(filename,
20 parallel={'band': scalapack},
21 txt=name + '-all.txt')
22 calc.diagonalize_full_hamiltonian(bands)
23 calc.write(name + '-all.gpw', 'all')
25 ng = calc.wfs.pd.ngmax
26 mem = ng**2 * 16 / 1024**2
27 print('Maximum matrix size: {0}x{0} = {1:.3f} MB'.format(ng, mem))
30class CLICommand:
31 """Calculate all or some eigenvectors/values for fixed H."""
33 @staticmethod
34 def add_arguments(parser):
35 parser.add_argument('gpw', metavar='gpw-file')
36 parser.add_argument('-b', '--bands', type=int)
37 parser.add_argument('-s', '--scalapack', type=int, default=1)
39 @staticmethod
40 def run(args):
41 fulldiag(args.gpw, args.bands, args.scalapack)