Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4536aa6
merge master to devel (#563)
wanghan-iapcm Oct 31, 2023
94741be
add psi4/inp format (#564)
njzjz Nov 1, 2023
f2d09a5
move to ruff formatter (#565)
njzjz Nov 1, 2023
f608def
exclude docs and tests from sdist (#570)
njzjz Nov 3, 2023
d4b28ba
add error message when Gaussian input orientation is missing (#568)
njzjz Nov 3, 2023
2b8779d
fix psi4 length conversion (#571)
njzjz Nov 6, 2023
e52b699
QE: Support output files without stress (#572)
Yi-FanLi Nov 6, 2023
fb27e05
fix vasp/xml errors when no virial is printed (#574)
njzjz Nov 7, 2023
e948661
fix duplicated elements in vasp/xml (#575)
njzjz Nov 7, 2023
ec08ebb
Add new format for OpenMX (#585)
shigeandtomo Dec 6, 2023
af40337
fix a bug when reading the key block of STRU (#591)
pxlxingliang Dec 25, 2023
f22e66d
print detailed information on outcar reading failure (#596)
wanghan-iapcm Jan 22, 2024
1355f7b
Fix bug when reading file in "pwmat/movement" format (#599)
lhycms Jan 24, 2024
5ad1751
Orca support (#597)
hl2500 Jan 24, 2024
e43f00e
Update the Plugin class docstring (#601)
robinzyb Jan 29, 2024
9a03f77
fix virial in HybridDriver (#604)
njzjz Feb 2, 2024
85e00ff
[pre-commit.ci] pre-commit autoupdate (#573)
pre-commit-ci[bot] Feb 11, 2024
247cfe8
[pre-commit.ci] pre-commit autoupdate (#607)
pre-commit-ci[bot] Feb 15, 2024
81eb4b4
[pre-commit.ci] pre-commit autoupdate (#608)
pre-commit-ci[bot] Feb 21, 2024
46a8952
[pre-commit.ci] pre-commit autoupdate (#613)
pre-commit-ci[bot] Mar 13, 2024
4008687
add ASE's traj support (#614)
thangckt Mar 19, 2024
0b8014f
[pre-commit.ci] pre-commit autoupdate (#617)
pre-commit-ci[bot] Mar 19, 2024
b048b37
Make improvements to the format for OpenMX (#619)
shigeandtomo Mar 20, 2024
b76ade8
test with the latest Python version (3.12) (#618)
njzjz Mar 25, 2024
7223290
CI: Bump codecov/codecov-action from v3 to v4 (#620)
njzjz-bot Mar 25, 2024
2a99ef7
CI: Setup Dependabot for GitHub Actions (#621)
njzjz-bot Mar 25, 2024
09ddfb4
[pre-commit.ci] pre-commit autoupdate (#624)
pre-commit-ci[bot] Mar 25, 2024
1dadd7e
[pre-commit.ci] pre-commit autoupdate (#625)
pre-commit-ci[bot] Apr 2, 2024
8d37fbc
raise error instead of sys.exit (#569)
njzjz Apr 3, 2024
4daf372
remove .DS_Store and add it to gitignore (#629)
njzjz Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "devel"
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +26,9 @@ jobs:
- name: Test
run: cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report
- name: Run codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
pass:
needs: [build]
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ docs/drivers.csv
docs/minimizers.csv
docs/api/
docs/formats/
.DS_Store
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ repos:
- id: check-symlinks
- id: check-toml
# Python
- repo: https://github.com/psf/black
rev: 23.10.1
hooks:
- id: black-jupyter
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.3
rev: v0.3.5
hooks:
- id: ruff
args: ["--fix"]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]
# numpydoc
- repo: https://github.com/Carreau/velin
rev: 0.0.12
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
prune docs
prune tests
prune plugin_example
9 changes: 5 additions & 4 deletions docs/make_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ def generate_sub_format_pages(formats: dict):
buff.append(""" :noindex:""")
buff.append("")
if docstring is None or method not in format.__dict__:
docstring = """ Convert this format to :class:`%s`.""" % (
method_classes[method]
docstring = (
""" Convert this format to :class:`%s`."""
% (method_classes[method])
)
doc_obj = SphinxDocString(docstring)
if len(doc_obj["Parameters"]) > 0:
Expand Down Expand Up @@ -293,8 +294,8 @@ def generate_sub_format_pages(formats: dict):
and "to_system" in format.__dict__
)
):
docstring = "Convert :class:`%s` to this format." % (
method_classes[method]
docstring = (
"Convert :class:`%s` to this format." % (method_classes[method])
)
doc_obj = SphinxDocString(docstring)
if len(doc_obj["Parameters"]) > 0:
Expand Down
39 changes: 36 additions & 3 deletions dpdata/abacus/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
ry2ev = EnergyConversion("rydberg", "eV").value()
kbar2evperang3 = PressureConversion("kbar", "eV/angstrom^3").value()

ABACUS_STRU_KEYS = [
"ATOMIC_SPECIES",
"NUMERICAL_ORBITAL",
"LATTICE_CONSTANT",
"LATTICE_VECTORS",
"ATOMIC_POSITIONS",
"NUMERICAL_DESCRIPTOR",
"PAW_FILES",
]


def CheckFile(ifile):
if not os.path.isfile(ifile):
Expand Down Expand Up @@ -43,6 +53,29 @@ def get_block(lines, keyword, skip=0, nlines=None):
return ret


def get_stru_block(lines, keyword):
# return the block of lines after keyword in STRU file, and skip the blank lines

def clean_comment(line):
return re.split("[#]", line)[0]

ret = []
found = False
for i in range(len(lines)):
if clean_comment(lines[i]).strip() == keyword:
found = True
for j in range(i + 1, len(lines)):
if clean_comment(lines[j]).strip() == "":
continue
elif clean_comment(lines[j]).strip() in ABACUS_STRU_KEYS:
break
else:
ret.append(clean_comment(lines[j]))
if not found:
return None
return ret


def get_geometry_in(fname, inlines):
geometry_path_in = os.path.join(fname, "STRU")
for line in inlines:
Expand All @@ -64,8 +97,8 @@ def get_path_out(fname, inlines):


def get_cell(geometry_inlines):
cell_lines = get_block(geometry_inlines, "LATTICE_VECTORS", skip=0, nlines=3)
celldm_lines = get_block(geometry_inlines, "LATTICE_CONSTANT", skip=0, nlines=1)
cell_lines = get_stru_block(geometry_inlines, "LATTICE_VECTORS")
celldm_lines = get_stru_block(geometry_inlines, "LATTICE_CONSTANT")

celldm = float(celldm_lines[0].split()[0]) * bohr2ang # lattice const is in Bohr
cell = []
Expand All @@ -76,7 +109,7 @@ def get_cell(geometry_inlines):


def get_coords(celldm, cell, geometry_inlines, inlines=None):
coords_lines = get_block(geometry_inlines, "ATOMIC_POSITIONS", skip=0)
coords_lines = get_stru_block(geometry_inlines, "ATOMIC_POSITIONS")
# assuming that ATOMIC_POSITIONS is at the bottom of the STRU file
coord_type = coords_lines[0].split()[0].lower() # cartisan or direct
atom_names = [] # element abbr in periodic table
Expand Down
1 change: 1 addition & 0 deletions dpdata/amber/mask.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Amber mask."""

try:
import parmed
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions dpdata/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command line interface for dpdata."""

import argparse
from typing import Optional

Expand Down
4 changes: 1 addition & 3 deletions dpdata/cp2k/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ def get_xyz_block_generator(self):
lines.append(self.xyz_file_object.readline())
if not lines[-1]:
raise RuntimeError(
"this xyz file may lack of lines, should be {};lines:{}".format(
atom_num + 2, lines
)
f"this xyz file may lack of lines, should be {atom_num + 2};lines:{lines}"
)
yield lines

Expand Down
1 change: 1 addition & 0 deletions dpdata/deepmd/hdf5.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils for deepmd/hdf5 format."""

from __future__ import annotations

import warnings
Expand Down
3 changes: 3 additions & 0 deletions dpdata/driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Driver plugin system."""

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Callable, List, Union

Expand Down Expand Up @@ -163,6 +164,8 @@ def label(self, data: dict) -> dict:
else:
labeled_data["energies"] += lb_data["energies"]
labeled_data["forces"] += lb_data["forces"]
if "virials" in labeled_data and "virials" in lb_data:
labeled_data["virials"] += lb_data["virials"]
return labeled_data


Expand Down
1 change: 1 addition & 0 deletions dpdata/format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implement the format plugin system."""

import os
from abc import ABC

Expand Down
27 changes: 27 additions & 0 deletions dpdata/gaussian/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@


def to_system_data(file_name, md=False):
"""Read Gaussian log file.

Parameters
----------
file_name : str
file name
md : bool, default False
whether to read multiple frames

Returns
-------
data : dict
system data

Raises
------
RuntimeError
if the input orientation is not found
"""
data = {}
# read from log lines
flag = 0
Expand All @@ -20,6 +39,7 @@ def to_system_data(file_name, md=False):
forces_t = []
cells_t = []
nopbc = True
coords = None

with open(file_name) as fp:
for line in fp:
Expand All @@ -44,6 +64,12 @@ def to_system_data(file_name, md=False):
elif flag == 4:
# forces
if line.startswith(" -------"):
if coords is None:
raise RuntimeError(
"Input orientation is not found. Using Gaussian keyword "
"`Geom=PrintInputOrient` to always print the input orientation. "
"See https://gaussian.com/geom/ for more details."
)
forces_t.append(forces)
energy_t.append(energy)
coords_t.append(coords)
Expand All @@ -55,6 +81,7 @@ def to_system_data(file_name, md=False):
[[100.0, 0.0, 0.0], [0.0, 100.0, 0.0], [0.0, 0.0, 100.0]]
)
flag = 0
coords = None
else:
s = line.split()
if line[14:16] == "-2":
Expand Down
4 changes: 2 additions & 2 deletions dpdata/lammps/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def safe_get_posi(lines, cell, orig=np.zeros(3), unwrap=False):
category=UnwrapWarning,
)
return (
posis % 1
) @ cell # Convert scaled coordinates back to Cartesien coordinates with wraping at periodic boundary conditions
(posis % 1) @ cell
) # Convert scaled coordinates back to Cartesien coordinates with wraping at periodic boundary conditions


def get_dumpbox(lines):
Expand Down
Empty file added dpdata/openmx/__init__.py
Empty file.
Loading