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: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ endif()
if(ENABLE_PEXSI)
find_package(PEXSI REQUIRED CONFIG)
if(PEXSI_VERSION VERSION_LESS "2.0.0")
message(FATAL_ERROR "PEXSI >= 2.0.0 is required")
message(FATAL_ERROR "PEXSI >= 2.0.0 is required; found version ${PEXSI_VERSION}")
endif()
set(CMAKE_CXX_STANDARD 14)
endif()
Expand Down Expand Up @@ -369,7 +369,10 @@ if(NOT USE_KML AND NOT MKL_FOUND AND NOT USE_SW)
endif()

if(ENABLE_DFTD4)
find_package(dftd4 4.2.0 REQUIRED)
find_package(dftd4 REQUIRED)
if(dftd4_VERSION VERSION_LESS "4.3.0")
message(FATAL_ERROR "dftd4 >= 4.3.0 is required; found version ${dftd4_VERSION}")
endif()
endif()

include(CheckLanguage)
Expand Down Expand Up @@ -610,7 +613,7 @@ endif()
if(ENABLE_LIBXC)
find_package(Libxc CONFIG REQUIRED)
if(Libxc_VERSION VERSION_LESS "5.1.7")
message(FATAL_ERROR "Libxc >= 5.1.7 is required")
message(FATAL_ERROR "Libxc >= 5.1.7 is required; found version ${Libxc_VERSION}")
endif()
endif()

Expand Down
10 changes: 8 additions & 2 deletions source/source_hamilt/module_vdw/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ AddTest(
SOURCES vdw_test.cpp vdwd3_evaluator_test.cpp
)

if(ENABLE_DFTD4)
target_link_libraries(MODULE_HAMILT_vdwTest PRIVATE dftd4::dftd4)
if(ENABLE_DFTD4 AND ENABLE_MPI)
add_test(
NAME MODULE_HAMILT_vdwd4Test_2np
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2
${MPIEXEC_PREFLAGS} $<TARGET_FILE:MODULE_HAMILT_vdwTest>
--gtest_filter=vdwd4Test.* ${MPIEXEC_POSTFLAGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
25 changes: 25 additions & 0 deletions source/source_hamilt/module_vdw/vdwd4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "source_base/constants.h"
#include "source_base/element_name.h"
#ifdef __MPI
#include "source_base/parallel_reduce.h"
#include <mpi.h>
#endif
#include "source_base/timer.h"
#include "source_base/tool_quit.h"

Expand Down Expand Up @@ -231,6 +235,15 @@ void Vdwd4::compute(double& energy_ha,
smooth_width_3b_);
check_dftd4_error(error, "dftd4_set_model_realspace_cutoff_smooth");

#ifdef __MPI
int rank = 0;
int nranks = 1;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nranks);
dftd4_set_model_work_partition(error, model, rank, nranks);
Comment thread
mohanchen marked this conversation as resolved.
check_dftd4_error(error, "dftd4_set_model_work_partition");
#endif

std::vector<char> method(xc_name_.begin(), xc_name_.end());
method.push_back('\0');

Expand All @@ -247,6 +260,18 @@ void Vdwd4::compute(double& energy_ha,
dftd4_get_dispersion(error, mol, model, param, &energy_ha, gradient, sigma);
check_dftd4_error(error, "dftd4_get_dispersion");

#ifdef __MPI
Parallel_Reduce::reduce_all(energy_ha);
if (gradient != nullptr)
{
Parallel_Reduce::reduce_all(gradient, 3 * ucell_.nat);
}
if (sigma != nullptr)
{
Parallel_Reduce::reduce_all(sigma, 9);
}
#endif

dftd4_delete_param(&param);
dftd4_delete_model(&model);
dftd4_delete_structure(&mol);
Expand Down
4 changes: 2 additions & 2 deletions toolchain/scripts/package_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ scalapack_alt_sha256="a2f0c9180a210bf7ffe126c9cb81099cf337da1a7120ddb4cbe4894eb7
# =============================================================================

# DFT-D4 dispersion correction
dftd4_ver="4.2.0"
dftd4_sha256="467e024071510ad82b862c66c383c2ebc164fc1140e15dfc79f48d2f999fd184"
dftd4_ver="4.3.0"
dftd4_sha256="e94c5d021c0a4b4aa9b5587e36fda2f398271dc2dc1abfbe097fdb04022bef35"

# LibTorch (supports dual versions) - main=2.1.2, alt=1.12.1
libtorch_main_ver="2.1.2"
Expand Down
Loading