Skip to content

Set kpoints in from_str method as integer in auto Gamma and Monkhorst modes #3994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Aug 20, 2024
Merged
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
25a74db
kpoints as int in auto Gamma and Monkhorst
DanielYang59 Aug 12, 2024
f027ec6
add deprecation warning and docstring tweak
DanielYang59 Aug 12, 2024
1e368eb
Merge branch 'master' into fix-kpts-as-int
DanielYang59 Aug 12, 2024
c90a3fe
add unit test
DanielYang59 Aug 12, 2024
72f494f
filter Kpoints warning
DanielYang59 Aug 12, 2024
a7e36c1
docstring tweaks
DanielYang59 Aug 12, 2024
1a6b5f5
also test deprecation warning
DanielYang59 Aug 12, 2024
7225618
merge tests into test_static_constructors
DanielYang59 Aug 12, 2024
4d4e02c
assert int type in automatic_density methods
DanielYang59 Aug 12, 2024
17b2b38
clarify typing for Kpoint
DanielYang59 Aug 12, 2024
5dee8ce
relocate setter and getter to avoid mypy redefine errors
DanielYang59 Aug 12, 2024
4f07349
type annotate some class vars
DanielYang59 Aug 12, 2024
c6d73d4
remove boilerplate code
DanielYang59 Aug 12, 2024
5311143
revert changes in io.vasp.inputs
DanielYang59 Aug 12, 2024
c55c885
revert change in POTCAR_spec
DanielYang59 Aug 12, 2024
2698e61
reapply deprecation warning
DanielYang59 Aug 12, 2024
182ab95
My bad, reapply float -> int change
DanielYang59 Aug 12, 2024
b4cfdca
use Tuple3Ints for more specific typing
DanielYang59 Aug 14, 2024
8a4d8f3
use Tuple3Floats when type is known
DanielYang59 Aug 14, 2024
179eb39
Merge branch 'master' into fix-kpts-as-int
DanielYang59 Aug 15, 2024
225b1e0
Merge branch 'master' into fix-kpts-as-int
DanielYang59 Aug 16, 2024
bfedeb2
Merge branch 'master' into fix-kpts-as-int
DanielYang59 Aug 16, 2024
b3926d9
Merge branch 'master' into fix-kpts-as-int
DanielYang59 Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/pymatgen/io/vasp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ def style(self, style) -> None:
def automatic(cls, subdivisions: int) -> Self:
"""
Constructor for a fully automatic Kpoint grid, with
gamma centered Monkhorst-Pack grids and the number of subdivisions
Copy link
Contributor Author

@DanielYang59 DanielYang59 Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be Gamma-centered only according to the VASP Wiki?

The following KPOINTS file generates a regular Γ \Gamma -centered k-point.

Gamma-centered grids and the number of subdivisions
along each reciprocal lattice vector determined by the scheme in the
VASP manual.

Expand All @@ -1250,6 +1250,8 @@ def automatic(cls, subdivisions: int) -> Self:
Returns:
Kpoints object
"""
warnings.warn("Please use INCAR KSPACING tag.", DeprecationWarning, stacklevel=2)

return cls(
"Fully automatic kpoint scheme",
0,
Expand Down Expand Up @@ -1520,9 +1522,9 @@ def from_str(cls, string: str) -> Self:

coord_pattern = re.compile(r"^\s*([\d+.\-Ee]+)\s+([\d+.\-Ee]+)\s+([\d+.\-Ee]+)")

# Automatic gamma and Monk KPOINTS, with optional shift
# Automatic Gamma-centered or Monkhorst-Pack KPOINTS, with optional shift
if style in {"g", "m"}:
_kpt: list[float] = [float(i) for i in lines[3].split()]
_kpt: list[float] = [int(i) for i in lines[3].split()]
if len(_kpt) != 3:
raise ValueError("Invalid Kpoint length.")
kpt: Tuple3Floats = cast(Tuple3Floats, tuple(_kpt))
Expand Down
Loading