Skip to content

Commit

Permalink
Add support for 2D band structure calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
wladerer committed Nov 30, 2023
1 parent af137a8 commit 71c2c05
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vsh/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ def input(subparsers):
default=None,
help="KPOINTS file for band structure calculation",
)
subp_inputs.add_argument(
"--kplane",
type=int,
default=None,
help="KPOINTS file for 2D band structure calculation",
)
subp_inputs.add_argument(
"--symprec",
type=float,
Expand Down
35 changes: 35 additions & 0 deletions vsh/scripts/input.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3

from jinja2 import Template

import os
import json

Expand All @@ -10,6 +12,23 @@
from pymatgen.io.vasp.inputs import Potcar, Kpoints, Poscar, Incar
from pymatgen.symmetry.bandstructure import HighSymmKpath

two_d_kpath_template = """
Two dimensional Kpath
{{kpath}}
Line-Mode
Reciprocal
0.5000000000 0.0000000000 0.0000000000 M
0.3333333333 0.3333333333 0.0000000000 K
0.3333333333 0.3333333333 0.0000000000 K
0.0000000000 0.0000000000 0.0000000000 GAMMA
0.0000000000 0.0000000000 0.0000000000 GAMMA
0.5000000000 0.0000000000 0.0000000000 M
"""


def get_atoms(args):
'''Creates ASE atoms object from a file'''

Expand Down Expand Up @@ -63,6 +82,21 @@ def write_kpath(args) -> Kpoints:

return kpoints

def write_kplane(args) -> str:
'''Creates a 2D kpath from a jinja 2 template'''

template = Template(two_d_kpath_template)
kplane = template.render(kpath=args.kplane)

if not args.output:
print(kplane)
else:
with open(args.output, "w") as f:
f.write(kplane)

return kplane


def sort_poscar(args) -> Poscar:
structure = Structure.from_file(args.input)
poscar = Poscar(structure, sort_structure=True)
Expand Down Expand Up @@ -129,6 +163,7 @@ def run(args):
"potcar": write_potcar,
"kpoints": write_kpoints,
"kpath": write_kpath,
"kplane": write_kplane,
"sort": sort_poscar,
"mp_poscar": mp_poscar,
"incar": write_incar,
Expand Down

0 comments on commit 71c2c05

Please sign in to comment.