Skip to content

Commit

Permalink
resolved KPointsCard import and return blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ebanyas committed Aug 16, 2024
1 parent 522e8bb commit 43aa519
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions pymatgen/io/espresso/caffeinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pymatgen.core.structure import Structure

from pymatgen.io.vasp.inputs import Kpoints, Poscar
from pymatgen.io.espresso.inputs import pwin
from pymatgen.io.espresso.inputs.pwin import KPointsCard

# TODO
# introduce class Caffeinator():
Expand Down Expand Up @@ -68,7 +68,7 @@ def _caffeinate_kpoints(kpoints):
opt_str = "automatic"

# TODO: option assignment from string should be fixed in next version
option = pwin.KPointsCard.opts.from_string(opt_str)
option = KPointsCard.opts.from_string(opt_str)
grid = [ int(x) for x in k_pts[0] ]
shift = [ bool(x) for x in k_shift ]

Expand All @@ -80,13 +80,9 @@ def _caffeinate_kpoints(kpoints):
if not x % 2:
shift[i] = not shift[i]

return pwin.KPointsCard(
option = option,
grid = grid,
shift = shift,
k = [],
weights = [],
labels = [])
pw_k = []
pw_wts = []
pw_lbls = []

elif k_style.name.lower()[0] == "l":
if k_coord.lower()[0] == "r":
Expand All @@ -111,15 +107,9 @@ def _caffeinate_kpoints(kpoints):
pw_k.append(list(k_pts[i]))

pw_wts[-1] = 1
option = pwin.KPointsCard.opts.from_string(opt_str)

return pwin.KPointsCard(
option = option,
grid = [],
shift = [],
k = pw_k,
weights = pw_wts,
labels = pw_lbls)
option = KPointsCard.opts.from_string(opt_str)
grid = []
shift = []

elif k_style.name.lower()[0] in "rc" and k_num > 0:
if k_num == 1 and (
Expand All @@ -132,7 +122,12 @@ def _caffeinate_kpoints(kpoints):
else:
opt_str = "crystal"

option = pwin.KPointsCard.opts.from_string(opt_str)
option = KPointsCard.opts.from_string(opt_str)
grid = []
shift = []
pw_k = []
pw_wts = []
pw_lbls = []
# TODO: finish parsing k-points


Expand All @@ -145,7 +140,7 @@ def _caffeinate_kpoints(kpoints):
# TODO: Define a warning
return kpoints

if "tpiba" in option:
if "tpiba" in opt_str:
# TODO: Define a warning.
# Without an accompanying POSCAR, VASP's cartesian coordinates
# cannot properly be converted to PWSCF's tpiba coordinates.
Expand All @@ -154,7 +149,13 @@ def _caffeinate_kpoints(kpoints):
pass

# DEBUGGING (TODO)
return option
return KPointsCard(
option = option,
grid = grid,
shift = shift,
k = pw_k,
weights = pw_wts,
labels = pw_lbls)

# TODO:
def _caffeinate_poscar(poscar):
Expand Down

0 comments on commit 43aa519

Please sign in to comment.