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

Fix lattice velocities formatting #3433

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Changes from 4 commits
Commits
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
5 changes: 4 additions & 1 deletion pymatgen/io/vasp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class Poscar(MSONable):
i.e. a list of three 1x3 arrays for each site (typically read in from a MD CONTCAR).
predictor_corrector_preamble: Predictor corrector preamble contains the predictor-corrector key,
POTIM, and thermostat parameters that precede the site-specific predictor corrector data in MD CONTCAR.
lattice_velocities: Lattice velocities and current lattice (typically read
in from a MD CONTCAR). A 6x3 array of floats.
temperature: Temperature of velocity Maxwell-Boltzmann initialization.
Initialized to -1 (MB hasn't been performed).
"""
Expand Down Expand Up @@ -545,7 +547,8 @@ def get_str(self, direct: bool = True, vasp4_compatible: bool = False, significa
lines.append("Lattice velocities and vectors")
lines.append(" 1")
for v in self.lattice_velocities:
lines.append(" ".join(format_str.format(i) for i in v))
# vasp is strict about the format when reading this quantity
lines.append(" ".join(f" {i: .7E}" for i in v))
Copy link
Member

Choose a reason for hiding this comment

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

If VASP is strict about this, could you add a test that checks for the right float precision?

except Exception:
warnings.warn("Lattice velocities are missing or corrupted.")

Expand Down