Skip to content

Commit

Permalink
Remove deprecated sections LIBXC and KE_LIBXC (#1921)
Browse files Browse the repository at this point in the history
  • Loading branch information
fstein93 committed Feb 2, 2022
1 parent f0d6ce0 commit 38b4e3b
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 327 deletions.
58 changes: 15 additions & 43 deletions src/atom_output.F
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ MODULE atom_output
do_rhf_atom, do_rks_atom, do_rohf_atom, do_sczoramp_atom, do_uhf_atom, do_uks_atom, &
do_zoramp_atom, poly_conf, xc_none
USE input_cp2k_check, ONLY: xc_functionals_expand
USE input_section_types, ONLY: section_vals_duplicate,&
section_vals_get,&
section_vals_get_subs_vals,&
USE input_section_types, ONLY: section_vals_get_subs_vals,&
section_vals_get_subs_vals2,&
section_vals_release,&
section_vals_type,&
section_vals_val_get
USE kinds, ONLY: default_string_length,&
Expand All @@ -38,8 +35,7 @@ MODULE atom_output
USE physcon, ONLY: evolt
USE xc_derivatives, ONLY: xc_functional_get_info
USE xc_libxc, ONLY: libxc_check_existence_in_libxc,&
libxc_get_reference_length,&
libxc_version_info
libxc_get_reference_length
#include "./base/base_uses.f90"

IMPLICIT NONE
Expand Down Expand Up @@ -508,13 +504,11 @@ SUBROUTINE atom_print_method(atom, iw)
INTEGER, INTENT(IN) :: iw
CHARACTER(len=160) :: shortform
CHARACTER(len=20) :: tmpStr
CHARACTER(LEN=20) :: tmpStr
CHARACTER(len=:), ALLOCATABLE :: reference
INTEGER :: i_rep, ifun, il, meth, myfun, n_rep, &
reltyp
INTEGER :: ifun, il, meth, myfun, reltyp
LOGICAL :: lsd
TYPE(section_vals_type), POINTER :: libxc_fun, xc_fun, xc_fun_section, &
xc_section
TYPE(section_vals_type), POINTER :: xc_fun, xc_fun_section, xc_section
NULLIFY (xc_fun, xc_fun_section, xc_section)
Expand Down Expand Up @@ -609,40 +603,18 @@ SUBROUTINE atom_print_method(atom, iw)
ifun = ifun + 1
xc_fun => section_vals_get_subs_vals2(xc_fun_section, i_section=ifun)
IF (.NOT. ASSOCIATED(xc_fun)) EXIT
IF (TRIM(xc_fun%section%name) /= "LIBXC") THEN
IF (libxc_check_existence_in_libxc(xc_fun)) THEN
ALLOCATE (CHARACTER(LEN=libxc_get_reference_length(xc_fun, lsd)) :: reference)
ELSE
ALLOCATE (CHARACTER(LEN=20*default_string_length) :: reference)
END IF
CALL xc_functional_get_info(xc_fun, lsd=lsd, reference=reference, shortform=shortform)
WRITE (iw, fmt="(' FUNCTIONAL| ',a,':')") &
TRIM(xc_fun%section%name)
DO il = 1, LEN_TRIM(reference), 67
WRITE (iw, fmt="(' FUNCTIONAL| ',a67)") reference(il:)
END DO
DEALLOCATE (reference)
IF (libxc_check_existence_in_libxc(xc_fun)) THEN
ALLOCATE (CHARACTER(LEN=libxc_get_reference_length(xc_fun, lsd)) :: reference)
ELSE
! LIBXC is the only repeatable functional section - for each we need
! NOT the single values, but the whole section_vals_type independently
CALL section_vals_get(xc_fun, n_repetition=n_rep)
DO i_rep = 1, n_rep
NULLIFY (libxc_fun)
CALL section_vals_duplicate(xc_fun, libxc_fun, i_rep_start=i_rep, i_rep_end=i_rep)
IF (.NOT. ASSOCIATED(libxc_fun)) EXIT
ALLOCATE (CHARACTER(LEN=libxc_get_reference_length(libxc_fun, lsd)) :: reference)
CALL xc_functional_get_info(libxc_fun, lsd=lsd, reference=reference, shortform=shortform)
CALL section_vals_release(libxc_fun)
CALL libxc_version_info(tmpStr)
WRITE (iw, fmt="(A,A,A)") ' FUNCTIONAL| LIBXC Vers. ', TRIM(tmpStr(1:5)), &
' (Marques, Oliveira, Burnus, CPC 183, 2272 (2012))'
WRITE (iw, fmt="(' FUNCTIONAL| ',a,':')") TRIM(shortform)
DO il = 1, LEN_TRIM(reference), 67
WRITE (iw, fmt="(' FUNCTIONAL| ',a67)") reference(il:)
END DO
DEALLOCATE (reference)
END DO
ALLOCATE (CHARACTER(LEN=20*default_string_length) :: reference)
END IF
CALL xc_functional_get_info(xc_fun, lsd=lsd, reference=reference, shortform=shortform)
WRITE (iw, fmt="(' FUNCTIONAL| ',a,':')") &
TRIM(xc_fun%section%name)
DO il = 1, LEN_TRIM(reference), 67
WRITE (iw, fmt="(' FUNCTIONAL| ',a67)") reference(il:)
END DO
DEALLOCATE (reference)
END DO
END IF
ELSE
Expand Down
66 changes: 2 additions & 64 deletions src/input_cp2k_xc.F
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
MODULE input_cp2k_xc
USE bibliography, ONLY: &
Becke1988, Becke1997, BeckeRoussel1989, Goedecker1996, Grimme2006, Grimme2010, Grimme2011, &
Heyd2004, Kruse2012, Lee1988, Lehtola2018, Marques2012, Ortiz1994, Perdew1981, Perdew1996, &
Perdew2008, Proynov2007, Tao2003, Tran2013, Vosko1980, Wellendorff2012, Zhang1998
Heyd2004, Kruse2012, Lee1988, Ortiz1994, Perdew1981, Perdew1996, Perdew2008, Proynov2007, &
Tao2003, Tran2013, Vosko1980, Wellendorff2012, Zhang1998
USE cp_output_handling, ONLY: add_last_numeric,&
cp_print_key_section_create,&
high_print_level
Expand Down Expand Up @@ -270,20 +270,6 @@ SUBROUTINE create_xc_fun_section(section)
CALL section_add_subsection(section, subsection)
CALL section_release(subsection)

CALL create_libxc_section(subsection, "LIBXC", &
"Uses functionals from LIBXC, see also "// &
"https://www.tddft.org/programs/libxc/functionals/", &
"FUNCTIONAL GGA_X_PBE")
CALL section_add_subsection(section, subsection)
CALL section_release(subsection)

CALL create_libxc_section(subsection, "KE_LIBXC", &
"To be used for KG runs. Uses kinetic energy functionals from LIBXC, "// &
"https://www.tddft.org/programs/libxc/functionals/", &
"FUNCTIONAL GGA_K_LLP")
CALL section_add_subsection(section, subsection)
CALL section_release(subsection)

CALL libxc_add_sections(section)

CALL section_create(subsection, __LOCATION__, name="CS1", &
Expand Down Expand Up @@ -732,54 +718,6 @@ SUBROUTINE create_xc_fun_section(section)

END SUBROUTINE create_xc_fun_section

! **************************************************************************************************
!> \brief ...
!> \param section ...
!> \param name ...
!> \param description ...
!> \param usage ...
! **************************************************************************************************
SUBROUTINE create_libxc_section(section, name, description, usage)
TYPE(section_type), POINTER :: section
CHARACTER(len=*), INTENT(in) :: name, description, usage

TYPE(keyword_type), POINTER :: keyword

CPASSERT(.NOT. ASSOCIATED(section))
CPASSERT(name == "LIBXC" .OR. name == "KE_LIBXC")
NULLIFY (keyword)
CALL section_create(section, __LOCATION__, name, description, &
n_keywords=3, n_subsections=0, repeats=.TRUE., &
citations=(/Marques2012, Lehtola2018/))
CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
description="activates functionals from libxc library", &
lone_keyword_l_val=.TRUE., default_l_val=.FALSE., &
deprecation_notice="Instead of &"//name//" with set keyword "// &
"FUNCTIONAL <FUNCTIONAL_KEY> use the section &<FUNCTIONAL_KEY>.")
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
CALL keyword_create(keyword, __LOCATION__, name="FUNCTIONAL", &
description="name of the functional, see also "// &
"https://www.tddft.org/programs/libxc/functionals/ "// &
"The precise list of available functionals depends on "// &
"the version of the linked libxc.", &
usage=usage, type_of_var=char_t)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
CALL keyword_create(keyword, __LOCATION__, name="SCALE", &
description="scaling factors for the functional", &
usage="SCALE 0.8", type_of_var=real_t, &
default_r_val=1.0_dp)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
CALL keyword_create(keyword, __LOCATION__, name="PARAMETERS", &
description="list of external parameters for the functional", &
usage="PARAMETERS 0.3 [0.5 [1.4]]", type_of_var=real_t, &
default_r_vals=(/HUGE(0.0_dp)/), n_var=-1)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
END SUBROUTINE

! **************************************************************************************************
!> \brief creates the structure of the section needed to select an xc potential
!> \param section the section that will be created
Expand Down
21 changes: 3 additions & 18 deletions src/sirius_interface.F
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ MODULE sirius_interface
sirius_option_get_info, sirius_option_get_section_length, sirius_option_set, &
sirius_set_atom_position, sirius_set_atom_type_dion, sirius_set_atom_type_radial_grid, &
sirius_set_lattice_vectors, sirius_set_mpi_grid_dims, sirius_update_ground_state
USE xc_libxc, ONLY: libxc_check_existence_in_libxc
#include "./base/base_uses.f90"

IMPLICIT NONE
Expand Down Expand Up @@ -176,28 +175,14 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
! manually is prone to errors

IF (ASSOCIATED(xc_section)) THEN
! LIBXC is the only repeatable functional section - for each we need
! NOT the single values, but the whole section_vals_type independently
ifun = 0
DO
ifun = ifun + 1
xc_fun => section_vals_get_subs_vals2(xc_section, i_section=ifun)
IF (.NOT. ASSOCIATED(xc_fun)) EXIT
IF (TRIM(xc_fun%section%name) == "LIBXC") THEN
CALL section_vals_get(xc_fun, n_repetition=n)
DO i = 1, n
CALL section_vals_val_get(xc_fun, "FUNCTIONAL", i_rep_section=i, c_val=section_name)
IF (section_name(1:3) == "XC_") THEN
CALL sirius_add_xc_functional(sctx, section_name)
ELSE
CALL sirius_add_xc_functional(sctx, "XC_"//section_name)
END IF
END DO
ELSE IF (libxc_check_existence_in_libxc(xc_fun)) THEN
! Here, we do not have to check whether the functional name starts with XC_
! because we only allow the shorter form w/o XC_
CALL sirius_add_xc_functional(sctx, "XC_"//TRIM(xc_fun%section%name))
END IF
! Here, we do not have to check whether the functional name starts with XC_
! because we only allow the shorter form w/o XC_
CALL sirius_add_xc_functional(sctx, "XC_"//TRIM(xc_fun%section%name))
END DO
END IF

Expand Down
67 changes: 11 additions & 56 deletions src/xc/xc_derivatives.F
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
! **************************************************************************************************
MODULE xc_derivatives

USE input_section_types, ONLY: section_vals_duplicate,&
section_vals_get,&
section_vals_get_subs_vals2,&
section_vals_release,&
USE input_section_types, ONLY: section_vals_get_subs_vals2,&
section_vals_type,&
section_vals_val_get
USE kinds, ONLY: dp
Expand Down Expand Up @@ -226,12 +223,6 @@ SUBROUTINE xc_functional_get_info(functional, lsd, reference, shortform, &
ELSE
CALL optx_lda_info(reference, shortform, needs, max_deriv)
END IF
CASE ("LIBXC", "KE_LIBXC")
IF (lsd) THEN
CALL libxc_lsd_info(functional, reference, shortform, needs, max_deriv, print_warn)
ELSE
CALL libxc_lda_info(functional, reference, shortform, needs, max_deriv, print_warn)
END IF
CASE ("CS1")
IF (lsd) THEN
CALL cs1_lsd_info(reference, shortform, needs, max_deriv)
Expand Down Expand Up @@ -431,12 +422,6 @@ SUBROUTINE xc_functional_eval(functional, lsd, rho_set, deriv_set, deriv_order)
ELSE
CALL optx_lda_eval(rho_set, deriv_set, deriv_order, functional)
END IF
CASE ("LIBXC", "KE_LIBXC")
IF (lsd) THEN
CALL libxc_lsd_eval(rho_set, deriv_set, deriv_order, functional)
ELSE
CALL libxc_lda_eval(rho_set, deriv_set, deriv_order, functional)
END IF
CASE ("CS1")
IF (lsd) THEN
CALL cs1_lsd_eval(rho_set, deriv_set, deriv_order)
Expand Down Expand Up @@ -582,37 +567,20 @@ SUBROUTINE xc_functionals_eval(functionals, lsd, rho_set, deriv_set, &
TYPE(xc_derivative_set_type), POINTER :: deriv_set
INTEGER, INTENT(in) :: deriv_order

INTEGER :: i_rep, ifun, n_rep
TYPE(section_vals_type), POINTER :: libxc_fun, xc_fun
INTEGER :: ifun
TYPE(section_vals_type), POINTER :: xc_fun

CPASSERT(ASSOCIATED(functionals))
ifun = 0
DO
ifun = ifun + 1
xc_fun => section_vals_get_subs_vals2(functionals, i_section=ifun)
IF (.NOT. ASSOCIATED(xc_fun)) EXIT
IF (TRIM(xc_fun%section%name) /= "LIBXC") THEN
CALL xc_functional_eval(xc_fun, &
lsd=lsd, &
rho_set=rho_set, &
deriv_set=deriv_set, &
deriv_order=deriv_order)
ELSE
! LIBXC is the only repeatable functional section - for each we need
! NOT the single values, but the whole section_vals_type independently
CALL section_vals_get(xc_fun, n_repetition=n_rep)
DO i_rep = 1, n_rep
NULLIFY (libxc_fun)
CALL section_vals_duplicate(xc_fun, libxc_fun, i_rep_start=i_rep, i_rep_end=i_rep)
IF (.NOT. ASSOCIATED(libxc_fun)) EXIT
CALL xc_functional_eval(libxc_fun, &
lsd=lsd, &
rho_set=rho_set, &
deriv_set=deriv_set, &
deriv_order=deriv_order)
CALL section_vals_release(libxc_fun)
END DO
END IF
CALL xc_functional_eval(xc_fun, &
lsd=lsd, &
rho_set=rho_set, &
deriv_set=deriv_set, &
deriv_order=deriv_order)
END DO
END SUBROUTINE xc_functionals_eval

Expand All @@ -634,9 +602,9 @@ FUNCTION xc_functionals_get_needs(functionals, lsd, add_basic_components) &
LOGICAL, INTENT(in), OPTIONAL :: add_basic_components
TYPE(xc_rho_cflags_type) :: needs

INTEGER :: i_rep, ifun, n_rep
INTEGER :: ifun
LOGICAL :: my_add_basic_components
TYPE(section_vals_type), POINTER :: libxc_fun, xc_fun
TYPE(section_vals_type), POINTER :: xc_fun

my_add_basic_components = .FALSE.
IF (PRESENT(add_basic_components)) my_add_basic_components = add_basic_components
Expand All @@ -649,20 +617,7 @@ FUNCTION xc_functionals_get_needs(functionals, lsd, add_basic_components) &
ifun = ifun + 1
xc_fun => section_vals_get_subs_vals2(functionals, i_section=ifun)
IF (.NOT. ASSOCIATED(xc_fun)) EXIT
IF (TRIM(xc_fun%section%name) /= "LIBXC") THEN
CALL xc_functional_get_info(xc_fun, lsd=lsd, needs=needs)
ELSE
! LIBXC is the only repeatable functional section - for each we need
! NOT the single values, but the whole section_vals_type independently
CALL section_vals_get(xc_fun, n_repetition=n_rep)
DO i_rep = 1, n_rep
NULLIFY (libxc_fun)
CALL section_vals_duplicate(xc_fun, libxc_fun, i_rep_start=i_rep, i_rep_end=i_rep)
IF (.NOT. ASSOCIATED(libxc_fun)) EXIT
CALL xc_functional_get_info(libxc_fun, lsd=lsd, needs=needs)
CALL section_vals_release(libxc_fun)
END DO
END IF
CALL xc_functional_get_info(xc_fun, lsd=lsd, needs=needs)
END DO

IF (my_add_basic_components) THEN
Expand Down

0 comments on commit 38b4e3b

Please sign in to comment.