Skip to content

Commit

Permalink
add decrecaption warning when dpdata throws errors while parsing cp2k
Browse files Browse the repository at this point in the history
  • Loading branch information
robinzyb committed Oct 20, 2023
1 parent 0576449 commit 03cc010
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions dpdata/plugins/cp2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,44 @@
from dpdata.format import Format


string_warning = """
Hi, you got an error from dpdata,
please check if your cp2k files include full information,
otherwise its version is not supported by dpdata.
Try use dpdata plugin from cp2kdata package,
for details, please refer to
https://robinzyb.github.io/cp2kdata/
"""

@Format.register("cp2k/aimd_output")
class CP2KAIMDOutputFormat(Format):
def from_labeled_system(self, file_name, restart=False, **kwargs):
xyz_file = sorted(glob.glob(f"{file_name}/*pos*.xyz"))[0]
log_file = sorted(glob.glob(f"{file_name}/*.log"))[0]
return tuple(Cp2kSystems(log_file, xyz_file, restart))
try:
xyz_file = sorted(glob.glob(f"{file_name}/*pos*.xyz"))[0]
log_file = sorted(glob.glob(f"{file_name}/*.log"))[0]
return tuple(Cp2kSystems(log_file, xyz_file, restart))
except :
raise PendingDeprecationWarning(string_warning)


@Format.register("cp2k/output")
class CP2KOutputFormat(Format):
def from_labeled_system(self, file_name, restart=False, **kwargs):
data = {}
(
data["atom_names"],
data["atom_numbs"],
data["atom_types"],
data["cells"],
data["coords"],
data["energies"],
data["forces"],
tmp_virial,
) = dpdata.cp2k.output.get_frames(file_name)
if tmp_virial is not None:
data["virials"] = tmp_virial
return data
try:
data = {}
(
data["atom_names"],
data["atom_numbs"],
data["atom_types"],
data["cells"],
data["coords"],
data["energies"],
data["forces"],
tmp_virial,
) = dpdata.cp2k.output.get_frames(file_name)
if tmp_virial is not None:
data["virials"] = tmp_virial
return data
except:
raise PendingDeprecationWarning(string_warning)

0 comments on commit 03cc010

Please sign in to comment.