From c7a0062c1d72661c7e3b6a28378eaf9caf67cbd9 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Mon, 4 May 2026 12:23:58 +0200 Subject: [PATCH 1/2] Fix gradient for ATM contribution (#359) --- src/dftd4/damping/atm.f90 | 9 ++++++--- test/unit/test_periodic.f90 | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/dftd4/damping/atm.f90 b/src/dftd4/damping/atm.f90 index 1b2fc6c53..2ea6307d3 100644 --- a/src/dftd4/damping/atm.f90 +++ b/src/dftd4/damping/atm.f90 @@ -367,9 +367,12 @@ subroutine get_atm_dispersion_derivs(mol, trans, cutoff, s9, a1, a2, alp, r4r2, energy_local(jat) = energy_local(jat) - dE_third energy_local(kat) = energy_local(kat) - dE_third - gradient_local(:, iat) = gradient_local(:, iat) - dGij - dGik - gradient_local(:, jat) = gradient_local(:, jat) + dGij - dGjk - gradient_local(:, kat) = gradient_local(:, kat) + dGik + dGjk + gradient_local(:, iat) = gradient_local(:, iat) & + & - (dGij + dGik) * triple + gradient_local(:, jat) = gradient_local(:, jat) & + & + (dGij - dGjk) * triple + gradient_local(:, kat) = gradient_local(:, kat) & + & + (dGik + dGjk) * triple dS(:, :) = spread(dGij, 1, 3) * spread(vij, 2, 3)& & + spread(dGik, 1, 3) * spread(vik, 2, 3)& diff --git a/test/unit/test_periodic.f90 b/test/unit/test_periodic.f90 index 8df7d3370..8a7023b93 100644 --- a/test/unit/test_periodic.f90 +++ b/test/unit/test_periodic.f90 @@ -48,7 +48,9 @@ subroutine collect_periodic(testsuite) & new_unittest("BLYP-D4", test_blypd4_adaman), & & new_unittest("BLYP-D4S", test_blypd4s_adaman), & & new_unittest("TPSS-D4", test_tpssd4_ammonia), & + & new_unittest("TPSS-D4+ATM", test_tpssd4atm_ammonia), & & new_unittest("TPSS-D4S", test_tpssd4s_ammonia), & + & new_unittest("TPSS-D4S+ATM", test_tpssd4satm_ammonia), & & new_unittest("SCAN-D4", test_scand4_anthracene), & & new_unittest("SCAN-D4S", test_scand4s_anthracene) & & ] @@ -285,6 +287,41 @@ subroutine test_tpssd4s_ammonia(error) end subroutine test_tpssd4s_ammonia +subroutine test_tpssd4atm_ammonia(error) + + !> Error handling + type(error_type), allocatable, intent(out) :: error + + type(structure_type) :: mol + type(d4_model) :: d4 + type(rational_damping_param) :: param = rational_damping_param(& + & s6 = 1.0_wp, s9 = 1.0_wp, alp = 16.0_wp, & + & s8 = 1.76596355_wp, a1 = 0.42822303_wp, a2 = 4.54257102_wp ) + + call get_structure(mol, "X23", "ammonia") + call new_d4_model(error, d4, mol) + call test_numgrad(error, mol, d4, param) + +end subroutine test_tpssd4atm_ammonia + +subroutine test_tpssd4satm_ammonia(error) + + !> Error handling + type(error_type), allocatable, intent(out) :: error + + type(structure_type) :: mol + type(d4s_model) :: d4s + type(rational_damping_param) :: param = rational_damping_param(& + & s6 = 1.0_wp, s9 = 1.0_wp, alp = 16.0_wp, & + & s8 = 1.76596355_wp, a1 = 0.42822303_wp, a2 = 4.54257102_wp ) + + call get_structure(mol, "X23", "ammonia") + call new_d4s_model(error, d4s, mol) + call test_numgrad(error, mol, d4s, param) + +end subroutine test_tpssd4satm_ammonia + + subroutine test_scand4_anthracene(error) !> Error handling From 6b80189ae840151dc021f8196236ff719641899f Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Mon, 4 May 2026 16:47:13 +0200 Subject: [PATCH 2/2] Update to version 4.1.1 (#360) --- .github/workflows/fortran-build.yml | 4 ++-- CMakeLists.txt | 2 +- README.md | 6 +++--- doc/recipe/vasp.rst | 6 +++--- fpm.toml | 2 +- meson.build | 2 +- python/README.rst | 2 +- python/dftd4/__init__.py | 2 +- python/dftd4/library.py | 2 +- python/ffibuilder.py | 4 ++-- python/meson.build | 2 +- python/pyproject.toml | 3 ++- src/dftd4/version.f90 | 4 ++-- 13 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/fortran-build.yml b/.github/workflows/fortran-build.yml index 2a1b5f5b5..33de03827 100644 --- a/.github/workflows/fortran-build.yml +++ b/.github/workflows/fortran-build.yml @@ -299,7 +299,7 @@ jobs: --no-rebuild --num-processes 1 --suite dftd4 - -t 2 + -t 10 env: OMP_NUM_THREADS: 1,2,1 BUILD_DIR: ${{ env.BUILD_DIR }} @@ -313,7 +313,7 @@ jobs: --no-rebuild --num-processes 1 --suite dftd4 - -t 2 + -t 10 --benchmark env: BUILD_DIR: ${{ env.BUILD_DIR }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ca732915..e5edb13cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ cmake_minimum_required(VERSION 3.14) project( "dftd4" LANGUAGES "Fortran" - VERSION "4.1.0" + VERSION "4.1.1" DESCRIPTION "Generally Applicable Atomic-Charge Dependent London Dispersion Correction" ) diff --git a/README.md b/README.md index c8c524556..6c3ca7639 100644 --- a/README.md +++ b/README.md @@ -338,13 +338,13 @@ pkg-config --modversion dftd4 If your ``dftd4`` installation is not findable, you have to update your environment variables. One option is to provide a module file for your ``dftd4`` installation. -The example module file below can be placed in your ``MODULEPATH`` to provide access to an installation in ``~/opt/dftd4/4.1.0``. +The example module file below can be placed in your ``MODULEPATH`` to provide access to an installation in ``~/opt/dftd4/4.1.1``. Retry the above comment after loading the ``dftd4`` module and adjust the module file until ``pkg-config`` finds your installation. ```lua --- dftd4/4.1.0.lua +-- dftd4/4.1.1.lua local name = "dftd4" -local version = "4.1.0" +local version = "4.1.1" local prefix = pathJoin(os.getenv("HOME"), "opt", name, version) local libdir = "lib" -- or lib64 diff --git a/doc/recipe/vasp.rst b/doc/recipe/vasp.rst index d236c8a84..0bb91d728 100644 --- a/doc/recipe/vasp.rst +++ b/doc/recipe/vasp.rst @@ -18,14 +18,14 @@ After you completed the installation of ``dftd4``, make sure it is findable by ` If your ``dftd4`` installation is not findable, you have to update your environment variables. One option is to provide a module file for your ``dftd4`` installation. -The example module file below can be placed in your ``MODULEPATH`` to provide access to an installation in ``~/opt/dftd4/4.1.0``. +The example module file below can be placed in your ``MODULEPATH`` to provide access to an installation in ``~/opt/dftd4/4.1.1``. Retry the above comment after loading the ``dftd4`` module and adjust the module file until ``pkg-config`` finds your installation. .. code-block:: lua - -- dftd4/4.1.0.lua + -- dftd4/4.1.1.lua local name = "dftd4" - local version = "4.1.0" + local version = "4.1.1" local prefix = pathJoin(os.getenv("HOME"), "opt", name, version) local libdir = "lib" -- or lib64 diff --git a/fpm.toml b/fpm.toml index 079facfe2..c0b9cf813 100644 --- a/fpm.toml +++ b/fpm.toml @@ -1,5 +1,5 @@ name = "dftd4" -version = "4.1.0" +version = "4.1.1" license = "LGPL-3.0-or-later" maintainer = ["@awvwgk"] author = ["Eike Caldeweyher", "Sebastian Ehlert", "Stefan Grimme"] diff --git a/meson.build b/meson.build index b9a766b5c..4fc1b2102 100644 --- a/meson.build +++ b/meson.build @@ -17,7 +17,7 @@ project( 'dftd4', 'fortran', - version: '4.1.0', + version: '4.1.1', license: 'LGPL-3.0-or-later', meson_version: '>=0.55,!=1.8.0', default_options: [ diff --git a/python/README.rst b/python/README.rst index 53b306788..17710fba1 100644 --- a/python/README.rst +++ b/python/README.rst @@ -239,7 +239,7 @@ Now you are ready to use ``dftd4``, check if you can import it with >>> import dftd4 >>> from dftd4.libdftd4 import get_api_version >>> get_api_version() - '4.1.0' + '4.1.1' Building the extension module diff --git a/python/dftd4/__init__.py b/python/dftd4/__init__.py index f27d39c84..0e964a0ba 100644 --- a/python/dftd4/__init__.py +++ b/python/dftd4/__init__.py @@ -18,4 +18,4 @@ # make sure we have a CFFI available import cffi -__version__ = "4.1.0" +__version__ = "4.1.1" diff --git a/python/dftd4/library.py b/python/dftd4/library.py index 7f66c1368..46240bfd1 100644 --- a/python/dftd4/library.py +++ b/python/dftd4/library.py @@ -25,7 +25,7 @@ ------- >>> from dftd4.library import get_api_version >>> get_api_version() -'4.1.0' +'4.1.1' """ import functools diff --git a/python/ffibuilder.py b/python/ffibuilder.py index 0ba6eaad2..d33980796 100644 --- a/python/ffibuilder.py +++ b/python/ffibuilder.py @@ -59,9 +59,9 @@ raise ModuleNotFoundError( "Unable to find pkg-config package 'dftd4'" ) - if pkgconfig.installed(library, "< 3.0"): + if pkgconfig.installed(library, "< 4.0"): raise RuntimeError( - "Installed 'dftd4' version is too old, 3.0 or newer is required" + "Installed 'dftd4' version is too old, 4.0 or newer is required" ) kwargs = pkgconfig.parse(library) diff --git a/python/meson.build b/python/meson.build index 7f75a63da..17eaa1965 100644 --- a/python/meson.build +++ b/python/meson.build @@ -19,7 +19,7 @@ project( 'dftd4', 'c', - version: '4.1.0', + version: '4.1.1', license: 'LGPL-3.0-or-later', meson_version: '>=0.55,!=1.8.0', default_options: [ diff --git a/python/pyproject.toml b/python/pyproject.toml index b13874dc8..c7aee74b6 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "mesonpy" [project] name = "dftd4" -version = "4.1.0" +version = "4.1.1" description = "Python API of the DFT-D4 project" readme = "README.rst" license.text = "LGPL-3.0-or-later" @@ -25,6 +25,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Scientific/Engineering :: Chemistry", "Topic :: Scientific/Engineering :: Physics", ] diff --git a/src/dftd4/version.f90 b/src/dftd4/version.f90 index 3fd9e96a6..38389e946 100644 --- a/src/dftd4/version.f90 +++ b/src/dftd4/version.f90 @@ -24,10 +24,10 @@ module dftd4_version !> String representation of the dftd4 version - character(len=*), parameter :: dftd4_version_string = "4.1.0" + character(len=*), parameter :: dftd4_version_string = "4.1.1" !> Numeric representation of the dftd4 version - integer, parameter :: dftd4_version_compact(3) = [4, 1, 0] + integer, parameter :: dftd4_version_compact(3) = [4, 1, 1] contains