Skip to content

Commit

Permalink
Merge pull request #106 from vanderhe/supportLibxc7
Browse files Browse the repository at this point in the history
Support for libxc 7
  • Loading branch information
vanderhe authored Dec 18, 2024
2 parents 873955c + b2a6bf0 commit b6c8c31
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ jobs:
# Switch from openmpi to mpich, since installing openmpi-mpifort
# from the conda-forge channel downgrades gfortran at the moment
mpi: [nompi, mpich]
libxc: [6, 7]
config: [Debug]
# Serial binary is tested with libxc 7
exclude:
- mpi: nompi
libxc: 6

steps:
- name: Checkout code
Expand Down Expand Up @@ -63,36 +68,46 @@ jobs:
- name: Install BLAS
run: mamba install openblas libopenblas

- name: Install libxc
- name: Install libxc (6.2.2)
if: contains(matrix.libxc, '6')
run: mamba install libxc=6.2.2

- name: Install libxc (7.0.0)
if: contains(matrix.libxc, '7')
run: mamba install libxc=7.0.0

- name: Set libxc search path
run: echo "CMAKE_PREFIX_PATH=${CONDA_PREFIX}/" >> $GITHUB_ENV

- name: Install requirements (conda)
run: mamba install cmake fypp numpy scipy

- name: Configure build
- name: Configure build (-DTEST_MPI_PROCS=1)
if: contains(matrix.mpi, 'nompi') || contains(matrix.libxc, '6')
run: |
cmake -B ${BUILD_DIR} -DWITH_MPI=${WITH_MPI} \
-DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR} \
-DCMAKE_BUILD_TYPE=${{ matrix.config }} -DTEST_MPI_PROCS=1 .
- name: Configure build (-DTEST_MPI_PROCS=2)
if: "! contains(matrix.mpi, 'nompi') && ! contains(matrix.libxc, '6')"
run: |
cmake -B ${BUILD_DIR} -DWITH_MPI=${WITH_MPI} \
-DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR} \
-DCMAKE_BUILD_TYPE=${{ matrix.config }} .
-DCMAKE_BUILD_TYPE=${{ matrix.config }} -DTEST_MPI_PROCS=2 .
- name: Build project
run: cmake --build ${BUILD_DIR}

- name: Run regression tests
- name: Run regression tests (-j2)
if: contains(matrix.mpi, 'nompi') || contains(matrix.libxc, '6')
run: |
pushd ${BUILD_DIR}
ctest -j2 --output-on-failure
popd
- name: Configure build (TEST_MPI_PROCS=2)
if: contains(matrix.mpi, 'openmpi') || contains(matrix.mpi, 'mpich')
run: cmake -B ${BUILD_DIR} -DTEST_MPI_PROCS=2 .

- name: Run regression tests (TEST_MPI_PROCS=2)
if: contains(matrix.mpi, 'openmpi') || contains(matrix.mpi, 'mpich')
- name: Run regression tests (-j1)
if: "! contains(matrix.mpi, 'nompi') && ! contains(matrix.libxc, '6')"
run: |
pushd ${BUILD_DIR}
ctest -j1 --output-on-failure
Expand Down
2 changes: 2 additions & 0 deletions cmake/SkProgsUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function (skprogs_add_fypp_defines fyppflags)
list(APPEND _fyppflags -DWITH_MPI)
endif()

list(APPEND _fyppflags -DLIBXC_VERSION_MAJOR="${Libxc_VERSION_MAJOR}")

set(${fyppflags} ${_fyppflags} PARENT_SCOPE)

endfunction()
Expand Down
1 change: 1 addition & 0 deletions common/include/common.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#:set DEBUG = getvar('DEBUG', 0)
#:set WITH_ASSERT = defined('WITH_ASSERT') or DEBUG > 0
#:set WITH_MPI = defined('WITH_MPI')
#:set LIBXC_VERSION_MAJOR = getvar('LIBXC_VERSION_MAJOR')


#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
7 changes: 7 additions & 0 deletions sktwocnt/lib/twocnt.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ module twocnt

use, intrinsic :: iso_c_binding, only : c_size_t

#:if LIBXC_VERSION_MAJOR == 6
use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_vxc,&
& xc_f03_gga_vxc, XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_C_PBE,&
& XC_GGA_X_B88, XC_GGA_C_LYP, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP,&
& XC_HYB_GGA_XC_CAMY_B3LYP, XC_UNPOLARIZED, xc_f03_func_set_ext_params
#:elif LIBXC_VERSION_MAJOR == 7
use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_vxc,&
& xc_f03_gga_vxc, xc_f03_func_set_ext_params, XC_UNPOLARIZED
use xc_f03_funcs_m, only : XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_C_PBE,&
& XC_GGA_X_B88, XC_GGA_C_LYP, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP, XC_HYB_GGA_XC_CAMY_B3LYP
#:endif

implicit none
private
Expand Down
4 changes: 2 additions & 2 deletions slateratom/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ set(sources-f90
output.f90
total_energy.f90
utilities.f90
xcfunctionals.f90
zora_routines.f90)

set(sources-fpp
Expand All @@ -34,7 +33,8 @@ set(sources-fpp
confinement.F90
input.F90
lapackroutines.F90
simplemixer.F90)
simplemixer.F90
xcfunctionals.F90)

skprogs_preprocess("${FYPP}" "${fypp_flags}" "F90" "f90" "${sources-fpp}" sources-f90-preproc)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
#:include 'common.fypp'

!> Module related to supported xc-functionals of the slateratom code.
module xcfunctionals

use, intrinsic :: iso_c_binding, only : c_size_t
use common_accuracy, only : dp
use common_constants, only : rec4pi
use utilities, only : zeroOutCpotOfEmptyDensitySpinChannels
#:if LIBXC_VERSION_MAJOR == 6
use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_exc_vxc,&
& xc_f03_gga_exc_vxc, xc_f03_func_set_ext_params, XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW,&
& XC_GGA_X_PBE, XC_GGA_X_B88, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP,&
& XC_HYB_GGA_XC_CAMY_B3LYP, XC_GGA_C_PBE, XC_GGA_C_LYP, XC_POLARIZED
#:elif LIBXC_VERSION_MAJOR == 7
use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_exc_vxc,&
& xc_f03_gga_exc_vxc, xc_f03_func_set_ext_params, XC_POLARIZED
use xc_f03_funcs_m, only : XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_X_B88,&
& XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP, XC_HYB_GGA_XC_CAMY_B3LYP, XC_GGA_C_PBE,&
& XC_GGA_C_LYP
#:endif

implicit none
private
Expand Down

0 comments on commit b6c8c31

Please sign in to comment.