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