-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvasp-property.py
47 lines (35 loc) · 1.21 KB
/
vasp-property.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import argparse
from pymatgen.io.vasp.outputs import Vasprun
from rich.console import Console
from rich.table import Table
def extract_band_gap(console, table):
try:
vasprun = Vasprun("vasprun.xml")
except:
console.print("Unable to locate vasprun.xml")
exit()
band_gap, cbm, vbm, _ = vasprun.eigenvalue_band_properties
fmt = "{:.4f}"
table.add_row("Band Gap", fmt.format(band_gap), "eV")
table.add_row("Conduction Band Minimum", fmt.format(cbm), "eV")
table.add_row("Valence Band Maximum", fmt.format(vbm), "eV")
if __name__ == "__main__":
console = Console()
parser = argparse.ArgumentParser(description="Extracts a property from output files in the current directory.")
parser.add_argument(
"--band-gap",
help="extracts the band gap from a vasprun.xml file",
action="store_true",
dest="band_gap",
)
table = Table(title="Simulation Properties")
table.add_column("Name")
table.add_column("Value")
table.add_column("Units")
args = parser.parse_args()
if args.band_gap:
extract_band_gap(console, table)
else:
console.print("No properties selected")
exit()
console.print(table)