dpdata


Namedpdata JSON
Version 0.2.19 PyPI version JSON
download
home_pageNone
SummaryManipulating data formats of DeePMD-kit, VASP, QE, PWmat, and LAMMPS, etc.
upload_time2024-06-06 00:07:05
maintainerNone
docs_urlNone
authorDeepModeling
requires_python>=3.7
licenseGNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
keywords lammps vasp deepmd-kit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dpdata

[![conda-forge](https://img.shields.io/conda/dn/conda-forge/dpdata?color=red&label=conda-forge&logo=conda-forge)](https://anaconda.org/conda-forge/dpdata)
[![pip install](https://img.shields.io/pypi/dm/dpdata?label=pip%20install&logo=pypi)](https://pypi.org/project/dpdata)
[![Documentation Status](https://readthedocs.org/projects/dpdata/badge/)](https://dpdata.readthedocs.io/)

**dpdata** is a python package for manipulating data formats of software in computational science, including DeePMD-kit, VASP, LAMMPS, GROMACS, Gaussian.
dpdata only works with python 3.7 or above.


## Installation
One can download the source code of dpdata by
```bash
git clone https://github.com/deepmodeling/dpdata.git dpdata
```
then use `pip` to install the module from source
```bash
cd dpdata
pip install .
```

`dpdata` can also by install via pip without source
```bash
pip 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.
```python
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
```python
d_poscar = dpdata.System("POSCAR", fmt="vasp/poscar")
```
or let dpdata infer the format (`vasp/poscar`) of the file from the file name extension
```python
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](https://github.com/deepmodeling/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,
```python
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         | False   | System	    | 'deepmd/raw'  |
| deepmd  | npy    | True         | False   | System        | 'deepmd/npy'  |
| deepmd  | raw    | True         | True    | LabeledSystem | 'deepmd/raw'  |
| deepmd  | npy    | True         | True    | LabeledSystem | 'deepmd/npy'  |
| deepmd  | npy    | True         | True    | MultiSystems | 'deepmd/npy/mixed'  |
| deepmd  | npy    | True         | False    | MultiSystems | 'deepmd/npy/mixed'  |
| gaussian| log    | False        | True    | LabeledSystem | 'gaussian/log'|
| gaussian| log    | True         | True    | LabeledSystem | 'gaussian/md' |
| siesta  | output | False        | True    | LabeledSystem | 'siesta/output'|
| siesta  | aimd_output  | True         | True    | LabeledSystem | 'siesta/aimd_output' |
| cp2k(deprecated in future)    | output | False        | True    | LabeledSystem | 'cp2k/output' |
| cp2k(deprecated in future)    | aimd_output  | True         | True    | LabeledSystem | 'cp2k/aimd_output' |
| cp2k([plug-in](https://github.com/robinzyb/cp2kdata#plug-in-for-dpdata))    | stdout | False        | True    | LabeledSystem | 'cp2kdata/e_f' |
| cp2k([plug-in](https://github.com/robinzyb/cp2kdata#plug-in-for-dpdata))    | stdout  | True         | True    | LabeledSystem | 'cp2kdata/md' |
| QE      | log    | False        | True    | LabeledSystem | 'qe/pw/scf'   |
| QE      | log    | True         | False   | System        | 'qe/cp/traj'  |
| QE      | log    | True         | True    | LabeledSystem | 'qe/cp/traj'  |
| Fhi-aims| output | True         | True    | LabeledSystem | 'fhi_aims/md'  |
| Fhi-aims| output | False        | True    | LabeledSystem | 'fhi_aims/scf'  |
|quip/gap|xyz|True|True|MultiSystems|'quip/gap/xyz'|
| PWmat   | atom.config | False        | False   | System        | 'pwmat/atom.config'  |
| PWmat   | movement    | True         | True    | LabeledSystem | 'pwmat/movement'     |
| PWmat   | OUT.MLMD    | True         | True    | LabeledSystem | 'pwmat/out.mlmd'     |
| Amber   | multi       | True         | True    | LabeledSystem | 'amber/md'           |
| Amber/sqm | sqm.out   | False        | False   | System        | 'sqm/out'            |
| Gromacs | gro         | True         | False   | System        | 'gromacs/gro'        |
| ABACUS  | STRU        | False        | False   | System        | 'abacus/stru'        |
| ABACUS  | STRU        | False        | True    | LabeledSystem | 'abacus/scf'         |
| ABACUS  | cif         | True         | True    | LabeledSystem | 'abacus/md'          |
| ABACUS  | STRU        | True         | True    | LabeledSystem | 'abacus/relax'       |
| ase     | structure   | True         | True    | MultiSystems  | 'ase/structure'      |
| DFTB+   | dftbplus    | False        | True    | LabeledSystem | 'dftbplus'           |
| n2p2    | n2p2        | True         | True    | LabeledSystem | 'n2p2'               |


The Class `dpdata.MultiSystems`  can read data  from a dir which may contains many files of different systems, or from single xyz file which contains different systems.

Use `dpdata.MultiSystems.from_dir` to read from a  directory, `dpdata.MultiSystems` will walk in the directory
Recursively  and  find all file with specific file_name. Supports all the file formats that `dpdata.LabeledSystem` supports.

Use  `dpdata.MultiSystems.from_file` to read from single file. Single-file support is available for the `quip/gap/xyz` and `ase/structure` formats.

For example, for `quip/gap xyz` files, single .xyz file may contain many different configurations with different atom numbers and atom type.

The following commands relating to `Class dpdata.MultiSystems` may be useful.
```python
# load data

xyz_multi_systems = dpdata.MultiSystems.from_file(
    file_name="tests/xyz/xyz_unittest.xyz", fmt="quip/gap/xyz"
)
vasp_multi_systems = dpdata.MultiSystems.from_dir(
    dir_name="./mgal_outcar", file_name="OUTCAR", fmt="vasp/outcar"
)

# use wildcard
vasp_multi_systems = dpdata.MultiSystems.from_dir(
    dir_name="./mgal_outcar", file_name="*OUTCAR", fmt="vasp/outcar"
)

# print the multi_system infomation
print(xyz_multi_systems)
print(xyz_multi_systems.systems)  # return a dictionaries

# print the system infomation
print(xyz_multi_systems.systems["B1C9"].data)

# dump a system's data to ./my_work_dir/B1C9_raw folder
xyz_multi_systems.systems["B1C9"].to_deepmd_raw("./my_work_dir/B1C9_raw")

# dump all systems
xyz_multi_systems.to_deepmd_raw("./my_deepmd_data/")
```

You may also use the following code to parse muti-system:
```python
from dpdata import LabeledSystem, MultiSystems
from glob import glob

"""
process multi systems
"""
fs = glob("./*/OUTCAR")  # remeber to change here !!!
ms = MultiSystems()
for f in fs:
    try:
        ls = LabeledSystem(f)
    except:
        print(f)
    if len(ls) > 0:
        ms.append(ls)

ms.to_deepmd_raw("deepmd")
ms.to_deepmd_npy("deepmd")
```

### Access data
These properties stored in `System` and `LabeledSystem` can be accessed by operator `[]` with the key of the property supplied, for example
```python
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:
```python
d_outcar.to("lammps/lmp", "conf.lmp", frame_idx=0)
```
The first frames of `d_outcar` will be dumped to 'conf.lmp'
```python
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
```python
d_outcar.to("deepmd/raw", "dpmd_raw")
```
Or a simpler command:
```python
dpdata.LabeledSystem("OUTCAR").to("deepmd/raw", "dpmd_raw")
```
Frame selection can be implemented by
```python
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`.


### replicate
dpdata will create a super cell of the current atom configuration.
```python
dpdata.System("./POSCAR").replicate(
    (
        1,
        2,
        3,
    )
)
```
tuple(1,2,3) means don't copy atom configuration in x direction, make 2 copys in y direction, make 3 copys in z direction.


### perturb
By the following example, each frame of the original system (`dpdata.System('./POSCAR')`) is perturbed to generate three new frames. For each frame, the cell is perturbed by 5% and the atom positions are perturbed by 0.6 Angstrom. `atom_pert_style` indicates that the perturbation to the atom positions is subject to normal distribution. Other available options to `atom_pert_style` are`uniform` (uniform in a ball), and `const` (uniform on a sphere).
```python
perturbed_system = dpdata.System("./POSCAR").perturb(
    pert_num=3,
    cell_pert_fraction=0.05,
    atom_pert_distance=0.6,
    atom_pert_style="normal",
)
print(perturbed_system.data)
```

### replace
By the following example, Random 8 Hf atoms in the system will be replaced by Zr atoms with the atom postion unchanged.
```python
s = dpdata.System("tests/poscars/POSCAR.P42nmc", fmt="vasp/poscar")
s.replace("Hf", "Zr", 8)
s.to_vasp_poscar("POSCAR.P42nmc.replace")
```

## BondOrderSystem
A new class `BondOrderSystem` which inherits from class `System` is introduced in dpdata. This new class contains information of chemical bonds and formal charges (stored in `BondOrderSystem.data['bonds']`, `BondOrderSystem.data['formal_charges']`). Now BondOrderSystem can only read from .mol/.sdf formats, because of its dependency on rdkit (which means rdkit must be installed if you want to use this function). Other formats, such as pdb, must be converted to .mol/.sdf format (maybe with software like open babel).
```python
import dpdata

system_1 = dpdata.BondOrderSystem(
    "tests/bond_order/CH3OH.mol", fmt="mol"
)  # read from .mol file
system_2 = dpdata.BondOrderSystem(
    "tests/bond_order/methane.sdf", fmt="sdf"
)  # read from .sdf file
```
In sdf file, all molecules must be of the same topology (i.e. conformers of the same molecular configuration).
`BondOrderSystem` also supports initialize from a `rdkit.Chem.rdchem.Mol` object directly.
```python
from rdkit import Chem
from rdkit.Chem import AllChem
import dpdata

mol = Chem.MolFromSmiles("CC")
mol = Chem.AddHs(mol)
AllChem.EmbedMultipleConfs(mol, 10)
system = dpdata.BondOrderSystem(rdkit_mol=mol)
```

### Bond Order Assignment
The `BondOrderSystem` implements a more robust sanitize procedure for rdkit Mol, as defined in `dpdata.rdkit.santizie.Sanitizer`. This class defines 3 level of sanitization process by: low, medium and high. (default is medium).
+ low: use `rdkit.Chem.SanitizeMol()` function to sanitize molecule.
+ medium: before using rdkit, the programm will first assign formal charge of each atom to avoid inappropriate valence exceptions. However, this mode requires the rightness of the bond order information in the given molecule.
+ high: the program will try to fix inappropriate bond orders in aromatic hetreocycles, phosphate, sulfate, carboxyl, nitro, nitrine, guanidine groups. If this procedure fails to sanitize the given molecule, the program will then try to call `obabel` to pre-process the mol and repeat the sanitization procedure. **That is to say, if you wan't to use this level of sanitization, please ensure `obabel` is installed in the environment.**
According to our test, our sanitization procedure can successfully read 4852 small molecules in the PDBBind-refined-set. It is necessary to point out that the in the molecule file (mol/sdf), the number of explicit hydrogens has to be correct. Thus, we recommend to use
 `obabel xxx -O xxx -h` to pre-process the file. The reason why we do not implement this hydrogen-adding procedure in dpdata is that we can not ensure its correctness.

```python
import dpdata

for sdf_file in glob.glob("bond_order/refined-set-ligands/obabel/*sdf"):
    syst = dpdata.BondOrderSystem(sdf_file, sanitize_level="high", verbose=False)
```
### Formal Charge Assignment
BondOrderSystem implement a method to assign formal charge for each atom based on the 8-electron rule (see below). Note that it only supports common elements in bio-system: B,C,N,O,P,S,As
```python
import dpdata

syst = dpdata.BondOrderSystem("tests/bond_order/CH3NH3+.mol", fmt="mol")
print(syst.get_formal_charges())  # return the formal charge on each atom
print(syst.get_charge())  # return the total charge of the system
```

If a valence of 3 is detected on carbon, the formal charge will be assigned to -1. Because for most cases (in alkynyl anion, isonitrile, cyclopentadienyl anion), the formal charge on 3-valence carbon is -1, and this is also consisent with the 8-electron rule.

## Mixed Type Format
The format `deepmd/npy/mixed` is the mixed type numpy format for DeePMD-kit, and can be loaded or dumped through class `dpdata.MultiSystems`.

Under this format, systems with the same number of atoms but different formula can be put together
for a larger system, especially when the frame numbers in systems are sparse.

This also helps to mixture the type information together for model training with type embedding network.

Here are examples using `deepmd/npy/mixed` format:

- Dump a MultiSystems into a mixed type numpy directory:
```python
import dpdata

dpdata.MultiSystems(*systems).to_deepmd_npy_mixed("mixed_dir")
```

- Load a mixed type data into a MultiSystems:
```python
import dpdata

dpdata.MultiSystems().load_systems_from_file("mixed_dir", fmt="deepmd/npy/mixed")
```

## Plugins

One can follow [a simple example](plugin_example/) to add their own format by creating and installing plugins. It's critical to add the [Format](dpdata/format.py) class to `entry_points['dpdata.plugins']` in [`pyproject.toml`](plugin_example/pyproject.toml):
```toml
[project.entry-points.'dpdata.plugins']
random = "dpdata_random:RandomFormat"
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dpdata",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "lammps, vasp, deepmd-kit",
    "author": "DeepModeling",
    "author_email": "Han Wang <wang_han@iapcm.ac.cn>",
    "download_url": "https://files.pythonhosted.org/packages/42/43/929d3440fcad559b57017ddd7bc5bfede2f178ce1f5c2219567e47f762cc/dpdata-0.2.19.tar.gz",
    "platform": null,
    "description": "# dpdata\n\n[![conda-forge](https://img.shields.io/conda/dn/conda-forge/dpdata?color=red&label=conda-forge&logo=conda-forge)](https://anaconda.org/conda-forge/dpdata)\n[![pip install](https://img.shields.io/pypi/dm/dpdata?label=pip%20install&logo=pypi)](https://pypi.org/project/dpdata)\n[![Documentation Status](https://readthedocs.org/projects/dpdata/badge/)](https://dpdata.readthedocs.io/)\n\n**dpdata** is a python package for manipulating data formats of software in computational science, including DeePMD-kit, VASP, LAMMPS, GROMACS, Gaussian.\ndpdata only works with python 3.7 or above.\n\n\n## Installation\nOne can download the source code of dpdata by\n```bash\ngit clone https://github.com/deepmodeling/dpdata.git dpdata\n```\nthen use `pip` to install the module from source\n```bash\ncd dpdata\npip install .\n```\n\n`dpdata` can also by install via pip without source\n```bash\npip install dpdata\n```\n\n\n## Quick start\n\nThis section gives some examples on how dpdata works. Firstly one needs to import the module in a python 3.x compatible code.\n```python\nimport dpdata\n```\nThe typicall workflow of `dpdata` is\n\n1. Load data from vasp or lammps or deepmd-kit data files.\n2. Manipulate data\n3. Dump data to in a desired format\n\n\n### Load data\n```python\nd_poscar = dpdata.System(\"POSCAR\", fmt=\"vasp/poscar\")\n```\nor let dpdata infer the format (`vasp/poscar`) of the file from the file name extension\n```python\nd_poscar = dpdata.System(\"my.POSCAR\")\n```\nThe number of atoms, atom types, coordinates are loaded from the `POSCAR` and stored to a data `System` called `d_poscar`.\nA data `System` (a concept used by [deepmd-kit](https://github.com/deepmodeling/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`.\nIt is noted that `POSCAR` only contains one frame.\nIf the multiple frames stored in, for example, a `OUTCAR` is wanted,\n```python\nd_outcar = dpdata.LabeledSystem(\"OUTCAR\")\n```\nThe 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`.\n\nThe `System` or `LabeledSystem` can be constructed from the following file formats with the `format key` in the table passed to argument `fmt`:\n\n| Software| format | multi frames | labeled | class\t    | format key    |\n| ------- | :---   | :---:        | :---:   | :---          | :---          |\n| vasp\t  | poscar | False        | False   | System\t    | 'vasp/poscar' |\n| vasp    | outcar | True         | True    | LabeledSystem | 'vasp/outcar' |\n| vasp    | xml    | True         | True    | LabeledSystem | 'vasp/xml'    |\n| lammps  | lmp    | False        | False   | System        | 'lammps/lmp'  |\n| lammps  | dump   | True         | False   | System        | 'lammps/dump' |\n| deepmd  | raw    | True         | False   | System\t    | 'deepmd/raw'  |\n| deepmd  | npy    | True         | False   | System        | 'deepmd/npy'  |\n| deepmd  | raw    | True         | True    | LabeledSystem | 'deepmd/raw'  |\n| deepmd  | npy    | True         | True    | LabeledSystem | 'deepmd/npy'  |\n| deepmd  | npy    | True         | True    | MultiSystems | 'deepmd/npy/mixed'  |\n| deepmd  | npy    | True         | False    | MultiSystems | 'deepmd/npy/mixed'  |\n| gaussian| log    | False        | True    | LabeledSystem | 'gaussian/log'|\n| gaussian| log    | True         | True    | LabeledSystem | 'gaussian/md' |\n| siesta  | output | False        | True    | LabeledSystem | 'siesta/output'|\n| siesta  | aimd_output  | True         | True    | LabeledSystem | 'siesta/aimd_output' |\n| cp2k(deprecated in future)    | output | False        | True    | LabeledSystem | 'cp2k/output' |\n| cp2k(deprecated in future)    | aimd_output  | True         | True    | LabeledSystem | 'cp2k/aimd_output' |\n| cp2k([plug-in](https://github.com/robinzyb/cp2kdata#plug-in-for-dpdata))    | stdout | False        | True    | LabeledSystem | 'cp2kdata/e_f' |\n| cp2k([plug-in](https://github.com/robinzyb/cp2kdata#plug-in-for-dpdata))    | stdout  | True         | True    | LabeledSystem | 'cp2kdata/md' |\n| QE      | log    | False        | True    | LabeledSystem | 'qe/pw/scf'   |\n| QE      | log    | True         | False   | System        | 'qe/cp/traj'  |\n| QE      | log    | True         | True    | LabeledSystem | 'qe/cp/traj'  |\n| Fhi-aims| output | True         | True    | LabeledSystem | 'fhi_aims/md'  |\n| Fhi-aims| output | False        | True    | LabeledSystem | 'fhi_aims/scf'  |\n|quip/gap|xyz|True|True|MultiSystems|'quip/gap/xyz'|\n| PWmat   | atom.config | False        | False   | System        | 'pwmat/atom.config'  |\n| PWmat   | movement    | True         | True    | LabeledSystem | 'pwmat/movement'     |\n| PWmat   | OUT.MLMD    | True         | True    | LabeledSystem | 'pwmat/out.mlmd'     |\n| Amber   | multi       | True         | True    | LabeledSystem | 'amber/md'           |\n| Amber/sqm | sqm.out   | False        | False   | System        | 'sqm/out'            |\n| Gromacs | gro         | True         | False   | System        | 'gromacs/gro'        |\n| ABACUS  | STRU        | False        | False   | System        | 'abacus/stru'        |\n| ABACUS  | STRU        | False        | True    | LabeledSystem | 'abacus/scf'         |\n| ABACUS  | cif         | True         | True    | LabeledSystem | 'abacus/md'          |\n| ABACUS  | STRU        | True         | True    | LabeledSystem | 'abacus/relax'       |\n| ase     | structure   | True         | True    | MultiSystems  | 'ase/structure'      |\n| DFTB+   | dftbplus    | False        | True    | LabeledSystem | 'dftbplus'           |\n| n2p2    | n2p2        | True         | True    | LabeledSystem | 'n2p2'               |\n\n\nThe Class `dpdata.MultiSystems`  can read data  from a dir which may contains many files of different systems, or from single xyz file which contains different systems.\n\nUse `dpdata.MultiSystems.from_dir` to read from a  directory, `dpdata.MultiSystems` will walk in the directory\nRecursively  and  find all file with specific file_name. Supports all the file formats that `dpdata.LabeledSystem` supports.\n\nUse  `dpdata.MultiSystems.from_file` to read from single file. Single-file support is available for the `quip/gap/xyz` and `ase/structure` formats.\n\nFor example, for `quip/gap xyz` files, single .xyz file may contain many different configurations with different atom numbers and atom type.\n\nThe following commands relating to `Class dpdata.MultiSystems` may be useful.\n```python\n# load data\n\nxyz_multi_systems = dpdata.MultiSystems.from_file(\n    file_name=\"tests/xyz/xyz_unittest.xyz\", fmt=\"quip/gap/xyz\"\n)\nvasp_multi_systems = dpdata.MultiSystems.from_dir(\n    dir_name=\"./mgal_outcar\", file_name=\"OUTCAR\", fmt=\"vasp/outcar\"\n)\n\n# use wildcard\nvasp_multi_systems = dpdata.MultiSystems.from_dir(\n    dir_name=\"./mgal_outcar\", file_name=\"*OUTCAR\", fmt=\"vasp/outcar\"\n)\n\n# print the multi_system infomation\nprint(xyz_multi_systems)\nprint(xyz_multi_systems.systems)  # return a dictionaries\n\n# print the system infomation\nprint(xyz_multi_systems.systems[\"B1C9\"].data)\n\n# dump a system's data to ./my_work_dir/B1C9_raw folder\nxyz_multi_systems.systems[\"B1C9\"].to_deepmd_raw(\"./my_work_dir/B1C9_raw\")\n\n# dump all systems\nxyz_multi_systems.to_deepmd_raw(\"./my_deepmd_data/\")\n```\n\nYou may also use the following code to parse muti-system:\n```python\nfrom dpdata import LabeledSystem, MultiSystems\nfrom glob import glob\n\n\"\"\"\nprocess multi systems\n\"\"\"\nfs = glob(\"./*/OUTCAR\")  # remeber to change here !!!\nms = MultiSystems()\nfor f in fs:\n    try:\n        ls = LabeledSystem(f)\n    except:\n        print(f)\n    if len(ls) > 0:\n        ms.append(ls)\n\nms.to_deepmd_raw(\"deepmd\")\nms.to_deepmd_npy(\"deepmd\")\n```\n\n### Access data\nThese properties stored in `System` and `LabeledSystem` can be accessed by operator `[]` with the key of the property supplied, for example\n```python\ncoords = d_outcar[\"coords\"]\n```\nAvailable properties are (nframe: number of frames in the system, natoms: total number of atoms in the system)\n\n| key\t\t|  type\t\t| dimension\t\t| are labels\t| description\n| ---\t\t| ---\t\t| ---\t\t\t| ---\t\t| ---\n| 'atom_names'\t| list of str\t| ntypes\t\t| False\t\t| The name of each atom type\n| 'atom_numbs'\t| list of int\t| ntypes\t\t| False\t\t| The number of atoms of each atom type\n| 'atom_types'\t| np.ndarray\t| natoms\t\t| False\t\t| Array assigning type to each atom\n| 'cells'\t| np.ndarray\t| nframes x 3 x 3\t| False\t\t| The cell tensor of each frame\n| 'coords'\t| np.ndarray\t| nframes x natoms x 3\t| False\t\t| The atom coordinates\n| 'energies'\t| np.ndarray\t| nframes\t\t| True\t\t| The frame energies\n| 'forces'\t| np.ndarray\t| nframes x natoms x 3\t| True\t\t| The atom forces\n| 'virials'\t| np.ndarray\t| nframes x 3 x 3\t| True\t\t| The virial tensor of each frame\n\n\n### Dump data\nThe data stored in `System` or `LabeledSystem` can be dumped in 'lammps/lmp' or 'vasp/poscar' format, for example:\n```python\nd_outcar.to(\"lammps/lmp\", \"conf.lmp\", frame_idx=0)\n```\nThe first frames of `d_outcar` will be dumped to 'conf.lmp'\n```python\nd_outcar.to(\"vasp/poscar\", \"POSCAR\", frame_idx=-1)\n```\nThe last frames of `d_outcar` will be dumped to 'POSCAR'.\n\nThe data stored in `LabeledSystem` can be dumped to deepmd-kit raw format, for example\n```python\nd_outcar.to(\"deepmd/raw\", \"dpmd_raw\")\n```\nOr a simpler command:\n```python\ndpdata.LabeledSystem(\"OUTCAR\").to(\"deepmd/raw\", \"dpmd_raw\")\n```\nFrame selection can be implemented by\n```python\ndpdata.LabeledSystem(\"OUTCAR\").sub_system([0, -1]).to(\"deepmd/raw\", \"dpmd_raw\")\n```\nby which only the first and last frames are dumped to `dpmd_raw`.\n\n\n### replicate\ndpdata will create a super cell of the current atom configuration.\n```python\ndpdata.System(\"./POSCAR\").replicate(\n    (\n        1,\n        2,\n        3,\n    )\n)\n```\ntuple(1,2,3) means don't copy atom configuration in x direction, make 2 copys in y direction, make 3 copys in z direction.\n\n\n### perturb\nBy the following example, each frame of the original system (`dpdata.System('./POSCAR')`) is perturbed to generate three new frames. For each frame, the cell is perturbed by 5% and the atom positions are perturbed by 0.6 Angstrom. `atom_pert_style` indicates that the perturbation to the atom positions is subject to normal distribution. Other available options to `atom_pert_style` are`uniform` (uniform in a ball), and `const` (uniform on a sphere).\n```python\nperturbed_system = dpdata.System(\"./POSCAR\").perturb(\n    pert_num=3,\n    cell_pert_fraction=0.05,\n    atom_pert_distance=0.6,\n    atom_pert_style=\"normal\",\n)\nprint(perturbed_system.data)\n```\n\n### replace\nBy the following example, Random 8 Hf atoms in the system will be replaced by Zr atoms with the atom postion unchanged.\n```python\ns = dpdata.System(\"tests/poscars/POSCAR.P42nmc\", fmt=\"vasp/poscar\")\ns.replace(\"Hf\", \"Zr\", 8)\ns.to_vasp_poscar(\"POSCAR.P42nmc.replace\")\n```\n\n## BondOrderSystem\nA new class `BondOrderSystem` which inherits from class `System` is introduced in dpdata. This new class contains information of chemical bonds and formal charges (stored in `BondOrderSystem.data['bonds']`, `BondOrderSystem.data['formal_charges']`). Now BondOrderSystem can only read from .mol/.sdf formats, because of its dependency on rdkit (which means rdkit must be installed if you want to use this function). Other formats, such as pdb, must be converted to .mol/.sdf format (maybe with software like open babel).\n```python\nimport dpdata\n\nsystem_1 = dpdata.BondOrderSystem(\n    \"tests/bond_order/CH3OH.mol\", fmt=\"mol\"\n)  # read from .mol file\nsystem_2 = dpdata.BondOrderSystem(\n    \"tests/bond_order/methane.sdf\", fmt=\"sdf\"\n)  # read from .sdf file\n```\nIn sdf file, all molecules must be of the same topology (i.e. conformers of the same molecular configuration).\n`BondOrderSystem` also supports initialize from a `rdkit.Chem.rdchem.Mol` object directly.\n```python\nfrom rdkit import Chem\nfrom rdkit.Chem import AllChem\nimport dpdata\n\nmol = Chem.MolFromSmiles(\"CC\")\nmol = Chem.AddHs(mol)\nAllChem.EmbedMultipleConfs(mol, 10)\nsystem = dpdata.BondOrderSystem(rdkit_mol=mol)\n```\n\n### Bond Order Assignment\nThe `BondOrderSystem` implements a more robust sanitize procedure for rdkit Mol, as defined in `dpdata.rdkit.santizie.Sanitizer`. This class defines 3 level of sanitization process by: low, medium and high. (default is medium).\n+ low: use `rdkit.Chem.SanitizeMol()` function to sanitize molecule.\n+ medium: before using rdkit, the programm will first assign formal charge of each atom to avoid inappropriate valence exceptions. However, this mode requires the rightness of the bond order information in the given molecule.\n+ high: the program will try to fix inappropriate bond orders in aromatic hetreocycles, phosphate, sulfate, carboxyl, nitro, nitrine, guanidine groups. If this procedure fails to sanitize the given molecule, the program will then try to call `obabel` to pre-process the mol and repeat the sanitization procedure. **That is to say, if you wan't to use this level of sanitization, please ensure `obabel` is installed in the environment.**\nAccording to our test, our sanitization procedure can successfully read 4852 small molecules in the PDBBind-refined-set. It is necessary to point out that the in the molecule file (mol/sdf), the number of explicit hydrogens has to be correct. Thus, we recommend to use\n `obabel xxx -O xxx -h` to pre-process the file. The reason why we do not implement this hydrogen-adding procedure in dpdata is that we can not ensure its correctness.\n\n```python\nimport dpdata\n\nfor sdf_file in glob.glob(\"bond_order/refined-set-ligands/obabel/*sdf\"):\n    syst = dpdata.BondOrderSystem(sdf_file, sanitize_level=\"high\", verbose=False)\n```\n### Formal Charge Assignment\nBondOrderSystem implement a method to assign formal charge for each atom based on the 8-electron rule (see below). Note that it only supports common elements in bio-system: B,C,N,O,P,S,As\n```python\nimport dpdata\n\nsyst = dpdata.BondOrderSystem(\"tests/bond_order/CH3NH3+.mol\", fmt=\"mol\")\nprint(syst.get_formal_charges())  # return the formal charge on each atom\nprint(syst.get_charge())  # return the total charge of the system\n```\n\nIf a valence of 3 is detected on carbon, the formal charge will be assigned to -1. Because for most cases (in alkynyl anion, isonitrile, cyclopentadienyl anion), the formal charge on 3-valence carbon is -1, and this is also consisent with the 8-electron rule.\n\n## Mixed Type Format\nThe format `deepmd/npy/mixed` is the mixed type numpy format for DeePMD-kit, and can be loaded or dumped through class `dpdata.MultiSystems`.\n\nUnder this format, systems with the same number of atoms but different formula can be put together\nfor a larger system, especially when the frame numbers in systems are sparse.\n\nThis also helps to mixture the type information together for model training with type embedding network.\n\nHere are examples using `deepmd/npy/mixed` format:\n\n- Dump a MultiSystems into a mixed type numpy directory:\n```python\nimport dpdata\n\ndpdata.MultiSystems(*systems).to_deepmd_npy_mixed(\"mixed_dir\")\n```\n\n- Load a mixed type data into a MultiSystems:\n```python\nimport dpdata\n\ndpdata.MultiSystems().load_systems_from_file(\"mixed_dir\", fmt=\"deepmd/npy/mixed\")\n```\n\n## Plugins\n\nOne can follow [a simple example](plugin_example/) to add their own format by creating and installing plugins. It's critical to add the [Format](dpdata/format.py) class to `entry_points['dpdata.plugins']` in [`pyproject.toml`](plugin_example/pyproject.toml):\n```toml\n[project.entry-points.'dpdata.plugins']\nrandom = \"dpdata_random:RandomFormat\"\n```\n",
    "bugtrack_url": null,
    "license": "GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.   This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.  0. Additional Definitions.  As used herein, \"this License\" refers to version 3 of the GNU Lesser General Public License, and the \"GNU GPL\" refers to version 3 of the GNU General Public License.  \"The Library\" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.  An \"Application\" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.  A \"Combined Work\" is a work produced by combining or linking an Application with the Library.  The particular version of the Library with which the Combined Work was made is also called the \"Linked Version\".  The \"Minimal Corresponding Source\" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.  The \"Corresponding Application Code\" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.  1. Exception to Section 3 of the GNU GPL.  You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.  2. Conveying Modified Versions.  If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:  a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or  b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.  3. Object Code Incorporating Material from Library Header Files.  The object code form of an Application may incorporate material from a header file that is part of the Library.  You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:  a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.  b) Accompany the object code with a copy of the GNU GPL and this license document.  4. Combined Works.  You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:  a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.  b) Accompany the Combined Work with a copy of the GNU GPL and this license document.  c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.  d) Do one of the following:  0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.  1) Use a suitable shared library mechanism for linking with the Library.  A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.  e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)  5. Combined Libraries.  You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:  a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.  b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.  6. Revised Versions of the GNU Lesser General Public License.  The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.  Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License \"or any later version\" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.  If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ",
    "summary": "Manipulating data formats of DeePMD-kit, VASP, QE, PWmat, and LAMMPS, etc.",
    "version": "0.2.19",
    "project_urls": {
        "Homepage": "https://github.com/deepmodeling/dpdata",
        "documentation": "https://docs.deepmodeling.com/projects/dpdata",
        "repository": "https://github.com/deepmodeling/dpdata"
    },
    "split_keywords": [
        "lammps",
        " vasp",
        " deepmd-kit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "58feceffd9c973d81e775ac6fd3dbb9f203cbc24a908bfc6ab8335f889925cf1",
                "md5": "635990ab50968699a319ba197d1e85e3",
                "sha256": "a93ffdc3e8c2229380b81c70d5a4b424b801d148bfb9925f071ab9fc63b88540"
            },
            "downloads": -1,
            "filename": "dpdata-0.2.19-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "635990ab50968699a319ba197d1e85e3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 151395,
            "upload_time": "2024-06-06T00:07:03",
            "upload_time_iso_8601": "2024-06-06T00:07:03.167512Z",
            "url": "https://files.pythonhosted.org/packages/58/fe/ceffd9c973d81e775ac6fd3dbb9f203cbc24a908bfc6ab8335f889925cf1/dpdata-0.2.19-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4243929d3440fcad559b57017ddd7bc5bfede2f178ce1f5c2219567e47f762cc",
                "md5": "642964c5312dfdba705b8dfc3127273d",
                "sha256": "83233e2356321db88a93561487f11a985a0cce96709f041b8e4f2807fcc9f38e"
            },
            "downloads": -1,
            "filename": "dpdata-0.2.19.tar.gz",
            "has_sig": false,
            "md5_digest": "642964c5312dfdba705b8dfc3127273d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 128893,
            "upload_time": "2024-06-06T00:07:05",
            "upload_time_iso_8601": "2024-06-06T00:07:05.431645Z",
            "url": "https://files.pythonhosted.org/packages/42/43/929d3440fcad559b57017ddd7bc5bfede2f178ce1f5c2219567e47f762cc/dpdata-0.2.19.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-06 00:07:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "deepmodeling",
    "github_project": "dpdata",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dpdata"
}
        
Elapsed time: 0.24947s