You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`.frompymatgen.io.vasp.inputsimportKpointsKpoints_str="""\An example0Gamma3 3 30.0 0.0 0.0"""kpoints=Kpoints.from_str(Kpoints_str)
kpoints.write_file("KPOINTS")
Relevant files to reproduce this bug
No response
The text was updated successfully, but these errors were encountered:
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 frompymatgen.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 thefrom_str
method of the Kpoints class, the fourth line of the KPOINTS file is cast tokpts
asSequence[tuple[float, float, float]]
. Thekpts
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 aslist[int]
infrom_str
method, but it was changed toSequence[tuple[float, float, float]]
in #3758. While this change itself is not problematic, it would be more convenient ifkpts
were an integer sequence for Gamma-centered or Monkhorst-Pack.Minimal example
Relevant files to reproduce this bug
No response
The text was updated successfully, but these errors were encountered: