From 75aee351f69f9f26f12aea47d56df00d23ac0967 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Wed, 30 Jan 2019 20:08:08 +0100 Subject: [PATCH 01/13] add m4 file for libvdwxc --- m4/libvdwxc.m4 | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 m4/libvdwxc.m4 diff --git a/m4/libvdwxc.m4 b/m4/libvdwxc.m4 new file mode 100644 index 0000000000..6e7de7b9b7 --- /dev/null +++ b/m4/libvdwxc.m4 @@ -0,0 +1,63 @@ +AC_DEFUN([ACX_LIBVDWXC], +[ + + acx_libvdwxc_ok=no + + dnl BACKUP LIBS AND FCFLAGS + acx_libvdwxc_save_LIBS="$LIBS" + acx_libvdwxc_save_FCFLAGS="$FCFLAGS" + + dnl Check if the library was given in the command line + AC_ARG_WITH(libvdwxc-prefix, [AS_HELP_STRING([--with-libvdwxc-prefix=DIR], [Directory where libvdwxc is installed.])]) + + if test x"$FCFLAGS_LIBVDWXC" = x; then + case $with_libvdwxc_prefix in + "") FCFLAGS_LIBVDWXC="-I/usr/include" ;; + *) FCFLAGS_LIBVDWXC="-I$with_libvdwxc_prefix/include" ;; + esac + fi + + + AC_MSG_CHECKING([for libvdwxc]) + + libvdwxc_program="AC_LANG_PROGRAM([],[ + implicit none + + include 'vdwxcfort.f90' + + integer, pointer :: vdw + call vdwxc_new(1, vdw) + call vdwxc_print(vdw) + call vdwxc_finalize(vdw) + + ])" + + FCFLAGS="$FCFLAGS_LIBVDWXC $acx_libvdwxc_save_FCFLAGS" + + if test ! -z "$with_libvdwxc_prefix"; then + LIBS_LIBVDWXC="-L$with_libvdwxc_prefix/lib" + else + LIBS_LIBVDWXC="" + fi + + dnl We do not append -lvdwxc at the end, as we might need to prefix other libraries + + LIBS="$LIBS_LIBVDWXC -lvdwxcfort $acx_libvdwxc_save_LIBS" + AC_LINK_IFELSE($libvdwxc_program, [acx_libvdwxc_ok=yes], [acx_libvdwxc_ok=no]) + + AC_MSG_RESULT([$acx_libvdwxc_ok ($FCFLAGS_LIBVDWXC $LIBS_LIBVDWXC -lvdwxcfort)]) + + if test x"$acx_libvdwxc_ok" = xyes; then + AC_DEFINE(HAVE_LIBVDWXC, 1, [Define if LIBVDWXC is available]) + else + AC_MSG_WARN([Could not find libvdwxc library. + *** Will compile without libvdwxc support]) + fi + + LIBS_LIBVDWXC="$LIBS_LIBVDWXC -lvdwxcfort" + + AC_SUBST(LIBS_LIBVDWXC) + + FCFLAGS="$acx_libvdwxc_save_FCFLAGS" + LIBS="$acx_libvdwxc_save_LIBS" +]) -- GitLab From b45a5f1e353c14062cb15342d96dea24b22db997 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Wed, 30 Jan 2019 20:08:26 +0100 Subject: [PATCH 02/13] include libvdwxc in configure --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index da52c58a9d..4221d9202c 100644 --- a/configure.ac +++ b/configure.ac @@ -268,6 +268,7 @@ dnl =================================================================== dnl now we search for libraries ACX_LIBXC +ACX_LIBVDWXC dnl check for BLAS ACX_BLAS([], AC_MSG_ERROR([could not find required BLAS library])) -- GitLab From 84b35f16929b55c015cd2c91e64a0723b07e529b Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Wed, 30 Jan 2019 20:32:20 +0100 Subject: [PATCH 03/13] not sure when and if we need to link libvdwxc last (like the fftw3 m4 file). We omit this for now. Also, be sure to set FCFLAGS --- m4/libvdwxc.m4 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/m4/libvdwxc.m4 b/m4/libvdwxc.m4 index 6e7de7b9b7..bfcdd49a84 100644 --- a/m4/libvdwxc.m4 +++ b/m4/libvdwxc.m4 @@ -35,14 +35,12 @@ AC_DEFUN([ACX_LIBVDWXC], FCFLAGS="$FCFLAGS_LIBVDWXC $acx_libvdwxc_save_FCFLAGS" if test ! -z "$with_libvdwxc_prefix"; then - LIBS_LIBVDWXC="-L$with_libvdwxc_prefix/lib" + LIBS_LIBVDWXC="-L$with_libvdwxc_prefix/lib -lvdwxcfort" else - LIBS_LIBVDWXC="" + LIBS_LIBVDWXC="-lvdwxcfort" fi - dnl We do not append -lvdwxc at the end, as we might need to prefix other libraries - - LIBS="$LIBS_LIBVDWXC -lvdwxcfort $acx_libvdwxc_save_LIBS" + LIBS="$LIBS_LIBVDWXC $acx_libvdwxc_save_LIBS" AC_LINK_IFELSE($libvdwxc_program, [acx_libvdwxc_ok=yes], [acx_libvdwxc_ok=no]) AC_MSG_RESULT([$acx_libvdwxc_ok ($FCFLAGS_LIBVDWXC $LIBS_LIBVDWXC -lvdwxcfort)]) @@ -54,8 +52,7 @@ AC_DEFUN([ACX_LIBVDWXC], *** Will compile without libvdwxc support]) fi - LIBS_LIBVDWXC="$LIBS_LIBVDWXC -lvdwxcfort" - + AC_SUBST(FCFLAGS_LIBVDWXC) AC_SUBST(LIBS_LIBVDWXC) FCFLAGS="$acx_libvdwxc_save_FCFLAGS" -- GitLab From 5b802a4a8812280b02de4717b0c369f1168db675 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Wed, 30 Jan 2019 20:56:58 +0100 Subject: [PATCH 04/13] accidentally printed -lvdwxcfort twice --- m4/libvdwxc.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/libvdwxc.m4 b/m4/libvdwxc.m4 index bfcdd49a84..6648e7f56c 100644 --- a/m4/libvdwxc.m4 +++ b/m4/libvdwxc.m4 @@ -43,7 +43,7 @@ AC_DEFUN([ACX_LIBVDWXC], LIBS="$LIBS_LIBVDWXC $acx_libvdwxc_save_LIBS" AC_LINK_IFELSE($libvdwxc_program, [acx_libvdwxc_ok=yes], [acx_libvdwxc_ok=no]) - AC_MSG_RESULT([$acx_libvdwxc_ok ($FCFLAGS_LIBVDWXC $LIBS_LIBVDWXC -lvdwxcfort)]) + AC_MSG_RESULT([$acx_libvdwxc_ok ($FCFLAGS_LIBVDWXC $LIBS_LIBVDWXC)]) if test x"$acx_libvdwxc_ok" = xyes; then AC_DEFINE(HAVE_LIBVDWXC, 1, [Define if LIBVDWXC is available]) -- GitLab From 42345627ee1d681714b7efc7f745a11c99d48823 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Thu, 31 Jan 2019 15:15:18 +0100 Subject: [PATCH 05/13] include libvdwxc in common-rules.make --- src/common-rules.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common-rules.make b/src/common-rules.make index d9ee34199e..a6bd571ed4 100644 --- a/src/common-rules.make +++ b/src/common-rules.make @@ -50,7 +50,7 @@ scalapack_LIBS = @LIBS_ELPA@ @LIBS_SCALAPACK@ @LIBS_BLACS@ core_LIBS = \ @LIBS_FFTW@ @LIBS_LAPACK@ @LIBS_BLAS@ \ $(top_builddir)/liboct_parser/liboct_parser.a \ - @GSL_LIBS@ @LIBS_LIBXC@ @FCEXTRALIBS@ + @GSL_LIBS@ @LIBS_LIBXC@ @LIBS_LIBVDWXC@ @FCEXTRALIBS@ external_LIBS = \ $(top_builddir)/external_libs/qshep/libqshep.a \ @@ -60,7 +60,7 @@ external_LIBS = \ $(top_builddir)/external_libs/yaml-0.1.4/src/libyaml.a # we should not have libyaml here if we used an external one... -FCFLAGS_MODS += @FCFLAGS_LIBXC@ @FCFLAGS_PSPIO@ @FCFLAGS_ISF@ @FCFLAGS_FFTW@ @FCFLAGS_PFFT@ @FCFLAGS_PNFFT@ @FCFLAGS_NETCDF@ @FCFLAGS_ETSF_IO@ @FCFLAGS_BERKELEYGW@ @FCFLAGS_NLOPT@ @FCFLAGS_LIBFM@ @FCFLAGS_ELPA@ @FCFLAGS_POKE@ @FCFLAGS_LIKWID@ +FCFLAGS_MODS += @FCFLAGS_LIBXC@ @FCFLAGS_LIBVDWXC@ @FCFLAGS_PSPIO@ @FCFLAGS_ISF@ @FCFLAGS_FFTW@ @FCFLAGS_PFFT@ @FCFLAGS_PNFFT@ @FCFLAGS_NETCDF@ @FCFLAGS_ETSF_IO@ @FCFLAGS_BERKELEYGW@ @FCFLAGS_NLOPT@ @FCFLAGS_LIBFM@ @FCFLAGS_ELPA@ @FCFLAGS_POKE@ @FCFLAGS_LIKWID@ if COMPILE_OPENCL external_LIBS += $(top_builddir)/external_libs/fortrancl/libfortrancl.a @LIBS_CLBLAS@ @LIBS_CLFFT@ @CL_LIBS@ -- GitLab From 22ccba4457214b6c4563922b645fdb569882d643 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Mon, 25 Feb 2019 20:44:06 +0100 Subject: [PATCH 06/13] do not set LIBS/FCFLAGS for libvdwxc when things were not found. Include LIBS_LIBVDWXC in common-rules under outside rather than core libs --- m4/libvdwxc.m4 | 2 ++ src/common-rules.make | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/m4/libvdwxc.m4 b/m4/libvdwxc.m4 index 6648e7f56c..185a774f82 100644 --- a/m4/libvdwxc.m4 +++ b/m4/libvdwxc.m4 @@ -48,6 +48,8 @@ AC_DEFUN([ACX_LIBVDWXC], if test x"$acx_libvdwxc_ok" = xyes; then AC_DEFINE(HAVE_LIBVDWXC, 1, [Define if LIBVDWXC is available]) else + LIBS_LIBVDWXC="" + FCFLAGS_LIBVDWXC="" AC_MSG_WARN([Could not find libvdwxc library. *** Will compile without libvdwxc support]) fi diff --git a/src/common-rules.make b/src/common-rules.make index a6bd571ed4..e53386c936 100644 --- a/src/common-rules.make +++ b/src/common-rules.make @@ -50,7 +50,7 @@ scalapack_LIBS = @LIBS_ELPA@ @LIBS_SCALAPACK@ @LIBS_BLACS@ core_LIBS = \ @LIBS_FFTW@ @LIBS_LAPACK@ @LIBS_BLAS@ \ $(top_builddir)/liboct_parser/liboct_parser.a \ - @GSL_LIBS@ @LIBS_LIBXC@ @LIBS_LIBVDWXC@ @FCEXTRALIBS@ + @GSL_LIBS@ @LIBS_LIBXC@ @FCEXTRALIBS@ external_LIBS = \ $(top_builddir)/external_libs/qshep/libqshep.a \ @@ -60,7 +60,7 @@ external_LIBS = \ $(top_builddir)/external_libs/yaml-0.1.4/src/libyaml.a # we should not have libyaml here if we used an external one... -FCFLAGS_MODS += @FCFLAGS_LIBXC@ @FCFLAGS_LIBVDWXC@ @FCFLAGS_PSPIO@ @FCFLAGS_ISF@ @FCFLAGS_FFTW@ @FCFLAGS_PFFT@ @FCFLAGS_PNFFT@ @FCFLAGS_NETCDF@ @FCFLAGS_ETSF_IO@ @FCFLAGS_BERKELEYGW@ @FCFLAGS_NLOPT@ @FCFLAGS_LIBFM@ @FCFLAGS_ELPA@ @FCFLAGS_POKE@ @FCFLAGS_LIKWID@ +FCFLAGS_MODS += @FCFLAGS_LIBXC@ @FCFLAGS_PSPIO@ @FCFLAGS_ISF@ @FCFLAGS_FFTW@ @FCFLAGS_PFFT@ @FCFLAGS_PNFFT@ @FCFLAGS_NETCDF@ @FCFLAGS_ETSF_IO@ @FCFLAGS_LIBVDWXC@ @FCFLAGS_BERKELEYGW@ @FCFLAGS_NLOPT@ @FCFLAGS_LIBFM@ @FCFLAGS_ELPA@ @FCFLAGS_POKE@ @FCFLAGS_LIKWID@ if COMPILE_OPENCL external_LIBS += $(top_builddir)/external_libs/fortrancl/libfortrancl.a @LIBS_CLBLAS@ @LIBS_CLFFT@ @CL_LIBS@ @@ -77,7 +77,7 @@ endif # e.g. ETSF_IO depends on netCDF, ISF depends on LAPACK outside_LIBS = @LIBS_PSPIO@ @LIBS_POKE@ @LIBS_ISF@ @LIBS_NFFT@ @LIBS_PNFFT@ @LIBS_PFFT@ \ @LIBS_SPARSKIT@ @LIBS_ETSF_IO@ @LIBS_NETCDF@ @LIBS_LIBFM@ \ - @LIBS_BERKELEYGW@ @LIBS_NLOPT@ @GD_LIBS@ \ + @LIBS_LIBVDWXC@ @LIBS_BERKELEYGW@ @LIBS_NLOPT@ @GD_LIBS@ \ @LIBS_PARMETIS@ @LIBS_METIS@ @LIBS_LIKWID@ @LIBS_CUDA@ @LIBS_MPI@ other_LIBS = $(external_LIBS) $(scalapack_LIBS) $(outside_LIBS) $(core_LIBS) @CXXLIBS@ -- GitLab From c3d71fc6e1f9cba4a27ff4e5d3e61cdf78f12224 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Tue, 26 Feb 2019 19:40:29 +0100 Subject: [PATCH 07/13] check for both serial and MPI-enabled libvdwxc when installing. --- m4/libvdwxc.m4 | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/m4/libvdwxc.m4 b/m4/libvdwxc.m4 index 185a774f82..38959aded8 100644 --- a/m4/libvdwxc.m4 +++ b/m4/libvdwxc.m4 @@ -2,6 +2,7 @@ AC_DEFUN([ACX_LIBVDWXC], [ acx_libvdwxc_ok=no + acx_libvdwxc_mpi_ok=no dnl BACKUP LIBS AND FCFLAGS acx_libvdwxc_save_LIBS="$LIBS" @@ -17,19 +18,35 @@ AC_DEFUN([ACX_LIBVDWXC], esac fi - AC_MSG_CHECKING([for libvdwxc]) - libvdwxc_program="AC_LANG_PROGRAM([],[ + libvdwxc_program_serial="AC_LANG_PROGRAM([],[ implicit none include 'vdwxcfort.f90' integer, pointer :: vdw + call vdwxc_new(1, vdw) call vdwxc_print(vdw) + call vdwxc_init_serial(vdw) call vdwxc_finalize(vdw) + ])" + libvdwxc_program_mpi="AC_LANG_PROGRAM([],[ + implicit none + + include 'vdwxcfort.f90' + + integer, pointer :: vdw + integer :: has_mpi + + call vdwxc_new(1, vdw) + ! We are supposed to pass a communicator like MPI_COMM_WORLD below, + ! but I do not know how to get that here. We pass 42 instead. + ! The build system is happy as long as it compiles. + call vdwxc_init_mpi(vdw, 42) + call vdwxc_finalize(vdw) ])" FCFLAGS="$FCFLAGS_LIBVDWXC $acx_libvdwxc_save_FCFLAGS" @@ -41,15 +58,23 @@ AC_DEFUN([ACX_LIBVDWXC], fi LIBS="$LIBS_LIBVDWXC $acx_libvdwxc_save_LIBS" - AC_LINK_IFELSE($libvdwxc_program, [acx_libvdwxc_ok=yes], [acx_libvdwxc_ok=no]) + AC_LINK_IFELSE($libvdwxc_program_serial, [acx_libvdwxc_ok=yes], [acx_libvdwxc_ok=no]) + AC_LINK_IFELSE($libvdwxc_program_mpi, [acx_libvdwxc_mpi_ok=yes], [acx_libvdwxc_mpi_ok=no]) - AC_MSG_RESULT([$acx_libvdwxc_ok ($FCFLAGS_LIBVDWXC $LIBS_LIBVDWXC)]) if test x"$acx_libvdwxc_ok" = xyes; then - AC_DEFINE(HAVE_LIBVDWXC, 1, [Define if LIBVDWXC is available]) + AC_DEFINE(HAVE_LIBVDWXC, 1, [Define if libvdwxc is available]) + AC_MSG_RESULT([$acx_libvdwxc_ok ($FCFLAGS_LIBVDWXC $LIBS_LIBVDWXC)]) + if test x"$acx_libvdwxc_mpi_ok" = xyes; then + AC_DEFINE(HAVE_LIBVDWXC_MPI, 1, [Define if libvdwxc has MPI support]) + AC_MSG_RESULT([$acx_libvdwxc_mpi_ok]) + else + AC_MSG_WARN([libvdwxc not compiled with MPI, cannot be used with domain decomposition]) + fi else LIBS_LIBVDWXC="" FCFLAGS_LIBVDWXC="" + AC_MSG_RESULT([$acx_libvdwxc_ok]) AC_MSG_WARN([Could not find libvdwxc library. *** Will compile without libvdwxc support]) fi -- GitLab From eb48606f81a2e8c32e40fc42bc5a724f53a2a2c9 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Tue, 26 Feb 2019 19:40:40 +0100 Subject: [PATCH 08/13] libvdwxc will ship include-file with fortran interface; include using preprocessor instead of defining it all. Check whether libvdwxc has MPI support and write error message if used with domain decomposition without MPI --- src/hamiltonian/libvdwxc.F90 | 73 ++++-------------------------------- 1 file changed, 8 insertions(+), 65 deletions(-) diff --git a/src/hamiltonian/libvdwxc.F90 b/src/hamiltonian/libvdwxc.F90 index 05d59ef037..5703d9419b 100644 --- a/src/hamiltonian/libvdwxc.F90 +++ b/src/hamiltonian/libvdwxc.F90 @@ -5,6 +5,7 @@ ! * Functions that start with libvdwxc_ are public, to be called from other parts of Octopus. ! * Interfaces that start with vdwxc_ are actual functions of libvdwxc. + module libvdwxc_oct_m use cube_oct_m use cube_function_oct_m @@ -53,69 +54,7 @@ module libvdwxc_oct_m end type libvdwxc_t #ifdef HAVE_LIBVDWXC - ! These interfaces correspond to functions in libvdwxc - interface - subroutine vdwxc_new(functional, vdw) - integer, intent(in) :: functional - integer, pointer, intent(out) :: vdw - end subroutine vdwxc_new - end interface - - interface - subroutine vdwxc_print(vdw) - integer, pointer, intent(in) :: vdw - end subroutine vdwxc_print - end interface - - interface - subroutine vdwxc_calculate(vdw, rho, sigma, dedn, dedsigma, energy) - integer, pointer, intent(inout) :: vdw - real(8), intent(in) :: rho(:,:,:) - real(8), intent(in) :: sigma(:,:,:) - real(8), intent(inout) :: dedn(:,:,:) - real(8), intent(inout) :: dedsigma(:,:,:) - real(8), intent(inout) :: energy - end subroutine vdwxc_calculate - end interface - - interface - subroutine vdwxc_set_unit_cell(vdw, nx, ny, nz, C00, C01, C02, & - C10, C11, C12, C20, C21, C22) - integer, pointer, intent(inout) :: vdw - integer, intent(in) :: nx, ny, nz - real(8), intent(in) :: C00, C01, C02, C10, C11, C12, C20, C21, C22 - end subroutine vdwxc_set_unit_cell - end interface - - interface - subroutine vdwxc_init_serial(vdw) - integer, pointer, intent(inout) :: vdw - end subroutine vdwxc_init_serial - end interface - -#ifdef HAVE_MPI - interface - subroutine vdwxc_init_mpi(vdw, comm) - integer, pointer, intent(inout) :: vdw - integer, intent(in) :: comm - end subroutine vdwxc_init_mpi - end interface - - interface - subroutine vdwxc_init_pfft(vdw, comm, ncpu1, ncpu2) - integer, pointer, intent(inout) :: vdw - integer, intent(in) :: comm - integer, intent(in) :: ncpu1 - integer, intent(in) :: ncpu2 - end subroutine vdwxc_init_pfft - end interface -#endif - - interface - subroutine vdwxc_finalize(vdw) - integer, pointer, intent(inout) :: vdw - end subroutine vdwxc_finalize - end interface + include "vdwxcfort.f90" #endif contains @@ -254,8 +193,12 @@ contains if(libvdwxc_mode == LIBVDWXC_MODE_SERIAL) then call vdwxc_init_serial(this%libvdwxc_ptr) else -#ifdef HAVE_MPI +#ifdef HAVE_LIBVDWXC_MPI call vdwxc_init_mpi(this%libvdwxc_ptr, mesh%mpi_grp%comm) +#else + message(1) = "libvdwxc was not compiled with MPI" + message(2) = "Recompile libvdwxc with MPI for vdW with domain decomposition" + call messages_fatal(2) #endif end if call vdwxc_print(this%libvdwxc_ptr) @@ -279,7 +222,7 @@ contains #ifdef HAVE_MPI integer :: ierr #endif - + PUSH_SUB(libvdwxc_calculate) ASSERT(size(rho, 2) == 1) -- GitLab From 11904cecd3d35a343bcf96a5db7ec6aaa638f3e0 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Fri, 1 Mar 2019 02:32:12 +0100 Subject: [PATCH 09/13] add libvdwxc to get_optional_libraries --- src/basic/utils.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/basic/utils.F90 b/src/basic/utils.F90 index 0e90117f49..0cdec6c7d5 100644 --- a/src/basic/utils.F90 +++ b/src/basic/utils.F90 @@ -312,6 +312,9 @@ contains #ifdef HAVE_LIBISF get_optional_libraries = trim(get_optional_libraries)//' libisf' #endif +#ifdef HAVE_LIBVDWXC + get_optional_libraries = trim(get_optional_libraries)//' libvdwxc' +#endif #ifdef HAVE_METIS get_optional_libraries = trim(get_optional_libraries)//' metis' #endif -- GitLab From 58c9bb1931a3fa188d6ef129dc22c88b0455250b Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Fri, 1 Mar 2019 15:49:32 +0100 Subject: [PATCH 10/13] add test of libvdwxc with h2o --- testsuite/functionals/13-vdw_df_cx_h2o.inp | 8 ++++++++ testsuite/functionals/13-vdw_df_cx_h2o.test | 11 +++++++++++ testsuite/functionals/Makefile.am | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 testsuite/functionals/13-vdw_df_cx_h2o.inp create mode 100644 testsuite/functionals/13-vdw_df_cx_h2o.test diff --git a/testsuite/functionals/13-vdw_df_cx_h2o.inp b/testsuite/functionals/13-vdw_df_cx_h2o.inp new file mode 100644 index 0000000000..6bead9a5b7 --- /dev/null +++ b/testsuite/functionals/13-vdw_df_cx_h2o.inp @@ -0,0 +1,8 @@ +XCFunctional = vdw_c_vdwdfcx + gga_x_lv_rpw86 +ExperimentalFeatures = yes + +%Coordinates + 'O' | 0.0 | 0.0 | 0.119 * angstrom + 'H' | 0.0 | 0.763 * angstrom | -0.477 * angstrom + 'H' | 0.0 | -0.763 * angstrom | -0.477 * angstrom +% diff --git a/testsuite/functionals/13-vdw_df_cx_h2o.test b/testsuite/functionals/13-vdw_df_cx_h2o.test new file mode 100644 index 0000000000..1544131b9f --- /dev/null +++ b/testsuite/functionals/13-vdw_df_cx_h2o.test @@ -0,0 +1,11 @@ +Test : vdW-DF-cx with libvdwxc - H2O +Program : octopus +Options : libvdwxc +TestGroups : short-run, functionals, libvdwxc +Enabled : Yes + +Input : 13-vdw_df_cx_h2o.inp + +match ; Total energy ; GREPFIELD(static/info, 'Total =', 3) ; -17.11611752 +match ; Exchange energy ; GREPFIELD(static/info, 'Exchange =', 3) ; -3.80140067 +match ; Correlation energy ; GREPFIELD(static/info, 'Correlation =', 3) ; -0.38368351 diff --git a/testsuite/functionals/Makefile.am b/testsuite/functionals/Makefile.am index 0f55d13a0b..3b822bd7ac 100644 --- a/testsuite/functionals/Makefile.am +++ b/testsuite/functionals/Makefile.am @@ -134,7 +134,9 @@ dist_share_DATA = \ 11-vdw_d3.01-gs.inp \ 12-vdw_solid_c6.test \ 12-vdw_solid_c6.01-gs_diamond.inp \ - 12-vdw_solid_c6.02-gs_graphene.inp + 12-vdw_solid_c6.02-gs_graphene.inp \ + 13-vdw_df_cx_h2o.inp \ + 13-vdw_df_cx_h2o.test CLEANFILES = *~ *.bak -- GitLab From afa1eee28eb6bddd80ad7a810db5e60e5bcee966 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Tue, 12 Mar 2019 15:14:32 +0100 Subject: [PATCH 11/13] support for non-orthogonal cells --- src/hamiltonian/libvdwxc.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hamiltonian/libvdwxc.F90 b/src/hamiltonian/libvdwxc.F90 index 5703d9419b..4884df9b85 100644 --- a/src/hamiltonian/libvdwxc.F90 +++ b/src/hamiltonian/libvdwxc.F90 @@ -186,9 +186,9 @@ contains #ifdef HAVE_LIBVDWXC call vdwxc_set_unit_cell(this%libvdwxc_ptr, & this%cube%rs_n_global(3), this%cube%rs_n_global(2), this%cube%rs_n_global(1), & - mesh%spacing(3) * this%cube%rs_n_global(3), 0.0_8, 0.0_8, & - 0.0_8, mesh%spacing(2) * this%cube%rs_n_global(2), 0.0_8, & - 0.0_8, 0.0_8, mesh%spacing(1) * this%cube%rs_n_global(1)) + mesh%sb%rlattice(3, 3), mesh%sb%rlattice(2, 3), mesh%sb%rlattice(1, 3), & + mesh%sb%rlattice(3, 2), mesh%sb%rlattice(2, 2), mesh%sb%rlattice(1, 2), & + mesh%sb%rlattice(3, 1), mesh%sb%rlattice(2, 1), mesh%sb%rlattice(1, 1)) if(libvdwxc_mode == LIBVDWXC_MODE_SERIAL) then call vdwxc_init_serial(this%libvdwxc_ptr) -- GitLab From 4e1cbc9a05064dd0e417e822a39870962c3f06d5 Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Tue, 12 Mar 2019 18:18:13 +0100 Subject: [PATCH 12/13] sb%rlattice does not necessarily give us the right box unless boxshape is PARALLELEPIPED. Revert to using mesh%spacing when we are not a parallel epiped --- src/hamiltonian/libvdwxc.F90 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/hamiltonian/libvdwxc.F90 b/src/hamiltonian/libvdwxc.F90 index 4884df9b85..c55f077957 100644 --- a/src/hamiltonian/libvdwxc.F90 +++ b/src/hamiltonian/libvdwxc.F90 @@ -21,6 +21,7 @@ module libvdwxc_oct_m use parser_oct_m use pfft_oct_m use profiling_oct_m + use simul_box_oct_m use unit_system_oct_m implicit none @@ -111,7 +112,7 @@ contains else if(this%functional == 2) then write(message(2), '(4x,a)') 'vdW-DF2 from libvdwxc' else if(this%functional == 3) then - write(message(2), '(4x,a)') 'vdW-DF-CX from libvdwxc' + write(message(2), '(4x,a)') 'vdW-DF-cx from libvdwxc' else write(message(2), '(4x,a)') 'unknown libvdwxc functional' end if @@ -184,11 +185,19 @@ contains ! Therefore we cannot use the PFFT stuff without a frightful mess. #ifdef HAVE_LIBVDWXC - call vdwxc_set_unit_cell(this%libvdwxc_ptr, & - this%cube%rs_n_global(3), this%cube%rs_n_global(2), this%cube%rs_n_global(1), & - mesh%sb%rlattice(3, 3), mesh%sb%rlattice(2, 3), mesh%sb%rlattice(1, 3), & - mesh%sb%rlattice(3, 2), mesh%sb%rlattice(2, 2), mesh%sb%rlattice(1, 2), & - mesh%sb%rlattice(3, 1), mesh%sb%rlattice(2, 1), mesh%sb%rlattice(1, 1)) + if(mesh%sb%box_shape == PARALLELEPIPED) then + call vdwxc_set_unit_cell(this%libvdwxc_ptr, & + this%cube%rs_n_global(3), this%cube%rs_n_global(2), this%cube%rs_n_global(1), & + mesh%sb%rlattice(3, 3), mesh%sb%rlattice(2, 3), mesh%sb%rlattice(1, 3), & + mesh%sb%rlattice(3, 2), mesh%sb%rlattice(2, 2), mesh%sb%rlattice(1, 2), & + mesh%sb%rlattice(3, 1), mesh%sb%rlattice(2, 1), mesh%sb%rlattice(1, 1)) + else + call vdwxc_set_unit_cell(this%libvdwxc_ptr, & + this%cube%rs_n_global(3), this%cube%rs_n_global(2), this%cube%rs_n_global(1), & + mesh%spacing(3) * this%cube%rs_n_global(3), 0.0_8, 0.0_8, & + 0.0_8, mesh%spacing(2) * this%cube%rs_n_global(2), 0.0_8, & + 0.0_8, 0.0_8, mesh%spacing(1) * this%cube%rs_n_global(1)) + end if if(libvdwxc_mode == LIBVDWXC_MODE_SERIAL) then call vdwxc_init_serial(this%libvdwxc_ptr) -- GitLab From 7566ddfcd9a099ac2b26d1906ba2956579e0a0df Mon Sep 17 00:00:00 2001 From: Ask Hjorth Larsen Date: Tue, 12 Mar 2019 18:19:11 +0100 Subject: [PATCH 13/13] add test of libvdwxc in periodic system --- testsuite/functionals/14-vdw_df_cx_be_hcp.inp | 22 +++++++++++++++++++ .../functionals/14-vdw_df_cx_be_hcp.test | 11 ++++++++++ testsuite/functionals/Makefile.am | 5 +++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 testsuite/functionals/14-vdw_df_cx_be_hcp.inp create mode 100644 testsuite/functionals/14-vdw_df_cx_be_hcp.test diff --git a/testsuite/functionals/14-vdw_df_cx_be_hcp.inp b/testsuite/functionals/14-vdw_df_cx_be_hcp.inp new file mode 100644 index 0000000000..beab871319 --- /dev/null +++ b/testsuite/functionals/14-vdw_df_cx_be_hcp.inp @@ -0,0 +1,22 @@ +%LatticeVectors + 4.327472828166566 | 0.0 | 0.0 + -2.163736414083283 | 3.747701403379137 | 0.0 + 0.0 | 0.0 | 6.781149921737009 +% + +PeriodicDimensions = 3 +ParKPoints = False +ExperimentalFeatures = True +Spacing = 0.15 * angstrom +XCFunctional = vdw_c_vdwdfcx + gga_x_lv_rpw86 +PseudopotentialSet = sg15 + +%KPointsGrid + 2 | 2 | 2 +% + + +%Coordinates + 'Be' | -1.0818682070416414 | -1.8738507016895685 | -3.3905749608685043 + 'Be' | -1.0818682070416414 | 0.6246169005631896 | 0.0 +% diff --git a/testsuite/functionals/14-vdw_df_cx_be_hcp.test b/testsuite/functionals/14-vdw_df_cx_be_hcp.test new file mode 100644 index 0000000000..9375be93e1 --- /dev/null +++ b/testsuite/functionals/14-vdw_df_cx_be_hcp.test @@ -0,0 +1,11 @@ +Test : vdW-DF-cx with libvdwxc - H2O +Program : octopus +Options : libvdwxc +TestGroups : short-run, functionals, libvdwxc +Enabled : Yes + +Input : 14-vdw_df_cx_be_hcp.inp + +match ; Total energy ; GREPFIELD(static/info, 'Total =', 3) ; -26.58900976 +match ; Exchange energy ; GREPFIELD(static/info, 'Exchange =', 3) ; -3.76910154 +match ; Correlation energy ; GREPFIELD(static/info, 'Correlation =', 3) ; -0.41403236 diff --git a/testsuite/functionals/Makefile.am b/testsuite/functionals/Makefile.am index 3b822bd7ac..877af99a14 100644 --- a/testsuite/functionals/Makefile.am +++ b/testsuite/functionals/Makefile.am @@ -135,8 +135,9 @@ dist_share_DATA = \ 12-vdw_solid_c6.test \ 12-vdw_solid_c6.01-gs_diamond.inp \ 12-vdw_solid_c6.02-gs_graphene.inp \ + 13-vdw_df_cx_h2o.test \ 13-vdw_df_cx_h2o.inp \ - 13-vdw_df_cx_h2o.test - + 14-vdw_df_cx_be_hcp.test \ + 14-vdw_df_cx_be_hcp.inp CLEANFILES = *~ *.bak -- GitLab