Skip to main content

Manipulating DeePMD-kit, VASP and LAMMPS data formats

Project description

dpdata is a python package for manipulating DeePMD-kit, VASP, LAMMPS data formats. dpdata only works with python 3.x.

Installation

One can download the source code of dpdata by

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

then use setup.py to install the module

cd dpdata
python setup.py install

dpdata can also by install via pip

pip3 install dpdata

Quick start

This section gives some examples on how dpdata works. Firstly one needs to import the module in a python 3.x compatible code.

import dpdata

The typicall workflow of dpdata is

  1. Load data from vasp or lammps or deepmd-kit data files.

  2. Manipulate data

  3. Dump data to in a desired format

Load data

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

or let dpdata infer the format (vasp/poscar) of the file from the file name extension

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

The number of atoms, atom types, coordinates are loaded from the POSCAR and stored to a data System called d_poscar. A data System (a concept used by deepmd-kit) contains frames that has the same number of atoms of the same type. The order of the atoms should be consistent among the frames in one System. It is noted that POSCAR only contains one frame. If the multiple frames stored in, for example, a OUTCAR is wanted,

d_outcar = dpdata.LabeledSystem('OUTCAR')

The labels provided in the OUTCAR, i.e. energies, forces and virials (if any), are loaded by LabeledSystem. It is noted that the forces of atoms are always assumed to exist. LabeledSystem is a derived class of System.

The System or LabeledSystem can be constructed from the following file formats with the format key in the table passed to argument fmt:

Software

format

multi frames

labeled

class

format key

vasp

poscar

False

False

System

‘vasp/poscar’

vasp

outcar

True

True

LabeledSystem

‘vasp/outcar’

vasp

xml

True

True

LabeledSystem

‘vasp/xml’

lammps

lmp

False

False

System

‘lammps/lmp’

lammps

dump

True

False

System

‘lammps/dump’

deepmd

raw

True

True

LabeledSystem

‘deepmd/raw’

gaussian

log

False

True

LabeledSystem

‘gaussian/log’

cp2k

output

False

True

LabeledSystem

‘cp2k/output’

Access data

These properties stored in System and LabeledSystem can be accessed by operator [] with the key of the property supplied, for example

coords = d_outcar['coords']

Available properties are (nframe: number of frames in the system, natoms: total number of atoms in the system)

key

type

dimension

are labels

description

‘atom_names’

list of str

ntypes

False

The name of each atom type

‘atom_numbs’

list of int

ntypes

False

The number of atoms of each atom type

‘atom_types’

np.ndarray

natoms

False

Array assigning type to each atom

‘cells’

np.ndarray

nframes x 3 x 3

False

The cell tensor of each frame

‘coords’

np.ndarray

nframes x natoms x 3

False

The atom coordinates

‘energies’

np.ndarray

nframes

True

The frame energies

‘forces’

np.ndarray

nframes x natoms x 3

True

The atom forces

‘virials’

np.ndarray

nframes x 3 x 3

True

The virial tensor of each frame

Dump data

The data stored in System or LabeledSystem can be dumped in ‘lammps/lmp’ or ‘vasp/poscar’ format, for example:

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

The first frames of d_outcar will be dumped to ‘conf.lmp’

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

The last frames of d_outcar will be dumped to ‘POSCAR’.

The data stored in LabeledSystem can be dumped to deepmd-kit raw format, for example

d_outcar.to_deepmd_raw('dpmd_raw')

Or a simpler command:

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

Frame selection can be implemented by

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

by which only the first and last frames are dumped to dpmd_raw.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dpdata-0.1.5.tar.gz (252.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dpdata-0.1.5-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file dpdata-0.1.5.tar.gz.

File metadata

  • Download URL: dpdata-0.1.5.tar.gz
  • Upload date:
  • Size: 252.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

File hashes

Hashes for dpdata-0.1.5.tar.gz
Algorithm Hash digest
SHA256 28c428d9a302edc6fa1738ba89df3dadcf1b39220d950e893254e797d2047615
MD5 f7e4e268ab407e07fff3c67e786195a3
BLAKE2b-256 cbd3f3684e530a39f335a215616671b3f13e9ce4ef93844640f534df383d3927

See more details on using hashes here.

File details

Details for the file dpdata-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: dpdata-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

File hashes

Hashes for dpdata-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e9cc77393d4f02c8a295ecdb76dfd7163bb32d997aa4612d8d37e1bc58893999
MD5 9c8268e00c785fa38fad585400f03620
BLAKE2b-256 ab9a09a131a5c43b1b7b02d0fe5087da9351b78ae0fcbcbe971b550c3085d5aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page