deepmodeling / dpdata

Manipulating multiple atomic simulation data formats, including DeePMD-kit, VASP, LAMMPS, ABACUS, etc.
https://docs.deepmodeling.com/projects/dpdata/
GNU Lesser General Public License v3.0
189 stars 128 forks source link

[BUG] dpdata extracts incorrect box information when extracting NPT_F dynamics trajectories calculated by cp2k (version 7.1) #589

Closed xiaohe-njust closed 6 months ago

xiaohe-njust commented 6 months ago

Bug summary

dpdata extracts incorrect box information when extracting NPT_F dynamics trajectories calculated by cp2k (version 7.1)

dpdata Version

v0.2.17

Input Files, Running Commands, Error Log, etc.

import dpdata import numpy as np data = dpdata.LabeledSystem('npt-30GPa', fmt = 'cp2k/aimd_output') data[20000].to_deepmd_raw("dpdata-30GPa-f20000")

30GPa-last frame.zip

bug

Steps to Reproduce

dpdata extracts incorrect box information when extracting NPT_F dynamics trajectories calculated by cp2k (version 7.1) I took the information from the last frame extracted by dpdata and compared it to the information in the restart file, the coordinate information is consistent, the box information is not. I viewed the two box information in ovito by adding each to the coordinate information of the last frame, and the box size information in the restart file is correct, the box information extracted by dpdata is incorrect, resulting in an error in the molecular structure when processing the periodicity.

Further Information, Files, and Links

No response

robinzyb commented 6 months ago

please provide the cp2k output files for me to debug.

Archive:  30GPa-last.frame.zip
   creating: dpdata-30GPa-f20000/
  inflating: dpdata-30GPa-f20000/box.raw  
  inflating: dpdata-30GPa-f20000/coord.raw  
  inflating: dpdata-30GPa-f20000/energy.raw  
  inflating: dpdata-30GPa-f20000/force.raw  
  inflating: dpdata-30GPa-f20000/type.raw  
  inflating: dpdata-30GPa-f20000/type_map.raw  
  inflating: cp2k-1.restart          

also, have you tried cp2kdata plugin? https://github.com/robinzyb/cp2kdata/tree/main

xiaohe-njust commented 6 months ago

please provide the cp2k output files for me to debug.

Archive:  30GPa-last.frame.zip
   creating: dpdata-30GPa-f20000/
  inflating: dpdata-30GPa-f20000/box.raw  
  inflating: dpdata-30GPa-f20000/coord.raw  
  inflating: dpdata-30GPa-f20000/energy.raw  
  inflating: dpdata-30GPa-f20000/force.raw  
  inflating: dpdata-30GPa-f20000/type.raw  
  inflating: dpdata-30GPa-f20000/type_map.raw  
  inflating: cp2k-1.restart          

also, have you tried cp2kdata plugin? https://github.com/robinzyb/cp2kdata/tree/main

@robinzyb I computed a ten frame NPT dynamics trajectory and output the real box information file (cp2k-1.cell) for your reference.

I found that dpdata is converting the Cell lengths and Cell angles information from the cp2k output file into box information, but this conversion does not determine the position of the box, which is rotated compared to the actual box. However, the information such as atomic coordinates are relative to the actual box, which causes the error periodic handling.

I have tried using the cp2kdata plugin and it extracts fine for cp2k version 2023 but reports errors for version 7.1. cp2kdata extracts the box information from Cell lengths and Cell angles information as well, hence the same error.

NPT_F-trajectory.zip

xiaohe-njust commented 6 months ago

please provide the cp2k output files for me to debug.

Archive:  30GPa-last.frame.zip
   creating: dpdata-30GPa-f20000/
  inflating: dpdata-30GPa-f20000/box.raw  
  inflating: dpdata-30GPa-f20000/coord.raw  
  inflating: dpdata-30GPa-f20000/energy.raw  
  inflating: dpdata-30GPa-f20000/force.raw  
  inflating: dpdata-30GPa-f20000/type.raw  
  inflating: dpdata-30GPa-f20000/type_map.raw  
  inflating: cp2k-1.restart          

also, have you tried cp2kdata plugin? https://github.com/robinzyb/cp2kdata/tree/main

I just updated the version of cp2kdata. It's able to extract box information from .cell files now, and it works for cp2k version 7.1 as well.

Thanks for your efforts!

robinzyb commented 6 months ago

Indeed, I found it is a severe bug when transforming the angles and lengths to cell matrices. As shown by your figures, the code assumes the cell a axis are always aligned to x axis, the x coordinate, which is not true. I have to add warning when parsing cell info from cp2k.log/output file

robinzyb commented 6 months ago

by the way, how do you print -1.cell file in input.inp. I rarely use npt ensemble.

xiaohe-njust commented 6 months ago

by the way, how do you print -1.cell file in input.inp. I rarely use npt ensemble.

The instructions are similar to those for outputting force information, and are as follows

image

robinzyb commented 6 months ago

Thank you. If the problem has been solved, please close the issue as well.