Skip to content

Commit

Permalink
LibXC: Add section for every functional
Browse files Browse the repository at this point in the history
SIRIUS: Append XC_ to LibXC functional names if absent
  • Loading branch information
Frederick Stein authored and fstein93 committed Mar 5, 2021
1 parent 439702f commit a3c0186
Show file tree
Hide file tree
Showing 62 changed files with 747 additions and 636 deletions.
5 changes: 2 additions & 3 deletions data/xc_section/vdW-DF-cx.sec
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#
&XC
&XC_FUNCTIONAL
&LIBXC
FUNCTIONAL XC_GGA_X_LV_RPW86
&END LIBXC
&GGA_X_LV_RPW86
&END GGA_X_LV_RPW86
&PW92
&END PW92
&END XC_FUNCTIONAL
Expand Down
5 changes: 2 additions & 3 deletions data/xc_section/vdW-DF-cx0p.sec
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#
&XC
&XC_FUNCTIONAL
&LIBXC
FUNCTIONAL XC_GGA_X_LV_RPW86
&GGA_X_LV_RPW86
SCALE 0.80
&END LIBXC
&END GGA_X_LV_RPW86
&PW92
&END PW92
&END XC_FUNCTIONAL
Expand Down
5 changes: 2 additions & 3 deletions data/xc_section/vdW-DF-optB88.sec
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#
&XC
&XC_FUNCTIONAL
&LIBXC
FUNCTIONAL XC_GGA_X_OPTB88_VDW
&END LIBXC
&GGA_X_OPTB88_VDW
&END GGA_X_OPTB88_VDW
&PW92
&END PW92
&END XC_FUNCTIONAL
Expand Down
5 changes: 2 additions & 3 deletions data/xc_section/vdW-DF-optPBE.sec
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#
&XC
&XC_FUNCTIONAL
&LIBXC
FUNCTIONAL XC_GGA_X_OPTPBE_VDW
&END LIBXC
&GGA_X_OPTPBE_VDW
&END GGA_X_OPTPBE_VDW
&PW92
&END PW92
&END XC_FUNCTIONAL
Expand Down
5 changes: 2 additions & 3 deletions data/xc_section/vdW-DF1-C09.sec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#
&XC
&XC_FUNCTIONAL
&LIBXC
FUNCTIONAL XC_GGA_X_C09X
&END LIBXC
&GGA_X_C09X
&END GGA_X_C09X
&PW92
&END PW92
&END XC_FUNCTIONAL
Expand Down
5 changes: 2 additions & 3 deletions data/xc_section/vdW-DF2-b86r.sec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#
&XC
&XC_FUNCTIONAL
&LIBXC
FUNCTIONAL XC_GGA_X_B86_R
&END LIBXC
&GGA_X_B86_R
&END GGA_X_B86_R
&PW92
&END PW92
&END XC_FUNCTIONAL
Expand Down
5 changes: 2 additions & 3 deletions data/xc_section/vdW-DF2.sec
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#
&XC
&XC_FUNCTIONAL
&LIBXC
FUNCTIONAL XC_GGA_X_RPW86
&END LIBXC
&GGA_X_RPW86
&END GGA_X_RPW86
&PW92
&END PW92
&END XC_FUNCTIONAL
Expand Down
6 changes: 2 additions & 4 deletions src/input_cp2k_check.F
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ SUBROUTINE xc_functionals_expand(functionals, xc_section)
!The cp2k-native PW92 gives disagreeing results (in the 0.01E_H
!decimal) and yields inconsistent forces in a DEBUG run.
!(rk, 6.3.2014)
CALL section_vals_val_set(functionals, "LIBXC%_SECTION_PARAMETERS_", & !60%LDA
CALL section_vals_val_set(functionals, "LDA_C_PW%_SECTION_PARAMETERS_", & !60%LDA
l_val=.TRUE.)
CALL section_vals_val_set(functionals, "LIBXC%FUNCTIONAL", &
c_val="LDA_C_PW")
CALL section_vals_val_set(functionals, "LIBXC%SCALE", &
CALL section_vals_val_set(functionals, "LDA_C_PW%SCALE", &
r_val=0.6001664769_dp)

CALL section_vals_val_set(functionals, "BEEF%_SECTION_PARAMETERS_", & !BEEF exchange
Expand Down
10 changes: 8 additions & 2 deletions src/input_cp2k_xc.F
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ MODULE input_cp2k_xc
xc_old_f_routine, xc_pbe_orig, xc_pbe_rev, xc_pbe_sol, xc_rho_nn10, xc_rho_nn50, &
xc_rho_no_smooth, xc_rho_spline2_smooth, xc_rho_spline3_smooth, xc_test_lsd_f_routine, &
xgga_b88x, xgga_ev93, xgga_opt, xgga_pbex, xgga_pw86, xgga_pw91, xgga_revpbe
USE xc_libxc, ONLY: libxc_add_sections
#include "./base/base_uses.f90"

IMPLICIT NONE
Expand All @@ -76,7 +77,8 @@ SUBROUTINE create_xc_fun_section(section)

CPASSERT(.NOT. ASSOCIATED(section))
CALL section_create(section, __LOCATION__, name="xc_functional", &
description="The xc functional to use", &
description="The xc functional to use. For Functionals "// &
"of the LibXC library use the appropriate section.", &
n_keywords=0, n_subsections=4, repeats=.FALSE., &
citations=(/Ortiz1994, Becke1988, Perdew1996, Zhang1998, Lee1988, &
Heyd2004, Vosko1980, Goedecker1996, Perdew1981, &
Expand Down Expand Up @@ -283,6 +285,8 @@ SUBROUTINE create_xc_fun_section(section)
CALL section_add_subsection(section, subsection)
CALL section_release(subsection)

CALL libxc_add_sections(section)

CALL section_create(subsection, __LOCATION__, name="CS1", &
description="Uses the CS1 functional", &
n_keywords=0, n_subsections=0, repeats=.FALSE.)
Expand Down Expand Up @@ -789,7 +793,9 @@ SUBROUTINE create_libxc_section(section, name, description, usage)
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.)
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", &
Expand Down
11 changes: 10 additions & 1 deletion src/sirius_interface.F
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ MODULE sirius_interface
sirius_option_set_double, sirius_option_set_int, sirius_option_set_logical, &
sirius_option_set_string, sirius_set_atom_position, sirius_set_atom_type_dion, &
sirius_set_atom_type_radial_grid, sirius_set_lattice_vectors, sirius_update_ground_state
USE xc_libxc, ONLY: libxc_check_existence_in_libxc
#include "./base/base_uses.f90"

IMPLICIT NONE
Expand Down Expand Up @@ -181,8 +182,16 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
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)
CALL sirius_option_add_string_to(sctx, 'parameters', 'xc_functionals', section_name)
IF (section_name(1:3) == "XC_") THEN
CALL sirius_option_add_string_to(sctx, 'parameters', 'xc_functionals', section_name)
ELSE
CALL sirius_option_add_string_to(sctx, 'parameters', 'xc_functionals', "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_option_add_string_to(sctx, 'parameters', 'xc_functionals', "XC_"//TRIM(xc_fun%section%name))
ENDIF
END DO
ENDIF
Expand Down
14 changes: 12 additions & 2 deletions src/xc/xc_derivatives.F
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ SUBROUTINE xc_functional_get_info(functional, lsd, reference, shortform, &
CASE ("SRLDA")
CALL sr_lda_info(reference, shortform, lsd, needs, max_deriv)
CASE default
CPABORT("unknown functional '"//TRIM(functional%section%name)//"'")
! If the functional has not been implemented internally, it's from 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)
ENDIF
END SELECT
END SUBROUTINE xc_functional_get_info

Expand Down Expand Up @@ -551,7 +556,12 @@ SUBROUTINE xc_functional_eval(functional, lsd, rho_set, deriv_set, deriv_order)
CALL sr_lda_eval(rho_set, deriv_set, deriv_order, functional)
END IF
CASE default
CPABORT("unknown functional '"//TRIM(functional%section%name)//"'")
! If functional not natively supported, ask 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)
ENDIF
END SELECT

CALL timestop(handle)
Expand Down

0 comments on commit a3c0186

Please sign in to comment.