robinzyb / cp2kdata

cp2k postprocessing tools
https://robinzyb.github.io/cp2kdata/
GNU Lesser General Public License v3.0
52 stars 18 forks source link

ask for help when using cp2kdata #28

Closed WeJear closed 9 months ago

WeJear commented 9 months ago

When I use cp2k to run molecular dynamics, I set some parameters so that the output data is output every 30 frames, but md.log file seems to output data once every frame. Can you tell me how to use cp2kdata to read such data, or whether you can add such a function.

robinzyb commented 9 months ago

cp2kdata will parse -pos-, -frc- files first. move -1.ener if you output energy every frame. cp2kdata will get energies from -pos- file as well.

WeJear commented 9 months ago

cp2kdata will parse -pos-, -frc- files first. move -1.ener if you output energy every frame. cp2kdata will get energies from -pos- file as well.

Can the md.log file be removed. it seems that only the md.log file output is not as I expected, then how do I write the program.

Here are my example files. Can you help me how to read data. 0.3ps.zip

robinzyb commented 9 months ago

md.log is mainly used to parse cell information. Other information like forces and positions will be parsed only -frc- and -pos- files are missing

WeJear commented 9 months ago

md.log is mainly used to parse cell information. Other information like forces and positions will be parsed only -frc- and -pos- files are missing

but i have such error, I suspect that the data in the md.log file does not match the data in other files.

--- You are parsing data using package Cp2kData ---
Parsing Energies from water-test/water-300K-1.ener
Parsing Structures from water-test/water-300K-pos-1.xyz
Parsing Froces from water-test/water-300K-frc-1.xyz
Parsing Stress from the CP2K output/log file: water-test/md.log
Parsing Cells Information from water-test/md.log
Atom names are fake chemical symbols as you set in cp2k input.
--- You are parsing data using package Cp2kData ---
Traceback (most recent call last):
  File "/home/xwj/materials/water/water-deepmd/water-dp.py", line 17, in <module>
    data = dpdata.LabeledSystem(cp2kmd_dir, cp2k_output_name=cp2kmd_output_name, fmt="cp2kdata/md")
  File "/home/xwj/miniconda3/envs/deepmd/lib/python3.10/site-packages/dpdata/system.py", line 183, in __init__
    self.from_fmt(
  File "/home/xwj/miniconda3/envs/deepmd/lib/python3.10/site-packages/dpdata/system.py", line 220, in from_fmt
    return self.from_fmt_obj(load_format(fmt), file_name, **kwargs)
  File "/home/xwj/miniconda3/envs/deepmd/lib/python3.10/site-packages/dpdata/system.py", line 1120, in from_fmt_obj
    self.check_data()
  File "/home/xwj/miniconda3/envs/deepmd/lib/python3.10/site-packages/dpdata/system.py", line 207, in check_data
    dd.check(self)
  File "/home/xwj/miniconda3/envs/deepmd/lib/python3.10/site-packages/dpdata/data_type.py", line 112, in check
    raise DataError(
dpdata.data_type.DataError: Shape of coords is (11, 687, 3), but expected (301, 687, 3)
robinzyb commented 9 months ago

because the cells are parsed from md.log, resulting in the inconsistence. I will update cp2kdata to parse cell from *cell file when ensemble is npt.

robinzyb commented 9 months ago

updated. 53be2b614fc7bbcfafa93c71a7831a0aa101225a. Now cp2kdata will try to prase the *.cell file first, the same for Stress. I noticed no stress tensor is incuded in log. In case you need stresses in the future, try print stress in the *.stress using the MOTION/RPINT/STRESS. This will avoid unnecessary problems.

import dpdata
cp2kmd_dir = "./"
cp2kmd_output_name = "md.log"
dp = dpdata.LabeledSystem(cp2kmd_dir, cp2k_output_name=cp2kmd_output_name, fmt="cp2kdata/md")
print(dp)
--- You are parsing data using package Cp2kData ---
Parsing Energies from ./water-300K-1.ener
Parsing Structures from ./water-300K-pos-1.xyz
Parsing Froces from ./water-300K-frc-1.xyz
Parsing Stress from the CP2K output/log file: ./md.log
Parsing Cells from ./water-300K-1.cell
Atom names are fake chemical symbols as you set in cp2k input.
--- You are parsing data using package Cp2kData ---
Data Summary
Labeled System
-------------------
Frame Numbers      : 11
Atom Numbers       : 687
Including Virials  : No
Element List       :
-------------------
O  H
229  458
WeJear commented 9 months ago

updated. 53be2b614fc7bbcfafa93c71a7831a0aa101225a. Now cp2kdata will try to prase the *.cell file first, the same for Stress. I noticed no stress tensor is incuded in log. In case you need stresses in the future, try print stress in the *.stress using the MOTION/RPINT/STRESS. This will avoid unnecessary problems.

import dpdata
cp2kmd_dir = "./"
cp2kmd_output_name = "md.log"
dp = dpdata.LabeledSystem(cp2kmd_dir, cp2k_output_name=cp2kmd_output_name, fmt="cp2kdata/md")
print(dp)
--- You are parsing data using package Cp2kData ---
Parsing Energies from ./water-300K-1.ener
Parsing Structures from ./water-300K-pos-1.xyz
Parsing Froces from ./water-300K-frc-1.xyz
Parsing Stress from the CP2K output/log file: ./md.log
Parsing Cells from ./water-300K-1.cell
Atom names are fake chemical symbols as you set in cp2k input.
--- You are parsing data using package Cp2kData ---
Data Summary
Labeled System
-------------------
Frame Numbers      : 11
Atom Numbers       : 687
Including Virials  : No
Element List       :
-------------------
O  H
229  458

OK, i will try. thanks for your help.

WeJear commented 9 months ago

updated. 53be2b6. Now cp2kdata will try to prase the *.cell file first, the same for Stress. I noticed no stress tensor is incuded in log. In case you need stresses in the future, try print stress in the *.stress using the MOTION/RPINT/STRESS. This will avoid unnecessary problems.

import dpdata
cp2kmd_dir = "./"
cp2kmd_output_name = "md.log"
dp = dpdata.LabeledSystem(cp2kmd_dir, cp2k_output_name=cp2kmd_output_name, fmt="cp2kdata/md")
print(dp)
--- You are parsing data using package Cp2kData ---
Parsing Energies from ./water-300K-1.ener
Parsing Structures from ./water-300K-pos-1.xyz
Parsing Froces from ./water-300K-frc-1.xyz
Parsing Stress from the CP2K output/log file: ./md.log
Parsing Cells from ./water-300K-1.cell
Atom names are fake chemical symbols as you set in cp2k input.
--- You are parsing data using package Cp2kData ---
Data Summary
Labeled System
-------------------
Frame Numbers      : 11
Atom Numbers       : 687
Including Virials  : No
Element List       :
-------------------
O  H
229  458

it can work, thanks.