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