Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.10
hooks:
# Run the linter.
- id: ruff
args: [--config, python/pyproject.toml, --fix]
# Run the formatter.
- id: ruff-format
args: [--config, python/pyproject.toml]
- repo: https://github.com/PlasmaFAIR/fortitude-pre-commit
rev: v0.9.0
hooks:
Expand Down
8 changes: 4 additions & 4 deletions doc/guide/minimal-example/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
num = np.array([6, 1, 1, 1, 1])
xyz = np.array( # coordinates in Bohr
[
[ 0.0000000, -0.0000000, 0.0000000],
[-1.1922080, 1.1922080, 1.1922080],
[ 1.1922080, -1.1922080, 1.1922080],
[0.0000000, -0.0000000, 0.0000000],
[-1.1922080, 1.1922080, 1.1922080],
[1.1922080, -1.1922080, 1.1922080],
[-1.1922080, -1.1922080, -1.1922080],
[ 1.1922080, 1.1922080, -1.1922080],
[1.1922080, 1.1922080, -1.1922080],
]
)
method = "PBE0"
Expand Down
2 changes: 1 addition & 1 deletion python/dftd3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"""Python API for the DFT-D3 dispersion model"""

# make sure we have a CFFI available
import cffi
import cffi # noqa

__version__ = "1.4.0"
27 changes: 13 additions & 14 deletions python/dftd3/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,21 @@
[-0. , 0.00004060, -0.00004786]])
"""

try:
import ase
except ModuleNotFoundError:
raise ModuleNotFoundError("This submodule requires ASE installed")

from typing import List, Optional

try:
from ase.calculators.calculator import (
Calculator,
InputError,
CalculationFailed,
all_changes,
)
from ase.calculators.mixing import SumCalculator
from ase.atoms import Atoms
from ase.units import Hartree, Bohr
except ModuleNotFoundError as e:
raise ModuleNotFoundError("This submodule requires ASE installed") from e

from .interface import (
DispersionModel,
DampingParam,
Expand All @@ -117,15 +125,6 @@
CSODampingParam,
ZDampingParam,
)
from ase.calculators.calculator import (
Calculator,
InputError,
CalculationFailed,
all_changes,
)
from ase.calculators.mixing import SumCalculator
from ase.atoms import Atoms
from ase.units import Hartree, Bohr


_damping_param = {
Expand Down
4 changes: 3 additions & 1 deletion python/dftd3/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ def new_z_damping(

def load_z_damping(method: str, atm: bool) -> ParamHandle:
"""Load Z damping parameters from internal storage"""
return ParamHandle.with_gc(error_check(lib.dftd3_load_z_damping)(_char(method), atm))
return ParamHandle.with_gc(
error_check(lib.dftd3_load_z_damping)(_char(method), atm)
)


def update_structure(
Expand Down
6 changes: 2 additions & 4 deletions python/dftd3/qcschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ def run_qcschema(input_data):

if schema_version == 1:
return qcel_v1.AtomicResult(**ret_data)

if "error" in ret_data:
return qcel_v2.FailedOperation(
input_data=atomic_input, error=ret_data["error"]
)
return qcel_v2.FailedOperation(input_data=atomic_input, error=ret_data["error"])
return qcel_v2.AtomicResult(**ret_data)
4 changes: 3 additions & 1 deletion python/dftd3/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ def test_b97d_d3_op(atm: bool, model: DispersionModel) -> None:

def test_pbe_d3_z(atm: bool, model: DispersionModel) -> None:
ref = -0.005741490224533363 if atm else -0.005841389688523762
res = model.get_dispersion(ZDampingParam(a1=200770.0, s9=1.0 if atm else 0.0), grad=False)
res = model.get_dispersion(
ZDampingParam(a1=200770.0, s9=1.0 if atm else 0.0), grad=False
)
assert approx(res.get("energy")) == ref


Expand Down
Loading
Loading