Skip to content
Open
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
8 changes: 7 additions & 1 deletion dpdata/plugins/qe.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np

import dpdata.md.pbc
import dpdata.qe.scf
import dpdata.qe.traj
Expand Down Expand Up @@ -26,9 +28,13 @@ def from_labeled_system(self, file_name, begin=0, step=1, **kwargs):
data["coords"],
data["cells"],
)
data["energies"], data["forces"], es = dpdata.qe.traj.to_system_label(
data["energies"], data["forces"], stress, es = dpdata.qe.traj.to_system_label(
file_name + ".in", file_name, begin=begin, step=step
)
if stress is not None:
# Compute virials of all frames by: virial = stress * volume
virial = stress * np.linalg.det(data["cells"])[:, np.newaxis, np.newaxis]
data["virials"] = virial
assert cs == es, "the step key between files are not consistent"
return data

Expand Down
13 changes: 11 additions & 2 deletions dpdata/qe/traj.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3
import os
import warnings

import numpy as np
Expand All @@ -16,6 +17,7 @@
length_convert = LengthConversion("bohr", "angstrom").value()
energy_convert = EnergyConversion("hartree", "eV").value()
force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value()
stress_convert = PressureConversion("GPa", "eV/angstrom^3").value()


def load_key(lines, key):
Expand Down Expand Up @@ -233,8 +235,15 @@ def to_system_label(input_name, prefix, begin=0, step=1):
step=step,
convert=force_convert,
)
assert esteps == fsteps, "the step key between files are not consistent "
return energy, force, esteps
# Load stress from .str file if it exists
if os.path.isfile(prefix + ".str"):
stress, vsteps = load_data(
prefix + ".str", 3, begin=begin, step=step, convert=stress_convert
)
else:
stress, vsteps = None, esteps
assert esteps == fsteps == vsteps, "the step key between files are not consistent "
return energy, force, stress, esteps


if __name__ == "__main__":
Expand Down