38 use,
intrinsic :: iso_fortran_env
72 use xc_functional_oct_m
102 logical :: calculating
103 logical :: time_present
105 real(real64),
allocatable :: density(:, :)
106 logical :: total_density_alloc
107 real(real64),
pointer,
contiguous :: total_density(:)
108 type(energy_t),
allocatable :: energy
109 type(states_elec_t),
pointer :: hf_st
110 real(real64),
allocatable :: vxc(:, :)
111 real(real64),
allocatable :: vtau(:, :)
112 real(real64),
allocatable :: axc(:, :, :)
113 real(real64),
allocatable :: a_ind(:, :)
114 real(real64),
allocatable :: b_ind(:, :)
115 logical :: calc_energy
120 integer,
public :: theory_level = -1
122 logical,
public :: frozen_hxc = .false.
124 integer,
public :: xc_family = 0
125 integer,
public :: xc_flags = 0
126 integer,
public :: xc_photon = 0
127 type(xc_t),
public :: xc
128 type(xc_photons_t),
public :: xc_photons
129 type(xc_oep_t),
public :: oep
130 type(xc_oep_photon_t),
public :: oep_photon
131 type(xc_ks_inversion_t),
public :: ks_inversion
132 type(xc_sic_t),
public :: sic
133 type(xc_vdw_t),
public :: vdw
134 type(grid_t),
pointer,
public :: gr
135 type(v_ks_calc_t) :: calc
136 logical :: calculate_current = .false.
137 type(current_t) :: current_calculator
138 logical :: include_td_field = .false.
139 logical,
public :: has_photons = .false.
140 logical :: xc_photon_include_hartree = .
true.
142 real(real64),
public :: stress_xc_gga(3, 3)
143 type(photon_mode_t),
pointer,
public :: pt => null()
144 type(mf_t),
public :: pt_mx
150 subroutine v_ks_init(ks, namespace, gr, st, ions, mc, space, kpoints)
151 type(v_ks_t),
intent(inout) :: ks
152 type(namespace_t),
intent(in) :: namespace
153 type(grid_t),
target,
intent(inout) :: gr
154 type(states_elec_t),
intent(in) :: st
155 type(ions_t),
intent(inout) :: ions
156 type(multicomm_t),
intent(in) :: mc
157 class(space_t),
intent(in) :: space
158 type(kpoints_t),
intent(in) :: kpoints
160 integer :: x_id, c_id, xk_id, ck_id, default, val
161 logical :: parsed_theory_level, using_hartree_fock
162 integer :: pseudo_x_functional, pseudo_c_functional
205 ks%xc_family = xc_family_none
211 parsed_theory_level = .false.
227 default = xc_get_default_functional(space%dim, pseudo_x_functional, pseudo_c_functional)
232 call messages_write(
'Info: the XCFunctional has been selected to match the pseudopotentials', new_line = .
true.)
247 call messages_write(
'The XCFunctional that you selected does not match the one used', new_line = .
true.)
296 call parse_variable(namespace,
'XCPhotonFunctional', option__xcphotonfunctional__none, ks%xc_photon)
306 call parse_variable(namespace,
'XCPhotonIncludeHartree', .
true., ks%xc_photon_include_hartree)
308 if (.not. ks%xc_photon_include_hartree)
then
319 using_hartree_fock = (ks%theory_level ==
hartree_fock) &
321 call xc_init(ks%xc, namespace, space%dim, space%periodic_dim, st%qtot, &
322 x_id, c_id, xk_id, ck_id,
hartree_fock = using_hartree_fock, ispin=st%d%ispin)
324 ks%xc_family = ks%xc%family
325 ks%xc_flags = ks%xc%flags
327 if (.not. parsed_theory_level)
then
331 if (family_is_hybrid(ks%xc) .or. family_is_mgga_with_exc(ks%xc))
then
336 call parse_variable(namespace,
'TheoryLevel', default, ks%theory_level)
343 if (family_is_mgga_with_exc(ks%xc))
then
348 ks%xc_family = ior(ks%xc_family, xc_family_oep)
358 ks%sic%amaldi_factor =
m_one
360 select case (ks%theory_level)
365 if (space%periodic_dim == space%dim)
then
368 if (kpoints%full%npoints > 1)
then
373 if (kpoints%full%npoints > 1)
then
378 if (kpoints%full%npoints > 1 .and. family_is_hybrid(ks%xc))
then
388 if (
bitand(ks%xc_family, xc_family_lda + xc_family_gga) /= 0)
then
389 call xc_sic_init(ks%sic, namespace, gr, st, mc, space)
392 if (
bitand(ks%xc_family, xc_family_oep) /= 0)
then
393 select case (ks%xc%functional(
func_x,1)%id)
394 case (xc_oep_x_slater)
395 if (kpoints%reduced%npoints > 1)
then
400 if (kpoints%reduced%npoints > 1)
then
405 if((.not. ks%has_photons) .or. (ks%xc_photon /= 0))
then
406 if(oep_type == -1)
then
409 call xc_oep_init(ks%oep, namespace, gr, st, mc, space, oep_type)
416 if (
bitand(ks%xc_family, xc_family_ks_inversion) /= 0)
then
423 message(1) =
"SICCorrection can only be used with Kohn-Sham DFT"
427 if (st%d%ispin ==
spinors)
then
428 if (
bitand(ks%xc_family, xc_family_mgga + xc_family_hyb_mgga) /= 0)
then
433 ks%frozen_hxc = .false.
438 ks%calc%calculating = .false.
443 call ks%vdw%init(namespace, space, gr, ks%xc, ions, x_id, c_id)
445 if (ks%xc_photon /= 0)
then
447 call ks%xc_photons%init(namespace, ks%xc_photon , space, gr, st)
459 integer,
intent(out) :: x_functional
460 integer,
intent(out) :: c_functional
462 integer :: xf, cf, ispecies
463 logical :: warned_inconsistent
468 warned_inconsistent = .false.
469 do ispecies = 1, ions%nspecies
470 select type(spec=>ions%species(ispecies)%s)
472 xf = spec%x_functional()
473 cf = spec%c_functional()
476 call messages_write(
"Unknown XC functional for species '"//trim(ions%species(ispecies)%s%get_label())//
"'")
484 if (xf /= x_functional .and. .not. warned_inconsistent)
then
485 call messages_write(
'Inconsistent XC functional detected between species')
487 warned_inconsistent = .
true.
494 if (cf /= c_functional .and. .not. warned_inconsistent)
then
495 call messages_write(
'Inconsistent XC functional detected between species')
497 warned_inconsistent = .
true.
517 type(
v_ks_t),
intent(inout) :: ks
523 select case (ks%theory_level)
525 if (
bitand(ks%xc_family, xc_family_ks_inversion) /= 0)
then
528 if (
bitand(ks%xc_family, xc_family_oep) /= 0)
then
538 if (ks%xc_photon /= 0)
then
539 call ks%xc_photons%end()
549 type(
v_ks_t),
intent(in) :: ks
550 integer,
optional,
intent(in) :: iunit
558 select case (ks%theory_level)
561 call xc_write_info(ks%xc, iunit, namespace)
565 call xc_write_info(ks%xc, iunit, namespace)
583 subroutine v_ks_h_setup(namespace, space, gr, ions, ext_partners, st, ks, hm, calc_eigenval, calc_current)
586 type(
grid_t),
intent(in) :: gr
587 type(
ions_t),
intent(in) :: ions
590 type(
v_ks_t),
intent(inout) :: ks
592 logical,
optional,
intent(in) :: calc_eigenval
593 logical,
optional,
intent(in) :: calc_current
595 integer,
allocatable :: ind(:)
597 real(real64),
allocatable :: copy_occ(:)
598 logical :: calc_eigenval_
599 logical :: calc_current_
607 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = calc_eigenval_, calc_current = calc_current_)
609 if (st%restart_reorder_occs .and. .not. st%fromScratch)
then
610 message(1) =
"Reordering occupations for restart."
613 safe_allocate(ind(1:st%nst))
614 safe_allocate(copy_occ(1:st%nst))
617 call sort(st%eigenval(:, ik), ind)
618 copy_occ(1:st%nst) = st%occ(1:st%nst, ik)
620 st%occ(ist, ik) = copy_occ(ind(ist))
624 safe_deallocate_a(ind)
625 safe_deallocate_a(copy_occ)
635 subroutine v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
636 calc_eigenval, time, calc_energy, calc_current, force_semilocal)
637 type(
v_ks_t),
intent(inout) :: ks
642 type(
ions_t),
intent(in) :: ions
644 logical,
optional,
intent(in) :: calc_eigenval
645 real(real64),
optional,
intent(in) :: time
646 logical,
optional,
intent(in) :: calc_energy
647 logical,
optional,
intent(in) :: calc_current
648 logical,
optional,
intent(in) :: force_semilocal
650 logical :: calc_current_
656 call v_ks_calc_start(ks, namespace, space, hm, st, ions, hm%kpoints%latt, ext_partners, time, &
657 calc_energy, calc_current_, force_semilocal=force_semilocal)
659 ext_partners, force_semilocal=force_semilocal)
670 call lalg_axpy(ks%gr%np, st%d%nspin,
m_one, hm%magnetic_constrain%pot, hm%ks_pot%vhxc)
682 subroutine v_ks_calc_start(ks, namespace, space, hm, st, ions, latt, ext_partners, time, &
683 calc_energy, calc_current, force_semilocal)
684 type(
v_ks_t),
target,
intent(inout) :: ks
686 class(
space_t),
intent(in) :: space
689 type(
ions_t),
intent(in) :: ions
692 real(real64),
optional,
intent(in) :: time
693 logical,
optional,
intent(in) :: calc_energy
694 logical,
optional,
intent(in) :: calc_current
695 logical,
optional,
intent(in) :: force_semilocal
697 logical :: calc_current_
702 .and. ks%calculate_current &
708 assert(.not. ks%calc%calculating)
709 ks%calc%calculating = .
true.
711 write(
message(1),
'(a)')
'Debug: Calculating Kohn-Sham potential.'
714 ks%calc%time_present =
present(time)
720 if (ks%frozen_hxc)
then
721 if (calc_current_)
then
731 allocate(ks%calc%energy)
735 ks%calc%energy%intnvxc =
m_zero
737 nullify(ks%calc%total_density)
747 if (ks%theory_level /=
hartree .and. ks%theory_level /=
rdmft)
call v_a_xc(hm, force_semilocal)
749 ks%calc%total_density_alloc = .false.
752 if (calc_current_)
then
757 nullify(ks%calc%hf_st)
760 .and. family_is_hybrid(ks%xc)))
then
761 safe_allocate(ks%calc%hf_st)
764 if (st%parallel_in_states)
then
766 call messages_write(
'State parallelization of Hartree-Fock exchange is not supported')
768 call messages_write(
'when running with OpenCL/CUDA. Please use domain parallelization')
770 call messages_write(
"or disable acceleration using 'DisableAccel = yes'.")
782 if (hm%self_induced_magnetic)
then
783 safe_allocate(ks%calc%a_ind(1:ks%gr%np_part, 1:space%dim))
784 safe_allocate(ks%calc%b_ind(1:ks%gr%np_part, 1:space%dim))
785 call magnetic_induced(namespace, ks%gr, st, hm%psolver, hm%kpoints, ks%calc%a_ind, ks%calc%b_ind)
788 if ((ks%has_photons) .and. (ks%calc%time_present) .and. (ks%xc_photon == 0) )
then
789 call mf_calc(ks%pt_mx, ks%gr, st, ions, ks%pt, time)
807 safe_allocate(ks%calc%density(1:ks%gr%np, 1:st%d%nspin))
812 call lalg_scal(ks%gr%np, st%d%nspin, ks%sic%amaldi_factor, ks%calc%density)
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.
819 safe_allocate(ks%calc%total_density(1:ks%gr%np))
822 ks%calc%total_density(ip) = sum(ks%calc%density(ip, 1:hm%d%spin_channels))
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)
830 ks%calc%total_density_alloc = .false.
831 ks%calc%total_density => ks%calc%density(:, 1)
838 subroutine v_a_xc(hm, force_semilocal)
840 logical,
optional,
intent(in) :: force_semilocal
847 ks%calc%energy%exchange =
m_zero
848 ks%calc%energy%correlation =
m_zero
849 ks%calc%energy%xc_j =
m_zero
850 ks%calc%energy%vdw =
m_zero
852 allocate(ks%calc%vxc(1:ks%gr%np, 1:st%d%nspin))
855 if (family_is_mgga_with_exc(hm%xc))
then
856 safe_allocate(ks%calc%vtau(1:ks%gr%np, 1:st%d%nspin))
861 if (ks%calc%calc_energy)
then
862 if (family_is_mgga_with_exc(hm%xc))
then
863 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, st%d%ispin, &
864 latt%rcell_volume, ks%calc%vxc, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation, &
865 deltaxc = ks%calc%energy%delta_xc, vtau = ks%calc%vtau, force_orbitalfree=force_semilocal)
867 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, st%d%ispin, &
868 latt%rcell_volume, ks%calc%vxc, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation, &
869 deltaxc = ks%calc%energy%delta_xc, stress_xc=ks%stress_xc_gga, force_orbitalfree=force_semilocal)
872 if (family_is_mgga_with_exc(hm%xc))
then
873 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, &
874 st%d%ispin, latt%rcell_volume, ks%calc%vxc, vtau = ks%calc%vtau, force_orbitalfree=force_semilocal)
876 call xc_get_vxc(ks%gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, ks%calc%density, &
877 st%d%ispin, latt%rcell_volume, ks%calc%vxc, stress_xc=ks%stress_xc_gga, force_orbitalfree=force_semilocal)
882 if (
bitand(hm%xc%family, xc_family_nc_lda + xc_family_nc_mgga) /= 0)
then
883 if (st%d%ispin /=
spinors)
then
884 message(1) =
"Noncollinear functionals can only be used with spinor wavefunctions."
889 message(1) =
"Cannot perform LCAO for noncollinear MGGAs."
890 message(2) =
"Please perform a LDA calculation first."
894 if (ks%calc%calc_energy)
then
895 if (family_is_mgga_with_exc(hm%xc))
then
896 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, ks%calc%vxc, &
897 vtau = ks%calc%vtau, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation)
899 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, ks%calc%vxc, &
900 ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation)
903 if (family_is_mgga_with_exc(hm%xc))
then
904 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, &
905 ks%calc%vxc, vtau = ks%calc%vtau)
907 call xc_get_nc_vxc(ks%gr, ks%xc, st, hm%kpoints, space, namespace, ks%calc%density, ks%calc%vxc)
920 if (family_is_mgga(hm%xc%family))
then
923 if (ks%calc%calc_energy)
then
924 call xc_sic_calc_adsic(ks%sic, namespace, space, ks%gr, st, hm, ks%xc, ks%calc%density, &
925 ks%calc%vxc, ex = ks%calc%energy%exchange, ec = ks%calc%energy%correlation)
927 call xc_sic_calc_adsic(ks%sic, namespace, space, ks%gr, st, hm, ks%xc, ks%calc%density, &
936 if (
bitand(ks%xc_family, xc_family_oep) /= 0 .or. family_is_mgga_with_exc(ks%xc))
then
938 if (ks%xc%functional(
func_x,1)%id == xc_oep_x_slater)
then
939 call x_slater_calc(namespace, ks%gr, space, hm%exxop, st, hm%kpoints, ks%calc%energy%exchange, &
941 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
942 call x_fbe_calc(ks%xc%functional(
func_x,1)%id, namespace, hm%psolver, ks%gr, st, space, &
943 ks%calc%energy%exchange, vxc = ks%calc%vxc)
945 else if (ks%xc%functional(
func_c,1)%id == xc_lda_c_fbe_sl)
then
947 call fbe_c_lda_sl(namespace, hm%psolver, ks%gr, st, space, &
948 ks%calc%energy%correlation, vxc = ks%calc%vxc)
954 hm, st, space, ks%calc%energy%exchange, ks%calc%energy%correlation, vxc = ks%calc%vxc)
957 hm, st, space, ks%calc%energy%exchange, ks%calc%energy%correlation, vxc = ks%calc%vxc)
959 ks%calc%energy%photon_exchange = ks%oep_photon%pt%ex
965 if (
bitand(ks%xc_family, xc_family_ks_inversion) /= 0)
then
967 call xc_ks_inversion_calc(ks%ks_inversion, namespace, space, ks%gr, hm, ext_partners, st, vxc = ks%calc%vxc, &
972 if (ks%xc_photon /= 0)
then
974 call ks%xc_photons%v_ks(namespace, ks%calc%total_density, ks%gr, space, hm%psolver, hm%ep, st)
977 do ispin = 1, hm%d%spin_channels
978 call lalg_axpy(ks%gr%np,
m_one, ks%xc_photons%vpx(1:ks%gr%np), ks%calc%vxc(1:ks%gr%np, ispin) )
982 ks%calc%energy%photon_exchange = ks%xc_photons%ex
987 call ks%vdw%calc(namespace, space, latt, ions%atom, ions%natoms, ions%pos, &
988 ks%gr, st, ks%calc%energy%vdw, ks%calc%vxc)
990 if (ks%calc%calc_energy)
then
1009 subroutine v_ks_calc_finish(ks, hm, namespace, space, latt, st, ext_partners, force_semilocal)
1010 type(
v_ks_t),
target,
intent(inout) :: ks
1013 class(
space_t),
intent(in) :: space
1017 logical,
optional,
intent(in) :: force_semilocal
1019 integer :: ip, ispin
1022 real(real64) :: exx_energy
1023 real(real64) :: factor
1027 assert(ks%calc%calculating)
1028 ks%calc%calculating = .false.
1030 if (ks%frozen_hxc)
then
1036 safe_deallocate_a(hm%energy)
1037 call move_alloc(ks%calc%energy, hm%energy)
1039 if (hm%self_induced_magnetic)
then
1040 hm%a_ind(1:ks%gr%np, 1:space%dim) = ks%calc%a_ind(1:ks%gr%np, 1:space%dim)
1041 hm%b_ind(1:ks%gr%np, 1:space%dim) = ks%calc%b_ind(1:ks%gr%np, 1:space%dim)
1043 safe_deallocate_a(ks%calc%a_ind)
1044 safe_deallocate_a(ks%calc%b_ind)
1047 if (
allocated(hm%v_static))
then
1048 hm%energy%intnvstatic =
dmf_dotp(ks%gr, ks%calc%total_density, hm%v_static)
1050 hm%energy%intnvstatic =
m_zero
1056 hm%energy%intnvxc =
m_zero
1057 hm%energy%hartree =
m_zero
1058 hm%energy%exchange =
m_zero
1059 hm%energy%exchange_hf =
m_zero
1060 hm%energy%correlation =
m_zero
1063 hm%energy%hartree =
m_zero
1064 call v_ks_hartree(namespace, ks, space, hm, ext_partners)
1070 call dxc_oep_calc(ks%sic%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1071 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1073 call zxc_oep_calc(ks%sic%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1074 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1081 if (ks%xc%functional(
func_x,1)%id == xc_oep_x .or. family_is_mgga_with_exc(ks%xc))
then
1083 call dxc_oep_calc(ks%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1084 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1086 call zxc_oep_calc(ks%oep, namespace, ks%xc, ks%gr, hm, st, space, &
1087 latt%rcell_volume, hm%energy%exchange, hm%energy%correlation, vxc = ks%calc%vxc)
1093 if (ks%calc%calc_energy)
then
1095 hm%energy%intnvxc =
m_zero
1098 do ispin = 1, hm%d%nspin
1099 if (ispin <= 2)
then
1104 hm%energy%intnvxc = hm%energy%intnvxc + &
1105 factor*
dmf_dotp(ks%gr, st%rho(:, ispin), ks%calc%vxc(:, ispin), reduce = .false.)
1107 if (ks%gr%parallel_in_domains)
call ks%gr%allreduce(hm%energy%intnvxc)
1112 if (ks%theory_level /=
hartree .and. ks%theory_level /=
rdmft)
then
1114 safe_deallocate_a(hm%ks_pot%vxc)
1115 call move_alloc(ks%calc%vxc, hm%ks_pot%vxc)
1117 if (family_is_mgga_with_exc(hm%xc))
then
1118 call hm%ks_pot%set_vtau(ks%calc%vtau)
1119 safe_deallocate_a(ks%calc%vtau)
1125 hm%energy%intnvxc = hm%energy%intnvxc &
1128 hm%energy%intnvxc = hm%energy%intnvxc &
1138 if (.not. ks%xc_photon_include_hartree)
then
1139 hm%energy%hartree =
m_zero
1140 hm%ks_pot%vhartree =
m_zero
1146 hm%ks_pot%vhxc(ip, 1) = hm%ks_pot%vxc(ip, 1) + hm%ks_pot%vhartree(ip)
1148 if (
allocated(hm%vberry))
then
1150 hm%ks_pot%vhxc(ip, 1) = hm%ks_pot%vhxc(ip, 1) + hm%vberry(ip, 1)
1156 hm%ks_pot%vhxc(ip, 2) = hm%ks_pot%vxc(ip, 2) + hm%ks_pot%vhartree(ip)
1158 if (
allocated(hm%vberry))
then
1160 hm%ks_pot%vhxc(ip, 2) = hm%ks_pot%vhxc(ip, 2) + hm%vberry(ip, 2)
1165 if (hm%d%ispin ==
spinors)
then
1168 hm%ks_pot%vhxc(ip, ispin) = hm%ks_pot%vxc(ip, ispin)
1174 hm%energy%exchange_hf =
m_zero
1179 if (
associated(hm%exxop%st))
then
1182 safe_deallocate_p(hm%exxop%st)
1184 if (
associated(ks%calc%hf_st) .and. hm%exxop%useACE)
then
1196 .and. family_is_hybrid(ks%xc))) .and. hm%exxop%useACE)
then
1200 ks%calc%hf_st, xst, hm%kpoints, exx_energy)
1204 ks%calc%hf_st, xst, hm%kpoints, exx_energy)
1205 if (hm%phase%is_allocated())
then
1212 exx_energy = exx_energy + hm%exxop%singul%energy
1216 select case (ks%theory_level)
1218 if (family_is_hybrid(ks%xc))
then
1220 hm%energy%exchange_hf = hm%energy%exchange_hf + exx_energy
1225 hm%energy%exchange_hf = hm%energy%exchange_hf + exx_energy
1239 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
1244 if (ks%has_photons .and. (ks%xc_photon == 0))
then
1245 if (
associated(ks%pt_mx%vmf))
then
1246 forall(ip = 1:ks%gr%np) hm%ks_pot%vhxc(ip, 1) = hm%ks_pot%vhxc(ip, 1) + ks%pt_mx%vmf(ip)
1248 forall(ip = 1:ks%gr%np) hm%ks_pot%vhxc(ip, 2) = hm%ks_pot%vhxc(ip, 2) + ks%pt_mx%vmf(ip)
1251 hm%ep%photon_forces(1:space%dim) = ks%pt_mx%fmf(1:space%dim)
1254 if (ks%vdw%vdw_correction /= option__vdwcorrection__none)
then
1255 hm%ep%vdw_forces = ks%vdw%forces
1256 hm%ep%vdw_stress = ks%vdw%stress
1257 safe_deallocate_a(ks%vdw%forces)
1259 hm%ep%vdw_forces = 0.0_real64
1262 if (ks%calc%time_present .or. hm%time_zero)
then
1263 call hm%update(ks%gr, namespace, space, ext_partners, time = ks%calc%time)
1269 safe_deallocate_a(ks%calc%density)
1270 if (ks%calc%total_density_alloc)
then
1271 safe_deallocate_p(ks%calc%total_density)
1273 nullify(ks%calc%total_density)
1284 subroutine v_ks_hartree(namespace, ks, space, hm, ext_partners)
1286 type(
v_ks_t),
intent(inout) :: ks
1287 class(
space_t),
intent(in) :: space
1295 call dpoisson_solve(hm%psolver, namespace, hm%ks_pot%vhartree, ks%calc%total_density, reset=.false.)
1301 if (ks%calc%calc_energy)
then
1303 hm%energy%hartree =
m_half*
dmf_dotp(ks%gr, ks%calc%total_density, hm%ks_pot%vhartree)
1307 if(ks%calc%time_present)
then
1310 ks%calc%total_density, hm%energy%pcm_corr, kick=hm%kick, time=ks%calc%time)
1313 ks%calc%total_density, hm%energy%pcm_corr, time=ks%calc%time)
1318 ks%calc%total_density, hm%energy%pcm_corr, kick=hm%kick)
1321 ks%calc%total_density, hm%energy%pcm_corr)
1332 type(
v_ks_t),
intent(inout) :: ks
1336 ks%frozen_hxc = .
true.
1343 type(
v_ks_t),
intent(inout) :: this
1344 logical,
intent(in) :: calc_cur
1348 this%calculate_current = calc_cur
constant times a vector plus a vector
scales a vector by a constant
This is the common interface to a sorting routine. It performs the shell algorithm,...
pure logical function, public accel_is_enabled()
subroutine, public current_calculate(this, namespace, gr, hm, space, st)
Compute total electronic current density.
subroutine, public current_init(this, namespace)
This module implements a calculator for the density and defines related functions.
subroutine, public states_elec_total_density(st, mesh, total_rho)
This routine calculates the total electronic density.
subroutine, public density_calc(st, gr, density, istin)
Computes the density from the orbitals in st.
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)
subroutine, public dexchange_operator_ace(this, namespace, mesh, st, xst, phase)
subroutine, public zexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, ex, F_out)
subroutine, public dexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, ex, F_out)
subroutine, public zexchange_operator_ace(this, namespace, mesh, st, xst, phase)
subroutine, public exchange_operator_reinit(this, omega, alpha, beta, st)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_half
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
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.
A module to handle KS potential, without the external potential.
integer, parameter, public rdmft
integer, parameter, public hartree
integer, parameter, public hartree_fock
integer, parameter, public independent_particles
integer, parameter, public generalized_kohn_sham_dft
integer, parameter, public kohn_sham_dft
integer, parameter, public dft_u_none
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...
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
subroutine, public messages_not_implemented(feature, namespace)
character(len=512), private msg
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
subroutine, public messages_new_line()
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_experimental(name, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module handles the communicators for the various parallelization strategies.
logical function, public parse_is_defined(namespace, name)
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)
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel, reset)
Calculates the Poisson equation. Given the density returns the corresponding potential.
subroutine, public dpoisson_solve_finish(this, pot)
logical pure function, public poisson_is_async(this)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
integer, parameter, public pseudo_exchange_unknown
integer, parameter, public pseudo_correlation_unknown
integer, parameter, public pseudo_correlation_any
integer, parameter, public pseudo_exchange_any
This module is intended to contain "only mathematical" functions and procedures.
integer, parameter, private libxc_c_index
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...
subroutine, public v_ks_calc_finish(ks, hm, namespace, space, latt, st, ext_partners, force_semilocal)
subroutine, public v_ks_freeze_hxc(ks)
subroutine, public v_ks_end(ks)
subroutine, public v_ks_calculate_current(this, calc_cur)
subroutine, public v_ks_write_info(ks, iunit, namespace)
subroutine, public v_ks_calc_start(ks, namespace, space, hm, st, ions, latt, ext_partners, time, calc_energy, calc_current, force_semilocal)
This routine starts the calculation of the Kohn-Sham potential. The routine v_ks_calc_finish must be ...
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
subroutine, public v_ks_h_setup(namespace, space, gr, ions, ext_partners, st, ks, hm, calc_eigenval, calc_current)
subroutine, public v_ks_init(ks, namespace, gr, st, ions, mc, space, kpoints)
subroutine, public x_slater_calc(namespace, gr, space, exxop, st, kpoints, ex, vxc)
Interface to X(slater_calc)
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....
subroutine, public fbe_c_lda_sl(namespace, psolver, gr, st, space, ec, vxc)
Sturm-Liouville version of the FBE local-density correlation functional.
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)
integer, parameter, public oep_type_mgga
integer, parameter, public oep_level_none
the OEP levels
subroutine, public xc_oep_end(oep)
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....
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....
subroutine, public xc_oep_write_info(oep, iunit, namespace)
integer, parameter, public oep_type_exx
The different types of OEP that we can work with.
subroutine, public xc_oep_init(oep, namespace, gr, st, mc, space, oep_type)
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.
integer, parameter, public sic_none
no self-interaction correction
subroutine, public xc_sic_write_info(sic, iunit, namespace)
integer, parameter, public sic_adsic
Averaged density SIC.
subroutine, public xc_sic_init(sic, namespace, gr, st, mc, space)
initialize the SIC object
subroutine, public xc_sic_end(sic)
finalize the SIC and, if needed, the included OEP
integer, parameter, public sic_pz_oep
Perdew-Zunger SIC (OEP way)
integer, parameter, public sic_amaldi
Amaldi correction term.
subroutine, public xc_sic_calc_adsic(sic, namespace, space, gr, st, hm, xc, density, vxc, ex, ec)
Computes the ADSIC potential and energy.
A module that takes care of xc contribution from vdW interactions.
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
The states_elec_t class contains all electronic wave functions.
subroutine get_functional_from_pseudos(x_functional, c_functional)
Tries to find out the functional from the pseudopotential.
subroutine v_a_xc(hm, force_semilocal)
subroutine calculate_density()