Skip to content

Commit

Permalink
fix vasp/xml errors when no virial is printed
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Nov 6, 2023
1 parent e52b699 commit 5f05b99
Show file tree
Hide file tree
Showing 3 changed files with 1,755 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 5f05b99

Please sign in to comment.