dpdata 0.2.21__tar.gz → 0.2.22__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/workflows/benchmark.yml +6 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/workflows/test.yml +10 -4
- {dpdata-0.2.21 → dpdata-0.2.22}/.pre-commit-config.yaml +3 -3
- {dpdata-0.2.21 → dpdata-0.2.22}/.readthedocs.yaml +1 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/PKG-INFO +6 -8
- {dpdata-0.2.21 → dpdata-0.2.22}/README.md +1 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/_version.py +2 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/abacus/md.py +11 -9
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/abacus/relax.py +6 -4
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/abacus/scf.py +133 -60
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/ase_calculator.py +2 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/data_type.py +1 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/deepmd/comp.py +2 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/deepmd/hdf5.py +2 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/deepmd/mixed.py +3 -3
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/deepmd/raw.py +1 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/driver.py +2 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/gaussian/gjf.py +4 -4
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/lammps/dump.py +104 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/lammps/lmp.py +74 -15
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/abacus.py +22 -3
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/amber.py +2 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/ase.py +9 -3
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/deepmd.py +30 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/gaussian.py +2 -2
- dpdata-0.2.22/dpdata/plugins/lammps.py +101 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/n2p2.py +9 -9
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/pwmat.py +3 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/pymatgen.py +4 -5
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/vasp.py +19 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/pwmat/atomconfig.py +2 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/pymatgen/structure.py +10 -1
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/qe/traj.py +2 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/rdkit/sanitize.py +2 -2
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/stat.py +19 -18
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/system.py +19 -14
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/unit.py +24 -6
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/utils.py +1 -6
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/vasp/outcar.py +3 -3
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/vasp/poscar.py +52 -7
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/vasp/xml.py +5 -5
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/xyz/quip_gap_xyz.py +5 -5
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata.egg-info/PKG-INFO +6 -8
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata.egg-info/requires.txt +2 -3
- {dpdata-0.2.21 → dpdata-0.2.22}/pyproject.toml +4 -8
- dpdata-0.2.21/dpdata/plugins/lammps.py +0 -51
- {dpdata-0.2.21 → dpdata-0.2.22}/.git-blame-ignore-revs +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.git_archival.txt +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.gitattributes +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/ISSUE_TEMPLATE/generic-issue.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/dependabot.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/workflows/mirror_gitee.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/workflows/pub-pypi.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/workflows/pyright.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.github/workflows/test_import.yml +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/.gitignore +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/LICENSE +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/MANIFEST.in +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/benchmark/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/benchmark/test_import.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/__about__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/__main__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/abacus/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/amber/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/amber/mask.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/amber/md.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/amber/sqm.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/bond_order_system.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/cli.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/cp2k/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/cp2k/cell.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/cp2k/output.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/deepmd/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/dftbplus/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/dftbplus/output.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/fhi_aims/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/fhi_aims/output.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/format.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/gaussian/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/gaussian/log.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/gromacs/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/gromacs/gro.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/lammps/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/md/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/md/msd.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/md/pbc.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/md/rdf.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/md/water.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/openmx/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/openmx/omx.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/orca/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/orca/output.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/periodic_table.json +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/periodic_table.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugin.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/3dmol.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/cp2k.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/dftbplus.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/fhi_aims.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/gromacs.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/list.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/openmx.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/orca.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/psi4.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/qe.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/rdkit.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/siesta.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/plugins/xyz.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/psi4/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/psi4/input.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/psi4/output.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/pwmat/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/pwmat/movement.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/py.typed +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/pymatgen/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/pymatgen/molecule.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/qe/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/qe/scf.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/rdkit/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/rdkit/utils.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/siesta/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/siesta/aiMD_output.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/siesta/output.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/vasp/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/xyz/__init__.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata/xyz/xyz.py +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata.egg-info/SOURCES.txt +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata.egg-info/dependency_links.txt +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata.egg-info/entry_points.txt +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/dpdata.egg-info/top_level.txt +0 -0
- {dpdata-0.2.21 → dpdata-0.2.22}/setup.cfg +0 -0
|
@@ -13,7 +13,12 @@ jobs:
|
|
|
13
13
|
uses: actions/setup-python@v5
|
|
14
14
|
with:
|
|
15
15
|
python-version: 3.12
|
|
16
|
-
-
|
|
16
|
+
- uses: astral-sh/setup-uv@v5
|
|
17
|
+
with:
|
|
18
|
+
enable-cache: true
|
|
19
|
+
cache-dependency-glob: |
|
|
20
|
+
**/requirements*.txt
|
|
21
|
+
**/pyproject.toml
|
|
17
22
|
- name: Install dependencies
|
|
18
23
|
run: uv pip install --system .[test,amber,ase,pymatgen,benchmark] rdkit openbabel-wheel
|
|
19
24
|
- name: Run benchmarks
|
|
@@ -6,10 +6,10 @@ on:
|
|
|
6
6
|
|
|
7
7
|
jobs:
|
|
8
8
|
build:
|
|
9
|
-
runs-on: ubuntu-
|
|
9
|
+
runs-on: ubuntu-22.04
|
|
10
10
|
strategy:
|
|
11
11
|
matrix:
|
|
12
|
-
python-version: ["3.
|
|
12
|
+
python-version: ["3.8", "3.12"]
|
|
13
13
|
|
|
14
14
|
steps:
|
|
15
15
|
- uses: actions/checkout@v4
|
|
@@ -18,13 +18,19 @@ jobs:
|
|
|
18
18
|
uses: actions/setup-python@v5
|
|
19
19
|
with:
|
|
20
20
|
python-version: ${{ matrix.python-version }}
|
|
21
|
-
-
|
|
21
|
+
- uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
enable-cache: true
|
|
24
|
+
cache-dependency-glob: |
|
|
25
|
+
**/requirements*.txt
|
|
26
|
+
**/pyproject.toml
|
|
27
|
+
cache-suffix: "py${{ matrix.python-version }}"
|
|
22
28
|
- name: Install dependencies
|
|
23
29
|
run: uv pip install --system .[test,amber,ase,pymatgen] coverage ./tests/plugin rdkit openbabel-wheel
|
|
24
30
|
- name: Test
|
|
25
31
|
run: cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report
|
|
26
32
|
- name: Run codecov
|
|
27
|
-
uses: codecov/codecov-action@
|
|
33
|
+
uses: codecov/codecov-action@v5
|
|
28
34
|
env:
|
|
29
35
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
30
36
|
pass:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
3
|
repos:
|
|
4
4
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
-
rev:
|
|
5
|
+
rev: v5.0.0
|
|
6
6
|
hooks:
|
|
7
7
|
# there are many log files in tests
|
|
8
8
|
# TODO: seperate py files and log files
|
|
@@ -21,7 +21,7 @@ repos:
|
|
|
21
21
|
# Python
|
|
22
22
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
23
23
|
# Ruff version.
|
|
24
|
-
rev: v0.
|
|
24
|
+
rev: v0.9.2
|
|
25
25
|
hooks:
|
|
26
26
|
- id: ruff
|
|
27
27
|
args: ["--fix"]
|
|
@@ -36,7 +36,7 @@ repos:
|
|
|
36
36
|
args: ["--write"]
|
|
37
37
|
# Python inside docs
|
|
38
38
|
- repo: https://github.com/asottile/blacken-docs
|
|
39
|
-
rev: 1.
|
|
39
|
+
rev: 1.19.1
|
|
40
40
|
hooks:
|
|
41
41
|
- id: blacken-docs
|
|
42
42
|
ci:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: dpdata
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.22
|
|
4
4
|
Summary: Manipulating data formats of DeePMD-kit, VASP, QE, PWmat, and LAMMPS, etc.
|
|
5
5
|
Author: DeepModeling
|
|
6
6
|
Author-email: Han Wang <wang_han@iapcm.ac.cn>
|
|
@@ -174,13 +174,12 @@ Project-URL: Homepage, https://github.com/deepmodeling/dpdata
|
|
|
174
174
|
Project-URL: documentation, https://docs.deepmodeling.com/projects/dpdata
|
|
175
175
|
Project-URL: repository, https://github.com/deepmodeling/dpdata
|
|
176
176
|
Keywords: lammps,vasp,deepmd-kit
|
|
177
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
178
177
|
Classifier: Programming Language :: Python :: 3.8
|
|
179
178
|
Classifier: Programming Language :: Python :: 3.9
|
|
180
179
|
Classifier: Programming Language :: Python :: 3.10
|
|
181
180
|
Classifier: Programming Language :: Python :: 3.11
|
|
182
181
|
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
|
|
183
|
-
Requires-Python: >=3.
|
|
182
|
+
Requires-Python: >=3.8
|
|
184
183
|
Description-Content-Type: text/markdown
|
|
185
184
|
License-File: LICENSE
|
|
186
185
|
Requires-Dist: numpy>=1.14.3
|
|
@@ -191,7 +190,6 @@ Requires-Dist: wcmatch
|
|
|
191
190
|
Requires-Dist: importlib_metadata>=1.4; python_version < "3.8"
|
|
192
191
|
Requires-Dist: typing_extensions; python_version < "3.8"
|
|
193
192
|
Provides-Extra: test
|
|
194
|
-
Requires-Dist: numpy<2; extra == "test"
|
|
195
193
|
Provides-Extra: ase
|
|
196
194
|
Requires-Dist: ase; extra == "ase"
|
|
197
195
|
Provides-Extra: amber
|
|
@@ -202,10 +200,10 @@ Requires-Dist: pymatgen; extra == "pymatgen"
|
|
|
202
200
|
Provides-Extra: docs
|
|
203
201
|
Requires-Dist: sphinx; extra == "docs"
|
|
204
202
|
Requires-Dist: recommonmark; extra == "docs"
|
|
205
|
-
Requires-Dist:
|
|
203
|
+
Requires-Dist: sphinx-book-theme; extra == "docs"
|
|
206
204
|
Requires-Dist: numpydoc; extra == "docs"
|
|
207
205
|
Requires-Dist: myst-parser; extra == "docs"
|
|
208
|
-
Requires-Dist: deepmodeling-sphinx>=0.
|
|
206
|
+
Requires-Dist: deepmodeling-sphinx>=0.3.0; extra == "docs"
|
|
209
207
|
Requires-Dist: sphinx-argparse<0.5.0; extra == "docs"
|
|
210
208
|
Requires-Dist: rdkit; extra == "docs"
|
|
211
209
|
Requires-Dist: jupyterlite-sphinx; extra == "docs"
|
|
@@ -224,7 +222,7 @@ Requires-Dist: pytest-codspeed; extra == "benchmark"
|
|
|
224
222
|
|
|
225
223
|
## Installation
|
|
226
224
|
|
|
227
|
-
|
|
225
|
+
dpdata only supports Python 3.8 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install dpdata:
|
|
228
226
|
|
|
229
227
|
- Install via pip: `pip install dpdata`
|
|
230
228
|
- Install via conda: `conda install -c conda-forge dpdata`
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
dpdata only supports Python 3.8 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install dpdata:
|
|
12
12
|
|
|
13
13
|
- Install via pip: `pip install dpdata`
|
|
14
14
|
- Install via conda: `conda install -c conda-forge dpdata`
|
|
@@ -56,9 +56,9 @@ def get_coords_from_dump(dumplines, natoms):
|
|
|
56
56
|
if "VIRIAL" in dumplines[6]:
|
|
57
57
|
calc_stress = True
|
|
58
58
|
check_line = 10
|
|
59
|
-
assert (
|
|
60
|
-
"POSITION
|
|
61
|
-
)
|
|
59
|
+
assert "POSITION" in dumplines[check_line], (
|
|
60
|
+
"keywords 'POSITION' cannot be found in the 6th line. Please check."
|
|
61
|
+
)
|
|
62
62
|
if "FORCE" in dumplines[check_line]:
|
|
63
63
|
calc_force = True
|
|
64
64
|
|
|
@@ -68,7 +68,7 @@ def get_coords_from_dump(dumplines, natoms):
|
|
|
68
68
|
else:
|
|
69
69
|
nframes_dump = int(nlines / (total_natoms + 9))
|
|
70
70
|
assert nframes_dump > 0, (
|
|
71
|
-
"Number of lines in MD_dump file = %d. Number of atoms = %d. The MD_dump file is incomplete."
|
|
71
|
+
"Number of lines in MD_dump file = %d. Number of atoms = %d. The MD_dump file is incomplete." # noqa: UP031
|
|
72
72
|
% (nlines, total_natoms)
|
|
73
73
|
)
|
|
74
74
|
cells = np.zeros([nframes_dump, 3, 3])
|
|
@@ -125,7 +125,7 @@ def get_coords_from_dump(dumplines, natoms):
|
|
|
125
125
|
)
|
|
126
126
|
iframe += 1
|
|
127
127
|
assert iframe == nframes_dump, (
|
|
128
|
-
"iframe=%d, nframe_dump=%d. Number of frames does not match number of lines in MD_dump."
|
|
128
|
+
"iframe=%d, nframe_dump=%d. Number of frames does not match number of lines in MD_dump." # noqa: UP031
|
|
129
129
|
% (iframe, nframes_dump)
|
|
130
130
|
)
|
|
131
131
|
stresses *= kbar2evperang3
|
|
@@ -145,7 +145,7 @@ def get_energy(outlines, ndump, dump_freq):
|
|
|
145
145
|
energy.append(np.nan)
|
|
146
146
|
nenergy += 1
|
|
147
147
|
assert ndump == len(energy), (
|
|
148
|
-
"Number of total energies in running_md.log = %d. Number of frames in MD_dump = %d. Please check."
|
|
148
|
+
"Number of total energies in running_md.log = %d. Number of frames in MD_dump = %d. Please check." # noqa: UP031
|
|
149
149
|
% (len(energy), ndump)
|
|
150
150
|
)
|
|
151
151
|
energy = np.array(energy)
|
|
@@ -167,7 +167,7 @@ def get_frame(fname):
|
|
|
167
167
|
with open_file(geometry_path_in) as fp:
|
|
168
168
|
geometry_inlines = fp.read().split("\n")
|
|
169
169
|
celldm, cell = get_cell(geometry_inlines)
|
|
170
|
-
atom_names, natoms, types, coords = get_coords(
|
|
170
|
+
atom_names, natoms, types, coords, move, magmom = get_coords(
|
|
171
171
|
celldm, cell, geometry_inlines, inlines
|
|
172
172
|
)
|
|
173
173
|
# This coords is not to be used.
|
|
@@ -191,7 +191,7 @@ def get_frame(fname):
|
|
|
191
191
|
force = np.delete(force, i - ndump, axis=0)
|
|
192
192
|
stress = np.delete(stress, i - ndump, axis=0)
|
|
193
193
|
energy = np.delete(energy, i - ndump, axis=0)
|
|
194
|
-
unconv_stru += "%d " % i
|
|
194
|
+
unconv_stru += "%d " % i # noqa: UP031
|
|
195
195
|
ndump = len(energy)
|
|
196
196
|
if unconv_stru != "":
|
|
197
197
|
warnings.warn(f"Structure {unconv_stru} are unconverged and not collected!")
|
|
@@ -220,6 +220,8 @@ def get_frame(fname):
|
|
|
220
220
|
if len(magmom) > 0:
|
|
221
221
|
data["spins"] = magmom
|
|
222
222
|
if len(magforce) > 0:
|
|
223
|
-
data["
|
|
223
|
+
data["force_mags"] = magforce
|
|
224
|
+
if len(move) > 0:
|
|
225
|
+
data["move"] = move
|
|
224
226
|
|
|
225
227
|
return data
|
|
@@ -47,7 +47,7 @@ def get_coords_from_log(loglines, natoms):
|
|
|
47
47
|
natoms_log += int(line.split()[-1])
|
|
48
48
|
|
|
49
49
|
assert natoms_log > 0 and natoms_log == natoms, (
|
|
50
|
-
"ERROR: detected atom number in log file is %d" % natoms
|
|
50
|
+
"ERROR: detected atom number in log file is %d" % natoms # noqa: UP031
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
energy = []
|
|
@@ -76,7 +76,7 @@ def get_coords_from_log(loglines, natoms):
|
|
|
76
76
|
list(map(lambda x: float(x) * a0, loglines[i + k].split()[1:4]))
|
|
77
77
|
)
|
|
78
78
|
else:
|
|
79
|
-
assert False, "Unrecongnized coordinate type, %s, line:%d" % (
|
|
79
|
+
assert False, "Unrecongnized coordinate type, %s, line:%d" % ( # noqa: UP031
|
|
80
80
|
loglines[i].split()[0],
|
|
81
81
|
i,
|
|
82
82
|
)
|
|
@@ -183,7 +183,7 @@ def get_frame(fname):
|
|
|
183
183
|
with open_file(geometry_path_in) as fp:
|
|
184
184
|
geometry_inlines = fp.read().split("\n")
|
|
185
185
|
celldm, cell = get_cell(geometry_inlines)
|
|
186
|
-
atom_names, natoms, types, coord_tmp = get_coords(
|
|
186
|
+
atom_names, natoms, types, coord_tmp, move, magmom = get_coords(
|
|
187
187
|
celldm, cell, geometry_inlines, inlines
|
|
188
188
|
)
|
|
189
189
|
|
|
@@ -217,6 +217,8 @@ def get_frame(fname):
|
|
|
217
217
|
if len(magmom) > 0:
|
|
218
218
|
data["spins"] = magmom
|
|
219
219
|
if len(magforce) > 0:
|
|
220
|
-
data["
|
|
220
|
+
data["force_mags"] = magforce
|
|
221
|
+
if len(move) > 0:
|
|
222
|
+
data["move"] = move
|
|
221
223
|
|
|
222
224
|
return data
|
|
@@ -258,6 +258,51 @@ def parse_stru_pos(pos_line):
|
|
|
258
258
|
return pos, move, velocity, magmom, angle1, angle2, constrain, lambda1
|
|
259
259
|
|
|
260
260
|
|
|
261
|
+
def get_atom_mag_cartesian(atommag, angle1, angle2):
|
|
262
|
+
"""Transform atommag, angle1, angle2 to magmom in cartesian coordinates.
|
|
263
|
+
|
|
264
|
+
Parameters
|
|
265
|
+
----------
|
|
266
|
+
atommag : float/list of float/None
|
|
267
|
+
Atom magnetic moment.
|
|
268
|
+
angle1 : float/None
|
|
269
|
+
value of angle1.
|
|
270
|
+
angle2 : float/None
|
|
271
|
+
value of angle2.
|
|
272
|
+
ABACUS support defining mag, angle1, angle2 at the same time.
|
|
273
|
+
angle1 is the angle between z-axis and real spin (in degrees).
|
|
274
|
+
angle2 is the angle between x-axis and real spin projection in xy-plane (in degrees).
|
|
275
|
+
If only mag is defined, then transfer it to magmom directly.
|
|
276
|
+
And if mag, angle1, angle2 are defined, then mag is only the norm of magmom, and the direction is defined by angle1 and angle2.
|
|
277
|
+
"""
|
|
278
|
+
if atommag is None:
|
|
279
|
+
return None
|
|
280
|
+
if not (isinstance(atommag, list) or isinstance(atommag, float)):
|
|
281
|
+
raise RuntimeError(f"Invalid atommag: {atommag}")
|
|
282
|
+
|
|
283
|
+
if angle1 is None and angle2 is None:
|
|
284
|
+
if isinstance(atommag, list):
|
|
285
|
+
return atommag
|
|
286
|
+
else:
|
|
287
|
+
return [0, 0, atommag]
|
|
288
|
+
else:
|
|
289
|
+
a1 = 0
|
|
290
|
+
a2 = 0
|
|
291
|
+
if angle1 is not None:
|
|
292
|
+
a1 = angle1
|
|
293
|
+
if angle2 is not None:
|
|
294
|
+
a2 = angle2
|
|
295
|
+
if isinstance(atommag, list):
|
|
296
|
+
mag_norm = np.linalg.norm(atommag)
|
|
297
|
+
else:
|
|
298
|
+
mag_norm = atommag
|
|
299
|
+
return [
|
|
300
|
+
mag_norm * np.sin(np.radians(a1)) * np.cos(np.radians(a2)),
|
|
301
|
+
mag_norm * np.sin(np.radians(a1)) * np.sin(np.radians(a2)),
|
|
302
|
+
mag_norm * np.cos(np.radians(a1)),
|
|
303
|
+
]
|
|
304
|
+
|
|
305
|
+
|
|
261
306
|
def get_coords(celldm, cell, geometry_inlines, inlines=None):
|
|
262
307
|
coords_lines = get_stru_block(geometry_inlines, "ATOMIC_POSITIONS")
|
|
263
308
|
# assuming that ATOMIC_POSITIONS is at the bottom of the STRU file
|
|
@@ -268,9 +313,7 @@ def get_coords(celldm, cell, geometry_inlines, inlines=None):
|
|
|
268
313
|
coords = [] # coordinations of atoms
|
|
269
314
|
move = [] # move flag of each atom
|
|
270
315
|
velocity = [] # velocity of each atom
|
|
271
|
-
|
|
272
|
-
angle1 = [] # angle1 of each atom
|
|
273
|
-
angle2 = [] # angle2 of each atom
|
|
316
|
+
mags = [] # magnetic moment of each atom
|
|
274
317
|
sc = [] # spin constraint flag of each atom
|
|
275
318
|
lambda_ = [] # lambda of each atom
|
|
276
319
|
|
|
@@ -278,6 +321,7 @@ def get_coords(celldm, cell, geometry_inlines, inlines=None):
|
|
|
278
321
|
line_idx = 1 # starting line of first element
|
|
279
322
|
for it in range(ntype):
|
|
280
323
|
atom_names.append(coords_lines[line_idx].split()[0])
|
|
324
|
+
atom_type_mag = float(coords_lines[line_idx + 1].split()[0])
|
|
281
325
|
line_idx += 2
|
|
282
326
|
atom_numbs.append(int(coords_lines[line_idx].split()[0]))
|
|
283
327
|
line_idx += 1
|
|
@@ -299,18 +343,23 @@ def get_coords(celldm, cell, geometry_inlines, inlines=None):
|
|
|
299
343
|
coords.append(xyz)
|
|
300
344
|
atom_types.append(it)
|
|
301
345
|
|
|
302
|
-
|
|
346
|
+
if imove is not None:
|
|
347
|
+
move.append(imove)
|
|
303
348
|
velocity.append(ivelocity)
|
|
304
|
-
mag.append(imagmom)
|
|
305
|
-
angle1.append(iangle1)
|
|
306
|
-
angle2.append(iangle2)
|
|
307
349
|
sc.append(iconstrain)
|
|
308
350
|
lambda_.append(ilambda1)
|
|
309
351
|
|
|
352
|
+
# calculate the magnetic moment in cartesian coordinates
|
|
353
|
+
mag = get_atom_mag_cartesian(imagmom, iangle1, iangle2)
|
|
354
|
+
if mag is None:
|
|
355
|
+
mag = [0, 0, atom_type_mag]
|
|
356
|
+
mags.append(mag)
|
|
357
|
+
|
|
310
358
|
line_idx += 1
|
|
311
359
|
coords = np.array(coords) # need transformation!!!
|
|
312
360
|
atom_types = np.array(atom_types)
|
|
313
|
-
|
|
361
|
+
move = np.array(move, dtype=bool)
|
|
362
|
+
return atom_names, atom_numbs, atom_types, coords, move, mags
|
|
314
363
|
|
|
315
364
|
|
|
316
365
|
def get_energy(outlines):
|
|
@@ -429,14 +478,20 @@ def get_mag_force(outlines):
|
|
|
429
478
|
j = i + 2
|
|
430
479
|
mag = []
|
|
431
480
|
while "-------------------------" not in outlines[j]:
|
|
432
|
-
|
|
481
|
+
imag = [float(ii) for ii in outlines[j].split()[1:]]
|
|
482
|
+
if len(imag) == 1:
|
|
483
|
+
imag = [0, 0, imag[0]]
|
|
484
|
+
mag.append(imag)
|
|
433
485
|
j += 1
|
|
434
486
|
mags.append(mag)
|
|
435
487
|
if "Magnetic force (eV/uB)" in line:
|
|
436
488
|
j = i + 2
|
|
437
489
|
magforce = []
|
|
438
490
|
while "-------------------------" not in outlines[j]:
|
|
439
|
-
|
|
491
|
+
imagforce = [float(ii) for ii in outlines[j].split()[1:]]
|
|
492
|
+
if len(imagforce) == 1:
|
|
493
|
+
imagforce = [0, 0, imagforce[0]]
|
|
494
|
+
magforce.append(imagforce)
|
|
440
495
|
j += 1
|
|
441
496
|
magforces.append(magforce)
|
|
442
497
|
return np.array(mags), np.array(magforces)
|
|
@@ -477,9 +532,12 @@ def get_frame(fname):
|
|
|
477
532
|
outlines = fp.read().split("\n")
|
|
478
533
|
|
|
479
534
|
celldm, cell = get_cell(geometry_inlines)
|
|
480
|
-
atom_names, natoms, types, coords =
|
|
481
|
-
|
|
535
|
+
atom_names, natoms, types, coords, move, magmom = (
|
|
536
|
+
get_coords( # here the magmom is the initial magnetic moment in STRU
|
|
537
|
+
celldm, cell, geometry_inlines, inlines
|
|
538
|
+
)
|
|
482
539
|
)
|
|
540
|
+
|
|
483
541
|
magmom, magforce = get_mag_force(outlines)
|
|
484
542
|
if len(magmom) > 0:
|
|
485
543
|
magmom = magmom[-1:]
|
|
@@ -509,7 +567,9 @@ def get_frame(fname):
|
|
|
509
567
|
if len(magmom) > 0:
|
|
510
568
|
data["spins"] = magmom
|
|
511
569
|
if len(magforce) > 0:
|
|
512
|
-
data["
|
|
570
|
+
data["force_mags"] = magforce
|
|
571
|
+
if len(move) > 0:
|
|
572
|
+
data["move"] = move[np.newaxis, :, :]
|
|
513
573
|
# print("atom_names = ", data['atom_names'])
|
|
514
574
|
# print("natoms = ", data['atom_numbs'])
|
|
515
575
|
# print("types = ", data['atom_types'])
|
|
@@ -561,7 +621,7 @@ def get_frame_from_stru(fname):
|
|
|
561
621
|
nele = get_nele_from_stru(geometry_inlines)
|
|
562
622
|
inlines = [f"ntype {nele}"]
|
|
563
623
|
celldm, cell = get_cell(geometry_inlines)
|
|
564
|
-
atom_names, natoms, types, coords = get_coords(
|
|
624
|
+
atom_names, natoms, types, coords, move, magmom = get_coords(
|
|
565
625
|
celldm, cell, geometry_inlines, inlines
|
|
566
626
|
)
|
|
567
627
|
data = {}
|
|
@@ -571,6 +631,9 @@ def get_frame_from_stru(fname):
|
|
|
571
631
|
data["cells"] = cell[np.newaxis, :, :]
|
|
572
632
|
data["coords"] = coords[np.newaxis, :, :]
|
|
573
633
|
data["orig"] = np.zeros(3)
|
|
634
|
+
data["spins"] = np.array([magmom])
|
|
635
|
+
if len(move) > 0:
|
|
636
|
+
data["move"] = move[np.newaxis, :, :]
|
|
574
637
|
|
|
575
638
|
return data
|
|
576
639
|
|
|
@@ -601,7 +664,7 @@ def make_unlabeled_stru(
|
|
|
601
664
|
System data
|
|
602
665
|
frame_idx : int
|
|
603
666
|
The index of the frame to dump
|
|
604
|
-
pp_file : list of string or dict
|
|
667
|
+
pp_file : list of string or dict
|
|
605
668
|
List of pseudo potential files, or a dictionary of pseudo potential files for each atomnames
|
|
606
669
|
numerical_orbital : list of string or dict, optional
|
|
607
670
|
List of orbital files, or a dictionary of orbital files for each atomnames
|
|
@@ -609,8 +672,8 @@ def make_unlabeled_stru(
|
|
|
609
672
|
numerical descriptor file
|
|
610
673
|
mass : list of float, optional
|
|
611
674
|
List of atomic masses
|
|
612
|
-
move : list of list of bool, optional
|
|
613
|
-
List of the move flag of each xyz direction of each atom
|
|
675
|
+
move : list of (list of list of bool), optional
|
|
676
|
+
List of the move flag of each xyz direction of each atom for each frame
|
|
614
677
|
velocity : list of list of float, optional
|
|
615
678
|
List of the velocity of each xyz direction of each atom
|
|
616
679
|
mag : list of (list of float or float), optional
|
|
@@ -628,6 +691,8 @@ def make_unlabeled_stru(
|
|
|
628
691
|
link_file : bool, optional
|
|
629
692
|
Whether to link the pseudo potential files and orbital files in the STRU file.
|
|
630
693
|
If True, then only filename will be written in the STRU file, and make a soft link to the real file.
|
|
694
|
+
dest_dir : str, optional
|
|
695
|
+
The destination directory to make the soft link of the pseudo potential files and orbital files.
|
|
631
696
|
For velocity, mag, angle1, angle2, sc, and lambda_, if the value is None, then the corresponding information will not be written.
|
|
632
697
|
ABACUS support defining "mag" and "angle1"/"angle2" at the same time, and in this case, the "mag" only define the norm of the magnetic moment, and "angle1" and "angle2" define the direction of the magnetic moment.
|
|
633
698
|
If data has spins, then it will be written as mag to STRU file; while if mag is passed at the same time, then mag will be used.
|
|
@@ -655,6 +720,23 @@ def make_unlabeled_stru(
|
|
|
655
720
|
else:
|
|
656
721
|
return i
|
|
657
722
|
|
|
723
|
+
def process_file_input(file_input, atom_names, input_name):
|
|
724
|
+
# For pp_file and numerical_orbital, process the file input, and return a list of file names
|
|
725
|
+
# file_input can be a list of file names, or a dictionary of file names for each atom names
|
|
726
|
+
if isinstance(file_input, (list, tuple)):
|
|
727
|
+
if len(file_input) != len(atom_names):
|
|
728
|
+
raise ValueError(
|
|
729
|
+
f"{input_name} length is not equal to the number of atom types"
|
|
730
|
+
)
|
|
731
|
+
return file_input
|
|
732
|
+
elif isinstance(file_input, dict):
|
|
733
|
+
for element in atom_names:
|
|
734
|
+
if element not in file_input:
|
|
735
|
+
raise KeyError(f"{input_name} does not contain {element}")
|
|
736
|
+
return [file_input[element] for element in atom_names]
|
|
737
|
+
else:
|
|
738
|
+
raise ValueError(f"Invalid {input_name}: {file_input}")
|
|
739
|
+
|
|
658
740
|
if link_file and dest_dir is None:
|
|
659
741
|
print(
|
|
660
742
|
"WARNING: make_unlabeled_stru: link_file is True, but dest_dir is None. Will write the filename to STRU but not making soft link."
|
|
@@ -665,6 +747,9 @@ def make_unlabeled_stru(
|
|
|
665
747
|
if mag is None and data.get("spins") is not None and len(data["spins"]) > 0:
|
|
666
748
|
mag = data["spins"][frame_idx]
|
|
667
749
|
|
|
750
|
+
if move is None and data.get("move", None) is not None and len(data["move"]) > 0:
|
|
751
|
+
move = data["move"][frame_idx]
|
|
752
|
+
|
|
668
753
|
atom_numbs = sum(data["atom_numbs"])
|
|
669
754
|
for key in [move, velocity, mag, angle1, angle2, sc, lambda_]:
|
|
670
755
|
if key is not None:
|
|
@@ -681,7 +766,15 @@ def make_unlabeled_stru(
|
|
|
681
766
|
# ATOMIC_SPECIES block
|
|
682
767
|
out = "ATOMIC_SPECIES\n"
|
|
683
768
|
if pp_file is not None:
|
|
684
|
-
|
|
769
|
+
ppfiles = process_file_input(
|
|
770
|
+
ndarray2list(pp_file), data["atom_names"], "pp_file"
|
|
771
|
+
)
|
|
772
|
+
else:
|
|
773
|
+
warnings.warn(
|
|
774
|
+
"pp_file is not provided, will use empty string for pseudo potential file."
|
|
775
|
+
)
|
|
776
|
+
ppfiles = [""] * len(data["atom_names"])
|
|
777
|
+
|
|
685
778
|
for iele in range(len(data["atom_names"])):
|
|
686
779
|
if data["atom_numbs"][iele] == 0:
|
|
687
780
|
continue
|
|
@@ -690,57 +783,37 @@ def make_unlabeled_stru(
|
|
|
690
783
|
out += f"{mass[iele]:.3f} "
|
|
691
784
|
else:
|
|
692
785
|
out += "1 "
|
|
693
|
-
if pp_file is not None:
|
|
694
|
-
if isinstance(pp_file, (list, tuple)):
|
|
695
|
-
ipp_file = pp_file[iele]
|
|
696
|
-
elif isinstance(pp_file, dict):
|
|
697
|
-
if data["atom_names"][iele] not in pp_file:
|
|
698
|
-
print(
|
|
699
|
-
f"ERROR: make_unlabeled_stru: pp_file does not contain {data['atom_names'][iele]}"
|
|
700
|
-
)
|
|
701
|
-
ipp_file = None
|
|
702
|
-
else:
|
|
703
|
-
ipp_file = pp_file[data["atom_names"][iele]]
|
|
704
|
-
else:
|
|
705
|
-
ipp_file = None
|
|
706
|
-
if ipp_file is not None:
|
|
707
|
-
if not link_file:
|
|
708
|
-
out += ipp_file
|
|
709
|
-
else:
|
|
710
|
-
out += os.path.basename(ipp_file.rstrip("/"))
|
|
711
|
-
if dest_dir is not None:
|
|
712
|
-
_link_file(dest_dir, ipp_file)
|
|
713
786
|
|
|
787
|
+
ipp_file = ppfiles[iele]
|
|
788
|
+
if ipp_file != "":
|
|
789
|
+
if not link_file:
|
|
790
|
+
out += ipp_file
|
|
791
|
+
else:
|
|
792
|
+
out += os.path.basename(ipp_file.rstrip("/"))
|
|
793
|
+
if dest_dir is not None:
|
|
794
|
+
_link_file(dest_dir, ipp_file)
|
|
714
795
|
out += "\n"
|
|
715
796
|
out += "\n"
|
|
716
797
|
|
|
717
798
|
# NUMERICAL_ORBITAL block
|
|
718
799
|
if numerical_orbital is not None:
|
|
719
|
-
assert len(numerical_orbital) == len(data["atom_names"])
|
|
720
800
|
numerical_orbital = ndarray2list(numerical_orbital)
|
|
801
|
+
orbfiles = process_file_input(
|
|
802
|
+
numerical_orbital, data["atom_names"], "numerical_orbital"
|
|
803
|
+
)
|
|
804
|
+
orbfiles = [
|
|
805
|
+
orbfiles[i]
|
|
806
|
+
for i in range(len(data["atom_names"]))
|
|
807
|
+
if data["atom_numbs"][i] != 0
|
|
808
|
+
]
|
|
721
809
|
out += "NUMERICAL_ORBITAL\n"
|
|
722
|
-
for
|
|
723
|
-
if
|
|
724
|
-
|
|
725
|
-
if isinstance(numerical_orbital, (list, tuple)):
|
|
726
|
-
inum_orbital = numerical_orbital[iele]
|
|
727
|
-
elif isinstance(numerical_orbital, dict):
|
|
728
|
-
if data["atom_names"][iele] not in numerical_orbital:
|
|
729
|
-
print(
|
|
730
|
-
f"ERROR: make_unlabeled_stru: numerical_orbital does not contain {data['atom_names'][iele]}"
|
|
731
|
-
)
|
|
732
|
-
inum_orbital = None
|
|
733
|
-
else:
|
|
734
|
-
inum_orbital = numerical_orbital[data["atom_names"][iele]]
|
|
810
|
+
for iorb in orbfiles:
|
|
811
|
+
if not link_file:
|
|
812
|
+
out += iorb
|
|
735
813
|
else:
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
out += inum_orbital
|
|
740
|
-
else:
|
|
741
|
-
out += os.path.basename(inum_orbital.rstrip("/"))
|
|
742
|
-
if dest_dir is not None:
|
|
743
|
-
_link_file(dest_dir, inum_orbital)
|
|
814
|
+
out += os.path.basename(iorb.rstrip("/"))
|
|
815
|
+
if dest_dir is not None:
|
|
816
|
+
_link_file(dest_dir, iorb)
|
|
744
817
|
out += "\n"
|
|
745
818
|
out += "\n"
|
|
746
819
|
|
|
@@ -62,7 +62,8 @@ class DPDataCalculator(Calculator):
|
|
|
62
62
|
self.results["energy"] = data["energies"][0]
|
|
63
63
|
# see https://gitlab.com/ase/ase/-/merge_requests/2485
|
|
64
64
|
self.results["free_energy"] = data["energies"][0]
|
|
65
|
-
|
|
65
|
+
if "forces" in data:
|
|
66
|
+
self.results["forces"] = data["forces"][0]
|
|
66
67
|
if "virials" in data:
|
|
67
68
|
self.results["virial"] = data["virials"][0].reshape(3, 3)
|
|
68
69
|
|
|
@@ -122,7 +122,7 @@ class DataType:
|
|
|
122
122
|
elif isinstance(data, list):
|
|
123
123
|
if len(shape) and shape[0] != len(data):
|
|
124
124
|
raise DataError(
|
|
125
|
-
"Length of %s is %d, but expected %d"
|
|
125
|
+
"Length of %s is %d, but expected %d" # noqa: UP031
|
|
126
126
|
% (self.name, len(data), shape[0])
|
|
127
127
|
)
|
|
128
128
|
else:
|
|
@@ -119,7 +119,7 @@ def dump(folder, data, set_size=5000, comp_prec=np.float32, remove_sets=True):
|
|
|
119
119
|
for ii in range(nsets):
|
|
120
120
|
set_stt = ii * set_size
|
|
121
121
|
set_end = (ii + 1) * set_size
|
|
122
|
-
set_folder = os.path.join(folder, "set.%03d" % ii)
|
|
122
|
+
set_folder = os.path.join(folder, "set.%03d" % ii) # noqa: UP031
|
|
123
123
|
os.makedirs(set_folder)
|
|
124
124
|
try:
|
|
125
125
|
os.remove(os.path.join(folder, "nopbc"))
|
|
@@ -158,5 +158,5 @@ def dump(folder, data, set_size=5000, comp_prec=np.float32, remove_sets=True):
|
|
|
158
158
|
for ii in range(nsets):
|
|
159
159
|
set_stt = ii * set_size
|
|
160
160
|
set_end = (ii + 1) * set_size
|
|
161
|
-
set_folder = os.path.join(folder, "set.%03d" % ii)
|
|
161
|
+
set_folder = os.path.join(folder, "set.%03d" % ii) # noqa: UP031
|
|
162
162
|
np.save(os.path.join(set_folder, dtype.deepmd_name), ddata[set_stt:set_end])
|
|
@@ -59,7 +59,7 @@ def to_system_data(
|
|
|
59
59
|
else:
|
|
60
60
|
my_type_map = []
|
|
61
61
|
for ii in range(ntypes):
|
|
62
|
-
my_type_map.append("Type_%d" % ii)
|
|
62
|
+
my_type_map.append("Type_%d" % ii) # noqa: UP031
|
|
63
63
|
assert len(my_type_map) >= len(data["atom_numbs"])
|
|
64
64
|
for ii in range(len(data["atom_numbs"])):
|
|
65
65
|
data["atom_names"].append(my_type_map[ii])
|
|
@@ -217,7 +217,7 @@ def dump(
|
|
|
217
217
|
for ii in range(nsets):
|
|
218
218
|
set_stt = ii * set_size
|
|
219
219
|
set_end = (ii + 1) * set_size
|
|
220
|
-
set_folder = g.create_group("set.%03d" % ii)
|
|
220
|
+
set_folder = g.create_group("set.%03d" % ii) # noqa: UP031
|
|
221
221
|
for dt, prop in data_types.items():
|
|
222
222
|
if dt in reshaped_data:
|
|
223
223
|
set_folder.create_dataset(
|
|
@@ -15,9 +15,9 @@ def to_system_data(folder, type_map=None, labels=True):
|
|
|
15
15
|
if type_map is not None:
|
|
16
16
|
assert isinstance(type_map, list)
|
|
17
17
|
missing_type = [i for i in old_type_map if i not in type_map]
|
|
18
|
-
assert (
|
|
19
|
-
|
|
20
|
-
)
|
|
18
|
+
assert not missing_type, (
|
|
19
|
+
f"These types are missing in selected type_map: {missing_type} !"
|
|
20
|
+
)
|
|
21
21
|
index_map = np.array([type_map.index(i) for i in old_type_map])
|
|
22
22
|
data["atom_names"] = type_map.copy()
|
|
23
23
|
else:
|
|
@@ -27,7 +27,7 @@ def load_type(folder, type_map=None):
|
|
|
27
27
|
else:
|
|
28
28
|
my_type_map = []
|
|
29
29
|
for ii in range(ntypes):
|
|
30
|
-
my_type_map.append("Type_%d" % ii)
|
|
30
|
+
my_type_map.append("Type_%d" % ii) # noqa: UP031
|
|
31
31
|
data["atom_names"] = my_type_map
|
|
32
32
|
data["atom_numbs"] = []
|
|
33
33
|
for ii, _ in enumerate(data["atom_names"]):
|