操作deepmd工具包、vasp和lammps数据格式

dpdata的Python项目详细描述


dpdata是一个用于操作deepmd kit、vasp、lammps数据格式的python包。 dpdata仅适用于python 3.x。

安装

您可以通过

git clone https://github.com/deepmodeling/dpdata.git dpdata

然后使用setup.py安装模块

cd dpdata
python setup.py install

dpdata也可以通过pip安装

pip3 install dpdata

快速启动

本节给出了一些关于dpdata如何工作的示例。首先需要将模块导入到与Python3.x兼容的代码中。

importdpdata

dpdata的典型调用工作流是

  1. 从vasp或lammps或deepmd工具包数据文件加载数据。
  2. 操作数据
  3. 以所需格式将数据转储到

加载数据

d_poscar=dpdata.System('POSCAR',fmt='vasp/poscar')

或者让dpdata从文件扩展名推断文件的格式(vasp/poscar

d_poscar=dpdata.System('my.POSCAR')

原子数、原子类型、坐标从POSCAR加载并存储到名为d_poscar的数据System。 数据System(由deepmd-kit使用的概念)包含具有相同类型原子数的帧。原子的顺序在一个System的帧之间应该是一致的。 注意,POSCAR只包含一个帧。 例如,如果需要存储在OUTCAR中的多个帧,

d_outcar=dpdata.LabeledSystem('OUTCAR')

OUTCAR中提供的标签,即能量、力和病毒(如果有的话),由LabeledSystem加载。人们注意到原子的力总是假定存在的。LabeledSystemSystem的派生类。

SystemLabeledSystem可以由以下文件格式构造,表中的format key传递给参数fmt

Softwareformatmulti frameslabeledclassformat key
vaspposcarFalseFalseSystem‘vasp/poscar’
vaspoutcarTrueTrueLabeledSystem‘vasp/outcar’
vaspxmlTrueTrueLabeledSystem‘vasp/xml’
lammpslmpFalseFalseSystem‘lammps/lmp’
lammpsdumpTrueFalseSystem‘lammps/dump’
deepmdrawTrueTrueLabeledSystem‘deepmd/raw’
gaussianlogFalseTrueLabeledSystem‘gaussian/log’
cp2koutputFalseTrueLabeledSystem‘cp2k/output’

访问数据

存储在SystemLabeledSystem中的这些属性可以由运算符[]使用提供的属性键访问,例如

coords=d_outcar['coords']

可用属性为(nframe:系统中的帧数,natoms:系统中的原子总数)

keytypedimensionare labelsdescription
‘atom_names’list of strntypesFalseThe name of each atom type
‘atom_numbs’list of intntypesFalseThe number of atoms of each atom type
‘atom_types’np.ndarraynatomsFalseArray assigning type to each atom
‘cells’np.ndarraynframes x 3 x 3FalseThe cell tensor of each frame
‘coords’np.ndarraynframes x natoms x 3FalseThe atom coordinates
‘energies’np.ndarraynframesTrueThe frame energies
‘forces’np.ndarraynframes x natoms x 3TrueThe atom forces
‘virials’np.ndarraynframes x 3 x 3TrueThe virial tensor of each frame

转储数据

存储在SystemLabeledSystem中的数据可以转储为'lammps/lmp'或'vasp/poscar'格式,例如:

d_outcar.to_lammps_lmp('conf.lmp',frame_idx=0)

d_outcar的第一帧将转储到“conf.lmp”

d_outcar.to_vasp_poscar('POSCAR',frame_idx=-1)

d_outcar的最后一帧将转储到“poscar”。

存储在LabeledSystem中的数据可以转储为deepmd kit raw格式,例如

d_outcar.to_deepmd_raw('dpmd_raw')

或更简单的命令:

dpdata.LabeledSystem('OUTCAR').to_deepmd_raw('dpmd_raw')

帧选择可以通过

dpdata.LabeledSystem('OUTCAR').sub_system([0,-1]).to_deepmd_raw('dpmd_raw')

仅将第一帧和最后一帧转储到dpmd_raw

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java与Groovy正则表达式匹配混淆   java控制台未定义为JSNI   主目录中的java指针异常   java如何获取hashmap中的arrayList的大小   ApachePOI用于文本,Java代码中的word doc(.docx)中没有进行追加   Ruby对象到Java对象   JavaSpringJPA哈希集只返回一个值   Java在执行由配置了精确类路径参数的mavenjarpluin生成的可执行jar时无法找到依赖项   java我试图在画布上写一个文本,但什么也没发生   java HTTP 404源服务器找不到目标资源的当前表示形式,或者不愿意透露存在该表示形式。不起作用   java提取小数点后的最后一个数字   oop Java:无法访问对象的元素   PHP URL中RecyclerView中的java句柄空异常   不调用OnCreateViewHolder的java Update RecyclerView适配器项