dpdata icon indicating copy to clipboard operation
dpdata copied to clipboard

[BUG] convesion from cp2k output to deepMD format

Open link796 opened this issue 1 year ago • 2 comments

Bug summary

Hello,

I'm trying to convert the cp2k output file to DeepMD input format, but I keep getting an error even though I have turned on Forces, Print, Trajectories, and so on.

gen = reverse_readfile(filename) if reverse else zopen(filename, "rt")

File "/home1/.local/lib/python3.9/site-packages/monty/io.py", line 46, in zopen _name, ext = os.path.splitext(filename) File "/opt/apps/intel19/python3/3.9.7/lib/python3.9/posixpath.py", line 118, in splitext p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType

cp2k_test.zip

I have added my input and output log files

dpdata Version

0.2.18

Input Files, Running Commands, Error Log, etc.

**import dpdata

x = dpdata.LabeledSystem('aimd', cp2k_outputtname="out.log", fmt='cp2k/aimd_output') x.to('deepmd/npy', 'dpmd_npy')**

I have used above script for reformatting data.

Steps to Reproduce

cp2k_test.zip

Further Information, Files, and Links

No response

link796 avatar Jun 10 '24 04:06 link796

Hi, I have not used the dpdata to convert the CP2K's output, but after checking the related code, I suggest changing x = dpdata.LabeledSystem('aimd', cp2k_outputtname="out.log", fmt='cp2k/aimd_output') to x = dpdata.LabeledSystem('aimd', cp2k_outputtname="/PATH/TO/YOUR/CALCULATION/FLODER, NOT THE LOG FILE", fmt='cp2k/aimd_output')

You can find the reason in the source code at https://github.com/deepmodeling/dpdata/blob/master/dpdata/plugins/cp2k.py

MoseyQAQ avatar Jun 12 '24 12:06 MoseyQAQ

please install cp2kdata as dpdata plugin and parse your output files using the following code:

import dpdata
cp2kmd_dir = "./cp2k_test/"
cp2kmd_output_name = "out.log"

dp = dpdata.LabeledSystem(cp2kmd_dir, cp2k_output_name=cp2kmd_output_name, fmt="cp2kdata/md", restart=False)
print(dp)

Note that your out.log contains duplicated header until 1147 lines, please delete these information.

robinzyb avatar Jun 12 '24 19:06 robinzyb