Octopus
xc.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module xc_oct_m
22 use comm_oct_m
23 use debug_oct_m
28 use global_oct_m
29 use grid_oct_m
30 use io_oct_m
32 use iso_c_binding
33 use, intrinsic :: iso_fortran_env
38 use math_oct_m
39 use mesh_oct_m
42 use mpi_oct_m
44 use parser_oct_m
47 use space_oct_m
51 use xc_cam_oct_m
52 use xc_f03_lib_m
53#ifdef HAVE_LIBXC_FUNCS
54 use xc_f03_funcs_m
55#endif
56 use xc_fbe_oct_m
59
60 implicit none
61
62 private
63 public :: &
64 xc_t, &
65 xc_init, &
66 xc_end, &
69 xc_get_vxc, &
71 xc_get_fxc, &
72 xc_get_kxc, &
80
81 ! A Structure that contains the quantities needed to compute the functionals
83 real(real64), pointer :: rho(:,:) ! A pointer to the full density
84
85 real(real64), allocatable :: dens(:,:) ! Density (in the local frame of the magnetization)
86 real(real64), allocatable :: gdens(:,:,:) ! Gradient of the density
87 real(real64), allocatable :: ldens(:,:) ! Laplacian of the density
88 real(real64), allocatable :: tau(:,:) ! Kinetic energy density
90
91
92 type xc_t
93 private
94 integer, public :: family
95 integer, public :: flags
96 integer, public :: kernel_family
97 type(xc_functional_t), public :: functional(2,2)
99
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
105
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
112 logical :: parallel
113
114 type(internal_quantities_t) :: quantities
115
116 contains
117 procedure :: compute_exchange => xc_compute_exchange
118
119 end type xc_t
120
122 real(real64), public, parameter :: xc_tiny = 1.0e-12_real64
123
124 integer, parameter :: &
125 LR_NONE = 0, &
126 lr_x = 1
127
128contains
129
130 ! ---------------------------------------------------------
131 subroutine xc_write_info(xcs, iunit, namespace)
132 type(xc_t), intent(in) :: xcs
133 integer, optional, intent(in) :: iunit
134 type(namespace_t), optional, intent(in) :: namespace
135
136 integer :: ifunc
137
138 push_sub(xc_write_info)
139
140 write(message(1), '(a)') "Exchange-correlation:"
141 call messages_info(1, iunit=iunit, namespace=namespace)
142
143 do ifunc = func_x, func_c
144 call xc_functional_write_info(xcs%functional(ifunc, 1), iunit, namespace)
145 end do
146
147 if (abs(xcs%cam%alpha + xcs%cam%beta) > m_epsilon) then
148 write(message(1), '(1x)')
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
152 call messages_info(4, iunit=iunit, namespace=namespace)
153 end if
154
155
156 pop_sub(xc_write_info)
157 end subroutine xc_write_info
158
159 ! ---------------------------------------------------------
160 subroutine xc_write_fxc_info(xcs, iunit, namespace)
161 type(xc_t), intent(in) :: xcs
162 integer, optional, intent(in) :: iunit
163 type(namespace_t), optional, intent(in) :: namespace
164
165 integer :: ifunc
166
167 push_sub(xc_write_fxc_info)
168
169 write(message(1), '(a)') "Exchange-correlation kernel:"
170 call messages_info(1, iunit=iunit, namespace=namespace)
171
172 do ifunc = func_x, func_c
173 call xc_functional_write_info(xcs%kernel(ifunc, 1), iunit, namespace)
174 end do
175
176 pop_sub(xc_write_fxc_info)
177 end subroutine xc_write_fxc_info
179
180 ! ---------------------------------------------------------
181 subroutine xc_init(xcs, namespace, ndim, periodic_dim, nel, x_id, c_id, xk_id, ck_id, hartree_fock, ispin)
182 type(xc_t), intent(out) :: xcs
183 type(namespace_t), intent(in) :: namespace
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
191 logical, intent(in) :: hartree_fock
192 integer, intent(in) :: ispin
193
194 integer :: isp, xc_major, xc_minor, xc_micro
195 logical :: ll
196 type(block_t) :: blk
197 type(xc_cam_t) :: cam_ext
199 push_sub(xc_init)
200
201 call xc_f03_version(xc_major, xc_minor, xc_micro)
203 xcs%family = 0
204 xcs%flags = 0
205 xcs%kernel_family = 0
207 call parse()
208
209 !we also need XC functionals that do not depend on the current
210 !get both spin-polarized and unpolarized
211
212 ! TODO: check that nel should not be spin polarized here
213 do isp = 1, 2
214
215 call xc_functional_init(xcs%functional(func_x, isp), namespace, x_id, ndim, nel, isp)
216 call xc_functional_init(xcs%functional(func_c, isp), namespace, c_id, ndim, nel, isp)
218 call xc_functional_init(xcs%kernel(func_x, isp), namespace, xk_id, ndim, nel, isp)
219 call xc_functional_init(xcs%kernel(func_c, isp), namespace, ck_id, ndim, nel, isp)
220
221 end do
222
223 xcs%family = ior(xcs%family, xcs%functional(func_x,1)%family)
224 xcs%family = ior(xcs%family, xcs%functional(func_c,1)%family)
225
226 xcs%flags = ior(xcs%flags, xcs%functional(func_x,1)%flags)
227 xcs%flags = ior(xcs%flags, xcs%functional(func_c,1)%flags)
228
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)
231
232
233 if (xc_is_not_size_consistent(xcs, namespace) .and. periodic_dim > 0) then
234 message(1) = "Cannot perform a periodic calculation with a functional"
235 message(2) = "that depends on the number of electrons."
236 call messages_fatal(2, namespace=namespace)
237 end if
238
239 ! Take care of hybrid functionals (they appear in the correlation functional)
240 xcs%cam = cam_null
241
242 ll = (hartree_fock) &
243 .or.(xcs%functional(func_x,1)%id == xc_oep_x) &
244 .or. family_is_hybrid(xcs)
245 if (ll) then
246 if ((xcs%functional(func_x,1)%id /= 0).and.(xcs%functional(func_x,1)%id /= xc_oep_x)) then
247 message(1) = "You cannot use an exchange functional when performing"
248 message(2) = "a Hartree-Fock calculation or using a hybrid functional."
249 call messages_fatal(2, namespace=namespace)
250 end if
251
252 if (periodic_dim == ndim) then
253 call messages_experimental("Fock operator (Hartree-Fock, OEP, hybrids) in fully periodic systems", namespace=namespace)
254 end if
256 ! get the mixing coefficient for hybrids
257 if (family_is_hybrid(xcs)) then
258 if( .not. cam_ext%is_null() ) call set_hybrid_params(xcs, namespace, cam_ext)
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)
263 else
264 ! we are doing Hartree-Fock plus possibly a correlation functional
265 xcs%cam = cam_exact_exchange
266 end if
267
268 ! reset certain variables
269 xcs%functional(func_x,1)%family = xc_family_oep
270 xcs%functional(func_x,1)%id = xc_oep_x
271 xcs%functional(func_x,2)%family = xc_family_oep
272 xcs%functional(func_x,2)%id = xc_oep_x
273 if (.not. hartree_fock) then
274 xcs%family = ior(xcs%family, xc_family_oep)
275 end if
276 end if
277
278 if (in_family(xcs%family, [xc_family_lca])) then
279 call messages_not_implemented("LCA current functionals", namespace) ! not even in libxc!
280 end if
281
282 call messages_obsolete_variable(namespace, 'MGGAimplementation')
283 call messages_obsolete_variable(namespace, 'CurrentInTau', 'XCUseGaugeIndependentKED')
284
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"
287 call messages_fatal(1, namespace=namespace)
288 end if
289
290 if (family_is_mgga(xcs%family) .or. family_is_nc_mgga(xcs%family)) then
291 !%Variable XCUseGaugeIndependentKED
292 !%Type logical
293 !%Default yes
294 !%Section Hamiltonian::XC
295 !%Description
296 !% If true, when evaluating the XC functional, a term including the (paramagnetic or total) current
297 !% is added to the kinetic-energy density such as to make it gauge-independent.
298 !% Applies only to meta-GGA (and hybrid meta-GGA) functionals.
299 !%End
300 call parse_variable(namespace, 'XCUseGaugeIndependentKED', .true., xcs%use_gi_ked)
301 end if
302
303 pop_sub(xc_init)
304
305 contains
306
307 subroutine parse()
308
309 push_sub(xc_init.parse)
310
311 ! the values of x_id, c_id, xk_id, and c_id are read outside the routine
312
313 !%Variable XCKernelLRCAlpha
314 !%Type float
315 !%Default 0.0
316 !%Section Hamiltonian::XC
317 !%Description
318 !% Set to a non-zero value to add a long-range correction for solids to the kernel.
319 !% This is the <math>\alpha</math> parameter defined in S. Botti <i>et al.</i>, <i>Phys. Rev. B</i>
320 !% 69, 155112 (2004). The <math>\Gamma = \Gamma` = 0</math> term <math>-\alpha/q^2</math> is taken
321 !% into account by introducing an additional pole to the polarizability (see R. Stubner
322 !% <i>et al.</i>, <i>Phys. Rev. B</i> 70, 245119 (2004)). The rest of the terms are included by
323 !% multiplying the Hartree term by <math>1 - \alpha / 4 \pi</math>. The use of non-zero
324 !% <math>\alpha</math> in combination with <tt>HamiltonianVariation</tt> = <tt>V_ext_only</tt>
325 !% corresponds to account of only the <math>\Gamma = \Gamma` = 0</math> term.
326 !% Applicable only to isotropic systems. (Experimental)
327 !%End
328
329 call parse_variable(namespace, 'XCKernelLRCAlpha', m_zero, xcs%kernel_lrc_alpha)
330 if (abs(xcs%kernel_lrc_alpha) > m_epsilon) then
331 call messages_experimental("Long-range correction to kernel", namespace=namespace)
332 end if
333
334 !%Variable XCProcaResonantTerm
335 !%Type float
336 !%Default 0.0
337 !%Section Hamiltonian :: XC
338 !%Description
339 !% This variable is the a_0 parameter in the Proca equation
340 !% Set to a nonzero value to give to the Maxwell equation a linear term correction as suggested in
341 !% J. K. Dewhurst <i>et al.</i>, <i>Phys. Rev. B</i> 111, L060302 (2025).
342 !%End
343 call parse_variable(namespace, 'XCProcaResonantTerm', m_zero, xcs%kernel_proca_a_zero)
344 if (abs(xcs%kernel_proca_a_zero) > m_epsilon) then
345 call messages_experimental("Proca equation a0", namespace=namespace)
346 end if
347
348 !%Variable XCProcaDamping
349 !%Type float
350 !%Default 0.0
351 !%Section Hamiltonian :: XC
352 !%Description
353 !% This variable is the a_1 parameter in the Proca equation
354 !% Set to a nonzero value to give to the Maxwell equation a first-order derivative term correction as suggested in
355 !% J. K. Dewhurst <i>et al.</i>, <i>Phys. Rev. B</i> 111, L060302 (2025).
356 !%End
357 call parse_variable(namespace, 'XCProcaDamping', m_zero, xcs%kernel_proca_a_one)
358 if (abs(xcs%kernel_proca_a_one) > m_epsilon) then
359 call messages_experimental("Proca equation a1", namespace=namespace)
360 end if
361
362 !%Variable XCDensityCorrection
363 !%Type integer
364 !%Default none
365 !%Section Hamiltonian::XC::DensityCorrection
366 !%Description
367 !% This variable controls the long-range correction of the XC
368 !% potential using the <a href=http://arxiv.org/abs/1107.4339>XC density representation</a>.
369 !%Option none 0
370 !% No correction is applied.
371 !%Option long_range_x 1
372 !% The correction is applied to the exchange potential.
373 !%End
374 call parse_variable(namespace, 'XCDensityCorrection', lr_none, xcs%xc_density_correction)
375
376 if (xcs%xc_density_correction /= lr_none) then
377 call messages_experimental('XC density correction', namespace=namespace)
378
379 if(ispin /= unpolarized) then
380 call messages_not_implemented('XCDensityCorrection with SpinComponents /= unpolarized', namespace)
381 end if
382
383 !%Variable XCDensityCorrectionOptimize
384 !%Type logical
385 !%Default true
386 !%Section Hamiltonian::XC::DensityCorrection
387 !%Description
388 !% When enabled, the density cutoff will be
389 !% optimized to replicate the boundary conditions of the exact
390 !% XC potential. If the variable is set to no, the value of
391 !% the cutoff must be given by the <tt>XCDensityCorrectionCutoff</tt>
392 !% variable.
393 !%End
394 call parse_variable(namespace, 'XCDensityCorrectionOptimize', .true., xcs%xcd_optimize_cutoff)
395
396 !%Variable XCDensityCorrectionCutoff
397 !%Type float
398 !%Default 0.0
399 !%Section Hamiltonian::XC::DensityCorrection
400 !%Description
401 !% The value of the cutoff applied to the XC density.
402 !%End
403 call parse_variable(namespace, 'XCDensityCorrectionCutoff', m_zero, xcs%xcd_ncutoff)
404
405 !%Variable XCDensityCorrectionMinimum
406 !%Type logical
407 !%Default true
408 !%Section Hamiltonian::XC::DensityCorrection
409 !%Description
410 !% When enabled, the cutoff optimization will
411 !% return the first minimum of the <math>q_{xc}</math> function if it does
412 !% not find a value of -1 (<a href=http://arxiv.org/abs/1107.4339>details</a>).
413 !% This is required for atoms or small
414 !% molecules, but may cause numerical problems.
415 !%End
416 call parse_variable(namespace, 'XCDensityCorrectionMinimum', .true., xcs%xcd_minimum)
417
418 !%Variable XCDensityCorrectionNormalize
419 !%Type logical
420 !%Default true
421 !%Section Hamiltonian::XC::DensityCorrection
422 !%Description
423 !% When enabled, the correction will be
424 !% normalized to reproduce the exact boundary conditions of
425 !% the XC potential.
426 !%End
427 call parse_variable(namespace, 'XCDensityCorrectionNormalize', .true., xcs%xcd_normalize)
428
429 end if
430
431 !%Variable ParallelXC
432 !%Type logical
433 !%Default true
434 !%Section Execution::Parallelization
435 !%Description
436 !% When enabled, additional parallelization
437 !% will be used for the calculation of the XC functional.
438 !%End
439 call messages_obsolete_variable(namespace, 'XCParallel', 'ParallelXC')
440 call parse_variable(namespace, 'ParallelXC', .true., xcs%parallel)
441
442
443 !%Variable HybridCAMParameters
444 !%Type block
445 !%Section Hamiltonian::XC
446 !%Description
447 !% This variable specifies the <math>\alpha, \beta, \omega<math> for CAM-type
448 !% hybrid functionals. Defaults are zero.
449 !%End
450 cam_ext = cam_null
451
452 if(parse_block(namespace, 'HybridCamParameters', blk) == 0) then
453 call parse_block_float(blk, 0, 0, cam_ext%alpha)
454 call parse_block_float(blk, 0, 1, cam_ext%beta)
455 call parse_block_float(blk, 0, 2, cam_ext%omega)
456 call parse_block_end(blk)
457 end if
458
459 if(.not. cam_ext%is_null()) then
460 call cam_ext%print(namespace, msg="Info: Setting external CAM parameters")
461 endif
462
463 pop_sub(xc_init.parse)
464 end subroutine parse
465
466 end subroutine xc_init
467
468
469 ! ---------------------------------------------------------
470 subroutine xc_end(xcs)
471 type(xc_t), intent(inout) :: xcs
472
473 integer :: isp
474
475 push_sub(xc_end)
476
477 do isp = 1, 2
478 call xc_functional_end(xcs%functional(func_x, isp))
479 call xc_functional_end(xcs%functional(func_c, isp))
480 call xc_functional_end(xcs%kernel(func_x, isp))
481 call xc_functional_end(xcs%kernel(func_c, isp))
482 end do
483 xcs%family = 0
484 xcs%flags = 0
485
486 pop_sub(xc_end)
487 end subroutine xc_end
488
489 ! ---------------------------------------------------------
494 logical pure function xc_is_orbital_dependent(xcs)
495 type(xc_t), intent(in) :: xcs
496
497 xc_is_orbital_dependent = family_is_hybrid(xcs) .or. &
498 in_family(xcs%functional(func_x,1)%family, [xc_family_oep]) .or. &
499 in_family(xcs%family, [xc_family_mgga, xc_family_nc_mgga])
500
501 end function xc_is_orbital_dependent
502
503 ! ---------------------------------------------------------
505 pure logical function family_is_gga(family, only_collinear)
506 integer, intent(in) :: family
507 logical, optional, intent(in) :: only_collinear
508
509 if(optional_default(only_collinear, .false.)) then
510 family_is_gga = in_family(family, [xc_family_gga, xc_family_hyb_gga, &
511 xc_family_mgga, xc_family_hyb_mgga, xc_family_libvdwxc])
512 else
513 family_is_gga = in_family(family, [xc_family_gga, xc_family_hyb_gga, &
514 xc_family_mgga, xc_family_hyb_mgga, xc_family_libvdwxc, xc_family_nc_mgga])
515 end if
516 end function family_is_gga
517
518 !----------------------------------------------------------------------
523 pure logical function family_is_supported(family)
524 integer, intent(in) :: family
525
526 family_is_supported = in_family(family, [xc_family_lda, xc_family_hyb_lda, xc_family_gga, xc_family_hyb_gga, &
527 xc_family_mgga, xc_family_hyb_mgga, xc_family_libvdwxc])
528 end function family_is_supported
529
530 ! ---------------------------------------------------------
532 pure logical function family_is_mgga(family, only_collinear)
533 integer, optional, intent(in) :: family
534 logical, optional, intent(in) :: only_collinear
535
536 if(optional_default(only_collinear, .false.)) then
537 family_is_mgga = in_family(family, [xc_family_mgga, xc_family_hyb_mgga])
538 else
539 family_is_mgga = in_family(family, [xc_family_mgga, xc_family_hyb_mgga, xc_family_nc_mgga])
540 end if
541 end function family_is_mgga
542
543 ! ---------------------------------------------------------
545 logical pure function family_is_mgga_with_exc(xcs)
546 type(xc_t), intent(in) :: xcs
547
548 integer :: ixc
549
551 do ixc = 1, 2
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
555 end if
556 end do
557 end function family_is_mgga_with_exc
558
560 logical pure function family_is_hybrid(xcs)
561 type(xc_t), intent(in) :: xcs
562
563 integer :: ixc
564
566 do ixc = 1, 2
567 if (in_family(xcs%functional(ixc, 1)%family, [xc_family_hyb_lda, xc_family_hyb_gga, xc_family_hyb_mgga])) then
569 end if
570 end do
571 end function family_is_hybrid
572
573 pure logical function in_family(family, xc_families)
574 integer, intent(in) :: family
575 integer, intent(in) :: xc_families(:)
576
577 in_family = bitand(family, sum(xc_families)) /= 0
578 end function in_family
579
581 logical function xc_compute_exchange(xc, theory_level)
582 class(xc_t), intent(in) :: xc
583 integer, intent(in) :: theory_level
584
585 integer, parameter :: exchange_theory_level(3) = [hartree, hartree_fock, rdmft]
586
587 push_sub(xc_compute_exchange)
588
589 xc_compute_exchange = any(exchange_theory_level == theory_level) .or. &
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)
593
594 pop_sub(xc_compute_exchange)
595
596 end function xc_compute_exchange
597
598 ! ---------------------------------------------------------
600 subroutine copy_global_to_local(global, local, n_block, nspin, ip)
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
606
607 integer :: ib, is
608
609 push_sub(copy_global_to_local)
610
611 do is = 1, nspin
612 !$omp parallel do
613 do ib = 1, n_block
614 local(is, ib) = global(ib + ip - 1, is)
615 end do
616 end do
617
619 end subroutine copy_global_to_local
620
621 ! ---------------------------------------------------------
622 subroutine copy_local_to_global(local, global, n_block, spin_channels, ip)
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
628
629 integer :: ib, is
630
632
633 do is = 1, spin_channels
634 !$omp parallel do
635 do ib = 1, n_block
636 global(ib + ip - 1, is) = global(ib + ip - 1, is) + local(is, ib)
637 end do
638 end do
639
641 end subroutine copy_local_to_global
642
643 ! ---------------------------------------------------------
645 subroutine set_hybrid_params(xcs, namespace, cam_ext)
646 type(xc_t), intent(inout) :: xcs
647 type(namespace_t), intent(in) :: namespace
648 type(xc_cam_t), intent(in) :: cam_ext
649
650 real(real64), parameter :: default_alpha_pbe0 = 0.25_real64
651 real(real64) :: parameters(3)
652
653 push_sub(set_hybrid_params)
654
655 ! LibXC expects an array of reals, ordered [alpha, beta, omega]
656 parameters = cam_ext%as_array()
657 xcs%cam%alpha = parameters(1)
658
659 select case(xcs%functional(func_c, 1)%id)
660
661 case(xc_hyb_gga_xc_pbeh, xc_hyb_lda_xc_lda0) ! original PBE0/LDA0 in libxc
662 if(parameters(1) < m_zero) parameters(1) = default_alpha_pbe0
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)
667
668 case(xc_hyb_gga_xc_cam_pbeh, xc_hyb_lda_xc_cam_lda0)
669 xcs%cam%beta = parameters(2)
670 xcs%cam%omega = parameters(3)
671 ! check parameters
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:")
677
678 case default
679 assert(.false.)
680
681 end select
682
683 pop_sub(set_hybrid_params)
684 end subroutine set_hybrid_params
685
686 ! ---------------------------------------------------------
688 logical function xc_is_not_size_consistent(xcs, namespace)
689 type(xc_t), intent(in) :: xcs
690 type(namespace_t), intent(in) :: namespace
691
692 xc_is_not_size_consistent = xc_functional_is_not_size_consistent(xcs%functional(func_x,1), namespace) &
693 .or. xc_functional_is_not_size_consistent(xcs%functional(func_c,1), namespace)
694 end function xc_is_not_size_consistent
696 ! ---------------------------------------------------------
698 logical pure function xc_is_energy_functional(xcs)
699 type(xc_t), intent(in) :: xcs
700 xc_is_energy_functional = xc_functional_is_energy_functional(xcs%functional(func_x,1)) &
701 .or. xc_functional_is_energy_functional(xcs%functional(func_c,1))
702 end function xc_is_energy_functional
703
704#include "xc_vxc_inc.F90"
705#include "xc_fxc_inc.F90"
706#include "xc_kxc_inc.F90"
707
708#include "xc_vxc_nc_inc.F90"
709
710end module xc_oct_m
711
712
713!! Local Variables:
714!! mode: f90
715!! coding: utf-8
716!! End:
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public unpolarized
Parameters...
real(real64), parameter, public m_zero
Definition: global.F90:190
integer, parameter, public hartree_fock
Definition: global.F90:236
real(real64), parameter, public m_epsilon
Definition: global.F90:206
This module implements the underlying real-space grid.
Definition: grid.F90:119
Definition: io.F90:116
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:117
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1097
character(len=512), private msg
Definition: messages.F90:167
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1029
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:416
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1069
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:600
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:621
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.
Definition: xc_cam.F90:152
type(xc_cam_t), parameter, public cam_exact_exchange
Use only Hartree Fock exact exchange.
Definition: xc_cam.F90:155
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
Definition: xc.F90:116
subroutine, public xc_write_info(xcs, iunit, namespace)
Definition: xc.F90:227
subroutine xc_compute_vxc(der, xcs, st, psolver, namespace, space, quantities, ispin, vxc, ex, ec, deltaxc, vtau, ex_density, ec_density, stress_xc)
Definition: xc.F90:1045
subroutine, public xc_init(xcs, namespace, ndim, periodic_dim, nel, x_id, c_id, xk_id, ck_id, hartree_fock, ispin)
Definition: xc.F90:277
subroutine, public xc_get_kxc(xcs, mesh, namespace, rho, ispin, kxc)
Definition: xc.F90:2392
pure logical function family_is_supported(family)
Is the xc family internally supported by Octopus.
Definition: xc.F90:619
pure logical function, public family_is_mgga(family, only_collinear)
Is the xc function part of the mGGA family.
Definition: xc.F90:628
subroutine set_hybrid_params(xcs, namespace, cam_ext)
Sets external parameters for some hybrid functionals.
Definition: xc.F90:741
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
Definition: xc.F90:641
integer, parameter lr_x
Definition: xc.F90:219
subroutine, public xc_end(xcs)
Definition: xc.F90:566
logical pure function, public xc_is_energy_functional(xcs)
Is one of the x or c functional is not an energy functional.
Definition: xc.F90:794
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)
Definition: xc.F90:820
logical pure function, public family_is_hybrid(xcs)
Returns true if the functional is an hybrid functional.
Definition: xc.F90:656
logical function, public xc_is_not_size_consistent(xcs, namespace)
Is one of the x or c functional is not size consistent.
Definition: xc.F90:784
subroutine copy_local_to_global(local, global, n_block, spin_channels, ip)
Definition: xc.F90:718
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...
Definition: xc.F90:2578
pure logical function family_is_nc_mgga(family)
Returns true is the functional is a noncollinear functional.
Definition: xc.F90:3151
subroutine, public xc_get_fxc(xcs, gr, namespace, rho, ispin, fxc, fxc_grad, fxc_grad_spin)
Returns the exchange-correlation kernel.
Definition: xc.F90:2050
pure logical function family_is_gga(family, only_collinear)
Is the xc function part of the GGA family.
Definition: xc.F90:601
logical function xc_compute_exchange(xc, theory_level)
Theory levels and functionals for which exacy exchange is required.
Definition: xc.F90:677
pure logical function, public in_family(family, xc_families)
Definition: xc.F90:669
subroutine, public xc_write_fxc_info(xcs, iunit, namespace)
Definition: xc.F90:256
subroutine copy_global_to_local(global, local, n_block, nspin, ip)
make a local copy with the correct memory order for libxc
Definition: xc.F90:696
logical pure function, public xc_is_orbital_dependent(xcs)
Is the xc family orbital dependent.
Definition: xc.F90:590
Coulomb-attenuating method parameters, used in the partitioning of the Coulomb potential into a short...
Definition: xc_cam.F90:141
int true(void)
subroutine parse()
Definition: xc.F90:403