Octopus
xc_functional.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
22 use accel_oct_m
23 use debug_oct_m
24 use global_oct_m
25 use iso_c_binding
29 use parser_oct_m
30 use pseudo_oct_m
31 use xc_f03_lib_m
32#ifdef HAVE_LIBXC_FUNCS
33 use xc_f03_funcs_m
34#endif
35
36 implicit none
37
38 ! Although the following file only contain comments, we include it here to make sure it exists.
39 ! Otherwise the code might compile, but not run properly, as the variables documentations
40 ! will be incomplete.
41#include "functionals_list.F90"
42
43 private
44 public :: &
53
54
57 integer, public, parameter :: &
58 XC_OEP_X = 901, & !< Exact exchange
59 xc_oep_x_slater = 902, &
60 xc_oep_x_fbe = 903, &
61 xc_ks_inversion = 904, &
62 xc_rdmft_xc_m = 905, &
63 xc_oep_x_fbe_sl = 906, &
64 xc_lda_c_fbe = 907, &
65 xc_lda_c_fbe_sl = 908, &
66 xc_vdw_c_vdwdf = 918, &
67 xc_vdw_c_vdwdf2 = 919, &
68 xc_vdw_c_vdwdfcx = 920, &
71 xc_mgga_x_nc_br = 923, &
72 xc_mgga_x_nc_br_1 = 924, &
73 xc_mgga_c_nc_cs = 925, &
75 ! !! with an explicit inversion of x(y), gamma = 0.8
76
79 integer, public, parameter :: &
80 XC_FAMILY_KS_INVERSION = 1024, &
81 xc_family_rdmft = 2048, &
82 xc_family_libvdwxc = 4096, &
83 xc_family_nc_lda = 8192, &
84 xc_family_nc_mgga = 16384
85
87 ! Components are public by default
88 integer :: family = xc_family_unknown
89 integer :: type = 0
90 integer :: id = 0
91
92 integer :: spin_channels = 0
93 integer :: flags = 0
94
95 logical, private :: from_libxc = .false.
96
97 type(xc_f03_func_t) :: conf
98 type(xc_f03_func_info_t), private :: info
99 type(libvdwxc_t) :: libvdwxc
100 end type xc_functional_t
101
102 integer, public, parameter :: LIBXC_C_INDEX = 1000
103
104contains
105
106 ! ---------------------------------------------------------
107 subroutine xc_functional_init_func(conf, func_id, nspin, on_cpu)
108 type(xc_f03_func_t), intent(inout) :: conf
109 integer, intent(in) :: func_id
110 integer, intent(in) :: nspin
111 logical, intent(in) :: on_cpu
112
113#ifdef HAVE_LIBXC_DEVICE
114 integer(c_int) :: xc_flag_host_device
115
116 if (on_cpu) then
117 xc_flag_host_device = xc_flags_on_host
118 else
119 xc_flag_host_device = xc_flags_on_device
120 end if
121
122 call xc_f03_func_init_flags(conf, func_id, nspin, xc_flag_host_device)
123#else
124 if (.not. on_cpu) then
125 message(1) = "LibXC does not support device offloading,"
126 message(2) = "but a functional was requested to be initialized on the device."
127 call messages_fatal(2)
128 end if
129 call xc_f03_func_init(conf, func_id, nspin)
130#endif
131 end subroutine xc_functional_init_func
132
133 ! ---------------------------------------------------------
134 subroutine xc_functional_init(functl, namespace, id, ndim, nel, spin_channels, functionals_on_cpu)
135 type(xc_functional_t), intent(inout) :: functl
136 type(namespace_t), intent(in) :: namespace
137 integer, intent(in) :: id
138 integer, intent(in) :: ndim
139 real(real64), intent(in) :: nel
140 integer, intent(in) :: spin_channels
141 logical, intent(in) :: functionals_on_cpu
142
143 integer :: interact_1d
144 real(real64) :: alpha, parameters(2)
145
146 integer(c_int) :: xc_flag_host_device
147
148 push_sub(xc_functional_init)
149
150 ! initialize structure
151 functl%id = id
152 functl%spin_channels = spin_channels
153
154 if (functl%id == 0) then
155 functl%family = xc_family_none
156 else
157 ! get the family of the functional
158 functl%family = xc_f03_family_from_id(functl%id)
159 ! this also ensures it is actually a functional defined by the linked version of libxc
160
161 if (functl%family == xc_family_unknown) then
162
163 select case (functl%id)
165 functl%family = xc_family_oep
166
167 case (xc_lda_c_fbe)
168 functl%family = xc_family_lda
169
170 case (xc_ks_inversion)
171 functl%family = xc_family_ks_inversion
172
174 functl%family = xc_family_libvdwxc
175 !functl%flags = functl%flags + XC_FLAGS_HAVE_VXC + XC_FLAGS_HAVE_EXC
176
177 case (xc_rdmft_xc_m)
178 functl%family = xc_family_rdmft
179
181 functl%family = xc_family_hyb_gga
182
184 functl%family = xc_family_nc_mgga
185
186 case default
187 call messages_input_error(namespace, 'XCFunctional', 'Unknown functional')
188
189 end select
190 end if
191 end if
192
193#ifdef HAVE_LIBXC_DEVICE
194 if (functionals_on_cpu) then
195 xc_flag_host_device = xc_flags_on_host
196 else
197 xc_flag_host_device = xc_flags_on_device
198 end if
199#else
200 xc_flag_host_device = 0_c_int
201#endif
202
203 if (functl%family == xc_family_oep) then
204 functl%type = xc_exchange
205 functl%flags = xc_flags_1d + xc_flags_2d + xc_flags_3d + xc_flag_host_device
206
207 else if (functl%family == xc_family_ks_inversion .or. functl%family == xc_family_rdmft) then
208 functl%type = xc_exchange_correlation
209 functl%flags = xc_flags_1d + xc_flags_2d + xc_flags_3d + xc_flag_host_device
210
211 else if (functl%family == xc_family_libvdwxc) then
212 call xc_functional_init_func(functl%conf, xc_lda_c_pw, spin_channels, functionals_on_cpu)
213 functl%info = xc_f03_func_get_info(functl%conf)
214 functl%type = xc_f03_func_info_get_kind(functl%info)
215 functl%flags = xc_f03_func_info_get_flags(functl%info)
216 ! Convert Octopus code for functional into corresponding libvdwxc code:
217 call libvdwxc_init(functl%libvdwxc, namespace, functl%id - xc_vdw_c_vdwdf + 1)
218
219 else if(functl%id == xc_lda_c_fbe) then
220 functl%type = xc_correlation
221 functl%flags = xc_flags_have_exc + xc_flags_have_vxc + xc_flags_3d
222
223 else if(functl%id == xc_lda_c_fbe_sl) then
224 functl%type = xc_correlation
225 functl%flags = xc_flags_have_exc + xc_flags_have_vxc + xc_flags_3d + xc_flag_host_device
226
227 else if (functl%id == xc_mgga_x_nc_br .or. functl%id == xc_mgga_x_nc_br_1 .or. functl%id == xc_mgga_x_nc_br_explicit) then
228 functl%type = xc_exchange
229 functl%flags = xc_flags_have_vxc + xc_flags_have_exc + xc_flags_3d + xc_flag_host_device
230
231 else if(functl%id == xc_mgga_c_nc_cs) then
232 functl%type = xc_correlation
233 functl%flags = xc_flags_have_vxc + xc_flags_have_exc + xc_flags_3d + xc_flag_host_device
234
235 else if (functl%family == xc_family_none) then
236 functl%type = -1
237 functl%flags = xc_flags_1d + xc_flags_2d + xc_flags_3d + xc_flag_host_device
238
239 else ! handled by libxc
240 ! initialize
241 functl%from_libxc = .true.
242
243 !For the two MVORB functionals, we initialize libxc with the non-MVORB functionals
244 select case (functl%id)
246 call xc_functional_init_func(functl%conf, xc_hyb_gga_xc_hse06, spin_channels, functionals_on_cpu)
247
249 call xc_functional_init_func(functl%conf, xc_hyb_gga_xc_pbeh, spin_channels, functionals_on_cpu)
250
251 case default
252 call xc_functional_init_func(functl%conf, functl%id, spin_channels, functionals_on_cpu)
253 end select
254 functl%info = xc_f03_func_get_info(functl%conf)
255 functl%type = xc_f03_func_info_get_kind(functl%info)
256 functl%flags = xc_f03_func_info_get_flags(functl%info)
257
258 ! FIXME: no need to say this for kernel
259 if (bitand(functl%flags, xc_flags_have_exc) == 0) then
260 message(1) = 'Specified functional does not have total energy available.'
261 message(2) = 'Corresponding component of energy will just be left as zero.'
262 call messages_warning(2, namespace=namespace)
263 end if
264
265 if (bitand(functl%flags, xc_flags_have_vxc) == 0) then
266 message(1) = 'Specified functional does not have XC potential available.'
267 message(2) = 'Cannot run calculations. Choose another XCFunctional.'
268 call messages_fatal(2, namespace=namespace)
269 end if
270 end if
271
272 ! Octopus-defined functionals need to provide the proper flags
273 if (functl%family /= xc_family_none) then
274 call xc_check_dimension(functl, ndim, namespace)
275 end if
276
277 ! Yukawa hybrids not supported yet
278 if (bitand(functl%flags, xc_flags_hyb_camy) /= 0) then
279 call messages_not_implemented("Yukawa-range separated hybrids", namespace=namespace)
280 end if
281
282 ! VV10 correlations not supported yet
283 if (bitand(functl%flags, xc_flags_vv10) /= 0) then
284 call messages_not_implemented("VV10 correlation functionals", namespace=namespace)
285 end if
286
287 ! FIXME: aren`t there other parameters that can or should be set?
288 ! special parameters that have to be configured
289 select case (functl%id)
290 ! FIXME: aren`t there other Xalpha functionals?
291 case (xc_lda_c_xalpha)
292
293 !%Variable Xalpha
294 !%Type float
295 !%Default 1.0
296 !%Section Hamiltonian::XC
297 !%Description
298 !% The parameter of the Slater X<math>\alpha</math> functional. Applies only for
299 !% <tt>XCFunctional = lda_c_xalpha</tt>.
300 !% Typically one runs an exchange-correlation calculation as
301 !% <tt>XCFunctional = lda_x + lda_c_xalpha</tt>.
302 !%End
303 call parse_variable(namespace, 'Xalpha', m_one, parameters(1))
304
305 call xc_f03_func_set_ext_params(functl%conf, parameters(1))
306
307 ! FIXME: doesn`t this apply to other 1D functionals?
308 case (xc_lda_x_1d_soft, xc_lda_c_1d_csc)
309 !%Variable Interaction1D
310 !%Type integer
311 !%Default interaction_soft_coulomb
312 !%Section Hamiltonian::XC
313 !%Description
314 !% When running in 1D, one has to soften the Coulomb interaction. This softening
315 !% is not unique, and several possibilities exist in the literature.
316 !%Option interaction_exp_screened 0
317 !% Exponentially screened Coulomb interaction.
318 !% See, <i>e.g.</i>, M Casula, S Sorella, and G Senatore, <i>Phys. Rev. B</i> <b>74</b>, 245427 (2006).
319 !%Option interaction_soft_coulomb 1
320 !% Soft Coulomb interaction of the form <math>1/\sqrt{x^2 + \alpha^2}</math>.
321 !%End
322 call messages_obsolete_variable(namespace, 'SoftInteraction1D_alpha', 'Interaction1D')
323 call parse_variable(namespace, 'Interaction1D', option__interaction1d__interaction_soft_coulomb, interact_1d)
324
325 !%Variable Interaction1DScreening
326 !%Type float
327 !%Default 1.0
328 !%Section Hamiltonian::XC
329 !%Description
330 !% Defines the screening parameter <math>\alpha</math> of the softened Coulomb interaction
331 !% when running in 1D.
332 !%End
333 call messages_obsolete_variable(namespace, 'SoftInteraction1D_alpha', 'Interaction1DScreening')
334 call parse_variable(namespace, 'Interaction1DScreening', m_one, alpha)
335 parameters(1) = real(interact_1d, real64)
336 parameters(2) = alpha
337 call xc_f03_func_set_ext_params(functl%conf, parameters(1))
338
339 case (xc_gga_x_lb)
340 if (parse_is_defined(namespace, 'LB94_modified')) then
341 call messages_obsolete_variable(namespace, 'LB94_modified')
342 end if
343
344 if (parse_is_defined(namespace, 'LB94_threshold')) then
345 call messages_obsolete_variable(namespace, 'LB94_threshold')
346 end if
347 end select
348
349
350 ! For functionals that depend on the number of electrons, we set the number of electrons
351 ! This is currently the case of GGA_K_TFLW, LDA_X_2D_PRM, and LDA_X_RAE
352 if (xc_functional_is_not_size_consistent(functl, namespace)) then
353 assert(xc_f03_func_info_get_n_ext_params(functl%info) == 1)
354 parameters(1) = nel
355 call xc_f03_func_set_ext_params(functl%conf, parameters(1))
356 write(message(1), '(a,i1)') "Info: Setting the number of electrons for the functional for spin ", spin_channels
357 call messages_info(1, namespace=namespace)
358 end if
359
360 pop_sub(xc_functional_init)
361 end subroutine xc_functional_init
362
363
364 ! ---------------------------------------------------------
365 subroutine xc_functional_end(functl)
366 type(xc_functional_t), intent(inout) :: functl
367
368 push_sub(xc_functional_end)
369
370 if (functl%family /= xc_family_none .and. functl%family /= xc_family_oep .and. &
371 functl%family /= xc_family_ks_inversion .and. functl%id /= xc_lda_c_fbe &
372 .and. functl%family /= xc_family_nc_lda .and. functl%family /= xc_family_nc_mgga) then
373 call xc_f03_func_end(functl%conf)
374 end if
375
376 if (functl%family == xc_family_libvdwxc) then
377 call libvdwxc_end(functl%libvdwxc)
378 end if
379
380 pop_sub(xc_functional_end)
381 end subroutine xc_functional_end
382
383
384 ! ---------------------------------------------------------
386 subroutine xc_functional_write_info(functl, iunit, namespace)
387 type(xc_functional_t), intent(in) :: functl
388 integer, optional, intent(in) :: iunit
389 type(namespace_t), optional, intent(in) :: namespace
390
391 character(len=1024) :: reference
392 character(len=120) :: family
393 integer :: ii, ind, istart, iend
394
396
397 if (functl%family == xc_family_oep) then
398 ! this is handled separately
399
400 select case (functl%id)
401 case (xc_oep_x)
402 write(message(1), '(2x,a)') 'Exchange'
403 write(message(2), '(4x,a)') 'Exact exchange'
404 call messages_info(2, iunit=iunit, namespace=namespace)
405
406 case(xc_oep_x_slater)
407 write(message(1), '(2x,a)') 'Exchange'
408 write(message(2), '(4x,a)') 'Slater exchange'
409 call messages_info(2, iunit=iunit, namespace=namespace)
410
411 case (xc_oep_x_fbe)
412 write(message(1), '(2x,a)') 'Exchange'
413 write(message(2), '(4x,a)') 'Force-based local exchange'
414 write(message(3), '(4x,a)') '[1] Tancogne-Dejean et al., J. Chem. Phys. 160, 024103 (2024)'
415 call messages_info(3, iunit=iunit, namespace=namespace)
416
417 case (xc_oep_x_fbe_sl)
418 write(message(1), '(2x,a)') 'Exchange'
419 write(message(2), '(4x,a)') 'Force-based local exchange - Sturm-Liouville'
420 call messages_info(2, iunit=iunit, namespace=namespace)
421
422 case (xc_lda_c_fbe_sl)
423 write(message(1), '(2x,a)') 'Correlation'
424 write(message(2), '(4x,a)') 'Force-based local-density correlation - Sturm-Liouville'
425 call messages_info(2, iunit=iunit, namespace=namespace)
426
427 case default
428 assert(.false.)
429 end select
430
431 else if ( functl%family == xc_family_rdmft) then
432 select case (functl%id)
433 case (xc_rdmft_xc_m)
434 write(message(1), '(2x,a)') 'RDMFT'
435 write(message(2), '(4x,a)') 'Mueller functional'
436 call messages_info(2, iunit=iunit, namespace=namespace)
437 end select
438
439 else if (functl%family == xc_family_ks_inversion) then
440 ! this is handled separately
441 select case (functl%id)
442 case (xc_ks_inversion)
443 write(message(1), '(2x,a)') 'Exchange-Correlation:'
444 write(message(2), '(4x,a)') ' KS Inversion'
445 call messages_info(2, iunit=iunit, namespace=namespace)
446 end select
447
448 else if (functl%family == xc_family_libvdwxc) then
449 call libvdwxc_write_info(functl%libvdwxc, iunit=iunit)
450
451 else if (functl%id == xc_mgga_x_nc_br) then
452 write(message(1), '(2x,a)') 'Exchange'
453 write(message(2), '(4x,a)') 'Noncollinear Becke-Roussel (MGGA)'
454 write(message(3), '(4x,a)') '[1] N. Tancogne-Dejean, A. Rubio, and C. A. Ullrich, Phys. Rev. B 107, 165111 (2023)'
455 call messages_info(3, iunit)
456
457 else if (functl%id == xc_mgga_x_nc_br_1) then
458 write(message(1), '(2x,a)') 'Exchange'
459 write(message(2), '(4x,a)') 'Noncollinear Becke-Roussel, gamma = 1.0 (MGGA)'
460 write(message(3), '(4x,a)') '[1] N. Tancogne-Dejean, A. Rubio, and C. A. Ullrich, Phys. Rev. B 107, 165111 (2023)'
461 call messages_info(3, iunit)
462
463 else if (functl%id == xc_mgga_x_nc_br_explicit) then
464 write(message(1), '(2x,a)') 'Exchange'
465 write(message(2), '(4x,a)') 'Noncollinear Becke-Roussel (MGGA) with explicit inversion of x(y)'
466 write(message(3), '(4x,a)') '[1] N. Tancogne-Dejean, A. Rubio, and C. A. Ullrich, Phys. Rev. B 107, 165111 (2023)'
467 write(message(4), '(4x,a)') '[2] E. Proynov et al., Chemical Physics Letters 455, 103 (2008)'
468 call messages_info(4, iunit)
469
470 else if (functl%id == xc_mgga_c_nc_cs) then
471 write(message(1), '(2x,a)') 'Correlation'
472 write(message(2), '(4x,a)') 'Noncollinear Colle-Salvetti (MGGA)'
473 write(message(3), '(4x,a)') '[1] N. Tancogne-Dejean, A. Rubio, and C. A. Ullrich, Phys. Rev. B 107, 165111 (2023)'
474 call messages_info(3, iunit)
475
476 else if(functl%id == xc_lda_c_fbe) then
477 write(message(1), '(2x,a)') 'Correlation'
478 write(message(2), '(4x,a)') 'Force-based LDA correlation'
479 write(message(3), '(4x,a)') '[1] N. Tancogne-Dejean, M. Penz, M. Ruggenthaler, A. Rubio, J. Phys. Chem. A 129, 3132 (2025)'
480 call messages_info(3, iunit=iunit, namespace=namespace)
481
482 else if (functl%family /= xc_family_none) then ! all the other families
483 select case (functl%type)
484 case (xc_exchange)
485 write(message(1), '(2x,a)') 'Exchange'
486 case (xc_correlation)
487 write(message(1), '(2x,a)') 'Correlation'
488 case (xc_exchange_correlation)
489 write(message(1), '(2x,a)') 'Exchange-correlation'
490 case (xc_kinetic)
491 call messages_not_implemented("kinetic-energy functionals", namespace=namespace)
492 case default
493 write(message(1), '(a,i6,a,i6)') "Unknown functional type ", functl%type, ' for functional ', functl%id
494 call messages_fatal(1, namespace=namespace)
495 end select
496
497 select case (functl%family)
498 case (xc_family_lda)
499 write(family,'(a)') "LDA"
500 case (xc_family_gga)
501 write(family,'(a)') "GGA"
502 case (xc_family_mgga)
503 write(family,'(a)') "MGGA"
504 case (xc_family_lca)
505 call messages_not_implemented("Support of LCA functional", namespace=namespace)
506 case (xc_family_hyb_lda)
507 write(family,'(a)') "Hybrid LDA"
508 case (xc_family_hyb_gga)
509 write(family,'(a)') "Hybrid GGA"
510 case (xc_family_hyb_mgga)
511 write(family,'(a)') "Hybrid MGGA"
512 end select
513 write(message(2), '(4x,4a)') trim(xc_f03_func_info_get_name(functl%info)), ' (', trim(family), ')'
514 call messages_info(2, iunit=iunit, namespace=namespace)
515
516 ii = 0
517 do while(ii >= 0 .and. ii < 256)
518 ! Preventing End of record error as message(1) has length of 256, and libxc returns 1024 characters
519 ind = ii + 1
520 write(reference, '(a)') trim(xc_f03_func_reference_get_ref(xc_f03_func_info_get_references(functl%info, ii)))
521 ! Some references are in fact notes, and references are void in this case
522 if (len_trim(reference) == 0) cycle
523 istart = 1
524 iend = len(message(1))-10
525 write(message(1), '(4x,a,i1,2a)') '[', ind, '] ', trim(reference(istart:iend))
526 call messages_info(1, iunit=iunit, namespace=namespace)
527 do while (iend < len_trim(reference))
528 istart = iend
529 iend = min(istart + len(message(1))-10, len_trim(reference))
530 write(message(1), '(7x,a)') trim(reference(istart:iend))
531 call messages_info(1, iunit=iunit, namespace=namespace)
532 end do
533 end do
534 end if
535
537 end subroutine xc_functional_write_info
538
539
541 integer function xc_get_default_functional(dim, pseudo_x_functional, pseudo_c_functional) result(default)
542 integer, intent(in) :: dim
543 integer, intent(in) :: pseudo_x_functional, pseudo_c_functional
544
546
547 default = 0
548
549 if (pseudo_x_functional /= pseudo_exchange_any) then
550 default = pseudo_x_functional
551 else
552 select case (dim)
553 case (3)
554 default = xc_lda_x
555 case (2)
556 default = xc_lda_x_2d
557 case (1)
558 default = xc_lda_x_1d_soft
559 end select
560 end if
561
562 assert(default >= 0)
563
564 if (pseudo_c_functional /= pseudo_correlation_any) then
565 default = default + libxc_c_index*pseudo_c_functional
566 else
567 select case (dim)
568 case (3)
569 default = default + libxc_c_index * xc_lda_c_pz_mod
570 case (2)
571 default = default + libxc_c_index * xc_lda_c_2d_amgb
572 case (1)
573 default = default + libxc_c_index * xc_lda_c_1d_csc
574 end select
575 end if
576
577 assert(default >= 0)
578
580 end function xc_get_default_functional
581
583 subroutine xc_check_dimension(functl, ndim, namespace)
584 type(xc_functional_t), intent(in) :: functl
585 integer, intent(in) :: ndim
586 type(namespace_t), intent(in) :: namespace
587
588 logical :: ok
589
590 push_sub(xc_check_dimension)
591
592 ! Check that the functional is used for the correct space dimension
593 ok = bitand(functl%flags, xc_flags_1d) /= 0
594 if (ndim == 1 .and. (.not. ok)) then
595 message(1) = 'Cannot use the specified functionals in 1D.'
596 call messages_fatal(1, namespace=namespace)
597 end if
598
599 ok = bitand(functl%flags, xc_flags_2d) /= 0
600 if (ndim == 2 .and. (.not. ok)) then
601 message(1) = 'Cannot use the specified functionals in 2D.'
602 call messages_fatal(1, namespace=namespace)
603 end if
604
605 ok = bitand(functl%flags, xc_flags_3d) /= 0
606 if (ndim == 3 .and. (.not. ok)) then
607 message(1) = 'Cannot use the specified functionals in 3D.'
608 call messages_fatal(1, namespace=namespace)
609 end if
610
611 pop_sub(xc_check_dimension)
612 end subroutine xc_check_dimension
613
615 logical function xc_functional_is_not_size_consistent(functl, namespace)
616 type(xc_functional_t), intent(in) :: functl
617 type(namespace_t), intent(in) :: namespace
618
619 integer :: n_ext_params, ip
620 character(len=128) :: ext_params_name
621
623 if (.not. functl%from_libxc) return
624
626
627 ! External parameters
628 n_ext_params = xc_f03_func_info_get_n_ext_params(functl%info)
629 do ip = 0, n_ext_params-1
630 ext_params_name = xc_f03_func_info_get_ext_params_name(functl%info, ip)
631 ! Internal parameters starts with '_'
632 if (ext_params_name(1:1) == '_') cycle
633 if (trim(xc_f03_func_info_get_ext_params_description(functl%info, ip)) == 'Number of electrons') then
635 end if
636 end do
637
638 ! We only support size inconsistent functionals with a single parameter at the moment
639 if (xc_functional_is_not_size_consistent .and. n_ext_params > 1) then
640 message(1) = 'The selected functional is currently not supported.'
641 call messages_fatal(1, namespace=namespace)
642 end if
643
646
647 logical pure function xc_functional_is_energy_functional(functl)
648 type(xc_functional_t), intent(in) :: functl
649
650 xc_functional_is_energy_functional = bitand(functl%flags, xc_flags_have_exc) /= 0
652
653end module xc_functional_oct_m
654
655!! Local Variables:
656!! mode: f90
657!! coding: utf-8
658!! End:
real(real64), parameter, public m_one
Definition: global.F90:201
subroutine, public libvdwxc_end(this)
Definition: libvdwxc.F90:462
subroutine, public libvdwxc_init(libvdwxc, namespace, functional)
Definition: libvdwxc.F90:163
subroutine, public libvdwxc_write_info(this, iunit, namespace)
Definition: libvdwxc.F90:209
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1068
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:525
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1000
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:410
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:691
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:594
logical function, public parse_is_defined(namespace, name)
Definition: parser.F90:463
integer, parameter, public pseudo_correlation_any
Definition: pseudo.F90:194
integer, parameter, public pseudo_exchange_any
Definition: pseudo.F90:190
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.
subroutine, public xc_functional_init_func(conf, func_id, nspin, on_cpu)
integer, parameter, public xc_hyb_gga_xc_mvorb_pbeh
Density-based mixing parameter of PBE0.
subroutine, public xc_functional_init(functl, namespace, id, ndim, nel, spin_channels, functionals_on_cpu)
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
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_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_mgga_x_nc_br_explicit
Noncollinear version of the Becke-Roussel functional.
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.
int true(void)