Skip to content

Commit

Permalink
SIRIUS: Add support for libvdwxc
Browse files Browse the repository at this point in the history
  • Loading branch information
mtaillefumier committed Sep 6, 2022
1 parent 6a17118 commit eb97e8d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 7 deletions.
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ SIRIUS is a domain specific library for electronic structure calculations.

- The code is available at <https://github.com/electronic-structure/SIRIUS>
- For building CP2K with SIRIUS add `-D__SIRIUS` to DFLAGS.
- Add `-D__LIBVDWXC` if support is activated in SIRIUS.
- See <https://electronic-structure.github.io/SIRIUS-doc/> for more information.

### 2q. FPGA (optional, plane wave FFT calculations)
Expand Down
4 changes: 4 additions & 0 deletions src/cp2k_info.F
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ FUNCTION cp2k_flags() RESULT(flags)
flags = TRIM(flags)//" spla_gemm_offloading"
#endif

#if defined(__LIBVDWXC)
flags = TRIM(flags)//" libvdwxc"
#endif

END FUNCTION cp2k_flags

! **************************************************************************************************
Expand Down
25 changes: 25 additions & 0 deletions src/input_cp2k_pwdft.F
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ MODULE input_cp2k_pwdft
medium_print_level, &
silent_print_level
USE kinds, ONLY: dp
USE string_utilities, ONLY: s2a
#include "./base/base_uses.f90"

IMPLICIT NONE
Expand All @@ -53,6 +54,11 @@ MODULE input_cp2k_pwdft

PUBLIC :: create_pwdft_section

INTEGER, PARAMETER, PUBLIC :: SIRIUS_NO_VDW = -1
INTEGER, PARAMETER, PUBLIC :: SIRIUS_FUNC_VDWDF = 1
INTEGER, PARAMETER, PUBLIC :: SIRIUS_FUNC_VDWDF2 = 2
INTEGER, PARAMETER, PUBLIC :: SIRIUS_FUNC_VDWDFCX = 3

CONTAINS

#if defined(__SIRIUS)
Expand Down Expand Up @@ -166,7 +172,26 @@ SUBROUTINE fill_in_section(section, section_name)
ALLOCATE (ivec(1:16))
ALLOCATE (rvec(1:16))
ALLOCATE (lvec(1:16))

#ifdef __LIBVDWXC
IF (section_name == "parameters") THEN
NULLIFY (keyword)
CALL keyword_create(keyword, __LOCATION__, name="VDW_FUNCTIONAL", &
description="Select the Van der Walls functionals corrections type", &
default_i_val=SIRIUS_NO_VDW, &
enum_i_vals=(/SIRIUS_NO_VDW, SIRIUS_FUNC_VDWDF, SIRIUS_FUNC_VDWDF2, SIRIUS_FUNC_VDWDFCX/), &
enum_c_vals=s2a("NONE", "FUNC_VDWDF", "FUNC_VDWDF2", "FUNC_VDWDFCX"), &
enum_desc=s2a("No VdW correction", &
"FUNC_VDWDF", &
"FUNC_VDWDF2", &
"FUNC_VDWDFCX"))
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
END IF
#endif

CALL sirius_option_get_section_length(section_name, length)

