dpdata 1.1.0__tar.gz → 1.2.0__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-1.1.0 → dpdata-1.2.0}/.github/workflows/pub-pypi.yml +1 -1
- {dpdata-1.1.0 → dpdata-1.2.0}/.pre-commit-config.yaml +1 -1
- {dpdata-1.1.0 → dpdata-1.2.0}/MANIFEST.in +1 -0
- {dpdata-1.1.0/dpdata.egg-info → dpdata-1.2.0}/PKG-INFO +1 -1
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/_version.py +3 -3
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/ase_calculator.py +5 -3
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/bond_order_system.py +4 -3
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/cli.py +13 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/abacus/scf.py +3 -1
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/abacus/stru.py +112 -12
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/cp2k/output.py +25 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/dftbplus/output.py +48 -8
- dpdata-1.2.0/dpdata/formats/qe/__init__.py +5 -0
- dpdata-1.2.0/dpdata/formats/qe/pwmd.py +14 -0
- dpdata-1.2.0/dpdata/formats/qe/scf.py +555 -0
- dpdata-1.2.0/dpdata/formats/qe/traj.py +684 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/dftbplus.py +28 -12
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/lmdb.py +8 -2
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/qe.py +52 -2
- dpdata-1.2.0/dpdata/skills.py +89 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/system.py +63 -18
- {dpdata-1.1.0 → dpdata-1.2.0/dpdata.egg-info}/PKG-INFO +1 -1
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata.egg-info/SOURCES.txt +19 -1
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata.egg-info/scm_file_list.json +40 -0
- dpdata-1.2.0/dpdata.egg-info/scm_version.json +8 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/pyproject.toml +21 -0
- dpdata-1.2.0/setup.py +53 -0
- dpdata-1.2.0/skills/README.md +14 -0
- dpdata-1.2.0/skills/dpdata-cli/README.md +6 -0
- dpdata-1.2.0/skills/dpdata-cli/SKILL.md +17 -0
- dpdata-1.2.0/skills/dpdata-convert/SKILL.md +69 -0
- dpdata-1.2.0/skills/dpdata-convert/references/producers/abacus.md +18 -0
- dpdata-1.2.0/skills/dpdata-convert/references/producers/cp2k.md +19 -0
- dpdata-1.2.0/skills/dpdata-convert/references/producers/qe.md +16 -0
- dpdata-1.2.0/skills/dpdata-convert/references/producers/vasp.md +19 -0
- dpdata-1.2.0/skills/dpdata-convert/references/semantic-validation.md +43 -0
- dpdata-1.2.0/skills/dpdata-driver/SKILL.md +13 -0
- dpdata-1.2.0/skills/dpdata-extend/SKILL.md +27 -0
- dpdata-1.2.0/skills/dpdata-inspect/SKILL.md +62 -0
- dpdata-1.2.0/skills/dpdata-inspect/scripts/validate_labeled_system.py +401 -0
- dpdata-1.2.0/skills/dpdata-minimizer/SKILL.md +13 -0
- dpdata-1.2.0/skills/dpdata-plugin/SKILL.md +13 -0
- dpdata-1.2.0/skills/dpdata-workflows/SKILL.md +32 -0
- dpdata-1.1.0/dpdata/formats/qe/__init__.py +0 -5
- dpdata-1.1.0/dpdata/formats/qe/scf.py +0 -188
- dpdata-1.1.0/dpdata/formats/qe/traj.py +0 -360
- dpdata-1.1.0/dpdata.egg-info/scm_version.json +0 -8
- dpdata-1.1.0/skills/dpdata-cli/README.md +0 -71
- {dpdata-1.1.0 → dpdata-1.2.0}/.git-blame-ignore-revs +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.git_archival.txt +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.gitattributes +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/ISSUE_TEMPLATE/generic-issue.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/dependabot.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/workflows/benchmark.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/workflows/mirror_gitee.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/workflows/pyright.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/workflows/test.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.github/workflows/test_import.yml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.gitignore +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/.readthedocs.yaml +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/AGENTS.md +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/LICENSE +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/README.md +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/benchmark/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/benchmark/test_import.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/__about__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/__main__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/data_type.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/driver.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/format.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/abacus/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/abacus/md.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/abacus/relax.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/amber/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/amber/mask.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/amber/md.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/amber/sqm.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/cp2k/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/cp2k/cell.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/deepmd/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/deepmd/comp.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/deepmd/hdf5.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/deepmd/lmdb/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/deepmd/lmdb/format.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/deepmd/mixed.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/deepmd/raw.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/dftbplus/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/fhi_aims/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/fhi_aims/output.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/gaussian/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/gaussian/fchk.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/gaussian/gjf.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/gaussian/log.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/gromacs/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/gromacs/gro.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/lammps/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/lammps/dump.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/lammps/lmp.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/openmx/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/openmx/omx.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/orca/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/orca/output.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/psi4/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/psi4/input.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/psi4/output.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/pwmat/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/pwmat/atomconfig.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/pwmat/movement.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/pymatgen/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/pymatgen/molecule.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/pymatgen/structure.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/rdkit/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/rdkit/sanitize.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/rdkit/utils.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/siesta/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/siesta/aiMD_output.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/siesta/output.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/vasp/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/vasp/outcar.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/vasp/poscar.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/vasp/xml.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/xyz/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/xyz/_unit_convert.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/xyz/quip_gap_xyz.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/formats/xyz/xyz.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/md/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/md/msd.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/md/pbc.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/md/rdf.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/md/water.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/periodic_table.json +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/periodic_table.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugin.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/3dmol.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/__init__.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/abacus.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/amber.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/ase.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/cp2k.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/deepmd.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/fhi_aims.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/gaussian.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/gromacs.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/lammps.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/list.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/n2p2.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/openmx.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/orca.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/psi4.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/pwmat.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/pymatgen.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/rdkit.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/siesta.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/vasp.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/plugins/xyz.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/py.typed +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/serialization.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/stat.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/unit.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata/utils.py +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata.egg-info/dependency_links.txt +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata.egg-info/entry_points.txt +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata.egg-info/requires.txt +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/dpdata.egg-info/top_level.txt +0 -0
- {dpdata-1.1.0 → dpdata-1.2.0}/setup.cfg +0 -0
- /dpdata-1.1.0/skills/dpdata-cli/SKILL.md → /dpdata-1.2.0/skills/dpdata-convert/references/cli-reference.md +0 -0
- /dpdata-1.1.0/skills/dpdata-driver/SKILL.md → /dpdata-1.2.0/skills/dpdata-extend/references/driver.md +0 -0
- /dpdata-1.1.0/skills/dpdata-plugin/SKILL.md → /dpdata-1.2.0/skills/dpdata-extend/references/format-plugin.md +0 -0
- /dpdata-1.1.0/skills/dpdata-minimizer/SKILL.md → /dpdata-1.2.0/skills/dpdata-extend/references/minimizer.md +0 -0
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '1.
|
|
22
|
-
__version_tuple__ = version_tuple = (1,
|
|
21
|
+
__version__ = version = '1.2.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 2, 0)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'ge229e64e4'
|
|
@@ -38,7 +38,7 @@ class DPDataCalculator(Calculator):
|
|
|
38
38
|
def calculate(
|
|
39
39
|
self,
|
|
40
40
|
atoms: Atoms | None = None,
|
|
41
|
-
properties: list[str] =
|
|
41
|
+
properties: list[str] | None = None,
|
|
42
42
|
system_changes: list[str] = all_changes,
|
|
43
43
|
):
|
|
44
44
|
"""Run calculation with a driver.
|
|
@@ -47,12 +47,14 @@ class DPDataCalculator(Calculator):
|
|
|
47
47
|
----------
|
|
48
48
|
atoms : Optional[Atoms], optional
|
|
49
49
|
atoms object to run the calculation on, by default None
|
|
50
|
-
properties : List[str], optional
|
|
50
|
+
properties : Optional[List[str]], optional
|
|
51
51
|
unused, only for function signature compatibility,
|
|
52
|
-
by default
|
|
52
|
+
by default None
|
|
53
53
|
system_changes : List[str], optional
|
|
54
54
|
unused, only for function signature compatibility, by default all_changes
|
|
55
55
|
"""
|
|
56
|
+
if properties is None:
|
|
57
|
+
properties = ["energy", "forces"]
|
|
56
58
|
assert atoms is not None
|
|
57
59
|
atoms = atoms.copy()
|
|
58
60
|
|
|
@@ -95,11 +95,12 @@ class BondOrderSystem(System):
|
|
|
95
95
|
self.check_data()
|
|
96
96
|
|
|
97
97
|
def from_fmt_obj(self, fmtobj, file_name, **kwargs):
|
|
98
|
+
post_func_controls = self._get_post_func_controls(
|
|
99
|
+
fmtobj.from_bond_order_system, kwargs
|
|
100
|
+
)
|
|
98
101
|
mol = fmtobj.from_bond_order_system(file_name, **kwargs)
|
|
99
102
|
self.from_rdkit_mol(mol)
|
|
100
|
-
|
|
101
|
-
for post_f in fmtobj.from_bond_order_system.post_func: # type: ignore
|
|
102
|
-
self.post_funcs.get_plugin(post_f)(self)
|
|
103
|
+
self._apply_post_funcs(fmtobj.from_bond_order_system, post_func_controls)
|
|
103
104
|
return self
|
|
104
105
|
|
|
105
106
|
def to_fmt_obj(self, fmtobj, *args, **kwargs):
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
|
+
import sys
|
|
6
7
|
|
|
7
8
|
from . import __version__
|
|
8
9
|
from .system import LabeledSystem, MultiSystems, System
|
|
@@ -16,9 +17,17 @@ def dpdata_parser() -> argparse.ArgumentParser:
|
|
|
16
17
|
argparse.ArgumentParser
|
|
17
18
|
dpdata cli parser
|
|
18
19
|
"""
|
|
20
|
+
from .skills import workflow_help
|
|
21
|
+
|
|
22
|
+
epilog_parts = [
|
|
23
|
+
workflow_help("dpdata-cli"),
|
|
24
|
+
"Discover other guides: dpdata skills list.",
|
|
25
|
+
"To convert a file named skills, use ./skills or -- skills.",
|
|
26
|
+
]
|
|
19
27
|
parser = argparse.ArgumentParser(
|
|
20
28
|
description="dpdata: Manipulating multiple atomic simulation data formats",
|
|
21
29
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
30
|
+
epilog=" ".join(part for part in epilog_parts if part),
|
|
22
31
|
)
|
|
23
32
|
|
|
24
33
|
parser.add_argument("from_file", type=str, help="read data from a file")
|
|
@@ -51,6 +60,10 @@ def dpdata_cli():
|
|
|
51
60
|
|
|
52
61
|
$ dpdata -iposcar POSCAR -odeepmd/npy -O data -n
|
|
53
62
|
"""
|
|
63
|
+
if sys.argv[1:2] == ["skills"]:
|
|
64
|
+
from .skills import skills_cli
|
|
65
|
+
|
|
66
|
+
return skills_cli(sys.argv[2:])
|
|
54
67
|
parser = dpdata_parser()
|
|
55
68
|
parsed_args = parser.parse_args()
|
|
56
69
|
convert(**vars(parsed_args))
|
|
@@ -221,7 +221,7 @@ def get_frame(fname):
|
|
|
221
221
|
return data
|
|
222
222
|
|
|
223
223
|
# read STRU file
|
|
224
|
-
data = get_frame_from_stru(geometry_path_in)
|
|
224
|
+
data, cell_flipped = get_frame_from_stru(geometry_path_in, return_flipped=True)
|
|
225
225
|
natoms = sum(data["atom_numbs"])
|
|
226
226
|
# should remove spins from STRU file
|
|
227
227
|
if "spins" in data:
|
|
@@ -236,6 +236,8 @@ def get_frame(fname):
|
|
|
236
236
|
magforce = magforce[-1:]
|
|
237
237
|
|
|
238
238
|
force = get_force(outlines, natoms)
|
|
239
|
+
if cell_flipped and force is not None:
|
|
240
|
+
force = -force
|
|
239
241
|
stress = get_stress(outlines)
|
|
240
242
|
|
|
241
243
|
data["energies"] = np.array(energy)[np.newaxis]
|
|
@@ -132,8 +132,11 @@ def parse_pos_oneline(pos_line):
|
|
|
132
132
|
- `mag` or `magmom`: Start magnetization for each atom. Can be one number (colinear) or three numbers (non-colinear).
|
|
133
133
|
- `angle1`: In non-colinear case, angle between c-axis and real spin (in degrees).
|
|
134
134
|
- `angle2`: In non-colinear case, angle between a-axis and real spin projection in ab-plane (in degrees).
|
|
135
|
-
- `
|
|
135
|
+
- `sc` or `constrain`: Three numbers (0 or 1) controlling the spin constraint of the atom.
|
|
136
|
+
ABACUS itself reads only `sc`.
|
|
136
137
|
- `lambda`: Three numbers controlling the lambda of the atom.
|
|
138
|
+
- `f`, `force`, or `forces`: Three force components, written by ABACUS into output
|
|
139
|
+
structure files. They are informational and are ignored when reading.
|
|
137
140
|
|
|
138
141
|
Parameters
|
|
139
142
|
----------
|
|
@@ -157,7 +160,7 @@ def parse_pos_oneline(pos_line):
|
|
|
157
160
|
Fe
|
|
158
161
|
1.0
|
|
159
162
|
2
|
|
160
|
-
0.0 0.0 0.0 m 0 0 0 mag 1.0 angle1 90 angle2 0
|
|
163
|
+
0.0 0.0 0.0 m 0 0 0 mag 1.0 angle1 90 angle2 0 sc 0 0 0
|
|
161
164
|
0.5 0.5 0.5 m 1 1 1 mag 1.0 angle1 90 angle2 180
|
|
162
165
|
```
|
|
163
166
|
"""
|
|
@@ -179,6 +182,7 @@ def parse_pos_oneline(pos_line):
|
|
|
179
182
|
angle2_list = None
|
|
180
183
|
constrain_list = None
|
|
181
184
|
lambda_list = None
|
|
185
|
+
force_list = None
|
|
182
186
|
label = "move"
|
|
183
187
|
for i in range(3, len(sline)):
|
|
184
188
|
# firstly read the label
|
|
@@ -202,6 +206,9 @@ def parse_pos_oneline(pos_line):
|
|
|
202
206
|
elif sline[i] in ["lambda"]:
|
|
203
207
|
label = "lambda"
|
|
204
208
|
lambda_list = []
|
|
209
|
+
elif sline[i] in ["f", "force", "forces"]:
|
|
210
|
+
label = "force"
|
|
211
|
+
force_list = []
|
|
205
212
|
|
|
206
213
|
# the read the value to the list
|
|
207
214
|
elif label == "move":
|
|
@@ -218,6 +225,8 @@ def parse_pos_oneline(pos_line):
|
|
|
218
225
|
constrain_list.append(bool(int(sline[i])))
|
|
219
226
|
elif label == "lambda":
|
|
220
227
|
lambda_list.append(float(sline[i]))
|
|
228
|
+
elif label == "force":
|
|
229
|
+
force_list.append(float(sline[i]))
|
|
221
230
|
|
|
222
231
|
if move_list is not None and len(move_list) > 0:
|
|
223
232
|
if len(move_list) == 3:
|
|
@@ -267,6 +276,10 @@ def parse_pos_oneline(pos_line):
|
|
|
267
276
|
else:
|
|
268
277
|
raise RuntimeError(f"Invalid lambda {pos_line}")
|
|
269
278
|
|
|
279
|
+
# forces are informational (ABACUS ignores them when reading a STRU file)
|
|
280
|
+
if force_list is not None and len(force_list) != 3:
|
|
281
|
+
raise RuntimeError(f"Invalid force {pos_line}")
|
|
282
|
+
|
|
270
283
|
return pos, move, velocity, magmom, angle1, angle2, constrain, lambda1
|
|
271
284
|
|
|
272
285
|
|
|
@@ -320,7 +333,10 @@ def get_cartesian_coords(coords, coord_type, celldm, cell):
|
|
|
320
333
|
|
|
321
334
|
Args:
|
|
322
335
|
coords (np.ndarray): atomic coordinates read from the STRU file.
|
|
323
|
-
coord_type (str): the coordination type
|
|
336
|
+
coord_type (str): the coordination type in lower case: "direct", "cartesian"
|
|
337
|
+
(in units of the lattice constant), "cartesian_au" (in bohr),
|
|
338
|
+
"cartesian_angstrom", or "cartesian_angstrom_center_xy"/"_xz"/"_yz"/"_xyz"
|
|
339
|
+
(in angstrom, relative to the center of the cell along the given axes).
|
|
324
340
|
celldm (float): the lattice constant.
|
|
325
341
|
cell (np.ndarray): the cell vectors in angstrom.
|
|
326
342
|
|
|
@@ -330,10 +346,30 @@ def get_cartesian_coords(coords, coord_type, celldm, cell):
|
|
|
330
346
|
"""
|
|
331
347
|
if coord_type == "cartesian":
|
|
332
348
|
return coords * celldm * bohr2ang
|
|
349
|
+
elif coord_type == "cartesian_au":
|
|
350
|
+
return coords * bohr2ang
|
|
351
|
+
elif coord_type == "cartesian_angstrom":
|
|
352
|
+
return coords
|
|
353
|
+
elif coord_type in (
|
|
354
|
+
"cartesian_angstrom_center_xy",
|
|
355
|
+
"cartesian_angstrom_center_xz",
|
|
356
|
+
"cartesian_angstrom_center_yz",
|
|
357
|
+
"cartesian_angstrom_center_xyz",
|
|
358
|
+
):
|
|
359
|
+
# same origin as ABACUS (calculate_lattice_center): half of the sum of the
|
|
360
|
+
# cell vectors, kept only along the axes named in the coordinate type
|
|
361
|
+
axes = coord_type[len("cartesian_angstrom_center_") :]
|
|
362
|
+
center = np.sum(cell, axis=0) / 2
|
|
363
|
+
center = np.where([c in axes for c in "xyz"], center, 0.0)
|
|
364
|
+
return coords + center
|
|
333
365
|
elif coord_type == "direct":
|
|
334
366
|
return np.matmul(coords, cell)
|
|
335
367
|
else:
|
|
336
|
-
raise RuntimeError(
|
|
368
|
+
raise RuntimeError(
|
|
369
|
+
f"Unsupported coordinate type: {coord_type}. Supported: "
|
|
370
|
+
"direct, cartesian, cartesian_au, cartesian_angstrom, "
|
|
371
|
+
"cartesian_angstrom_center_{xy,xz,yz,xyz}"
|
|
372
|
+
)
|
|
337
373
|
|
|
338
374
|
|
|
339
375
|
def parse_pos(coords_lines, atom_names, celldm, cell):
|
|
@@ -442,13 +478,55 @@ def right_hand_rule(
|
|
|
442
478
|
return cell, coord
|
|
443
479
|
|
|
444
480
|
|
|
445
|
-
def
|
|
481
|
+
def validate_duplicate_species(atom_names, masses, pp_files, orb_files):
|
|
482
|
+
"""Check that duplicate atom species definitions are consistent.
|
|
483
|
+
|
|
484
|
+
get_frame_from_stru merges repeated labels and keeps the metadata of the
|
|
485
|
+
first matching row for masses, pp_files, and orb_files. If a duplicate
|
|
486
|
+
row conflicts with the first one, raise an error instead of silently
|
|
487
|
+
discarding the conflicting metadata.
|
|
488
|
+
|
|
489
|
+
Args:
|
|
490
|
+
atom_names (list): list of atom names.
|
|
491
|
+
masses (list): list of atomic masses.
|
|
492
|
+
pp_files (list): list of pseudo potential files.
|
|
493
|
+
orb_files (list): list of orbital files.
|
|
494
|
+
|
|
495
|
+
Raises
|
|
496
|
+
------
|
|
497
|
+
RuntimeError: if duplicate species have conflicting metadata.
|
|
498
|
+
"""
|
|
499
|
+
for name in dict.fromkeys(atom_names):
|
|
500
|
+
indices = [j for j in range(len(atom_names)) if atom_names[j] == name]
|
|
501
|
+
if len(indices) < 2:
|
|
502
|
+
continue
|
|
503
|
+
ref_mass = masses[indices[0]]
|
|
504
|
+
ref_pp = pp_files[indices[0]]
|
|
505
|
+
ref_orb = orb_files[indices[0]] if orb_files else None
|
|
506
|
+
for j in indices[1:]:
|
|
507
|
+
if not np.isclose(masses[j], ref_mass):
|
|
508
|
+
raise RuntimeError(
|
|
509
|
+
f"Conflicting duplicate species '{name}': mass {masses[j]} != {ref_mass}"
|
|
510
|
+
)
|
|
511
|
+
if pp_files[j] != ref_pp:
|
|
512
|
+
raise RuntimeError(
|
|
513
|
+
f"Conflicting duplicate species '{name}': pp_file {pp_files[j]} != {ref_pp}"
|
|
514
|
+
)
|
|
515
|
+
if ref_orb is not None and orb_files[j] != ref_orb:
|
|
516
|
+
raise RuntimeError(
|
|
517
|
+
f"Conflicting duplicate species '{name}': orb_file {orb_files[j]} != {ref_orb}"
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
def get_frame_from_stru(stru, return_flipped=False):
|
|
446
522
|
"""Read the ABACUS STRU file and return the dpdata frame.
|
|
447
523
|
|
|
448
524
|
The description of ABACUS STRU can be found in https://abacus.deepmodeling.com/en/latest/advanced/input_files/stru.html
|
|
449
525
|
|
|
450
526
|
Args:
|
|
451
527
|
stru (str): path to the ABACUS STRU file.
|
|
528
|
+
return_flipped (bool): whether to return a flag indicating that the
|
|
529
|
+
input cell was left-handed and had to be reflected.
|
|
452
530
|
|
|
453
531
|
Returns
|
|
454
532
|
-------
|
|
@@ -489,31 +567,53 @@ def get_frame_from_stru(stru):
|
|
|
489
567
|
celldm = parse_lattice_constant_block(blocks["LATTICE_CONSTANT"])
|
|
490
568
|
cell = parse_lattice_vectors_block(blocks["LATTICE_VECTORS"])
|
|
491
569
|
cell = np.array(cell) * celldm * bohr2ang
|
|
570
|
+
cell_flipped = np.linalg.det(cell) < 0
|
|
492
571
|
atom_numbs, coords, move, mags, velocity, sc, lambda_ = parse_pos(
|
|
493
572
|
blocks["ATOMIC_POSITIONS"], atom_names, celldm, cell
|
|
494
573
|
)
|
|
495
574
|
|
|
575
|
+
validate_duplicate_species(atom_names, masses, pp_files, orb_files)
|
|
576
|
+
|
|
496
577
|
cell, coords = right_hand_rule(cell, coords)
|
|
578
|
+
uniq_name = []
|
|
579
|
+
uniq_atom_num = []
|
|
580
|
+
for i in atom_names:
|
|
581
|
+
if i not in uniq_name:
|
|
582
|
+
uniq_name.append(i)
|
|
583
|
+
uniq_atom_num.append(
|
|
584
|
+
sum(
|
|
585
|
+
[
|
|
586
|
+
atom_numbs[j]
|
|
587
|
+
for j in range(len(atom_names))
|
|
588
|
+
if atom_names[j] == i
|
|
589
|
+
]
|
|
590
|
+
)
|
|
591
|
+
)
|
|
497
592
|
data = {
|
|
498
|
-
"atom_names":
|
|
499
|
-
"atom_numbs":
|
|
593
|
+
"atom_names": uniq_name,
|
|
594
|
+
"atom_numbs": uniq_atom_num,
|
|
500
595
|
"atom_types": np.array(
|
|
501
|
-
[
|
|
596
|
+
[
|
|
597
|
+
uniq_name.index(atom_names[i])
|
|
598
|
+
for i in range(len(atom_numbs))
|
|
599
|
+
for j in range(atom_numbs[i])
|
|
600
|
+
]
|
|
502
601
|
),
|
|
503
|
-
"masses": np.array(masses),
|
|
504
|
-
"pp_files": pp_files,
|
|
602
|
+
"masses": np.array([masses[atom_names.index(i)] for i in uniq_name]),
|
|
603
|
+
"pp_files": [pp_files[atom_names.index(i)] for i in uniq_name],
|
|
505
604
|
"cells": np.array([cell]),
|
|
506
605
|
"coords": np.array([coords]),
|
|
507
606
|
}
|
|
508
607
|
if len(mags) > 0:
|
|
509
608
|
data["spins"] = np.array([mags])
|
|
510
609
|
if len(orb_files) > 0:
|
|
511
|
-
data["orb_files"] = orb_files
|
|
610
|
+
data["orb_files"] = [orb_files[atom_names.index(i)] for i in uniq_name]
|
|
512
611
|
if len(dpks_descriptor) > 0:
|
|
513
612
|
data["dpks_descriptor"] = dpks_descriptor[0].strip()
|
|
514
613
|
if len(move) > 0:
|
|
515
614
|
data["move"] = np.array([move])
|
|
516
|
-
|
|
615
|
+
if return_flipped:
|
|
616
|
+
return data, cell_flipped
|
|
517
617
|
return data
|
|
518
618
|
|
|
519
619
|
|
|
@@ -26,6 +26,13 @@ delimiter_patterns.append(delimiter_p2)
|
|
|
26
26
|
avail_patterns = []
|
|
27
27
|
avail_patterns.append(re.compile(r"^ INITIAL POTENTIAL ENERGY"))
|
|
28
28
|
avail_patterns.append(re.compile(r"^ ENSEMBLE TYPE"))
|
|
29
|
+
# Newer CP2K stress block (STRESS| prefix), in STRESS_UNIT (bar by default, or GPa):
|
|
30
|
+
# STRESS| Analytical stress tensor [bar]
|
|
31
|
+
# STRESS| x y z
|
|
32
|
+
# STRESS| x -2.60150458500E+04 -8.76461756245E+02 -2.91228225972E+02
|
|
33
|
+
stress_block_pattern = re.compile(
|
|
34
|
+
r"^ STRESS\|\s+(?:Analytical|Numerical) stress tensor \[(?P<unit>[^\]]+)\]"
|
|
35
|
+
)
|
|
29
36
|
|
|
30
37
|
|
|
31
38
|
class Cp2kSystems:
|
|
@@ -393,6 +400,7 @@ def get_frames(fname):
|
|
|
393
400
|
coord = []
|
|
394
401
|
force = []
|
|
395
402
|
stress = []
|
|
403
|
+
stress_block_idx = None
|
|
396
404
|
|
|
397
405
|
fp = open(fname)
|
|
398
406
|
# check if output is converged, if not, return sys = 0
|
|
@@ -483,6 +491,8 @@ def get_frames(fname):
|
|
|
483
491
|
force.append(ii.split()[3:6])
|
|
484
492
|
# add reading stress tensor
|
|
485
493
|
if "STRESS TENSOR [GPa" in ii:
|
|
494
|
+
stress = []
|
|
495
|
+
stress_block_idx = None
|
|
486
496
|
stress_flag = True
|
|
487
497
|
stress_idx = idx
|
|
488
498
|
if stress_flag:
|
|
@@ -491,6 +501,21 @@ def get_frames(fname):
|
|
|
491
501
|
stress_flag = False
|
|
492
502
|
else:
|
|
493
503
|
stress.append(ii.split()[1:4])
|
|
504
|
+
# newer STRESS| format: header, column labels, then the x/y/z rows;
|
|
505
|
+
# the eigenvector rows that follow are not part of the tensor.
|
|
506
|
+
stress_block = stress_block_pattern.match(ii)
|
|
507
|
+
if stress_block:
|
|
508
|
+
stress = []
|
|
509
|
+
stress_block_idx = idx
|
|
510
|
+
stress_unit = stress_block.group("unit")
|
|
511
|
+
try:
|
|
512
|
+
stress_to_gpa = PressureConversion(stress_unit, "GPa").value()
|
|
513
|
+
except (IndexError, ValueError, KeyError) as e:
|
|
514
|
+
raise RuntimeError(
|
|
515
|
+
f"Unsupported CP2K stress unit [{stress_unit}]: {ii.strip()}"
|
|
516
|
+
) from e
|
|
517
|
+
elif stress_block_idx is not None and 2 <= idx - stress_block_idx <= 4:
|
|
518
|
+
stress.append([float(v) * stress_to_gpa for v in ii.split()[2:5]])
|
|
494
519
|
|
|
495
520
|
fp.close()
|
|
496
521
|
assert coord, "cannot find coords"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
3
|
+
from typing import TYPE_CHECKING, Any
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
|
|
@@ -33,12 +33,38 @@ def read_dftb_plus(
|
|
|
33
33
|
np.ndarray
|
|
34
34
|
atomic forces
|
|
35
35
|
|
|
36
|
+
"""
|
|
37
|
+
frame = parse_dftb_plus(fn_1, fn_2)
|
|
38
|
+
return frame["symbols"], frame["coords"], frame["energy"], frame["forces"]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def parse_dftb_plus(fn_1: FileType, fn_2: FileType) -> dict[str, Any]:
|
|
42
|
+
"""Read one labeled frame, including the cell and stress, from DFTB+ files.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
fn_1 : str
|
|
47
|
+
DFTB+ input file name
|
|
48
|
+
fn_2 : str
|
|
49
|
+
DFTB+ output file name
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
dict
|
|
54
|
+
``symbols``, ``coords``, ``energy`` and ``forces`` as returned by
|
|
55
|
+
:func:`read_dftb_plus`; ``cell``, the lattice vectors of a periodic
|
|
56
|
+
(``S`` or ``F``) GenFormat geometry; and ``stress``, the ``Total stress
|
|
57
|
+
tensor`` in Hartree/Bohr^3. ``cell`` and ``stress`` are ``None`` when
|
|
58
|
+
the files do not contain them.
|
|
59
|
+
|
|
36
60
|
"""
|
|
37
61
|
coord = None
|
|
38
62
|
symbols = None
|
|
39
63
|
forces = None
|
|
40
64
|
energy = None
|
|
41
65
|
natoms = None
|
|
66
|
+
cell = None
|
|
67
|
+
stress = None
|
|
42
68
|
with open_file(fn_1) as f:
|
|
43
69
|
lines = iter(f)
|
|
44
70
|
for line in lines:
|
|
@@ -58,15 +84,18 @@ def read_dftb_plus(
|
|
|
58
84
|
s = next(lines).split()
|
|
59
85
|
symbols.append(components[int(s[1]) - 1])
|
|
60
86
|
coord.append([float(s[2]), float(s[3]), float(s[4])])
|
|
61
|
-
if coordinate_mode
|
|
62
|
-
#
|
|
63
|
-
# lattice
|
|
87
|
+
if coordinate_mode in {"S", "F"}:
|
|
88
|
+
# Periodic GenFormat geometries end with the origin and the
|
|
89
|
+
# three lattice vectors.
|
|
64
90
|
origin = np.array([float(value) for value in next(lines).split()])
|
|
65
|
-
|
|
91
|
+
cell = np.array(
|
|
66
92
|
[[float(value) for value in next(lines).split()] for _ in range(3)]
|
|
67
93
|
)
|
|
68
|
-
|
|
69
|
-
|
|
94
|
+
if coordinate_mode == "F":
|
|
95
|
+
# Fractional GenFormat coordinates are expressed in the
|
|
96
|
+
# lattice-vector basis.
|
|
97
|
+
coord = (np.asarray(coord) @ cell + origin).tolist()
|
|
98
|
+
elif coordinate_mode != "C":
|
|
70
99
|
raise ValueError(
|
|
71
100
|
f"unsupported GenFormat coordinate mode: {coordinate_mode}"
|
|
72
101
|
)
|
|
@@ -84,10 +113,21 @@ def read_dftb_plus(
|
|
|
84
113
|
elif line.startswith("Total energy:"):
|
|
85
114
|
s = line.split()
|
|
86
115
|
energy = float(s[2])
|
|
116
|
+
elif line.lstrip().startswith("Total stress tensor"):
|
|
117
|
+
stress = np.array(
|
|
118
|
+
[[float(value) for value in next(lines).split()] for _ in range(3)]
|
|
119
|
+
)
|
|
87
120
|
|
|
88
121
|
symbols = np.array(symbols)
|
|
89
122
|
forces = np.array(forces)
|
|
90
123
|
coord = np.array(coord)
|
|
91
124
|
assert coord.shape == forces.shape
|
|
92
125
|
|
|
93
|
-
return
|
|
126
|
+
return {
|
|
127
|
+
"symbols": symbols,
|
|
128
|
+
"coords": coord,
|
|
129
|
+
"energy": energy,
|
|
130
|
+
"forces": forces,
|
|
131
|
+
"cell": cell,
|
|
132
|
+
"stress": stress,
|
|
133
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Quantum ESPRESSO ``pw.x`` molecular-dynamics output reader.
|
|
2
|
+
|
|
3
|
+
The implementation is shared with the ``qe/pw/scf`` reader because a PWscf
|
|
4
|
+
output can contain either one labeled structure or a sequence of MD frames.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from .scf import get_frames
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def to_system_data(fname, begin=0, step=1):
|
|
13
|
+
"""Read PWscf AIMD frames from an output file and its matching input."""
|
|
14
|
+
return get_frames(fname, begin=begin, step=step)
|