Skip to content
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

Kpoints Sampling Saved as Float When Writing Kpoints file #3993

Closed
yutoml opened this issue Aug 11, 2024 · 1 comment · Fixed by #3994
Closed

Kpoints Sampling Saved as Float When Writing Kpoints file #3993

yutoml opened this issue Aug 11, 2024 · 1 comment · Fixed by #3994
Labels
bug io Input/output functionality vasp Vienna Ab initio Simulation Package

Comments

@yutoml
Copy link

yutoml commented Aug 11, 2024

Python version

Python 3.10.14

Pymatgen version

Version: 2024.7.18

Operating system version

Red Hat Enterprise Linux Ver 8.6

Current behavior

When using the Kpoints class from pymatgen.io.vasp.inputs to read a Gamma-centered KPOINTS file and then write it back, the fourth line of the KPOINTS file is converted to a float string. This causes VASP5.4.4 calculations to fail when using this file. Specifically, in the from_str method of the Kpoints class, the fourth line of the KPOINTS file is cast to kpts as Sequence[tuple[float, float, float]]. The kpts attribute is then handled as a sequence of floats throughout the process, and it is written back as floats.

Expected Behavior

When writting a Gamma-centered KPOINTS file, the number of K-point divisions should be cast to a int, or it should be explicitly cast to an integer when writing the file if the style is Gamma-centered or Monkhorst-Pack.
Initially, the kpts attribute of the Kpoints class was handled as list[int] in from_str method, but it was changed to Sequence[tuple[float, float, float]] in #3758. While this change itself is not problematic, it would be more convenient if kpts were an integer sequence for Gamma-centered or Monkhorst-Pack.

Minimal example

#The following source code is a simplified code that reproduces this problem.
#The fourth line of the KPOINTS file resulting from the output of this code is `3.0 3.0 3.0`.

from pymatgen.io.vasp.inputs import Kpoints

Kpoints_str = """\
An example
0
Gamma
3    3    3
0.0  0.0  0.0"""

kpoints = Kpoints.from_str(Kpoints_str)
kpoints.write_file("KPOINTS")

Relevant files to reproduce this bug

No response

@yutoml yutoml added the bug label Aug 11, 2024
@DanielYang59
Copy link
Contributor

DanielYang59 commented Aug 12, 2024

Hi thanks for reporting and diagnosing and sorry for the trouble caused. I could confirm the issue and would fix ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug io Input/output functionality vasp Vienna Ab initio Simulation Package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants