dpdata 0.2.22__tar.gz → 0.2.23__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.22 → dpdata-0.2.23}/.pre-commit-config.yaml +1 -1
- {dpdata-0.2.22 → dpdata-0.2.23}/PKG-INFO +1 -1
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/_version.py +2 -2
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/abacus/md.py +11 -14
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/abacus/relax.py +11 -21
- dpdata-0.2.23/dpdata/abacus/scf.py +250 -0
- dpdata-0.2.22/dpdata/abacus/scf.py → dpdata-0.2.23/dpdata/abacus/stru.py +236 -373
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/abacus.py +3 -2
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata.egg-info/PKG-INFO +1 -1
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata.egg-info/SOURCES.txt +1 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.git-blame-ignore-revs +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.git_archival.txt +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.gitattributes +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/ISSUE_TEMPLATE/generic-issue.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/dependabot.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/workflows/benchmark.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/workflows/mirror_gitee.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/workflows/pub-pypi.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/workflows/pyright.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/workflows/test.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.github/workflows/test_import.yml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.gitignore +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/.readthedocs.yaml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/LICENSE +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/MANIFEST.in +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/README.md +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/benchmark/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/benchmark/test_import.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/__about__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/__main__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/abacus/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/amber/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/amber/mask.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/amber/md.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/amber/sqm.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/ase_calculator.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/bond_order_system.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/cli.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/cp2k/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/cp2k/cell.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/cp2k/output.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/data_type.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/deepmd/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/deepmd/comp.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/deepmd/hdf5.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/deepmd/mixed.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/deepmd/raw.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/dftbplus/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/dftbplus/output.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/driver.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/fhi_aims/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/fhi_aims/output.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/format.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/gaussian/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/gaussian/gjf.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/gaussian/log.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/gromacs/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/gromacs/gro.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/lammps/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/lammps/dump.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/lammps/lmp.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/md/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/md/msd.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/md/pbc.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/md/rdf.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/md/water.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/openmx/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/openmx/omx.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/orca/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/orca/output.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/periodic_table.json +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/periodic_table.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugin.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/3dmol.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/amber.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/ase.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/cp2k.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/deepmd.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/dftbplus.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/fhi_aims.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/gaussian.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/gromacs.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/lammps.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/list.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/n2p2.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/openmx.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/orca.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/psi4.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/pwmat.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/pymatgen.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/qe.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/rdkit.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/siesta.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/vasp.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/plugins/xyz.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/psi4/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/psi4/input.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/psi4/output.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/pwmat/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/pwmat/atomconfig.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/pwmat/movement.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/py.typed +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/pymatgen/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/pymatgen/molecule.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/pymatgen/structure.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/qe/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/qe/scf.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/qe/traj.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/rdkit/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/rdkit/sanitize.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/rdkit/utils.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/siesta/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/siesta/aiMD_output.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/siesta/output.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/stat.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/system.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/unit.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/utils.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/vasp/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/vasp/outcar.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/vasp/poscar.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/vasp/xml.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/xyz/__init__.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/xyz/quip_gap_xyz.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata/xyz/xyz.py +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata.egg-info/dependency_links.txt +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata.egg-info/entry_points.txt +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata.egg-info/requires.txt +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/dpdata.egg-info/top_level.txt +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/pyproject.toml +0 -0
- {dpdata-0.2.22 → dpdata-0.2.23}/setup.cfg +0 -0
|
@@ -9,12 +9,11 @@ from dpdata.utils import open_file
|
|
|
9
9
|
|
|
10
10
|
from .scf import (
|
|
11
11
|
bohr2ang,
|
|
12
|
-
get_cell,
|
|
13
|
-
get_coords,
|
|
14
12
|
get_geometry_in,
|
|
15
13
|
get_mag_force,
|
|
16
14
|
kbar2evperang3,
|
|
17
15
|
)
|
|
16
|
+
from .stru import get_frame_from_stru
|
|
18
17
|
|
|
19
18
|
# Read in geometries from an ABACUS MD trajectory.
|
|
20
19
|
# The atomic coordinates are read in from generated files in OUT.XXXX.
|
|
@@ -164,12 +163,12 @@ def get_frame(fname):
|
|
|
164
163
|
geometry_path_in = get_geometry_in(fname, inlines) # base dir of STRU
|
|
165
164
|
path_out = get_path_out(fname, inlines)
|
|
166
165
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
166
|
+
data = get_frame_from_stru(geometry_path_in)
|
|
167
|
+
natoms = data["atom_numbs"]
|
|
168
|
+
# should remove spins from STRU file
|
|
169
|
+
if "spins" in data:
|
|
170
|
+
data.pop("spins")
|
|
171
|
+
|
|
173
172
|
# This coords is not to be used.
|
|
174
173
|
dump_freq = get_coord_dump_freq(inlines=inlines)
|
|
175
174
|
# ndump = int(os.popen("ls -l %s | grep 'md_pos_' | wc -l" %path_out).readlines()[0])
|
|
@@ -203,10 +202,6 @@ def get_frame(fname):
|
|
|
203
202
|
|
|
204
203
|
magmom, magforce = get_mag_force(outlines)
|
|
205
204
|
|
|
206
|
-
data = {}
|
|
207
|
-
data["atom_names"] = atom_names
|
|
208
|
-
data["atom_numbs"] = natoms
|
|
209
|
-
data["atom_types"] = types
|
|
210
205
|
data["cells"] = cells
|
|
211
206
|
# for idx in range(ndump):
|
|
212
207
|
# data['cells'][:, :, :] = cell
|
|
@@ -221,7 +216,9 @@ def get_frame(fname):
|
|
|
221
216
|
data["spins"] = magmom
|
|
222
217
|
if len(magforce) > 0:
|
|
223
218
|
data["force_mags"] = magforce
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
|
|
220
|
+
# need to expand the move.
|
|
221
|
+
if "move" in data:
|
|
222
|
+
data["move"] = [data["move"][0] for i in range(ndump)]
|
|
226
223
|
|
|
227
224
|
return data
|
|
@@ -10,12 +10,11 @@ from .scf import (
|
|
|
10
10
|
bohr2ang,
|
|
11
11
|
collect_force,
|
|
12
12
|
collect_stress,
|
|
13
|
-
get_cell,
|
|
14
|
-
get_coords,
|
|
15
13
|
get_geometry_in,
|
|
16
14
|
get_mag_force,
|
|
17
15
|
kbar2evperang3,
|
|
18
16
|
)
|
|
17
|
+
from .stru import get_frame_from_stru
|
|
19
18
|
|
|
20
19
|
# Read in geometries from an ABACUS RELAX(CELL-RELAX) trajectory in OUT.XXXX/runnning_relax/cell-relax.log.
|
|
21
20
|
|
|
@@ -47,7 +46,7 @@ def get_coords_from_log(loglines, natoms):
|
|
|
47
46
|
natoms_log += int(line.split()[-1])
|
|
48
47
|
|
|
49
48
|
assert natoms_log > 0 and natoms_log == natoms, (
|
|
50
|
-
"ERROR: detected atom number in log file is
|
|
49
|
+
f"ERROR: detected atom number in log file is {natoms_log}, while the atom number in STRU file is {natoms}"
|
|
51
50
|
)
|
|
52
51
|
|
|
53
52
|
energy = []
|
|
@@ -180,31 +179,22 @@ def get_frame(fname):
|
|
|
180
179
|
with open_file(path_in) as fp:
|
|
181
180
|
inlines = fp.read().split("\n")
|
|
182
181
|
geometry_path_in = get_geometry_in(fname, inlines) # base dir of STRU
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
|
|
183
|
+
data = get_frame_from_stru(geometry_path_in)
|
|
184
|
+
natoms = sum(data["atom_numbs"])
|
|
185
|
+
# should remove spins from STRU file
|
|
186
|
+
if "spins" in data:
|
|
187
|
+
data.pop("spins")
|
|
189
188
|
|
|
190
189
|
logf = get_log_file(fname, inlines)
|
|
191
190
|
assert os.path.isfile(logf), f"Error: can not find {logf}"
|
|
192
191
|
with open_file(logf) as f1:
|
|
193
192
|
lines = f1.readlines()
|
|
194
193
|
|
|
195
|
-
|
|
196
|
-
for i in natoms:
|
|
197
|
-
atomnumber += i
|
|
198
|
-
energy, cells, coords, force, stress, virial = get_coords_from_log(
|
|
199
|
-
lines, atomnumber
|
|
200
|
-
)
|
|
194
|
+
energy, cells, coords, force, stress, virial = get_coords_from_log(lines, natoms)
|
|
201
195
|
|
|
202
196
|
magmom, magforce = get_mag_force(lines)
|
|
203
197
|
|
|
204
|
-
data = {}
|
|
205
|
-
data["atom_names"] = atom_names
|
|
206
|
-
data["atom_numbs"] = natoms
|
|
207
|
-
data["atom_types"] = types
|
|
208
198
|
data["cells"] = cells
|
|
209
199
|
data["coords"] = coords
|
|
210
200
|
data["energies"] = energy
|
|
@@ -218,7 +208,7 @@ def get_frame(fname):
|
|
|
218
208
|
data["spins"] = magmom
|
|
219
209
|
if len(magforce) > 0:
|
|
220
210
|
data["force_mags"] = magforce
|
|
221
|
-
if
|
|
222
|
-
data["move"] = move
|
|
211
|
+
if "move" in data:
|
|
212
|
+
data["move"] = [data["move"][0] for i in range(len(data["energies"]))]
|
|
223
213
|
|
|
224
214
|
return data
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import re
|
|
5
|
+
import warnings
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from dpdata.utils import open_file
|
|
10
|
+
|
|
11
|
+
from ..unit import LengthConversion, PressureConversion
|
|
12
|
+
from .stru import get_frame_from_stru
|
|
13
|
+
|
|
14
|
+
bohr2ang = LengthConversion("bohr", "angstrom").value()
|
|
15
|
+
kbar2evperang3 = PressureConversion("kbar", "eV/angstrom^3").value()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def CheckFile(ifile):
|
|
19
|
+
if not os.path.isfile(ifile):
|
|
20
|
+
print(f"Can not find file {ifile}")
|
|
21
|
+
return False
|
|
22
|
+
return True
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_geometry_in(fname, inlines):
|
|
26
|
+
geometry_path_in = os.path.join(fname, "STRU")
|
|
27
|
+
for line in inlines:
|
|
28
|
+
if "stru_file" in line and "stru_file" == line.split()[0]:
|
|
29
|
+
atom_file = line.split()[1]
|
|
30
|
+
geometry_path_in = os.path.join(fname, atom_file)
|
|
31
|
+
break
|
|
32
|
+
return geometry_path_in
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_path_out(fname, inlines):
|
|
36
|
+
path_out = os.path.join(fname, "OUT.ABACUS/running_scf.log")
|
|
37
|
+
for line in inlines:
|
|
38
|
+
if "suffix" in line and "suffix" == line.split()[0]:
|
|
39
|
+
suffix = line.split()[1]
|
|
40
|
+
path_out = os.path.join(fname, f"OUT.{suffix}/running_scf.log")
|
|
41
|
+
break
|
|
42
|
+
return path_out
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_energy(outlines):
|
|
46
|
+
Etot = None
|
|
47
|
+
for line in reversed(outlines):
|
|
48
|
+
if "final etot is" in line:
|
|
49
|
+
Etot = float(line.split()[-2]) # in eV
|
|
50
|
+
return Etot, True
|
|
51
|
+
elif "convergence has NOT been achieved!" in line:
|
|
52
|
+
return Etot, False
|
|
53
|
+
elif "convergence has not been achieved" in line:
|
|
54
|
+
return Etot, False
|
|
55
|
+
|
|
56
|
+
return Etot, False
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def collect_force(outlines):
|
|
60
|
+
force = []
|
|
61
|
+
for i, line in enumerate(outlines):
|
|
62
|
+
if "TOTAL-FORCE (eV/Angstrom)" in line:
|
|
63
|
+
value_pattern = re.compile(
|
|
64
|
+
r"^\s*[A-Z][a-z]?[1-9][0-9]*\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$"
|
|
65
|
+
)
|
|
66
|
+
j = i
|
|
67
|
+
# find the first line of force
|
|
68
|
+
noforce = False
|
|
69
|
+
while not value_pattern.match(outlines[j]):
|
|
70
|
+
j += 1
|
|
71
|
+
if (
|
|
72
|
+
j >= i + 10
|
|
73
|
+
): # if can not find the first line of force in 10 lines, then stop
|
|
74
|
+
warnings.warn("Warning: can not find the first line of force")
|
|
75
|
+
noforce = True
|
|
76
|
+
break
|
|
77
|
+
if noforce:
|
|
78
|
+
break
|
|
79
|
+
|
|
80
|
+
force.append([])
|
|
81
|
+
while value_pattern.match(outlines[j]):
|
|
82
|
+
force[-1].append([float(ii) for ii in outlines[j].split()[1:4]])
|
|
83
|
+
j += 1
|
|
84
|
+
return force # only return the last force
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_force(outlines, natoms):
|
|
88
|
+
force = collect_force(outlines)
|
|
89
|
+
if len(force) == 0:
|
|
90
|
+
return None
|
|
91
|
+
else:
|
|
92
|
+
return np.array(force[-1]) # only return the last force
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def collect_stress(outlines):
|
|
96
|
+
stress = []
|
|
97
|
+
for i, line in enumerate(outlines):
|
|
98
|
+
if "TOTAL-STRESS (KBAR)" in line:
|
|
99
|
+
value_pattern = re.compile(
|
|
100
|
+
r"^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$"
|
|
101
|
+
)
|
|
102
|
+
j = i
|
|
103
|
+
nostress = False
|
|
104
|
+
while not value_pattern.match(outlines[j]):
|
|
105
|
+
j += 1
|
|
106
|
+
if (
|
|
107
|
+
j >= i + 10
|
|
108
|
+
): # if can not find the first line of stress in 10 lines, then stop
|
|
109
|
+
warnings.warn("Warning: can not find the first line of stress")
|
|
110
|
+
nostress = True
|
|
111
|
+
break
|
|
112
|
+
if nostress:
|
|
113
|
+
break
|
|
114
|
+
|
|
115
|
+
stress.append([])
|
|
116
|
+
while value_pattern.match(outlines[j]):
|
|
117
|
+
stress[-1].append(
|
|
118
|
+
list(map(lambda x: float(x), outlines[j].split()[0:3]))
|
|
119
|
+
)
|
|
120
|
+
j += 1
|
|
121
|
+
return stress
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def get_stress(outlines):
|
|
125
|
+
stress = collect_stress(outlines)
|
|
126
|
+
if len(stress) == 0:
|
|
127
|
+
return None
|
|
128
|
+
else:
|
|
129
|
+
return np.array(stress[-1]) * kbar2evperang3 # only return the last stress
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def get_mag_force(outlines):
|
|
133
|
+
"""Read atomic magmom and magnetic force from OUT.ABACUS/running_scf.log.
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
magmom: list of list of atomic magnetic moments (three dimensions: ION_STEP * NATOMS * 1/3)
|
|
138
|
+
magforce: list of list of atomic magnetic forces (three dimensions: ION_STEP * NATOMS * 1/3)
|
|
139
|
+
e.g.:
|
|
140
|
+
-------------------------------------------------------------------------------------------
|
|
141
|
+
Total Magnetism (uB)
|
|
142
|
+
-------------------------------------------------------------------------------------------
|
|
143
|
+
Fe 0.0000000001 0.0000000000 3.0000000307
|
|
144
|
+
Fe -0.0000000000 -0.0000000000 3.0000001151
|
|
145
|
+
-------------------------------------------------------------------------------------------
|
|
146
|
+
-------------------------------------------------------------------------------------------
|
|
147
|
+
Magnetic force (eV/uB)
|
|
148
|
+
-------------------------------------------------------------------------------------------
|
|
149
|
+
Fe 0.0000000000 0.0000000000 -1.2117698671
|
|
150
|
+
Fe 0.0000000000 0.0000000000 -1.2117928796
|
|
151
|
+
-------------------------------------------------------------------------------------------
|
|
152
|
+
|
|
153
|
+
"""
|
|
154
|
+
mags = []
|
|
155
|
+
magforces = []
|
|
156
|
+
for i, line in enumerate(outlines):
|
|
157
|
+
if "Total Magnetism (uB)" in line:
|
|
158
|
+
j = i + 2
|
|
159
|
+
mag = []
|
|
160
|
+
while "-------------------------" not in outlines[j]:
|
|
161
|
+
imag = [float(ii) for ii in outlines[j].split()[1:]]
|
|
162
|
+
if len(imag) == 1:
|
|
163
|
+
imag = [0, 0, imag[0]]
|
|
164
|
+
mag.append(imag)
|
|
165
|
+
j += 1
|
|
166
|
+
mags.append(mag)
|
|
167
|
+
if "Magnetic force (eV/uB)" in line:
|
|
168
|
+
j = i + 2
|
|
169
|
+
magforce = []
|
|
170
|
+
while "-------------------------" not in outlines[j]:
|
|
171
|
+
imagforce = [float(ii) for ii in outlines[j].split()[1:]]
|
|
172
|
+
if len(imagforce) == 1:
|
|
173
|
+
imagforce = [0, 0, imagforce[0]]
|
|
174
|
+
magforce.append(imagforce)
|
|
175
|
+
j += 1
|
|
176
|
+
magforces.append(magforce)
|
|
177
|
+
return np.array(mags), np.array(magforces)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def get_frame(fname):
|
|
181
|
+
data = {
|
|
182
|
+
"atom_names": [],
|
|
183
|
+
"atom_numbs": [],
|
|
184
|
+
"atom_types": [],
|
|
185
|
+
"cells": np.array([]),
|
|
186
|
+
"coords": np.array([]),
|
|
187
|
+
"energies": np.array([]),
|
|
188
|
+
"forces": np.array([]),
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if isinstance(fname, str):
|
|
192
|
+
# if the input parameter is only one string, it is assumed that it is the
|
|
193
|
+
# base directory containing INPUT file;
|
|
194
|
+
path_in = os.path.join(fname, "INPUT")
|
|
195
|
+
else:
|
|
196
|
+
raise RuntimeError("invalid input")
|
|
197
|
+
|
|
198
|
+
if not CheckFile(path_in):
|
|
199
|
+
return data
|
|
200
|
+
|
|
201
|
+
with open_file(path_in) as fp:
|
|
202
|
+
inlines = fp.read().split("\n")
|
|
203
|
+
|
|
204
|
+
geometry_path_in = get_geometry_in(fname, inlines)
|
|
205
|
+
|
|
206
|
+
# get OUT.ABACUS/running_scf.log
|
|
207
|
+
path_out = get_path_out(fname, inlines)
|
|
208
|
+
if not (CheckFile(geometry_path_in) and CheckFile(path_out)):
|
|
209
|
+
return data
|
|
210
|
+
with open_file(path_out) as fp:
|
|
211
|
+
outlines = fp.read().split("\n")
|
|
212
|
+
|
|
213
|
+
# get energy
|
|
214
|
+
energy, converge = get_energy(outlines)
|
|
215
|
+
if not converge:
|
|
216
|
+
return data
|
|
217
|
+
|
|
218
|
+
# read STRU file
|
|
219
|
+
data = get_frame_from_stru(geometry_path_in)
|
|
220
|
+
natoms = sum(data["atom_numbs"])
|
|
221
|
+
# should remove spins from STRU file
|
|
222
|
+
if "spins" in data:
|
|
223
|
+
data.pop("spins")
|
|
224
|
+
move = data.pop("move", None)
|
|
225
|
+
|
|
226
|
+
# get magmom and magforce, force and stress
|
|
227
|
+
magmom, magforce = get_mag_force(outlines)
|
|
228
|
+
if len(magmom) > 0:
|
|
229
|
+
magmom = magmom[-1:]
|
|
230
|
+
if len(magforce) > 0:
|
|
231
|
+
magforce = magforce[-1:]
|
|
232
|
+
|
|
233
|
+
force = get_force(outlines, natoms)
|
|
234
|
+
stress = get_stress(outlines)
|
|
235
|
+
|
|
236
|
+
data["energies"] = np.array(energy)[np.newaxis]
|
|
237
|
+
data["forces"] = np.empty((0,)) if force is None else force[np.newaxis, :, :]
|
|
238
|
+
data["orig"] = np.zeros(3)
|
|
239
|
+
if stress is not None:
|
|
240
|
+
cell = data["cells"][0]
|
|
241
|
+
stress *= np.abs(np.linalg.det(cell))
|
|
242
|
+
data["virials"] = stress[np.newaxis, :, :]
|
|
243
|
+
|
|
244
|
+
if len(magmom) > 0:
|
|
245
|
+
data["spins"] = magmom
|
|
246
|
+
if len(magforce) > 0:
|
|
247
|
+
data["force_mags"] = magforce
|
|
248
|
+
if move is not None:
|
|
249
|
+
data["move"] = move
|
|
250
|
+
return data
|