DO i = 1, length
NULLIFY (keyword)
name = ''
Expand Down
4 changes: 2 additions & 2 deletions src/pwdft_environment.F
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ SUBROUTINE pwdft_init(pwdft_env, root_section, para_env, force_env_section, subs
CALL cp_sirius_create_env(pwdft_env)

IF (iw > 0) THEN
WRITE (iw, '(A)') "SIRIUS INIT: FINISHED"
WRITE (iw, '(A)') "SIRIUS| INIT: FINISHED"
END IF
IF (iw > 0) CALL m_flush(iw)

Expand Down Expand Up @@ -235,7 +235,7 @@ SUBROUTINE pwdft_calc_energy_force(pwdft_env, calculate_forces, calculate_stress
! Sirius initialization
CALL cp_sirius_update_context(pwdft_env)
IF (iw > 0) THEN
WRITE (iw, '(A)') "SIRIUS UPDATE CONTEXT : FINISHED"
WRITE (iw, '(A)') "SIRIUS| UPDATE CONTEXT : FINISHED"
END IF
IF (iw > 0) CALL m_flush(iw)

Expand Down
26 changes: 23 additions & 3 deletions src/sirius_interface.F
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ MODULE sirius_interface
USE cp_para_types, ONLY: cp_para_env_type
USE external_potential_types, ONLY: gth_potential_type
USE input_constants, ONLY: do_gapw_log
USE input_cp2k_pwdft, ONLY: SIRIUS_FUNC_VDWDF,&
SIRIUS_FUNC_VDWDF2,&
SIRIUS_FUNC_VDWDFCX
USE input_section_types, ONLY: section_vals_get,&
section_vals_get_subs_vals,&
section_vals_get_subs_vals2,&
Expand Down Expand Up @@ -127,7 +130,7 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
CHARACTER(len=default_string_length) :: label
INTEGER :: i, iatom, ibeta, ifun, ikind, iwf, j, l, &
n, natom, nbeta, nkind, nmesh, &
num_mag_dims, sirius_mpi_comm
num_mag_dims, sirius_mpi_comm, vdw_func
INTEGER, DIMENSION(:), POINTER :: mpi_grid_dims
INTEGER(KIND=C_INT), DIMENSION(3) :: k_grid, k_shift
INTEGER, DIMENSION(:), POINTER :: kk
Expand Down Expand Up @@ -185,7 +188,7 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
END DO
END IF

! import control section
! import control section
pwdft_sub_section => section_vals_get_subs_vals(pwdft_section, "control")
IF (ASSOCIATED(pwdft_sub_section)) THEN
CALL cp_sirius_fill_in_section(sctx, pwdft_sub_section, "control")
Expand All @@ -194,6 +197,7 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)

! import parameters section
pwdft_sub_section => section_vals_get_subs_vals(pwdft_section, "parameters")

IF (ASSOCIATED(pwdft_sub_section)) THEN
CALL cp_sirius_fill_in_section(sctx, pwdft_sub_section, "parameters")
CALL section_vals_val_get(pwdft_sub_section, "ngridk", i_vals=kk)
Expand All @@ -208,6 +212,22 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
CALL section_vals_val_get(pwdft_sub_section, "num_mag_dims", i_val=num_mag_dims)
CALL section_vals_val_get(pwdft_sub_section, "use_symmetry", l_val=use_symmetry)
CALL section_vals_val_get(pwdft_sub_section, "so_correction", l_val=use_so)

! now check if van der walls corrections are needed
vdw_func = -1
#ifdef __LIBVDWXC
CALL section_vals_val_get(pwdft_sub_section, "vdw_functional", i_val=vdw_func)
SELECT CASE (vdw_func)
CASE (SIRIUS_FUNC_VDWDF)
CALL sirius_add_xc_functional(sctx, "XC_FUNC_VDWDF")
CASE (SIRIUS_FUNC_VDWDF2)
CALL sirius_add_xc_functional(sctx, "XC_FUNC_VDWDF2")
CASE (SIRIUS_FUNC_VDWDFCX)
CALL sirius_add_xc_functional(sctx, "XC_FUNC_VDWDF2")
CASE default
END SELECT
#endif

END IF

! import mixer section
Expand Down Expand Up @@ -250,7 +270,7 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
CALL sirius_set_lattice_vectors(sctx, a1(1), a2(1), a3(1))

IF (use_ref_cell) THEN
CPWARN("The specified CELL_REF will be ignored for PW_DFT calculations")
CPWARN("SIRIUS| The specified CELL_REF will be ignored for PW_DFT calculations")
END IF

! set up the atomic type definitions
Expand Down
4 changes: 2 additions & 2 deletions tools/toolchain/install_cp2k_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ if [ "${with_sirius}" = "__INSTALL__" ]; then
[ "${with_fftw}" = "__DONTUSE__" ] && with_fftw="__INSTALL__"
[ "${with_spglib}" = "__DONTUSE__" ] && with_spglib="__INSTALL__"
[ "${with_hdf5}" = "__DONTUSE__" ] && with_hdf5="__INSTALL__"
# [ "${with_libvdwxc}" = "__DONTUSE__" ] && with_libvdwxc="__INSTALL__"
# [ "${with_cosma}" = "__DONTUSE__" ] && with_cosma="__INSTALL__"
[ "${with_libvdwxc}" = "__DONTUSE__" ] && with_libvdwxc="__INSTALL__"
[ "${with_cosma}" = "__DONTUSE__" ] && with_cosma="__INSTALL__"
fi

if [ "${with_plumed}" = "__INSTALL__" ]; then
Expand Down

0 comments on commit eb97e8d

Please sign in to comment.