• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bjmorgan / vasppy / 18822600051

26 Oct 2025 07:20PM UTC coverage: 38.557%. Remained the same
18822600051

push

github

bjmorgan
Fixing mypy errors and typing

33 of 42 new or added lines in 14 files covered. (78.57%)

1 existing line in 1 file now uncovered.

839 of 2176 relevant lines covered (38.56%)

1.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/vasppy/scripts/convergence_testing.py
1
import argparse
×
2
import os
×
3
import numpy as np
×
NEW
4
from pymatgen.core import Structure
×
NEW
5
from pymatgen.io.vasp import Incar, Potcar
×
UNCOV
6
from vasppy.kpoints import get_convergence_testing_kspacing
×
7

8
def parse_args() -> argparse.Namespace:
×
9
    parser = argparse.ArgumentParser(description='Generate a series of VASP inputs for convergence testing. At minimum, this requires a template INCAR and the geometry of the system (a POSCAR).')
×
10
    parser.add_argument('-i', '--incar', required=True, help='Specify the template INCAR.')
×
11
    parser.add_argument('-p', '--poscar', required=True, help='Specify the geometry of the system (POSCAR).')
×
12
    parser.add_argument('-e', '--encut', nargs=3, default=(100, 700, 50), help='Set the upper/lower bounds and step size for the basis set size (ENCUT). Defaults to 100 700 50.')
×
13
    parser.add_argument('-k', '--kspacing', nargs=3, default=(0.1, 0.8, 0.02), help='Set the upper/lower bounds and step size for the minimum allowed distance between k-points (KSPACING). Defaults to 0.1 0.8 0.02')
×
14
    parser.add_argument('-d', '--directory', nargs='?', default='./convergence_testing', help='Specify the directory in which to place the generated VASP inputs. Defaults to ./convergence_testing.')
×
15
    parser.add_argument('--base-encut', nargs='?', default=400, help='Set the value of ENCUT for the KSPACING convergence tests. Defaults to 400.')
×
16
    parser.add_argument('--base-kspacing', nargs='?', default=0.3, help='Set the value of KSPACING for the ENCUT convergence tests. Defaults to 0.3.')
×
17
    parser.add_argument('--pseudopotentials', nargs='+', default=None, help='Specify the pseudopotentials (POTCARs) to be used e.g. Li_sv Mn_pv O. Defaults to None i.e. no POTCARs will be written. This functionality requires Pymatgen to be set up for VASP POTCARs.')
×
18
    args = parser.parse_args()
×
19

20
    return args
×
21

22
def main() -> None:
×
23
    args = parse_args()
×
24

25
    structure = Structure.from_file(args.poscar)
×
26
    reciprocal_lattice_vectors = structure.lattice.reciprocal_lattice_crystallographic.matrix
×
27
    kspacing_min, kspacing_max, step = args.kspacing
×
28
    kspacing = get_convergence_testing_kspacing(reciprocal_lattice_vectors, (kspacing_min, kspacing_max), step)
×
29

30
    encut_min, encut_max, step = args.encut
×
31
    encut = np.arange(encut_min, encut_max + step, step)
×
32

33
    base_incar_params = Incar.from_file(args.incar).as_dict()
×
34

35
    os.mkdir(args.directory)
×
36
    os.mkdir(args.directory + '/ENCUT')
×
37
    os.mkdir(args.directory + '/KSPACING')
×
38

39
    if args.pseudopotentials is not None:
×
40
        potcar = Potcar(args.pseudopotentials)
×
41

42
    for energy_cutoff in encut:
×
43
        path = args.directory + '/ENCUT' + f'/{energy_cutoff}'
×
44
        os.mkdir(path)
×
45

46
        incar_params = base_incar_params.copy()
×
47
        incar_params['ENCUT'] = energy_cutoff
×
48
        incar_params['KSPACING'] = args.base_kspacing
×
49
        incar = Incar.from_dict(incar_params)
×
50

51
        incar.write_file(path + '/INCAR')
×
52
        structure.to(fmt='poscar', filename=path + '/POSCAR')
×
53
        if args.pseudopotentials is not None:
×
54
            potcar.write_file(path + '/POTCAR')
×
55

56
    for minimum_distance in kspacing:
×
57
        path = args.directory + '/KSPACING' + f'/{minimum_distance}'
×
58
        os.mkdir(path)
×
59

60
        incar_params = base_incar_params.copy()
×
61
        incar_params['KSPACING'] = minimum_distance
×
62
        incar_params['ENCUT'] = args.base_encut
×
63
        incar = Incar.from_dict(incar_params)
×
64

65
        incar.write_file(path + '/INCAR')
×
66
        structure.to(fmt='poscar', filename=path + '/POSCAR')
×
67
        if args.pseudopotentials is not None:
×
68
            potcar.write_file(path + '/POTCAR')
×
69

70
if __name__ == '__main__':
×
71
    main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc