36#include "functionals_list.F90"
51 integer,
public,
parameter :: &
52 XC_OEP_X = 901, & !< Exact exchange
72 integer,
public,
parameter :: &
73 XC_FAMILY_KS_INVERSION = 1024, &
81 integer :: family = xc_family_unknown
85 integer :: spin_channels = 0
88 logical,
private :: from_libxc = .false.
90 type(xc_f03_func_t) :: conf
91 type(xc_f03_func_info_t),
private :: info
92 type(libvdwxc_t) :: libvdwxc
95 integer,
public,
parameter :: LIBXC_C_INDEX = 1000
101 type(xc_functional_t),
intent(inout) :: functl
102 type(namespace_t),
intent(in) :: namespace
103 integer,
intent(in) :: id
104 integer,
intent(in) :: ndim
105 real(real64),
intent(in) :: nel
106 integer,
intent(in) :: spin_channels
108 integer :: interact_1d
109 real(real64) :: alpha, parameters(2)
115 functl%spin_channels = spin_channels
117 if (functl%id == 0)
then
118 functl%family = xc_family_none
121 functl%family = xc_f03_family_from_id(functl%id)
124 if (functl%family == xc_family_unknown)
then
126 select case (functl%id)
128 functl%family = xc_family_oep
131 functl%family = xc_family_ks_inversion
135 functl%family = xc_family_lda
145 functl%family = xc_family_hyb_gga
157 if (functl%family == xc_family_oep)
then
158 functl%type = xc_exchange
159 functl%flags = xc_flags_1d + xc_flags_2d + xc_flags_3d
161 else if (functl%family == xc_family_ks_inversion .or. functl%family ==
xc_family_rdmft)
then
162 functl%type = xc_exchange_correlation
163 functl%flags = xc_flags_1d + xc_flags_2d + xc_flags_3d
166 call xc_f03_func_init(functl%conf, xc_lda_c_pw, spin_channels)
167 functl%info = xc_f03_func_get_info(functl%conf)
168 functl%type = xc_f03_func_info_get_kind(functl%info)
169 functl%flags = xc_f03_func_info_get_flags(functl%info)
174 functl%type = xc_exchange_correlation
175 functl%flags = xc_flags_1d + xc_flags_2d + xc_flags_3d
178 functl%family = xc_family_lda
179 functl%type = xc_correlation
180 functl%flags = xc_flags_have_exc + xc_flags_have_vxc + xc_flags_3d
183 functl%type = xc_exchange
184 functl%flags = xc_flags_have_vxc + xc_flags_have_exc + xc_flags_3d
187 functl%type = xc_correlation
188 functl%flags = xc_flags_have_vxc + xc_flags_have_exc + xc_flags_3d
190 else if (functl%family == xc_family_none)
then
192 functl%flags = xc_flags_1d + xc_flags_2d + xc_flags_3d
196 functl%from_libxc = .
true.
199 select case (functl%id)
201 call xc_f03_func_init(functl%conf, xc_hyb_gga_xc_hse06, spin_channels)
204 call xc_f03_func_init(functl%conf, xc_hyb_gga_xc_pbeh, spin_channels)
207 call xc_f03_func_init(functl%conf, functl%id, spin_channels)
209 functl%info = xc_f03_func_get_info(functl%conf)
210 functl%type = xc_f03_func_info_get_kind(functl%info)
211 functl%flags = xc_f03_func_info_get_flags(functl%info)
214 if (
bitand(functl%flags, xc_flags_have_exc) == 0)
then
215 message(1) =
'Specified functional does not have total energy available.'
216 message(2) =
'Corresponding component of energy will just be left as zero.'
220 if (
bitand(functl%flags, xc_flags_have_vxc) == 0)
then
221 message(1) =
'Specified functional does not have XC potential available.'
222 message(2) =
'Cannot run calculations. Choose another XCFunctional.'
228 if (functl%family /= xc_family_none)
then
233 if (
bitand(functl%flags, xc_flags_hyb_camy) /= 0)
then
239 select case (functl%id)
241 case (xc_lda_c_xalpha)
253 call xc_f03_func_set_ext_params(functl%conf, parameters(1))
256 case (xc_lda_x_1d_soft, xc_lda_c_1d_csc)
271 call parse_variable(namespace,
'Interaction1D', option__interaction1d__interaction_soft_coulomb, interact_1d)
283 parameters(1) = real(interact_1d, real64)
284 parameters(2) = alpha
285 call xc_f03_func_set_ext_params(functl%conf, parameters(1))
301 assert(xc_f03_func_info_get_n_ext_params(functl%info) == 1)
303 call xc_f03_func_set_ext_params(functl%conf, parameters(1))
304 write(
message(1),
'(a,i1)')
"Info: Setting the number of electrons for the functional for spin ", spin_channels
314 type(xc_functional_t),
intent(inout) :: functl
318 if (functl%family /= xc_family_none .and. functl%family /= xc_family_oep .and. &
319 functl%family /= xc_family_ks_inversion .and. functl%id /=
xc_half_hartree &
322 call xc_f03_func_end(functl%conf)
336 type(xc_functional_t),
intent(in) :: functl
337 integer,
optional,
intent(in) :: iunit
338 type(namespace_t),
optional,
intent(in) :: namespace
340 character(len=120) :: family
345 if (functl%family == xc_family_oep)
then
348 select case (functl%id)
350 write(
message(1),
'(2x,a)')
'Exchange'
351 write(
message(2),
'(4x,a)')
'Exact exchange'
355 write(
message(1),
'(2x,a)')
'Exchange'
356 write(
message(2),
'(4x,a)')
'Slater exchange'
360 write(
message(1),
'(2x,a)')
'Exchange'
361 write(
message(2),
'(4x,a)')
'Force-based local exchange'
362 write(
message(3),
'(4x,a)')
'[1] Tancogne-Dejean et al., J. Chem. Phys. 160, 024103 (2024)'
366 write(
message(1),
'(2x,a)')
'Exchange'
367 write(
message(2),
'(4x,a)')
'Force-based local exchange - Sturm-Liouville'
371 write(
message(1),
'(2x,a)')
'Correlation'
372 write(
message(2),
'(4x,a)')
'Force-based local-density correlation - Sturm-Liouville'
379 else if (functl%family == xc_family_ks_inversion)
then
381 select case (functl%id)
383 write(
message(1),
'(2x,a)')
'Exchange-Correlation:'
384 write(
message(2),
'(4x,a)')
' KS Inversion'
392 write(
message(1),
'(2x,a)')
'Exchange'
393 write(
message(2),
'(4x,a)')
'Noncollinear Becke-Roussel (MGGA)'
394 write(
message(3),
'(4x,a)')
'[1] N. Tancogne-Dejean, A. Rubio, and C. A. Ullrich, Phys. Rev. B 107, 165111 (2023)'
398 write(
message(1),
'(2x,a)')
'Exchange'
399 write(
message(2),
'(4x,a)')
'Noncollinear Becke-Roussel, gamma = 1.0 (MGGA)'
400 write(
message(3),
'(4x,a)')
'[1] N. Tancogne-Dejean, A. Rubio, and C. A. Ullrich, Phys. Rev. B 107, 165111 (2023)'
404 write(
message(1),
'(2x,a)')
'Correlation'
405 write(
message(2),
'(4x,a)')
'Noncollinear Colle-Salvetti (MGGA)'
406 write(
message(3),
'(4x,a)')
'[1] N. Tancogne-Dejean, A. Rubio, and C. A. Ullrich, Phys. Rev. B 107, 165111 (2023)'
411 write(
message(1),
'(2x,a)')
'Exchange-Correlation:'
412 write(
message(2),
'(4x,a)')
'Half-Hartree two-electron exchange'
416 write(
message(1),
'(2x,a)')
'Correlation'
417 write(
message(2),
'(4x,a)')
'Force-based LDA correlation'
420 else if (functl%family /= xc_family_none)
then
421 select case (functl%type)
423 write(
message(1),
'(2x,a)')
'Exchange'
424 case (xc_correlation)
425 write(
message(1),
'(2x,a)')
'Correlation'
426 case (xc_exchange_correlation)
427 write(
message(1),
'(2x,a)')
'Exchange-correlation'
431 write(
message(1),
'(a,i6,a,i6)')
"Unknown functional type ", functl%type,
' for functional ', functl%id
435 select case (functl%family)
437 write(family,
'(a)')
"LDA"
439 write(family,
'(a)')
"GGA"
440 case (xc_family_mgga)
441 write(family,
'(a)')
"MGGA"
444 case (xc_family_hyb_lda)
445 write(family,
'(a)')
"Hybrid LDA"
446 case (xc_family_hyb_gga)
447 write(family,
'(a)')
"Hybrid GGA"
448 case (xc_family_hyb_mgga)
449 write(family,
'(a)')
"Hybrid MGGA"
451 write(
message(2),
'(4x,4a)') trim(xc_f03_func_info_get_name(functl%info)),
' (', trim(family),
')'
456 write(
message(1),
'(4x,a,i1,2a)')
'[', ii + 1,
'] ', &
457 trim(xc_f03_func_reference_get_ref(xc_f03_func_info_get_references(functl%info, ii)))
468 integer,
intent(in) :: dim
469 integer,
intent(in) :: pseudo_x_functional, pseudo_c_functional
476 default = pseudo_x_functional
482 default = xc_lda_x_2d
484 default = xc_lda_x_1d_soft
491 default = default + libxc_c_index*pseudo_c_functional
495 default = default + libxc_c_index * xc_lda_c_pz_mod
497 default = default + libxc_c_index * xc_lda_c_2d_amgb
499 default = default + libxc_c_index * xc_lda_c_1d_csc
510 type(xc_functional_t),
intent(in) :: functl
511 integer,
intent(in) :: ndim
512 type(namespace_t),
intent(in) :: namespace
519 ok =
bitand(functl%flags, xc_flags_1d) /= 0
520 if (ndim == 1 .and. (.not. ok))
then
521 message(1) =
'Cannot use the specified functionals in 1D.'
525 ok =
bitand(functl%flags, xc_flags_2d) /= 0
526 if (ndim == 2 .and. (.not. ok))
then
527 message(1) =
'Cannot use the specified functionals in 2D.'
531 ok =
bitand(functl%flags, xc_flags_3d) /= 0
532 if (ndim == 3 .and. (.not. ok))
then
533 message(1) =
'Cannot use the specified functionals in 3D.'
542 type(xc_functional_t),
intent(in) :: functl
543 type(namespace_t),
intent(in) :: namespace
545 integer :: n_ext_params, ip
546 character(len=128) :: ext_params_name
549 if (.not. functl%from_libxc)
return
554 n_ext_params = xc_f03_func_info_get_n_ext_params(functl%info)
555 do ip = 0, n_ext_params-1
556 ext_params_name = xc_f03_func_info_get_ext_params_name(functl%info, ip)
558 if (ext_params_name(1:1) ==
'_') cycle
559 if (trim(xc_f03_func_info_get_ext_params_description(functl%info, ip)) ==
'Number of electrons')
then
566 message(1) =
'The selected functional is currently not supported.'
573 logical pure function xc_functional_is_energy_functional(functl)
574 type(xc_functional_t),
intent(in) :: functl
576 xc_functional_is_energy_functional =
bitand(functl%flags, xc_flags_have_exc) /= 0
real(real64), parameter, public m_one
subroutine, public libvdwxc_end(this)
subroutine, public libvdwxc_init(libvdwxc, namespace, functional)
subroutine, public libvdwxc_write_info(this, iunit, namespace)
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_experimental(name, namespace)
logical function, public parse_is_defined(namespace, name)
integer, parameter, public pseudo_correlation_any
integer, parameter, public pseudo_exchange_any
integer, parameter, public xc_ks_inversion
inversion of Kohn-Sham potential
integer, parameter, public xc_vdw_c_vdwdf
vdw-df correlation from libvdwxc
integer, parameter, public xc_family_rdmft
subroutine, public xc_functional_write_info(functl, iunit, namespace)
Write functional information.
integer function, public xc_get_default_functional(dim, pseudo_x_functional, pseudo_c_functional)
Returns the default functional given the one parsed from the pseudopotentials and the space dimension...
integer, parameter, public xc_mgga_c_nc_cs
Noncollinear version of the Colle-Salvetti correlation functional.
integer, parameter, public xc_hyb_gga_xc_mvorb_pbeh
Density-based mixing parameter of PBE0.
integer, parameter, public xc_mgga_x_nc_br
Noncollinear version of the Becke-Roussel functional.
integer, parameter, public xc_vdw_c_vdwdfcx
vdw-df-cx correlation from libvdwxc
subroutine, public xc_functional_init(functl, namespace, id, ndim, nel, spin_channels)
integer, parameter, public xc_lda_c_fbe
LDA correlation based ib the force-balance equation.
integer, parameter, public xc_family_nc_mgga
integer, parameter, public xc_half_hartree
half-Hartree exchange for two electrons (supports complex scaling)
integer, parameter, public xc_vdw_c_vdwdf2
vdw-df2 correlation from libvdwxc
subroutine xc_check_dimension(functl, ndim, namespace)
Check that the selected functional is compatible with the space dimension.
integer, parameter, public xc_family_libvdwxc
integer, parameter, public xc_hyb_gga_xc_mvorb_hse06
Density-based mixing parameter of HSE06.
subroutine, public xc_functional_end(functl)
integer, parameter, public xc_lda_c_fbe_sl
LDA correlation based ib the force-balance equation - Sturm-Liouville version.
integer, parameter, public xc_rdmft_xc_m
RDMFT Mueller functional.
integer, parameter, public xc_mgga_x_nc_br_1
Noncollinear version of the Becke-Roussel functional, gamma=1.
logical function, public xc_functional_is_not_size_consistent(functl, namespace)
Does the functional depend on the number of electrons or not.
integer, parameter, public xc_family_nc_lda
integer, parameter, public xc_oep_x_fbe_sl
Exchange approximation based on the force balance equation - Sturn-Liouville version.
integer, parameter, public xc_oep_x_fbe
Exchange approximation based on the force balance equation.
logical pure function, public xc_functional_is_energy_functional(functl)
integer, parameter, public xc_oep_x_slater
Slater approximation to the exact exchange.