Octopus
v_ks.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 v_ks_oct_m
22 use accel_oct_m
23 use comm_oct_m
25 use debug_oct_m
28 use energy_oct_m
32 use global_oct_m
33 use grid_oct_m
37 use ions_oct_m
38 use, intrinsic :: iso_fortran_env
39 use isdf_oct_m, only: isdf_parallel_ace_compute_potentials => isdf_ace_compute_potentials
44 use lda_u_oct_m
48 use mesh_oct_m
51 use mpi_oct_m
54 use parser_oct_m
59 use pseudo_oct_m
62 use sort_oct_m
63 use space_oct_m
71 use xc_cam_oct_m
72 use xc_oct_m
73 use xc_f03_lib_m
74 use xc_fbe_oct_m
78 use xc_oep_oct_m
79 use xc_sic_oct_m
81 use xc_vdw_oct_m
83
84 ! from the dftd3 library
85 use dftd3_api
86
87 implicit none
88
89 private
90 public :: &
91 v_ks_t, &
92 v_ks_init, &
93 v_ks_end, &
96 v_ks_calc, &
103
104 type v_ks_calc_t
105 private
106 logical :: calculating
107 logical :: time_present
108 real(real64) :: time
109 real(real64), allocatable :: density(:, :)
110 logical :: total_density_alloc
111 real(real64), pointer, contiguous :: total_density(:)
112 type(energy_t), allocatable :: energy
113
114 type(states_elec_t), pointer :: hf_st
118
119 real(real64), allocatable :: vxc(:, :)
120 real(real64), allocatable :: vtau(:, :)
121 real(real64), allocatable :: axc(:, :, :)
122 real(real64), allocatable :: a_ind(:, :)
123 real(real64), allocatable :: b_ind(:, :)
124 logical :: calc_energy
125 end type v_ks_calc_t
126
127 type v_ks_t
128 private
129 integer, public :: theory_level = -1
130 logical, public :: frozen_hxc = .false.
131
132 integer, public :: xc_family = 0
133 integer, public :: xc_flags = 0
134 integer, public :: xc_photon = 0
135 type(xc_t), public :: xc
136 type(xc_photons_t), public :: xc_photons
137 type(xc_oep_t), public :: oep
138 type(xc_oep_photon_t), public :: oep_photon
139 type(xc_ks_inversion_t), public :: ks_inversion
140 type(xc_sic_t), public :: sic
141 type(xc_vdw_t), public :: vdw
142 type(grid_t), pointer, public :: gr
143 type(v_ks_calc_t) :: calc
144 logical :: calculate_current = .false.
145 type(current_t) :: current_calculator
146 logical :: include_td_field = .false.
147 logical, public :: has_photons = .false.
148 logical :: xc_photon_include_hartree = .true.
149
150 real(real64), public :: stress_xc_gga(3, 3)
151 type(photon_mode_t), pointer, public :: pt => null()
152 type(mf_t), public :: pt_mx
153 end type v_ks_t
154
155contains
156
157 ! ---------------------------------------------------------
158 subroutine v_ks_init(ks, namespace, gr, st, ions, mc, space, kpoints)
159 type(v_ks_t), intent(inout) :: ks
160 type(namespace_t), intent(in) :: namespace
161 type(grid_t), target, intent(inout) :: gr
162 type(states_elec_t), intent(in) :: st
163 type(ions_t), intent(inout) :: ions
164 type(multicomm_t), intent(in) :: mc
165 class(space_t), intent(in) :: space
166 type(kpoints_t), intent(in) :: kpoints
167
168 integer :: x_id, c_id, xk_id, ck_id, default, val
169 logical :: parsed_theory_level, using_hartree_fock
170 integer :: pseudo_x_functional, pseudo_c_functional
171 integer :: oep_type
172
173 push_sub(v_ks_init)
174
175 ! We need to parse TheoryLevel and XCFunctional, this is
176 ! complicated because they are interdependent.
177
178 !%Variable TheoryLevel
179 !%Type integer
180 !%Section Hamiltonian
181 !%Description
182 !% The calculations can be run with different "theory levels" that
183 !% control how electrons are simulated. The default is
184 !% <tt>dft</tt>. When hybrid functionals are requested, through
185 !% the <tt>XCFunctional</tt> variable, the default is
186 !% <tt>hartree_fock</tt>.
187 !%Option independent_particles 2
188 !% Particles will be considered as independent, <i>i.e.</i> as non-interacting.
189 !% This mode is mainly used for testing purposes, as the code is usually
190 !% much faster with <tt>independent_particles</tt>.
191 !%Option hartree 1
192 !% Calculation within the Hartree method (experimental). Note that, contrary to popular
193 !% belief, the Hartree potential is self-interaction-free. Therefore, this run
194 !% mode will not yield the same result as <tt>kohn-sham</tt> without exchange-correlation.
195 !%Option hartree_fock 3
196 !% This is the traditional Hartree-Fock scheme. Like the Hartree scheme, it is fully
197 !% self-interaction-free.
198 !%Option kohn_sham 4
199 !% This is the default density-functional theory scheme. Note that you can also use
200 !% hybrid functionals in this scheme, but they will be handled the "DFT" way, <i>i.e.</i>,
201 !% solving the OEP equation.
202 !%Option generalized_kohn_sham 5
203 !% This is similar to the <tt>kohn-sham</tt> scheme, except that this allows for nonlocal operators.
204 !% This is the default mode to run hybrid functionals, meta-GGA functionals, or DFT+U.
205 !% It can be more convenient to use <tt>kohn-sham</tt> DFT within the OEP scheme to get similar (but not the same) results.
206 !% Note that within this scheme you can use a correlation functional, or a hybrid
207 !% functional (see <tt>XCFunctional</tt>). In the latter case, you will be following the
208 !% quantum-chemistry recipe to use hybrids.
209 !%Option rdmft 7
210 !% (Experimental) Reduced Density Matrix functional theory.
211 !%End
212
213 ks%xc_family = xc_family_none
214 ks%sic%level = sic_none
215 ks%oep%level = oep_level_none
216 ks%oep_photon%level = oep_level_none
218 ks%theory_level = kohn_sham_dft
219 parsed_theory_level = .false.
220
221 ! the user knows what he wants, give her that
222 if (parse_is_defined(namespace, 'TheoryLevel')) then
223 call parse_variable(namespace, 'TheoryLevel', kohn_sham_dft, ks%theory_level)
224 if (.not. varinfo_valid_option('TheoryLevel', ks%theory_level)) call messages_input_error(namespace, 'TheoryLevel')
226 parsed_theory_level = .true.
227 end if
229 ! parse the XC functional
231 call get_functional_from_pseudos(pseudo_x_functional, pseudo_c_functional)
233 default = 0
234 if (ks%theory_level == kohn_sham_dft .or. ks%theory_level == generalized_kohn_sham_dft) then
235 default = xc_get_default_functional(space%dim, pseudo_x_functional, pseudo_c_functional)
236 end if
238 if (.not. parse_is_defined(namespace, 'XCFunctional') &
239 .and. (pseudo_x_functional /= pseudo_exchange_any .or. pseudo_c_functional /= pseudo_correlation_any)) then
240 call messages_write('Info: the XCFunctional has been selected to match the pseudopotentials', new_line = .true.)
241 call messages_write(' used in the calculation.')
242 call messages_info(namespace=namespace)
243 end if
244
245 ! The description of this variable can be found in file src/xc/functionals_list.F90
246 call parse_variable(namespace, 'XCFunctional', default, val)
248 ! the first 3 digits of the number indicate the X functional and
249 ! the next 3 the C functional.
250 c_id = val / libxc_c_index
251 x_id = val - c_id * libxc_c_index
252
253 if ((x_id /= pseudo_x_functional .and. pseudo_x_functional /= pseudo_exchange_any) .or. &
254 (c_id /= pseudo_c_functional .and. pseudo_c_functional /= pseudo_exchange_any)) then
255 call messages_write('The XCFunctional that you selected does not match the one used', new_line = .true.)
256 call messages_write('to generate the pseudopotentials.')
257 call messages_warning(namespace=namespace)
258 end if
259
260 ! FIXME: we rarely need this. We should only parse when necessary.
261
262 !%Variable XCKernel
263 !%Type integer
264 !%Default -1
265 !%Section Hamiltonian::XC
266 !%Description
267 !% Defines the exchange-correlation kernel. Only LDA kernels are available currently.
268 !% The options are the same as <tt>XCFunctional</tt>.
269 !% Note: the kernel is only needed for Casida, Sternheimer, or optimal-control calculations.
270 !%Option xc_functional -1
271 !% The same functional defined by <tt>XCFunctional</tt>. By default, this is the case.
272 !%End
273 call parse_variable(namespace, 'XCKernel', -1, val)
274 if (-1 == val) then
275 ck_id = c_id
276 xk_id = x_id
277 else
278 ck_id = val / libxc_c_index
279 xk_id = val - ck_id * libxc_c_index
280 end if
281
282 call messages_obsolete_variable(namespace, 'XFunctional', 'XCFunctional')
283 call messages_obsolete_variable(namespace, 'CFunctional', 'XCFunctional')
284
285 !%Variable XCPhotonFunctional
286 !%Type integer
287 !%Default 0
288 !%Section Hamiltonian::XC
289 !%Description
290 !% Defines the exchange and correlation functionals to be used for the QEDFT
291 !% description of the electron-photon system.
292 !%Option none 0
293 !% No functional is used
294 !%Option photon_x_lda 10
295 !% Exchange-only local density approcimation
296 !%Option photon_xc_lda 11
297 !% Exchange-correlation local density approcimation
298 !%Option photon_x_wfn 20
299 !% Exchange-only based on wave functions
300 !%Option photon_xc_wfn 21
301 !% Exchange-correlation based on wave functions
302 !%End
303
304 call parse_variable(namespace, 'XCPhotonFunctional', option__xcphotonfunctional__none, ks%xc_photon)
305
306 !%Variable XCPhotonIncludeHartree
307 !%Type logical
308 !%Default yes
309 !%Section Hamiltonian::XC
310 !%Description
311 !% Use the Hartree potential and energy in calculations
312 !%End
313
314 call parse_variable(namespace, 'XCPhotonIncludeHartree', .true., ks%xc_photon_include_hartree)
315
316 if (.not. ks%xc_photon_include_hartree) then
317 call messages_write('turn off hartree potential and energy')
318 call messages_warning(namespace=namespace)
319 end if
320
321 ! initialize XC modules
322
323 ! This is a bit ugly, theory_level might not be generalized KS or HF now
324 ! but it might become generalized KS or HF later. This is safe because it
325 ! becomes generalized KS in the cases where the functional is hybrid
326 ! and the ifs inside check for both conditions.
327 using_hartree_fock = (ks%theory_level == hartree_fock) &
328 .or. (ks%theory_level == generalized_kohn_sham_dft .and. family_is_hybrid(ks%xc))
329 call xc_init(ks%xc, namespace, space%dim, space%periodic_dim, st%qtot, &
330 x_id, c_id, xk_id, ck_id, hartree_fock = using_hartree_fock, ispin=st%d%ispin)
331
332 ks%xc_family = ks%xc%family
333 ks%xc_flags = ks%xc%flags
334
335 if (.not. parsed_theory_level) then
336 default = kohn_sham_dft
337
338 ! the functional is a hybrid, use Hartree-Fock as theory level by default
339 if (family_is_hybrid(ks%xc) .or. family_is_mgga_with_exc(ks%xc)) then
341 end if
342
343 ! In principle we do not need to parse. However we do it for consistency
344 call parse_variable(namespace, 'TheoryLevel', default, ks%theory_level)
345 if (.not. varinfo_valid_option('TheoryLevel', ks%theory_level)) call messages_input_error(namespace, 'TheoryLevel')
346
347 end if
348
349 ! In case we need OEP, we need to find which type of OEP it is
350 oep_type = -1
351 if (family_is_mgga_with_exc(ks%xc)) then
352 call messages_experimental('MGGA energy functionals')
353
354 if (ks%theory_level == kohn_sham_dft) then
355 call messages_experimental("MGGA within the Kohn-Sham scheme")
356 ks%xc_family = ior(ks%xc_family, xc_family_oep)
357 oep_type = oep_type_mgga
358 end if
359 end if
360
361 call messages_obsolete_variable(namespace, 'NonInteractingElectrons', 'TheoryLevel')
362 call messages_obsolete_variable(namespace, 'HartreeFock', 'TheoryLevel')
363
364 ! Due to how the code is made, we need to set this to have theory level other than DFT
365 ! correct...
366 ks%sic%amaldi_factor = m_one
367
368 select case (ks%theory_level)
370
371 case (hartree)
372 call messages_experimental("Hartree theory level")
373 if (space%periodic_dim == space%dim) then
374 call messages_experimental("Hartree in fully periodic system")
375 end if
376 if (kpoints%full%npoints > 1) then
377 call messages_not_implemented("Hartree with k-points", namespace=namespace)
378 end if
379
380 case (hartree_fock)
381 if (kpoints%full%npoints > 1) then
382 call messages_experimental("Hartree-Fock with k-points")
383 end if
384
386 if (kpoints%full%npoints > 1 .and. family_is_hybrid(ks%xc)) then
387 call messages_experimental("Hybrid functionals with k-points")
388 end if
389
390 case (rdmft)
391 call messages_experimental('RDMFT theory level')
392
393 case (kohn_sham_dft)
394
395 ! check for SIC
396 if (bitand(ks%xc_family, xc_family_lda + xc_family_gga) /= 0) then
397 call xc_sic_init(ks%sic, namespace, gr, st, mc, space)
398 end if
399
400 if (bitand(ks%xc_family, xc_family_oep) /= 0) then
401 select case (ks%xc%functional(func_x,1)%id)
402 case (xc_oep_x_slater)
403 if (kpoints%reduced%npoints > 1 .and. st%d%ispin == spinors) then
404 call messages_not_implemented("Slater with k-points and spinor wavefunctions", namespace=namespace)
405 end if
406 if (kpoints%use_symmetries) then
407 call messages_not_implemented("Slater with k-points symmetries", namespace=namespace)
408 end if
409 ks%oep%level = oep_level_none
410 case (xc_oep_x_fbe)
411 if (kpoints%reduced%npoints > 1) then
412 call messages_not_implemented("FBE functional with k-points", namespace=namespace)
413 end if
414 ks%oep%level = oep_level_none
415 case default
416 if((.not. ks%has_photons) .or. (ks%xc_photon /= 0)) then
417 if(oep_type == -1) then ! Else we have a MGGA
418 oep_type = oep_type_exx
419 end if
420 call xc_oep_init(ks%oep, namespace, gr, st, mc, space, oep_type)
421 end if
422 end select
423 else
424 ks%oep%level = oep_level_none
425 end if
426
427 if (bitand(ks%xc_family, xc_family_ks_inversion) /= 0) then
428 call xc_ks_inversion_init(ks%ks_inversion, namespace, gr, ions, st, ks%xc, mc, space, kpoints)
429 end if
430
431 end select
432
433 if (ks%theory_level /= kohn_sham_dft .and. parse_is_defined(namespace, "SICCorrection")) then
434 message(1) = "SICCorrection can only be used with Kohn-Sham DFT"
435 call messages_fatal(1, namespace=namespace)
436 end if
437
438 if (st%d%ispin == spinors) then
439 if (bitand(ks%xc_family, xc_family_mgga + xc_family_hyb_mgga) /= 0) then
440 call messages_not_implemented("MGGA with spinors", namespace=namespace)
441 end if
442 end if
443
444 ks%frozen_hxc = .false.
445
446 call v_ks_write_info(ks, namespace=namespace)
447
448 ks%gr => gr
449 ks%calc%calculating = .false.
450
451 !The value of ks%calculate_current is set to false or true by Output
452 call current_init(ks%current_calculator, namespace)
453
454 call ks%vdw%init(namespace, space, gr, ks%xc, ions, x_id, c_id)
455 if (ks%vdw%vdw_correction /= option__vdwcorrection__none .and. ks%theory_level == rdmft) then
456 message(1) = "VDWCorrection and RDMFT are not compatible"
457 call messages_fatal(1, namespace=namespace)
458 end if
459 if (ks%vdw%vdw_correction /= option__vdwcorrection__none .and. ks%theory_level == independent_particles) then
460 message(1) = "VDWCorrection and independent particles are not compatible"
461 call messages_fatal(1, namespace=namespace)
462 end if
463
464 if (ks%xc_photon /= 0) then
465 ! initilize the photon free variables
466 call ks%xc_photons%init(namespace, ks%xc_photon , space, gr, st)
467 ! remornalize the electron mass due to light-matter interaction; here we only deal with it in free space
468 ks%oep_photon%level = oep_level_none
469 end if
470
471
472 pop_sub(v_ks_init)
473
474 contains
475
477 subroutine get_functional_from_pseudos(x_functional, c_functional)
478 integer, intent(out) :: x_functional
479 integer, intent(out) :: c_functional
480
481 integer :: xf, cf, ispecies
482 logical :: warned_inconsistent
483
484 x_functional = pseudo_exchange_any
485 c_functional = pseudo_correlation_any
486
487 warned_inconsistent = .false.
488 do ispecies = 1, ions%nspecies
489 select type(spec=>ions%species(ispecies)%s)
490 class is(pseudopotential_t)
491 xf = spec%x_functional()
492 cf = spec%c_functional()
493
494 if (xf == pseudo_exchange_unknown .or. cf == pseudo_correlation_unknown) then
495 call messages_write("Unknown XC functional for species '"//trim(ions%species(ispecies)%s%get_label())//"'")
496 call messages_warning(namespace=namespace)
497 cycle
498 end if
499
500 if (x_functional == pseudo_exchange_any) then
501 x_functional = xf
502 else
503 if (xf /= x_functional .and. .not. warned_inconsistent) then
504 call messages_write('Inconsistent XC functional detected between species')
505 call messages_warning(namespace=namespace)
506 warned_inconsistent = .true.
507 end if
508 end if
509
510 if (c_functional == pseudo_correlation_any) then
511 c_functional = cf
512 else
513 if (cf /= c_functional .and. .not. warned_inconsistent) then
514 call messages_write('Inconsistent XC functional detected between species')
515 call messages_warning(namespace=namespace)
516 warned_inconsistent = .true.
517 end if
518 end if
519
520 class default
523 end select
524
525 end do
526
527 assert(x_functional /= pseudo_exchange_unknown)
528 assert(c_functional /= pseudo_correlation_unknown)
529
530 end subroutine get_functional_from_pseudos
531 end subroutine v_ks_init
532 ! ---------------------------------------------------------
533
534 ! ---------------------------------------------------------
535 subroutine v_ks_end(ks)
536 type(v_ks_t), intent(inout) :: ks
537
538 push_sub(v_ks_end)
539
540 call ks%vdw%end()
541
542 select case (ks%theory_level)
543 case (kohn_sham_dft)
544 if (bitand(ks%xc_family, xc_family_ks_inversion) /= 0) then
545 call xc_ks_inversion_end(ks%ks_inversion)
546 end if
547 if (bitand(ks%xc_family, xc_family_oep) /= 0) then
548 call xc_oep_end(ks%oep)
549 end if
550 call xc_end(ks%xc)
552 call xc_end(ks%xc)
553 end select
554
555 call xc_sic_end(ks%sic)
556
557 if (ks%xc_photon /= 0) then
558 call ks%xc_photons%end()
559 end if
560
561 pop_sub(v_ks_end)
562 end subroutine v_ks_end
563 ! ---------------------------------------------------------
564
565
566 ! ---------------------------------------------------------
567 subroutine v_ks_write_info(ks, iunit, namespace)
568 type(v_ks_t), intent(in) :: ks
569 integer, optional, intent(in) :: iunit
570 type(namespace_t), optional, intent(in) :: namespace
571
573
574 call messages_print_with_emphasis(msg="Theory Level", iunit=iunit, namespace=namespace)
575 call messages_print_var_option("TheoryLevel", ks%theory_level, iunit=iunit, namespace=namespace)
576
577 select case (ks%theory_level)
579 call messages_info(iunit=iunit, namespace=namespace)
580 call xc_write_info(ks%xc, iunit, namespace)
581
582 case (kohn_sham_dft)
583 call messages_info(iunit=iunit, namespace=namespace)
584 call xc_write_info(ks%xc, iunit, namespace)
585
586 call messages_info(iunit=iunit, namespace=namespace)
587
588 call xc_sic_write_info(ks%sic, iunit, namespace)
589 call xc_oep_write_info(ks%oep, iunit, namespace)
590 call xc_ks_inversion_write_info(ks%ks_inversion, iunit, namespace)
591
592 end select
593
594 call messages_print_with_emphasis(iunit=iunit, namespace=namespace)
595
596 pop_sub(v_ks_write_info)
597 end subroutine v_ks_write_info
598 ! ---------------------------------------------------------
599
600
601 !----------------------------------------------------------
602 subroutine v_ks_h_setup(namespace, space, gr, ions, ext_partners, st, ks, hm, calc_eigenval, calc_current)
603 type(namespace_t), intent(in) :: namespace
604 type(electron_space_t), intent(in) :: space
605 type(grid_t), intent(in) :: gr
606 type(ions_t), intent(in) :: ions
607 type(partner_list_t), intent(in) :: ext_partners
608 type(states_elec_t), intent(inout) :: st
609 type(v_ks_t), intent(inout) :: ks
610 type(hamiltonian_elec_t), intent(inout) :: hm
611 logical, optional, intent(in) :: calc_eigenval
612 logical, optional, intent(in) :: calc_current
613
614 integer, allocatable :: ind(:)
615 integer :: ist, ik
616 real(real64), allocatable :: copy_occ(:)
617 logical :: calc_eigenval_
618 logical :: calc_current_
619
620 push_sub(v_ks_h_setup)
621
622 calc_eigenval_ = optional_default(calc_eigenval, .true.)
623 calc_current_ = optional_default(calc_current, .true.)
624 call states_elec_fermi(st, namespace, gr)
625 call density_calc(st, gr, st%rho)
626 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
627 calc_eigenval = calc_eigenval_, calc_current = calc_current_) ! get potentials
628
629 if (st%restart_reorder_occs .and. .not. st%fromScratch) then
630 message(1) = "Reordering occupations for restart."
631 call messages_info(1, namespace=namespace)
632
633 safe_allocate(ind(1:st%nst))
634 safe_allocate(copy_occ(1:st%nst))
635
636 do ik = 1, st%nik
637 call sort(st%eigenval(:, ik), ind)
638 copy_occ(1:st%nst) = st%occ(1:st%nst, ik)
639 do ist = 1, st%nst
640 st%occ(ist, ik) = copy_occ(ind(ist))
641 end do
642 end do
643
644 safe_deallocate_a(ind)
645 safe_deallocate_a(copy_occ)
646 end if
647
648 if (calc_eigenval_) call states_elec_fermi(st, namespace, gr) ! occupations
649 call energy_calc_total(namespace, space, hm, gr, st, ext_partners)
650
651 pop_sub(v_ks_h_setup)
652 end subroutine v_ks_h_setup
653
654 ! ---------------------------------------------------------
655 subroutine v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
656 calc_eigenval, time, calc_energy, calc_current, force_semilocal)
657 type(v_ks_t), intent(inout) :: ks
658 type(namespace_t), intent(in) :: namespace
659 type(electron_space_t), intent(in) :: space
660 type(hamiltonian_elec_t), intent(inout) :: hm
661 type(states_elec_t), intent(inout) :: st
662 type(ions_t), intent(in) :: ions
663 type(partner_list_t), intent(in) :: ext_partners
664 logical, optional, intent(in) :: calc_eigenval
665 real(real64), optional, intent(in) :: time
666 logical, optional, intent(in) :: calc_energy
667 logical, optional, intent(in) :: calc_current
668 logical, optional, intent(in) :: force_semilocal
669
670 logical :: calc_current_
671
672 push_sub(v_ks_calc)
673
674 calc_current_ = optional_default(calc_current, .true.) &
675 .and. ks%calculate_current &
676 .and. states_are_complex(st) &
678
679 if (calc_current_) then
680 call states_elec_allocate_current(st, space, ks%gr)
681 call current_calculate(ks%current_calculator, namespace, ks%gr, hm, space, st)
682 end if
683
684 call v_ks_calc_start(ks, namespace, space, hm, st, ions, hm%kpoints%latt, ext_partners, time, &
685 calc_energy, force_semilocal=force_semilocal)
686 call v_ks_calc_finish(ks, hm, namespace, space, hm%kpoints%latt, st, &
687 ext_partners, force_semilocal=force_semilocal)
688
689 if (optional_default(calc_eigenval, .false.)) then
690 call energy_calc_eigenvalues(namespace, hm, ks%gr%der, st)
691 end if
692
693 ! Update the magnetic constrain
694 call magnetic_constrain_update(hm%magnetic_constrain, ks%gr, st%d, space, hm%kpoints%latt, ions%pos, st%rho)
695 ! We add the potential to vxc, as this way the potential gets mixed together with vxc
696 ! While this is not ideal, this is a simple practical solution
697 if (hm%magnetic_constrain%level /= constrain_none) then
698 call lalg_axpy(ks%gr%np, st%d%nspin, m_one, hm%magnetic_constrain%pot, hm%ks_pot%vhxc)
699 end if
700
701 pop_sub(v_ks_calc)
702 end subroutine v_ks_calc
703
704 ! ---------------------------------------------------------
705
710 subroutine v_ks_calc_start(ks, namespace, space, hm, st, ions, latt, ext_partners, time, &
711 calc_energy, force_semilocal)
712 type(v_ks_t), target, intent(inout) :: ks
713 type(namespace_t), intent(in) :: namespace
714 class(space_t), intent(in) :: space
715 type(hamiltonian_elec_t), target, intent(in) :: hm
716 type(states_elec_t), target, intent(inout) :: st
717 type(ions_t), intent(in) :: ions
718 type(lattice_vectors_t), intent(in) :: latt
719 type(partner_list_t), intent(in) :: ext_partners
720 real(real64), optional, intent(in) :: time
721 logical, optional, intent(in) :: calc_energy
722 logical, optional, intent(in) :: force_semilocal
723
724 push_sub(v_ks_calc_start)
725
726 call profiling_in("KOHN_SHAM_CALC")
727
728 assert(.not. ks%calc%calculating)
729 ks%calc%calculating = .true.
730
731 write(message(1), '(a)') 'Debug: Calculating Kohn-Sham potential.'
732 call messages_info(1, namespace=namespace, debug_only=.true.)
733
734 ks%calc%time_present = present(time)
735 ks%calc%time = optional_default(time, m_zero)
736
737 ks%calc%calc_energy = optional_default(calc_energy, .true.)
738
739 ! If the Hxc term is frozen, there is nothing more to do (WARNING: MISSING ks%calc%energy%intnvxc)
740 if (ks%frozen_hxc) then
741 call profiling_out("KOHN_SHAM_CALC")
742 pop_sub(v_ks_calc_start)
743 return
744 end if
745
746 allocate(ks%calc%energy)
747
748 call energy_copy(hm%energy, ks%calc%energy)
749
750 ks%calc%energy%intnvxc = m_zero
751
752 nullify(ks%calc%total_density)
753
754 if (ks%theory_level /= independent_particles .and. abs(ks%sic%amaldi_factor) > m_epsilon) then
755
756 call calculate_density()
757
758 if (poisson_is_async(hm%psolver)) then
759 call dpoisson_solve_start(hm%psolver, ks%calc%total_density)
760 end if
761
762 if (ks%theory_level /= hartree .and. ks%theory_level /= rdmft) call v_a_xc(hm, force_semilocal)
763 else
764 ks%calc%total_density_alloc = .false.
765 end if
766
767 ! The exchange operator is computed from the states of the previous iteration
768 ! This is done by copying the state object to ks%calc%hf_st
769 ! For ACE, the states are the same in ks%calc%hf_st and st, as we compute the
770 ! ACE potential in v_ks_finish, so the copy is not needed
771 nullify(ks%calc%hf_st)
772 if (ks%theory_level == hartree .or. ks%theory_level == hartree_fock &
773 .or. ks%theory_level == rdmft .or. (ks%theory_level == generalized_kohn_sham_dft &
774 .and. family_is_hybrid(ks%xc))) then
775
776 if (st%parallel_in_states) then
777 if (accel_is_enabled()) then
778 call messages_write('State parallelization of Hartree-Fock exchange is not supported')
779 call messages_new_line()
780 call messages_write('when running with GPUs. Please use domain parallelization')
781 call messages_new_line()
782 call messages_write("or disable acceleration using 'DisableAccel = yes'.")
783 call messages_fatal(namespace=namespace)
784 end if
785 end if
786
787 if (hm%exxop%useACE) then
788 ks%calc%hf_st => st
789 else
790 safe_allocate(ks%calc%hf_st)
791 call states_elec_copy(ks%calc%hf_st, st)
792 end if
793 end if
794
795 ! Calculate the vector potential induced by the electronic current.
796 ! WARNING: calculating the self-induced magnetic field here only makes
797 ! sense if it is going to be used in the Hamiltonian, which does not happen
798 ! now. Otherwise one could just calculate it at the end of the calculation.
799 if (hm%self_induced_magnetic) then
800 safe_allocate(ks%calc%a_ind(1:ks%gr%np_part, 1:space%dim))
801 safe_allocate(ks%calc%b_ind(1:ks%gr%np_part, 1:space%dim))
802 call magnetic_induced(namespace, ks%gr, st, hm%psolver, hm%kpoints, ks%calc%a_ind, ks%calc%b_ind)
803 end if
804
805 if ((ks%has_photons) .and. (ks%calc%time_present) .and. (ks%xc_photon == 0) ) then
806 call mf_calc(ks%pt_mx, ks%gr, st, ions, ks%pt, time)
807 end if
808
809 ! if (ks%has_vibrations) then
810 ! call vibrations_eph_coup(ks%vib, ks%gr, hm, ions, st)
811 ! end if
812
813 call profiling_out("KOHN_SHAM_CALC")
814 pop_sub(v_ks_calc_start)
815
816 contains
817
818 subroutine calculate_density()
819 integer :: ip
820
822
823 ! get density taking into account non-linear core corrections
824 safe_allocate(ks%calc%density(1:ks%gr%np, 1:st%d%nspin))
825 call states_elec_total_density(st, ks%gr, ks%calc%density)
826
827 ! Amaldi correction
828 if (ks%sic%level == sic_amaldi) then
829 call lalg_scal(ks%gr%np, st%d%nspin, ks%sic%amaldi_factor, ks%calc%density)
830 end if
831
832 nullify(ks%calc%total_density)
833 if (allocated(st%rho_core) .or. hm%d%spin_channels > 1) then
834 ks%calc%total_density_alloc = .true.
835
836 safe_allocate(ks%calc%total_density(1:ks%gr%np))
837
838 do ip = 1, ks%gr%np
839 ks%calc%total_density(ip) = sum(ks%calc%density(ip, 1:hm%d%spin_channels))
840 end do
841
842 ! remove non-local core corrections
843 if (allocated(st%rho_core)) then
844 call lalg_axpy(ks%gr%np, -ks%sic%amaldi_factor, st%rho_core, ks%calc%total_density)
845 end if
846 else
847 ks%calc%total_density_alloc = .false.
848 ks%calc%total_density => ks%calc%density(:, 1)
849 end if
850
852 end subroutine calculate_density
853
854 ! ---------------------------------------------------------
855 subroutine v_a_xc(hm, force_semilocal)
856 type(hamiltonian_elec_t), intent(in) :: hm
857 logical, optional, intent(in) :: force_semilocal
858
859 integer :: ispin
860
861 push_sub(v_ks_calc_start.v_a_xc)
862 call profiling_in("XC")
863
864 ks%calc%energy%exchange = m_zero
865 ks%calc%energy%correlation = m_zero
866 ks%calc%energy%xc_j = m_zero
867 ks%calc%energy%vdw = m_zero
868
869 allocate(ks%calc%vxc(1:ks%gr%np, 1:st%d%nspin))
870 ks%calc%vxc = m_zero
871
872 if (family_is_mgga_with_exc(hm%xc)) then
873 safe_allocate(ks%calc%vtau(1:ks%gr%np, 1:st%d%nspin))
874 ks%calc%vtau = m_zero
875 end if
876
877 ! Get the *local* XC term
878 if (ks%calc%calc_energy) then
879 if (family_is_mgga_with_exc(hm%xc)) then
880 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, st%d%ispin, &
881 latt%rcell_volume, ks%calc%vxc, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation, &
882 deltaxc = ks%calc%energy%delta_xc, vtau = ks%calc%vtau, force_orbitalfree=force_semilocal)
883 else
884 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, st%d%ispin, &
885 latt%rcell_volume, ks%calc%vxc, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation, &
886 deltaxc = ks%calc%energy%delta_xc, stress_xc=ks%stress_xc_gga, force_orbitalfree=force_semilocal)
887 end if
888 else
889 if (family_is_mgga_with_exc(hm%xc)) then
890 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, &
891 st%d%ispin, latt%rcell_volume, ks%calc%vxc, vtau = ks%calc%vtau, force_orbitalfree=force_semilocal)
892 else
893 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, &
894 st%d%ispin, latt%rcell_volume, ks%calc%vxc, stress_xc=ks%stress_xc_gga, force_orbitalfree=force_semilocal)
895 end if
896 end if
897
898 !Noncollinear functionals
899 if (bitand(hm%xc%family, xc_family_nc_lda + xc_family_nc_mgga) /= 0) then
900 if (st%d%ispin /= spinors) then
901 message(1) = "Noncollinear functionals can only be used with spinor wavefunctions."
902 call messages_fatal(1)
903 end if
904
905 if (optional_default(force_semilocal, .false.)) then
906 message(1) = "Cannot perform LCAO for noncollinear MGGAs."
907 message(2) = "Please perform a LDA calculation first."
908 call messages_fatal(2)
909 end if
910
911 if (ks%calc%calc_energy) then
912 if (family_is_mgga_with_exc(hm%xc)) then
913 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, ks%calc%vxc, &
914 vtau = ks%calc%vtau, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation)
915 else
916 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, ks%calc%vxc, &
917 ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation)
918 end if
919 else
920 if (family_is_mgga_with_exc(hm%xc)) then
921 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, &
922 ks%calc%vxc, vtau = ks%calc%vtau)
923 else
924 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, ks%calc%vxc)
925 end if
926 end if
927 end if
928
929 call ks%vdw%calc(namespace, space, latt, ions%atom, ions%natoms, ions%pos, &
930 ks%gr, st, ks%calc%energy%vdw, ks%calc%vxc)
931
932 if (optional_default(force_semilocal, .false.)) then
933 call profiling_out("XC")
934 pop_sub(v_ks_calc_start.v_a_xc)
935 return
936 end if
937
938 ! ADSIC correction
939 if (ks%sic%level == sic_adsic) then
940 if (family_is_mgga(hm%xc%family)) then
941 call messages_not_implemented('ADSIC with MGGAs', namespace=namespace)
942 end if
943 if (ks%calc%calc_energy) then
944 call xc_sic_calc_adsic(ks%sic, namespace, space, ks%gr, st, hm, ks%xc, ks%calc%density, &
945 ks%calc%vxc, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation)
946 else
947 call xc_sic_calc_adsic(ks%sic, namespace, space, ks%gr, st, hm, ks%xc, ks%calc%density, &
948 ks%calc%vxc)
949 end if
950 end if
951 !PZ SIC is done in the finish routine as OEP full needs to update the Hamiltonian
952
953 if (ks%theory_level == kohn_sham_dft) then
954 ! The OEP family has to be handled specially
955 ! Note that OEP is done in the finish state, as it requires updating the Hamiltonian and needs the new Hartre and vxc term
956 if (bitand(ks%xc_family, xc_family_oep) /= 0 .or. family_is_mgga_with_exc(ks%xc)) then
957
958 if (ks%xc%functional(func_x,1)%id == xc_oep_x_slater) then
959 call x_slater_calc(namespace, ks%gr, space, hm%exxop, st, hm%kpoints, ks%calc%energy%exchange, &
960 vxc = ks%calc%vxc)
961 else if (ks%xc%functional(func_x,1)%id == xc_oep_x_fbe .or. ks%xc%functional(func_x,1)%id == xc_oep_x_fbe_sl) then
962 call x_fbe_calc(ks%xc%functional(func_x,1)%id, namespace, hm%psolver, ks%gr, st, space, &
963 ks%calc%energy%exchange, vxc = ks%calc%vxc)
964
965 else if (ks%xc%functional(func_c,1)%id == xc_lda_c_fbe_sl) then
966
967 call fbe_c_lda_sl(namespace, ks%gr, st, space, ks%calc%energy%correlation, vxc = ks%calc%vxc)
968
969 end if
970
971 end if
972
973 if (bitand(ks%xc_family, xc_family_ks_inversion) /= 0) then
974 ! Also treat KS inversion separately (not part of libxc)
975 call xc_ks_inversion_calc(ks%ks_inversion, namespace, space, ks%gr, hm, ext_partners, st, vxc = ks%calc%vxc, &
976 time = ks%calc%time)
977 end if
978
979 ! compute the photon-free photon exchange potential and energy
980 if (ks%xc_photon /= 0) then
981
982 call ks%xc_photons%v_ks(namespace, ks%calc%total_density, ks%gr, space, hm%psolver, st)
983
984 ! add the photon-free px potential into the xc potential
985 do ispin = 1, hm%d%spin_channels
986 call lalg_axpy(ks%gr%np, m_one, ks%xc_photons%vpx(1:ks%gr%np), ks%calc%vxc(1:ks%gr%np, ispin) )
987 end do
988
989 ! photon-exchange energy
990 ks%calc%energy%photon_exchange = ks%xc_photons%ex
991 end if
992
993 end if
994
995 if (ks%calc%calc_energy) then
996 ! MGGA vtau contribution is done after copying vtau to hm%vtau
997
998 call v_ks_update_dftu_energy(ks, namespace, hm, st, ks%calc%energy%int_dft_u)
999 end if
1000
1001 call profiling_out("XC")
1002 pop_sub(v_ks_calc_start.v_a_xc)
1003 end subroutine v_a_xc
1004
1005 end subroutine v_ks_calc_start
1006 ! ---------------------------------------------------------
1007
1008 subroutine v_ks_calc_finish(ks, hm, namespace, space, latt, st, ext_partners, force_semilocal)
1009 type(v_ks_t), target, intent(inout) :: ks
1010 type(hamiltonian_elec_t), intent(inout) :: hm
1011 type(namespace_t), intent(in) :: namespace
1012 class(space_t), intent(in) :: space
1013 type(lattice_vectors_t), intent(in) :: latt
1014 type(states_elec_t), intent(inout) :: st
1015 type(partner_list_t), intent(in) :: ext_partners
1016 logical, optional, intent(in) :: force_semilocal
1017
1018 integer :: ip, ispin
1019 type(states_elec_t) :: xst
1021 real(real64) :: exx_energy
1022 real(real64) :: factor
1023
1024 push_sub(v_ks_calc_finish)
1025
1026 assert(ks%calc%calculating)
1027 ks%calc%calculating = .false.
1028
1029 if (ks%frozen_hxc) then
1030 pop_sub(v_ks_calc_finish)
1031 return
1032 end if
1033
1034 !change the pointer to the energy object
1035 safe_deallocate_a(hm%energy)
1036 call move_alloc(ks%calc%energy, hm%energy)
1037
1038 if (hm%self_induced_magnetic) then
1039 hm%a_ind(1:ks%gr%np, 1:space%dim) = ks%calc%a_ind(1:ks%gr%np, 1:space%dim)
1040 hm%b_ind(1:ks%gr%np, 1:space%dim) = ks%calc%b_ind(1:ks%gr%np, 1:space%dim)
1041
1042 safe_deallocate_a(ks%calc%a_ind)
1043 safe_deallocate_a(ks%calc%b_ind)
1044 end if
1045
1046 if (allocated(hm%v_static)) then
1047 hm%energy%intnvstatic = dmf_dotp(ks%gr, ks%calc%total_density, hm%v_static)
1048 else
1049 hm%energy%intnvstatic = m_zero
1050 end if
1051
1052 if (ks%theory_level == independent_particles .or. abs(ks%sic%amaldi_factor) <= m_epsilon) then
1053
1054 hm%ks_pot%vhxc = m_zero
1055 hm%energy%intnvxc = m_zero
1056 hm%energy%hartree = m_zero
1057 hm%energy%exchange = m_zero
1058 hm%energy%exchange_hf = m_zero
1059 hm%energy%correlation = m_zero
1060 else
1061
1062 hm%energy%hartree = m_zero
1063 call v_ks_hartree(namespace, ks, space, hm, ext_partners)
1064
1065 if (.not. optional_default(force_semilocal, .false.)) then
1066 !PZ-SIC
1067 if(ks%sic%level == sic_pz_oep) then
1068 if (states_are_real(st)) then
1069 call dxc_oep_calc(ks%sic%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1070 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1071 else
1072 call zxc_oep_calc(ks%sic%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1073 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1074 end if
1075 end if
1076
1077 ! OEP for exchange ad MGGAs (within Kohn-Sham DFT)
1078 if (ks%theory_level == kohn_sham_dft .and. ks%oep%level /= oep_level_none) then
1079 ! The OEP family has to be handled specially
1080 if (ks%xc%functional(func_x,1)%id == xc_oep_x .or. family_is_mgga_with_exc(ks%xc)) then
1081 if (states_are_real(st)) then
1082 call dxc_oep_calc(ks%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1083 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1084 else
1085 call zxc_oep_calc(ks%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1086 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1087 end if
1088 end if
1089 end if
1090 end if
1091
1092 if (ks%theory_level == kohn_sham_dft .and. ks%oep_photon%level /= oep_level_none) then
1093 if (states_are_real(st)) then
1094 call dxc_oep_photon_calc(ks%oep_photon, namespace, ks%xc, ks%gr, &
1095 hm, st, space, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1096 else
1097 call zxc_oep_photon_calc(ks%oep_photon, namespace, ks%xc, ks%gr, &
1098 hm, st, space, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1099 end if
1100 hm%energy%photon_exchange = ks%oep_photon%pt%ex
1101 end if
1102
1104 if (ks%calc%calc_energy) then
1105 ! Now we calculate Int[n vxc] = energy%intnvxc
1106 hm%energy%intnvxc = m_zero
1107
1108 if (ks%theory_level /= independent_particles .and. ks%theory_level /= hartree .and. ks%theory_level /= rdmft) then
1109 do ispin = 1, hm%d%nspin
1110 if (ispin <= 2) then
1111 factor = m_one
1112 else
1113 factor = m_two
1114 end if
1115 hm%energy%intnvxc = hm%energy%intnvxc + &
1116 factor*dmf_dotp(ks%gr, st%rho(:, ispin), ks%calc%vxc(:, ispin), reduce = .false.)
1117 end do
1118 call ks%gr%allreduce(hm%energy%intnvxc)
1119 end if
1120 end if
1121
1122
1123 if (ks%theory_level /= hartree .and. ks%theory_level /= rdmft) then
1124 ! move allocation of vxc from ks%calc to hm
1125 safe_deallocate_a(hm%ks_pot%vxc)
1126 call move_alloc(ks%calc%vxc, hm%ks_pot%vxc)
1127
1128 if (family_is_mgga_with_exc(hm%xc)) then
1129 call hm%ks_pot%set_vtau(ks%calc%vtau)
1130 safe_deallocate_a(ks%calc%vtau)
1131
1132 ! We need to evaluate the energy after copying vtau to hm%vtau
1133 if (ks%theory_level == generalized_kohn_sham_dft .and. ks%calc%calc_energy) then
1134 ! MGGA vtau contribution
1135 if (states_are_real(st)) then
1136 hm%energy%intnvxc = hm%energy%intnvxc &
1137 + denergy_calc_electronic(namespace, hm, ks%gr%der, st, terms = term_mgga)
1138 else
1139 hm%energy%intnvxc = hm%energy%intnvxc &
1140 + zenergy_calc_electronic(namespace, hm, ks%gr%der, st, terms = term_mgga)
1141 end if
1142 end if
1143 end if
1144
1145 else
1146 hm%ks_pot%vxc = m_zero
1147 end if
1148
1149 if (.not. ks%xc_photon_include_hartree) then
1150 hm%energy%hartree = m_zero
1151 hm%ks_pot%vhartree = m_zero
1152 end if
1153
1154 ! Build Hartree + XC potential
1155
1156 do ip = 1, ks%gr%np
1157 hm%ks_pot%vhxc(ip, 1) = hm%ks_pot%vxc(ip, 1) + hm%ks_pot%vhartree(ip)
1158 end do
1159 if (allocated(hm%vberry)) then
1160 do ip = 1, ks%gr%np
1161 hm%ks_pot%vhxc(ip, 1) = hm%ks_pot%vhxc(ip, 1) + hm%vberry(ip, 1)
1162 end do
1163 end if
1164
1165 if (hm%d%ispin > unpolarized) then
1166 do ip = 1, ks%gr%np
1167 hm%ks_pot%vhxc(ip, 2) = hm%ks_pot%vxc(ip, 2) + hm%ks_pot%vhartree(ip)
1168 end do
1169 if (allocated(hm%vberry)) then
1170 do ip = 1, ks%gr%np
1171 hm%ks_pot%vhxc(ip, 2) = hm%ks_pot%vhxc(ip, 2) + hm%vberry(ip, 2)
1172 end do
1173 end if
1174 end if
1175
1176 if (hm%d%ispin == spinors) then
1177 do ispin=3, 4
1178 do ip = 1, ks%gr%np
1179 hm%ks_pot%vhxc(ip, ispin) = hm%ks_pot%vxc(ip, ispin)
1180 end do
1181 end do
1182 end if
1183
1184 ! Note: this includes hybrids calculated with the Fock operator instead of OEP
1185 hm%energy%exchange_hf = m_zero
1186 if (ks%theory_level == hartree .or. ks%theory_level == hartree_fock &
1187 .or. ks%theory_level == rdmft &
1188 .or. (ks%theory_level == generalized_kohn_sham_dft .and. family_is_hybrid(ks%xc))) then
1189
1190 ! swap the states object
1191 if (.not. hm%exxop%useACE) then
1192 ! We also close the MPI remote memory access to the old object
1193 if (associated(hm%exxop%st)) then
1195 call states_elec_end(hm%exxop%st)
1196 safe_deallocate_p(hm%exxop%st)
1197 end if
1198 ! We activate the MPI remote memory access for ks%calc%hf_st
1199 ! This allows to have all calls to exchange_operator_apply_standard to access
1200 ! the states over MPI
1202 end if
1203
1204 ! The exchange operator will use ks%calc%hf_st
1205 ! For the ACE case, this is the same as st
1206 if (.not. optional_default(force_semilocal, .false.)) then
1207 select case (ks%theory_level)
1209 if (family_is_hybrid(ks%xc)) then
1210 call exchange_operator_reinit(hm%exxop, ks%xc%cam, ks%calc%hf_st)
1211 end if
1212 case (hartree_fock)
1213 call exchange_operator_reinit(hm%exxop, ks%xc%cam, ks%calc%hf_st)
1214 case (hartree, rdmft)
1215 call exchange_operator_reinit(hm%exxop, cam_exact_exchange, ks%calc%hf_st)
1216 end select
1217
1218 !This should be changed and the CAM parameters should also be obtained from the restart information
1219 !Maybe the parameters should be mixed too.
1220 exx_energy = m_zero
1221 if (hm%exxop%useACE) then
1222 call xst%nullify()
1223 if (states_are_real(ks%calc%hf_st)) then
1224 ! TODO(Alex) Clean up nested if statements
1225 if (hm%exxop%with_isdf) then
1226 ! Find interpolation points from density, or read from file
1227 ! TODO(Alex) Issue #1195 Extend ISDF to spin-polarised systems
1228 call hm%exxop%isdf%get_interpolation_points(namespace, space, ks%gr, st%rho(1:ks%gr%np, 1))
1229 call isdf_ace_compute_potentials(hm%exxop, namespace, space, ks%gr, &
1230 ks%calc%hf_st, xst, hm%kpoints)
1231 else
1232 call dexchange_operator_compute_potentials(hm%exxop, namespace, space, ks%gr, &
1233 ks%calc%hf_st, xst, hm%kpoints)
1234 endif
1235 exx_energy = dexchange_operator_compute_ex(ks%gr, ks%calc%hf_st, xst)
1236 call dexchange_operator_ace(hm%exxop, namespace, ks%gr, ks%calc%hf_st, xst)
1237 else
1238 call zexchange_operator_compute_potentials(hm%exxop, namespace, space, ks%gr, &
1239 ks%calc%hf_st, xst, hm%kpoints)
1240 exx_energy = zexchange_operator_compute_ex(ks%gr, ks%calc%hf_st, xst)
1241 if (hm%phase%is_allocated()) then
1242 call zexchange_operator_ace(hm%exxop, namespace, ks%gr, ks%calc%hf_st, xst, hm%phase)
1243 else
1244 call zexchange_operator_ace(hm%exxop, namespace, ks%gr, ks%calc%hf_st, xst)
1245 end if
1246 end if
1247 call states_elec_end(xst)
1248 exx_energy = exx_energy + hm%exxop%singul%energy
1249 end if
1250
1251 ! Add the energy only the ACE case. In the non-ACE case, the singularity energy is added in energy_calc.F90
1252 select case (ks%theory_level)
1254 if (family_is_hybrid(ks%xc)) then
1255 hm%energy%exchange_hf = hm%energy%exchange_hf + exx_energy
1256 end if
1257 case (hartree_fock)
1258 hm%energy%exchange_hf = hm%energy%exchange_hf + exx_energy
1259 end select
1260 else
1261 ! If we ask for semilocal, we deactivate the exchange operator entirely
1262 call exchange_operator_reinit(hm%exxop, cam_null, ks%calc%hf_st)
1263 end if
1264 end if
1265
1266 end if
1267
1268 ! Because of the intent(in) in v_ks_calc_start, we need to update the parameters of hybrids for OEP
1269 ! here
1270 if (ks%theory_level == kohn_sham_dft .and. bitand(ks%xc_family, xc_family_oep) /= 0) then
1271 if (ks%xc%functional(func_x,1)%id /= xc_oep_x_slater .and. ks%xc%functional(func_x,1)%id /= xc_oep_x_fbe) then
1272 call exchange_operator_reinit(hm%exxop, ks%xc%cam)
1273 end if
1274 end if
1275
1276 if (ks%has_photons .and. (ks%xc_photon == 0)) then
1277 if (associated(ks%pt_mx%vmf)) then
1278 forall(ip = 1:ks%gr%np) hm%ks_pot%vhxc(ip, 1) = hm%ks_pot%vhxc(ip, 1) + ks%pt_mx%vmf(ip)
1279 if (hm%d%ispin > unpolarized) then
1280 forall(ip = 1:ks%gr%np) hm%ks_pot%vhxc(ip, 2) = hm%ks_pot%vhxc(ip, 2) + ks%pt_mx%vmf(ip)
1281 end if
1282 end if
1283 hm%ep%photon_forces(1:space%dim) = ks%pt_mx%fmf(1:space%dim)
1284 end if
1285
1286 if (ks%vdw%vdw_correction /= option__vdwcorrection__none) then
1287 assert(allocated(ks%vdw%forces))
1288 hm%ep%vdw_forces(:, :) = ks%vdw%forces(:, :)
1289 hm%ep%vdw_stress = ks%vdw%stress
1290 safe_deallocate_a(ks%vdw%forces)
1291 else
1292 hm%ep%vdw_forces = 0.0_real64
1293 end if
1294
1295 if (ks%calc%time_present .or. hm%time_zero) then
1296 call hm%update(ks%gr, namespace, space, ext_partners, time = ks%calc%time)
1297 else
1298 call hamiltonian_elec_update_pot(hm, ks%gr)
1299 end if
1300
1301
1302 safe_deallocate_a(ks%calc%density)
1303 if (ks%calc%total_density_alloc) then
1304 safe_deallocate_p(ks%calc%total_density)
1305 end if
1306 nullify(ks%calc%total_density)
1307
1308 pop_sub(v_ks_calc_finish)
1309 end subroutine v_ks_calc_finish
1310
1311
1314 !
1315 !! TODO(Alex) Once the implementation is finalised and benchmarked
1316 !! remove the serial version, and get rid of this routine.
1317 subroutine isdf_ace_compute_potentials(exxop, namespace, space, gr, hf_st, xst, kpoints)
1318 type(exchange_operator_t), intent(in ) :: exxop
1319 type(namespace_t), intent(in ) :: namespace
1320 class(space_t), intent(in ) :: space
1321 class(mesh_t), intent(in ) :: gr
1322 type(states_elec_t), intent(in ) :: hf_st
1323 type(kpoints_t), intent(in ) :: kpoints
1324
1325 type(states_elec_t), intent(inout) :: xst
1326
1327 if (exxop%isdf%use_serial) then
1328 call isdf_serial_ace_compute_potentials(exxop, namespace, space, gr, &
1329 hf_st, xst, kpoints)
1330 else
1331 call isdf_parallel_ace_compute_potentials(exxop, namespace, space, gr, &
1332 hf_st, xst, kpoints)
1333 endif
1334
1335 end subroutine isdf_ace_compute_potentials
1336
1337 ! ---------------------------------------------------------
1338 !
1342 !
1343 subroutine v_ks_hartree(namespace, ks, space, hm, ext_partners)
1344 type(namespace_t), intent(in) :: namespace
1345 type(v_ks_t), intent(inout) :: ks
1346 class(space_t), intent(in) :: space
1347 type(hamiltonian_elec_t), intent(inout) :: hm
1348 type(partner_list_t), intent(in) :: ext_partners
1349
1350 push_sub(v_ks_hartree)
1351
1352 if (.not. poisson_is_async(hm%psolver)) then
1353 ! solve the Poisson equation
1354 call dpoisson_solve(hm%psolver, namespace, hm%ks_pot%vhartree, ks%calc%total_density, reset=.false.)
1355 else
1356 ! The calculation was started by v_ks_calc_start.
1357 call dpoisson_solve_finish(hm%psolver, hm%ks_pot%vhartree)
1358 end if
1359
1360 if (ks%calc%calc_energy) then
1361 ! Get the Hartree energy
1362 hm%energy%hartree = m_half*dmf_dotp(ks%gr, ks%calc%total_density, hm%ks_pot%vhartree)
1363 end if
1364
1366 if(ks%calc%time_present) then
1367 if(hamiltonian_elec_has_kick(hm)) then
1368 call pcm_hartree_potential(hm%pcm, space, ks%gr, hm%psolver, ext_partners, hm%ks_pot%vhartree, &
1369 ks%calc%total_density, hm%energy%pcm_corr, kick=hm%kick, time=ks%calc%time)
1370 else
1371 call pcm_hartree_potential(hm%pcm, space, ks%gr, hm%psolver, ext_partners, hm%ks_pot%vhartree, &
1372 ks%calc%total_density, hm%energy%pcm_corr, time=ks%calc%time)
1373 end if
1374 else
1375 if(hamiltonian_elec_has_kick(hm)) then
1376 call pcm_hartree_potential(hm%pcm, space, ks%gr, hm%psolver, ext_partners, hm%ks_pot%vhartree, &
1377 ks%calc%total_density, hm%energy%pcm_corr, kick=hm%kick)
1378 else
1379 call pcm_hartree_potential(hm%pcm, space, ks%gr, hm%psolver, ext_partners, hm%ks_pot%vhartree, &
1380 ks%calc%total_density, hm%energy%pcm_corr)
1381 end if
1382 end if
1383
1384 pop_sub(v_ks_hartree)
1385 end subroutine v_ks_hartree
1386 ! ---------------------------------------------------------
1387
1388
1389 ! ---------------------------------------------------------
1390 subroutine v_ks_freeze_hxc(ks)
1391 type(v_ks_t), intent(inout) :: ks
1392
1393 push_sub(v_ks_freeze_hxc)
1394
1395 ks%frozen_hxc = .true.
1396
1397 pop_sub(v_ks_freeze_hxc)
1398 end subroutine v_ks_freeze_hxc
1399 ! ---------------------------------------------------------
1400
1401 subroutine v_ks_calculate_current(this, calc_cur)
1402 type(v_ks_t), intent(inout) :: this
1403 logical, intent(in) :: calc_cur
1404
1405 push_sub(v_ks_calculate_current)
1406
1407 this%calculate_current = calc_cur
1408
1409 pop_sub(v_ks_calculate_current)
1410 end subroutine v_ks_calculate_current
1411
1413 subroutine v_ks_update_dftu_energy(ks, namespace, hm, st, int_dft_u)
1414 type(v_ks_t), intent(inout) :: ks
1415 type(hamiltonian_elec_t), intent(in) :: hm
1416 type(namespace_t), intent(in) :: namespace
1417 type(states_elec_t), intent(inout) :: st
1418 real(real64), intent(out) :: int_dft_u
1419
1420 if (hm%lda_u_level == dft_u_none) return
1421
1422 push_sub(v_ks_update_dftu_energy)
1423
1424 if (states_are_real(st)) then
1425 int_dft_u = denergy_calc_electronic(namespace, hm, ks%gr%der, st, terms = term_dft_u)
1426 else
1427 int_dft_u = zenergy_calc_electronic(namespace, hm, ks%gr%der, st, terms = term_dft_u)
1428 end if
1429
1431 end subroutine v_ks_update_dftu_energy
1432end module v_ks_oct_m
1433
1434!! Local Variables:
1435!! mode: f90
1436!! coding: utf-8
1437!! End:
constant times a vector plus a vector
Definition: lalg_basic.F90:173
scales a vector by a constant
Definition: lalg_basic.F90:159
This is the common interface to a sorting routine. It performs the shell algorithm,...
Definition: sort.F90:151
pure logical function, public accel_is_enabled()
Definition: accel.F90:380
subroutine, public current_calculate(this, namespace, gr, hm, space, st)
Compute total electronic current density.
Definition: current.F90:371
subroutine, public current_init(this, namespace)
Definition: current.F90:181
This module implements a calculator for the density and defines related functions.
Definition: density.F90:122
subroutine, public states_elec_total_density(st, mesh, total_rho)
This routine calculates the total electronic density.
Definition: density.F90:853
subroutine, public density_calc(st, gr, density, istin)
Computes the density from the orbitals in st.
Definition: density.F90:612
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public unpolarized
Parameters...
integer, parameter, public spinors
subroutine, public energy_calc_total(namespace, space, hm, gr, st, ext_partners, iunit, full)
This subroutine calculates the total energy of the system. Basically, it adds up the KS eigenvalues,...
real(real64) function, public zenergy_calc_electronic(namespace, hm, der, st, terms)
real(real64) function, public denergy_calc_electronic(namespace, hm, der, st, terms)
subroutine, public energy_calc_eigenvalues(namespace, hm, der, st)
subroutine, public energy_copy(ein, eout)
Definition: energy.F90:170
subroutine, public dexchange_operator_ace(this, namespace, mesh, st, xst, phase)
subroutine, public zexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, F_out)
subroutine, public exchange_operator_reinit(this, cam, st)
subroutine, public dexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, F_out)
subroutine, public zexchange_operator_ace(this, namespace, mesh, st, xst, phase)
real(real64) function, public dexchange_operator_compute_ex(mesh, st, xst)
Compute the exact exchange energy.
real(real64) function, public zexchange_operator_compute_ex(mesh, st, xst)
Compute the exact exchange energy.
real(real64), parameter, public m_two
Definition: global.F90:193
real(real64), parameter, public m_zero
Definition: global.F90:191
integer, parameter, public rdmft
Definition: global.F90:237
integer, parameter, public hartree_fock
Definition: global.F90:237
integer, parameter, public independent_particles
Theory level.
Definition: global.F90:237
integer, parameter, public generalized_kohn_sham_dft
Definition: global.F90:237
integer, parameter, public kohn_sham_dft
Definition: global.F90:237
real(real64), parameter, public m_epsilon
Definition: global.F90:207
real(real64), parameter, public m_half
Definition: global.F90:197
real(real64), parameter, public m_one
Definition: global.F90:192
integer, parameter, public hartree
Definition: global.F90:237
This module implements the underlying real-space grid.
Definition: grid.F90:119
integer, parameter, public term_mgga
integer, parameter, public term_dft_u
logical function, public hamiltonian_elec_has_kick(hm)
logical function, public hamiltonian_elec_needs_current(hm, states_are_real)
subroutine, public hamiltonian_elec_update_pot(this, mesh, accumulate)
Update the KS potential of the electronic Hamiltonian.
This module defines classes and functions for interaction partners.
Interoperable Separable Density Fitting (ISDF) molecular implementation.
Definition: isdf.F90:116
subroutine, public isdf_ace_compute_potentials(exxop, namespace, space, mesh, st, Vx_on_st, kpoints)
ISDF wrapper computing interpolation points and vectors, which are used to build the potential used ...
Definition: isdf.F90:162
Serial prototype for benchmarking and validating ISDF implementation.
subroutine, public isdf_serial_ace_compute_potentials(exxop, namespace, space, mesh, st, Vx_on_st, kpoints)
ISDF wrapper computing interpolation points and vectors, which are used to build the potential used ...
A module to handle KS potential, without the external potential.
integer, parameter, public dft_u_none
Definition: lda_u.F90:203
This modules implements the routines for doing constrain DFT for noncollinear magnetism.
integer, parameter, public constrain_none
subroutine, public magnetic_constrain_update(this, mesh, std, space, latt, pos, rho)
Recomputes the magnetic contraining potential.
subroutine, public magnetic_induced(namespace, gr, st, psolver, kpoints, a_ind, b_ind)
This subroutine receives as input a current, and produces as an output the vector potential that it i...
Definition: magnetic.F90:371
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_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:898
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1091
character(len=512), private msg
Definition: messages.F90:167
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:525
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1023
subroutine, public messages_new_line()
Definition: messages.F90:1112
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_experimental(name, namespace)
Definition: messages.F90:1063
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:594
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
logical function, public parse_is_defined(namespace, name)
Definition: parser.F90:455
subroutine, public pcm_hartree_potential(pcm, space, mesh, psolver, ext_partners, vhartree, density, pcm_corr, kick, time)
PCM reaction field due to the electronic density.
subroutine, public mf_calc(this, gr, st, ions, pt_mode, time)
subroutine, public dpoisson_solve_start(this, rho)
Definition: poisson.F90:2029
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel, reset)
Calculates the Poisson equation. Given the density returns the corresponding potential.
Definition: poisson.F90:875
subroutine, public dpoisson_solve_finish(this, pot)
Definition: poisson.F90:2037
logical pure function, public poisson_is_async(this)
Definition: poisson.F90:1162
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:631
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:554
integer, parameter, public pseudo_exchange_unknown
Definition: pseudo.F90:190
integer, parameter, public pseudo_correlation_unknown
Definition: pseudo.F90:194
integer, parameter, public pseudo_correlation_any
Definition: pseudo.F90:194
integer, parameter, public pseudo_exchange_any
Definition: pseudo.F90:190
This module is intended to contain "only mathematical" functions and procedures.
Definition: sort.F90:119
integer, parameter, private libxc_c_index
Definition: species.F90:280
pure logical function, public states_are_complex(st)
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public states_elec_fermi(st, namespace, mesh, compute_spin)
calculate the Fermi level for the states in this object
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
subroutine, public states_elec_allocate_current(st, space, mesh)
This module provides routines for communicating states when using states parallelization.
subroutine, public states_elec_parallel_remote_access_stop(this)
stop remote memory access for states on other processors
subroutine, public states_elec_parallel_remote_access_start(this)
start remote memory access for states on other processors
subroutine v_ks_hartree(namespace, ks, space, hm, ext_partners)
Hartree contribution to the KS potential. This function is designed to be used by v_ks_calc_finish an...
Definition: v_ks.F90:1439
subroutine, public v_ks_calc_finish(ks, hm, namespace, space, latt, st, ext_partners, force_semilocal)
Definition: v_ks.F90:1104
subroutine, public v_ks_freeze_hxc(ks)
Definition: v_ks.F90:1486
subroutine, public v_ks_end(ks)
Definition: v_ks.F90:631
subroutine, public v_ks_calculate_current(this, calc_cur)
Definition: v_ks.F90:1497
subroutine, public v_ks_write_info(ks, iunit, namespace)
Definition: v_ks.F90:663
subroutine, public v_ks_update_dftu_energy(ks, namespace, hm, st, int_dft_u)
Update the value of <\psi | V_U | \psi>, where V_U is the DFT+U potential.
Definition: v_ks.F90:1509
subroutine, public v_ks_calc_start(ks, namespace, space, hm, st, ions, latt, ext_partners, time, calc_energy, force_semilocal)
This routine starts the calculation of the Kohn-Sham potential. The routine v_ks_calc_finish must be ...
Definition: v_ks.F90:807
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Definition: v_ks.F90:752
subroutine, public v_ks_h_setup(namespace, space, gr, ions, ext_partners, st, ks, hm, calc_eigenval, calc_current)
Definition: v_ks.F90:698
subroutine, public v_ks_init(ks, namespace, gr, st, ions, mc, space, kpoints)
Definition: v_ks.F90:254
subroutine, public x_slater_calc(namespace, gr, space, exxop, st, kpoints, ex, vxc)
Interface to X(slater_calc)
Definition: x_slater.F90:147
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 x_fbe_calc(id, namespace, psolver, gr, st, space, ex, vxc)
Interface to X(x_fbe_calc) Two possible run modes possible: adiabatic and Sturm-Liouville....
Definition: xc_fbe.F90:172
subroutine, public fbe_c_lda_sl(namespace, gr, st, space, ec, vxc)
Sturm-Liouville version of the FBE local-density correlation functional.
Definition: xc_fbe.F90:456
integer, parameter, public xc_family_ks_inversion
declaring 'family' constants for 'functionals' not handled by libxc careful not to use a value define...
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_family_nc_mgga
integer, parameter, public xc_oep_x
Exact exchange.
integer, parameter, public xc_lda_c_fbe_sl
LDA correlation based ib the force-balance equation - Sturm-Liouville version.
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.
integer, parameter, public xc_oep_x_slater
Slater approximation to the exact exchange.
integer, parameter, public func_c
integer, parameter, public func_x
subroutine, public xc_ks_inversion_end(ks_inv)
subroutine, public xc_ks_inversion_write_info(ks_inversion, iunit, namespace)
subroutine, public xc_ks_inversion_init(ks_inv, namespace, gr, ions, st, xc, mc, space, kpoints)
subroutine, public xc_ks_inversion_calc(ks_inversion, namespace, space, gr, hm, ext_partners, st, vxc, time)
Definition: xc.F90:116
subroutine, public xc_write_info(xcs, iunit, namespace)
Definition: xc.F90:226
subroutine, public xc_init(xcs, namespace, ndim, periodic_dim, nel, x_id, c_id, xk_id, ck_id, hartree_fock, ispin)
Definition: xc.F90:276
pure logical function, public family_is_mgga(family, only_collinear)
Is the xc function part of the mGGA family.
Definition: xc.F90:580
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:593
subroutine, public xc_end(xcs)
Definition: xc.F90:518
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:772
logical pure function, public family_is_hybrid(xcs)
Returns true if the functional is an hybrid functional.
Definition: xc.F90:608
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:2530
integer, parameter, public oep_type_mgga
Definition: xc_oep.F90:186
integer, parameter, public oep_level_none
the OEP levels
Definition: xc_oep.F90:174
subroutine, public xc_oep_end(oep)
Definition: xc_oep.F90:358
subroutine, public zxc_oep_calc(oep, namespace, xcs, gr, hm, st, space, rcell_volume, ex, ec, vxc)
This file handles the evaluation of the OEP potential, in the KLI or full OEP as described in S....
Definition: xc_oep.F90:2339
subroutine, public dxc_oep_calc(oep, namespace, xcs, gr, hm, st, space, rcell_volume, ex, ec, vxc)
This file handles the evaluation of the OEP potential, in the KLI or full OEP as described in S....
Definition: xc_oep.F90:1447
subroutine, public xc_oep_write_info(oep, iunit, namespace)
Definition: xc_oep.F90:380
integer, parameter, public oep_type_exx
The different types of OEP that we can work with.
Definition: xc_oep.F90:186
subroutine, public xc_oep_init(oep, namespace, gr, st, mc, space, oep_type)
Definition: xc_oep.F90:219
subroutine, public zxc_oep_photon_calc(oep, namespace, xcs, gr, hm, st, space, ex, ec, vxc)
This file handles the evaluation of the OEP potential, in the KLI or full OEP as described in S....
subroutine, public dxc_oep_photon_calc(oep, namespace, xcs, gr, hm, st, space, ex, ec, vxc)
This file handles the evaluation of the OEP potential, in the KLI or full OEP as described in S....
This module implements the "photon-free" electron-photon exchange-correlation functional.
Definition: xc_photons.F90:123
integer, parameter, public sic_none
no self-interaction correction
Definition: xc_sic.F90:151
subroutine, public xc_sic_write_info(sic, iunit, namespace)
Definition: xc_sic.F90:254
integer, parameter, public sic_adsic
Averaged density SIC.
Definition: xc_sic.F90:151
subroutine, public xc_sic_init(sic, namespace, gr, st, mc, space)
initialize the SIC object
Definition: xc_sic.F90:171
subroutine, public xc_sic_end(sic)
finalize the SIC and, if needed, the included OEP
Definition: xc_sic.F90:240
integer, parameter, public sic_pz_oep
Perdew-Zunger SIC (OEP way)
Definition: xc_sic.F90:151
integer, parameter, public sic_amaldi
Amaldi correction term.
Definition: xc_sic.F90:151
subroutine, public xc_sic_calc_adsic(sic, namespace, space, gr, st, hm, xc, density, vxc, ex, ec)
Computes the ADSIC potential and energy.
Definition: xc_sic.F90:285
A module that takes care of xc contribution from vdW interactions.
Definition: xc_vdw.F90:118
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Definition: grid.F90:171
Describes mesh distribution to nodes.
Definition: mesh.F90:187
The states_elec_t class contains all electronic wave functions.
int true(void)
subroutine get_functional_from_pseudos(x_functional, c_functional)
Tries to find out the functional from the pseudopotential.
Definition: v_ks.F90:573
subroutine v_a_xc(hm, force_semilocal)
Definition: v_ks.F90:951
subroutine calculate_density()
Definition: v_ks.F90:914