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 vasp/xml errors when no virial is printed #574

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading