33 use,
intrinsic :: iso_fortran_env
53#ifdef HAVE_LIBXC_FUNCS
83 real(real64),
pointer :: rho(:,:)
85 real(real64),
allocatable :: dens(:,:)
86 real(real64),
allocatable :: gdens(:,:,:)
87 real(real64),
allocatable :: ldens(:,:)
88 real(real64),
allocatable :: tau(:,:)
94 integer,
public :: family
95 integer,
public :: flags
96 integer,
public :: kernel_family
97 type(xc_functional_t),
public :: functional(2,2)
100 type(xc_functional_t),
public :: kernel(2,2)
101 real(real64),
public :: kernel_lrc_alpha
102 real(real64),
public :: kernel_proca_a_zero
103 real(real64),
public :: kernel_proca_a_one
104 type(xc_cam_t),
public :: cam
106 logical :: use_gi_ked
107 integer :: xc_density_correction
108 logical :: xcd_optimize_cutoff
109 real(real64) :: xcd_ncutoff
110 logical :: xcd_minimum
111 logical :: xcd_normalize
114 type(internal_quantities_t) :: quantities
122 real(real64),
public,
parameter :: xc_tiny = 1.0e-12_real64
124 integer,
parameter :: &
132 type(xc_t),
intent(in) :: xcs
133 integer,
optional,
intent(in) :: iunit
134 type(namespace_t),
optional,
intent(in) :: namespace
140 write(
message(1),
'(a)')
"Exchange-correlation:"
147 if (abs(xcs%cam%alpha + xcs%cam%beta) >
m_epsilon)
then
149 write(
message(2),
'(a,f8.5)')
"Exact exchange mixing = ", xcs%cam%alpha
150 write(
message(3),
'(a,f8.5)')
"Exact exchange for short-range beta = ", xcs%cam%beta
151 write(
message(4),
'(a,f8.5)')
"Exact exchange range-separate omega = ", xcs%cam%omega
161 type(xc_t),
intent(in) :: xcs
162 integer,
optional,
intent(in) :: iunit
163 type(namespace_t),
optional,
intent(in) :: namespace
169 write(
message(1),
'(a)')
"Exchange-correlation kernel:"
181 subroutine xc_init(xcs, namespace, ndim, periodic_dim, nel, x_id, c_id, xk_id, ck_id, hartree_fock, ispin)
184 integer,
intent(in) :: ndim
185 integer,
intent(in) :: periodic_dim
186 real(real64),
intent(in) :: nel
187 integer,
intent(in) :: x_id
188 integer,
intent(in) :: c_id
189 integer,
intent(in) :: xk_id
190 integer,
intent(in) :: ck_id
192 integer,
intent(in) :: ispin
194 integer :: isp, xc_major, xc_minor, xc_micro
201 call xc_f03_version(xc_major, xc_minor, xc_micro)
205 xcs%kernel_family = 0
223 xcs%family = ior(xcs%family, xcs%functional(
func_x,1)%family)
224 xcs%family = ior(xcs%family, xcs%functional(
func_c,1)%family)
226 xcs%flags = ior(xcs%flags, xcs%functional(
func_x,1)%flags)
227 xcs%flags = ior(xcs%flags, xcs%functional(
func_c,1)%flags)
229 xcs%kernel_family = ior(xcs%kernel_family, xcs%kernel(
func_x,1)%family)
230 xcs%kernel_family = ior(xcs%kernel_family, xcs%kernel(
func_c,1)%family)
234 message(1) =
"Cannot perform a periodic calculation with a functional"
235 message(2) =
"that depends on the number of electrons."
247 message(1) =
"You cannot use an exchange functional when performing"
248 message(2) =
"a Hartree-Fock calculation or using a hybrid functional."
252 if (periodic_dim == ndim)
then
253 call messages_experimental(
"Fock operator (Hartree-Fock, OEP, hybrids) in fully periodic systems", namespace=namespace)
259 call xc_f03_hyb_cam_coef(xcs%functional(
func_c,1)%conf, xcs%cam%omega, &
260 xcs%cam%alpha, xcs%cam%beta)
261 call xc_f03_hyb_cam_coef(xcs%functional(
func_c,2)%conf, xcs%cam%omega, &
262 xcs%cam%alpha, xcs%cam%beta)
269 xcs%functional(
func_x,1)%family = xc_family_oep
271 xcs%functional(
func_x,2)%family = xc_family_oep
274 xcs%family = ior(xcs%family, xc_family_oep)
278 if (
in_family(xcs%family, [xc_family_lca]))
then
285 if (xcs%functional(
func_x, 1)%id == xc_mgga_x_tb09 .and. periodic_dim /= 3)
then
286 message(1) =
"mgga_x_tb09 functional can only be used for 3D periodic systems"
330 if (abs(xcs%kernel_lrc_alpha) >
m_epsilon)
then
344 if (abs(xcs%kernel_proca_a_zero) >
m_epsilon)
then
358 if (abs(xcs%kernel_proca_a_one) >
m_epsilon)
then
374 call parse_variable(namespace,
'XCDensityCorrection', lr_none, xcs%xc_density_correction)
376 if (xcs%xc_density_correction /= lr_none)
then
394 call parse_variable(namespace,
'XCDensityCorrectionOptimize', .
true., xcs%xcd_optimize_cutoff)
427 call parse_variable(namespace,
'XCDensityCorrectionNormalize', .
true., xcs%xcd_normalize)
452 if(
parse_block(namespace,
'HybridCamParameters', blk) == 0)
then
459 if(.not. cam_ext%is_null())
then
460 call cam_ext%print(namespace,
msg=
"Info: Setting external CAM parameters")
471 type(
xc_t),
intent(inout) :: xcs
494 logical pure function xc_is_orbital_dependent(xcs)
495 type(
xc_t),
intent(in) :: xcs
506 integer,
intent(in) :: family
507 logical,
optional,
intent(in) :: only_collinear
509 if(optional_default(only_collinear, .false.))
then
511 xc_family_mgga, xc_family_hyb_mgga, xc_family_libvdwxc])
514 xc_family_mgga, xc_family_hyb_mgga, xc_family_libvdwxc, xc_family_nc_mgga])
524 integer,
intent(in) :: family
527 xc_family_mgga, xc_family_hyb_mgga, xc_family_libvdwxc])
533 integer,
optional,
intent(in) :: family
534 logical,
optional,
intent(in) :: only_collinear
536 if(optional_default(only_collinear, .false.))
then
545 logical pure function family_is_mgga_with_exc(xcs)
546 type(
xc_t),
intent(in) :: xcs
552 if (
in_family(xcs%functional(ixc, 1)%family, [xc_family_mgga, xc_family_hyb_mgga, xc_family_nc_mgga]) &
553 .and. xc_functional_is_energy_functional(xcs%functional(ixc, 1)))
then
560 logical pure function family_is_hybrid(xcs)
561 type(
xc_t),
intent(in) :: xcs
567 if (
in_family(xcs%functional(ixc, 1)%family, [xc_family_hyb_lda, xc_family_hyb_gga, xc_family_hyb_mgga]))
then
573 pure logical function in_family(family, xc_families)
574 integer,
intent(in) :: family
575 integer,
intent(in) :: xc_families(:)
577 in_family = bitand(family, sum(xc_families)) /= 0
582 class(
xc_t),
intent(in) :: xc
583 integer,
intent(in) :: theory_level
585 integer,
parameter :: exchange_theory_level(3) = [hartree, hartree_fock, rdmft]
590 (theory_level == generalized_kohn_sham_dft .and.
family_is_hybrid(xc)) .or. &
591 (xc%functional(func_x, 1)%id == xc_oep_x_slater) .or. &
592 (bitand(xc%family, xc_family_oep) /= 0)
601 real(real64),
intent(in) :: global(:,:)
602 real(real64),
intent(out) :: local(:,:)
603 integer,
intent(in) :: n_block
604 integer,
intent(in) :: nspin
605 integer,
intent(in) :: ip
614 local(is, ib) = global(ib + ip - 1, is)
623 real(real64),
intent(in) :: local(:,:)
624 real(real64),
intent(inout) :: global(:,:)
625 integer,
intent(in) :: n_block
626 integer,
intent(in) :: spin_channels
627 integer,
intent(in) :: ip
633 do is = 1, spin_channels
636 global(ib + ip - 1, is) = global(ib + ip - 1, is) + local(is, ib)
646 type(
xc_t),
intent(inout) :: xcs
647 type(namespace_t),
intent(in) :: namespace
648 type(xc_cam_t),
intent(in) :: cam_ext
650 real(real64),
parameter :: default_alpha_pbe0 = 0.25_real64
659 select case(xcs%functional(func_c, 1)%id)
661 case(xc_hyb_gga_xc_pbeh, xc_hyb_lda_xc_lda0)
663 call xc_f03_func_set_ext_params(xcs%functional(func_c, 1)%conf,
parameters)
664 call xc_f03_func_set_ext_params(xcs%functional(func_c, 2)%conf,
parameters)
665 write(message(1),
'(a,f6.3,a)')
'Info: Setting mixing parameter (' ,
parameters(1) ,
').'
666 call messages_info(1)
668 case(xc_hyb_gga_xc_cam_pbeh, xc_hyb_lda_xc_cam_lda0)
672 call xc_f03_hyb_cam_coef(xcs%functional(func_c,1)%conf, xcs%cam%omega, &
673 xcs%cam%alpha, xcs%cam%beta)
674 call xc_f03_hyb_cam_coef(xcs%functional(func_c,2)%conf, xcs%cam%omega, &
675 xcs%cam%alpha, xcs%cam%beta)
676 call xcs%cam%print(namespace, msg=
"Setting CAM parameters:")
689 type(
xc_t),
intent(in) :: xcs
690 type(namespace_t),
intent(in) :: namespace
693 .or. xc_functional_is_not_size_consistent(xcs%functional(func_c,1), namespace)
698 logical pure function xc_is_energy_functional(xcs)
699 type(
xc_t),
intent(in) :: xcs
701 .or. xc_functional_is_energy_functional(xcs%functional(func_c,1))
704#include "xc_vxc_inc.F90"
705#include "xc_fxc_inc.F90"
706#include "xc_kxc_inc.F90"
708#include "xc_vxc_nc_inc.F90"
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public unpolarized
Parameters...
real(real64), parameter, public m_zero
integer, parameter, public hartree_fock
real(real64), parameter, public m_epsilon
This module implements the underlying real-space grid.
This module is intended to contain "only mathematical" functions and procedures.
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_not_implemented(feature, namespace)
character(len=512), private msg
subroutine, public messages_obsolete_variable(namespace, name, rep)
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_experimental(name, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
This module handles spin dimensions of the states and the k-point distribution.
This module defines the unit system, used for input and output.
type(xc_cam_t), parameter, public cam_null
All CAM parameters set to zero.
type(xc_cam_t), parameter, public cam_exact_exchange
Use only Hartree Fock exact exchange.
subroutine, public xc_functional_write_info(functl, iunit, namespace)
Write functional information.
subroutine, public xc_functional_init(functl, namespace, id, ndim, nel, spin_channels)
integer, parameter, public xc_family_nc_mgga
integer, parameter, public xc_oep_x
Exact exchange.
subroutine, public xc_functional_end(functl)
integer, parameter, public func_c
integer, parameter, public func_x
subroutine, public xc_write_info(xcs, iunit, namespace)
subroutine xc_compute_vxc(der, xcs, st, psolver, namespace, space, quantities, ispin, vxc, ex, ec, deltaxc, vtau, ex_density, ec_density, stress_xc)
subroutine, public xc_init(xcs, namespace, ndim, periodic_dim, nel, x_id, c_id, xk_id, ck_id, hartree_fock, ispin)
subroutine, public xc_get_kxc(xcs, mesh, namespace, rho, ispin, kxc)
pure logical function family_is_supported(family)
Is the xc family internally supported by Octopus.
pure logical function, public family_is_mgga(family, only_collinear)
Is the xc function part of the mGGA family.
subroutine set_hybrid_params(xcs, namespace, cam_ext)
Sets external parameters for some hybrid functionals.
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
subroutine, public xc_end(xcs)
logical pure function, public xc_is_energy_functional(xcs)
Is one of the x or c functional is not an energy functional.
subroutine, public xc_get_vxc(gr, xcs, st, kpoints, psolver, namespace, space, rho, ispin, rcell_volume, vxc, ex, ec, deltaxc, vtau, ex_density, ec_density, stress_xc, force_orbitalfree)
logical pure function, public family_is_hybrid(xcs)
Returns true if the functional is an hybrid functional.
logical function, public xc_is_not_size_consistent(xcs, namespace)
Is one of the x or c functional is not size consistent.
subroutine copy_local_to_global(local, global, n_block, spin_channels, ip)
subroutine, public xc_get_nc_vxc(gr, xcs, st, kpoints, space, namespace, rho, vxc, ex, ec, vtau, ex_density, ec_density)
This routines is similar to xc_get_vxc but for noncollinear functionals, which are not implemented in...
pure logical function family_is_nc_mgga(family)
Returns true is the functional is a noncollinear functional.
subroutine, public xc_get_fxc(xcs, gr, namespace, rho, ispin, fxc, fxc_grad, fxc_grad_spin)
Returns the exchange-correlation kernel.
pure logical function family_is_gga(family, only_collinear)
Is the xc function part of the GGA family.
logical function xc_compute_exchange(xc, theory_level)
Theory levels and functionals for which exacy exchange is required.
pure logical function, public in_family(family, xc_families)
subroutine, public xc_write_fxc_info(xcs, iunit, namespace)
subroutine copy_global_to_local(global, local, n_block, nspin, ip)
make a local copy with the correct memory order for libxc
logical pure function, public xc_is_orbital_dependent(xcs)
Is the xc family orbital dependent.
Coulomb-attenuating method parameters, used in the partitioning of the Coulomb potential into a short...