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