Skip to content

Commit

Permalink
fix vasp/xml errors when no virial is printed (#574)
Browse files Browse the repository at this point in the history
Fix #212.

---------

Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Nov 7, 2023
1 parent e52b699 commit fb27e05
Show file tree
Hide file tree
Showing 3 changed files with 1,756 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dpdata/plugins/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def from_labeled_system(self, file_name, begin=0, step=1, **kwargs):
data["coords"],
data["energies"],
data["forces"],
data["virials"],
tmp_virial,
) = dpdata.vasp.xml.analyze(
file_name, type_idx_zero=True, begin=begin, step=step
)
Expand All @@ -121,9 +121,11 @@ def from_labeled_system(self, file_name, begin=0, step=1, **kwargs):
for ii in range(data["cells"].shape[0]):
data["coords"][ii] = np.matmul(data["coords"][ii], data["cells"][ii])
# scale virial to the unit of eV
v_pref = 1 * 1e3 / 1.602176621e6
for ii in range(data["cells"].shape[0]):
vol = np.linalg.det(np.reshape(data["cells"][ii], [3, 3]))
data["virials"][ii] *= v_pref * vol
if tmp_virial.size > 0:
data["virials"] = tmp_virial
v_pref = 1 * 1e3 / 1.602176621e6
for ii in range(data["cells"].shape[0]):
vol = np.linalg.det(np.reshape(data["cells"][ii], [3, 3]))
data["virials"][ii] *= v_pref * vol
data = uniq_atom_names(data)
return data
Loading

0 comments on commit fb27e05

Please sign in to comment.