52 #include "./base/base_uses.f90"
58 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_xc'
78 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: ext_density
79 TYPE(atom_type),
INTENT(INOUT) ::
atom
81 TYPE(opmat_type),
OPTIONAL,
POINTER :: xcmat
83 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_atom_zmp'
85 INTEGER :: extunit, handle, ir, nr, z
86 REAL(kind=
dp) :: int1, int2
87 REAL(kind=
dp),
DIMENSION(:),
POINTER :: deltarho, rho_dum, vxc, vxc1, vxc2
88 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rho
90 CALL timeset(routinen, handle)
92 nr =
atom%basis%grid%nr
94 ALLOCATE (rho(nr, 1), vxc(nr), vxc1(nr), vxc2(nr), rho_dum(nr), deltarho(nr))
97 int1 = integrate_grid(ext_density,
atom%basis%grid)
104 rho_dum = rho(:, 1)*int1/z
105 deltarho = rho_dum - ext_density
106 int2 = integrate_grid(deltarho,
atom%basis%grid)
109 vxc2 = vxc2*
atom%lambda
114 atom%energy%exc =
fourpi*integrate_grid(vxc, rho(:, 1),
atom%basis%grid)
119 CALL open_file(file_name=
"linear_potentials.dat", file_status=
"UNKNOWN", &
120 file_form=
"FORMATTED", file_action=
"WRITE", &
123 WRITE (extunit, fmt=
'("#",T10,"R[bohr]",T36,"Rho[au]",T61,"DRho[au]",T86,"V_XC[au]",T111,"V_XC1[au]",T136,"V_XC2[au]")')
125 WRITE (extunit, fmt=
'(T1,E24.15,T26,E24.15,T51,E24.15,T76,E24.15,T101,E24.15,T126,E24.15)') &
126 atom%basis%grid%rad(ir), rho(ir, 1), deltarho(ir), vxc(ir), vxc1(ir), vxc2(ir)
133 DEALLOCATE (rho, vxc, vxc1, vxc2, rho_dum, deltarho)
135 CALL timestop(handle)
148 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: vxc
149 TYPE(atom_type),
INTENT(INOUT) ::
atom
150 LOGICAL,
INTENT(in) :: lprint
151 TYPE(opmat_type),
INTENT(inout),
OPTIONAL,
POINTER :: xcmat
153 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_atom_ext_vxc'
155 INTEGER :: extunit, handle, ir, nr
156 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rho
158 CALL timeset(routinen, handle)
159 nr =
atom%basis%grid%nr
161 ALLOCATE (rho(nr, 1))
167 CALL open_file(file_name=
"linear_potentials.dat", file_status=
"UNKNOWN", &
168 file_form=
"FORMATTED", file_action=
"WRITE", &
171 WRITE (extunit, fmt=
'("#",T10,"R[bohr]",T36,"Rho[au]",T61,"V_XC[au]")')
173 WRITE (extunit, fmt=
'(T1,E24.15,T26,E24.15,T51,E24.15)') &
174 atom%basis%grid%rad(ir), rho(ir, 1), vxc(ir)
179 atom%energy%exc =
fourpi*integrate_grid(vxc, rho(:, 1),
atom%basis%grid)
184 CALL timestop(handle)
199 TYPE(opmat_type),
POINTER :: xcmat
200 TYPE(atom_type),
INTENT(INOUT) ::
atom
201 TYPE(section_vals_type),
POINTER :: xc_section
203 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_atom_vxc_lda'
205 INTEGER :: deriv_order, handle, i, l, myfun, n1, &
206 n2, n3, nr, nspins, unit_nr
207 INTEGER,
DIMENSION(2, 3) :: bounds
209 REAL(kind=
dp) :: density_cut, gradient_cut, tau_cut
210 REAL(kind=
dp),
DIMENSION(:),
POINTER :: exc, vxc
211 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: drho, lap, rho, tau
212 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: taumat, xcpot
213 TYPE(section_vals_type),
POINTER :: xc_fun_section
214 TYPE(xc_derivative_set_type) :: deriv_set
215 TYPE(xc_derivative_type),
POINTER :: deriv
216 TYPE(xc_rho_cflags_type) :: needs
217 TYPE(xc_rho_set_type) :: rho_set
219 CALL timeset(routinen, handle)
222 IF (
atom%potential%ppot_type == gth_pseudo)
THEN
223 nlcc =
atom%potential%gth_pot%nlcc
224 ELSE IF (
atom%potential%ppot_type == upf_pseudo)
THEN
225 nlcc =
atom%potential%upf_pot%core_correction
226 ELSE IF (
atom%potential%ppot_type == sgp_pseudo)
THEN
227 nlcc =
atom%potential%sgp_pot%has_nlcc
230 IF (
ASSOCIATED(xc_section))
THEN
235 atom%energy%exc = 0._dp
250 nr =
atom%basis%grid%nr
258 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
262 NULLIFY (rho, drho, tau)
264 ALLOCATE (rho(nr, 1))
270 IF (needs%norm_drho)
THEN
271 ALLOCATE (drho(nr, 1))
278 ALLOCATE (tau(nr, 1))
280 typ=
"KIN", rr=
atom%basis%grid%rad2)
282 IF (needs%laplace_rho)
THEN
283 ALLOCATE (lap(nr, 1))
285 typ=
"LAP", rr=
atom%basis%grid%rad2)
291 CALL fill_rho_set(rho_set, nspins, needs, rho, drho, tau, lap, nr)
297 deriv_order=deriv_order)
302 atom%energy%exc =
fourpi*integrate_grid(xcpot(:, 1, 1),
atom%basis%grid)
306 CALL open_file(unit_number=unit_nr, file_status=
"UNKNOWN", file_action=
"WRITE", file_name=
"atom.dat")
307 DO i = 1,
SIZE(xcpot(:, 1, 1))
308 WRITE (unit_nr, *)
atom%basis%grid%rad(i), rho(i, 1), xcpot(i, 1, 1)
318 CALL open_file(unit_number=unit_nr, file_status=
"UNKNOWN", file_action=
"WRITE", file_name=
"atompot.dat")
319 DO i = 1,
SIZE(xcpot(:, 1, 1))
320 WRITE (unit_nr, *)
atom%basis%grid%rad(i), rho(i, 1), xcpot(i, 1, 1)
326 IF (needs%norm_drho)
THEN
331 CALL open_file(unit_number=unit_nr, file_status=
"UNKNOWN", file_action=
"WRITE", file_name=
"atomdpot.dat")
332 DO i = 1,
SIZE(xcpot(:, 1, 1))
333 WRITE (unit_nr, *)
atom%basis%grid%rad(i), drho(i, 1), xcpot(i, 1, 1)
342 n1 =
SIZE(xcmat%op, 1)
343 n2 =
SIZE(xcmat%op, 2)
344 n3 =
SIZE(xcmat%op, 3)
345 ALLOCATE (taumat(n1, n2, 0:n3 - 1))
348 xcpot(:, 1, 1) = 0.5_dp*xcpot(:, 1, 1)
350 xcpot(:, 1, 1) = xcpot(:, 1, 1)/
atom%basis%grid%rad2(:)
353 xcmat%op(:, :, l) = xcmat%op(:, :, l) + real(l*(l + 1),
dp)*taumat(:, :, l)
361 IF (needs%laplace_rho)
THEN
374 nr =
atom%basis%grid%nr
375 ALLOCATE (rho(nr, 1), exc(nr), vxc(nr))
381 CALL lda_pade(rho(:, 1), exc, vxc)
386 DEALLOCATE (rho, exc, vxc)
390 CALL timestop(handle)
404 TYPE(opmat_type),
POINTER :: xcmata, xcmatb
405 TYPE(atom_type),
INTENT(INOUT) ::
atom
406 TYPE(section_vals_type),
POINTER :: xc_section
408 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_atom_vxc_lsd'
410 INTEGER :: deriv_order, handle, l, myfun, n1, n2, &
412 INTEGER,
DIMENSION(2, 3) :: bounds
414 REAL(kind=
dp) :: density_cut, gradient_cut, tau_cut
415 REAL(kind=
dp),
DIMENSION(:),
POINTER :: exc, vxca, vxcb, xfun
416 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: drho, lap, rho, tau
417 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: taumat, xcpot
418 TYPE(section_vals_type),
POINTER :: xc_fun_section
419 TYPE(xc_derivative_set_type) :: deriv_set
420 TYPE(xc_derivative_type),
POINTER :: deriv
421 TYPE(xc_rho_cflags_type) :: needs
422 TYPE(xc_rho_set_type) :: rho_set
424 CALL timeset(routinen, handle)
427 IF (
atom%potential%ppot_type == gth_pseudo)
THEN
428 nlcc =
atom%potential%gth_pot%nlcc
429 ELSE IF (
atom%potential%ppot_type == upf_pseudo)
THEN
430 nlcc =
atom%potential%upf_pot%core_correction
432 ELSE IF (
atom%potential%ppot_type == sgp_pseudo)
THEN
433 nlcc =
atom%potential%sgp_pot%has_nlcc
437 IF (
ASSOCIATED(xc_section))
THEN
439 nr =
atom%basis%grid%nr
447 atom%energy%exc = 0._dp
462 nr =
atom%basis%grid%nr
470 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
474 NULLIFY (rho, drho, tau)
475 IF (needs%rho_spin)
THEN
476 ALLOCATE (rho(nr, 2))
482 rho(:, 1) = rho(:, 1) + 0.5_dp*xfun(:)
483 rho(:, 2) = rho(:, 2) + 0.5_dp*xfun(:)
486 IF (needs%norm_drho_spin)
THEN
487 ALLOCATE (drho(nr, 2))
493 drho(:, 1) = drho(:, 1) + 0.5_dp*xfun(:)
494 drho(:, 2) = drho(:, 2) + 0.5_dp*xfun(:)
497 IF (needs%tau_spin)
THEN
498 ALLOCATE (tau(nr, 2))
500 typ=
"KIN", rr=
atom%basis%grid%rad2)
502 typ=
"KIN", rr=
atom%basis%grid%rad2)
504 IF (needs%laplace_rho_spin)
THEN
505 ALLOCATE (lap(nr, 2))
507 typ=
"LAP", rr=
atom%basis%grid%rad2)
509 typ=
"LAP", rr=
atom%basis%grid%rad2)
513 lap(:, 1) = lap(:, 1) + 0.5_dp*xfun(:)
514 lap(:, 2) = lap(:, 2) + 0.5_dp*xfun(:)
518 CALL fill_rho_set(rho_set, nspins, needs, rho, drho, tau, lap, nr)
524 deriv_order=deriv_order)
529 atom%energy%exc =
fourpi*integrate_grid(xcpot(:, 1, 1),
atom%basis%grid)
531 IF (needs%rho_spin)
THEN
540 IF (needs%norm_drho_spin)
THEN
554 IF (
ASSOCIATED(deriv))
THEN
561 IF (needs%tau_spin)
THEN
562 n1 =
SIZE(xcmata%op, 1)
563 n2 =
SIZE(xcmata%op, 2)
564 n3 =
SIZE(xcmata%op, 3)
565 ALLOCATE (taumat(n1, n2, 0:n3 - 1))
570 xcpot(:, 1, 1) = 0.5_dp*xcpot(:, 1, 1)
572 xcpot(:, 1, 1) = xcpot(:, 1, 1)/
atom%basis%grid%rad2(:)
575 xcmata%op(:, :, l) = xcmata%op(:, :, l) + real(l*(l + 1),
dp)*taumat(:, :, l)
581 xcpot(:, 1, 1) = 0.5_dp*xcpot(:, 1, 1)
583 xcpot(:, 1, 1) = xcpot(:, 1, 1)/
atom%basis%grid%rad2(:)
586 xcmatb%op(:, :, l) = xcmatb%op(:, :, l) + real(l*(l + 1),
dp)*taumat(:, :, l)
594 IF (needs%laplace_rho_spin)
THEN
604 IF (nlcc)
DEALLOCATE (xfun)
609 nr =
atom%basis%grid%nr
610 ALLOCATE (rho(nr, 2), exc(nr), vxca(nr), vxcb(nr))
611 IF (nlcc)
ALLOCATE (xfun(nr))
618 rho(:, 1) = rho(:, 1) + 0.5_dp*xfun(:)
619 rho(:, 2) = rho(:, 2) + 0.5_dp*xfun(:)
621 CALL lsd_pade(rho(:, 1), rho(:, 2), exc, vxca, vxcb)
627 DEALLOCATE (rho, exc, vxca, vxcb)
628 IF (nlcc)
DEALLOCATE (xfun)
632 CALL timestop(handle)
649 TYPE(atom_basis_type),
POINTER :: basis
650 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: pmat
651 INTEGER,
INTENT(IN) :: maxl
652 TYPE(section_vals_type),
POINTER :: xc_section
653 REAL(kind=
dp),
INTENT(OUT) :: fexc
654 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: xcmat
656 CHARACTER(LEN=*),
PARAMETER :: routinen =
'atom_vxc_lda'
658 INTEGER :: deriv_order, handle, l, myfun, n1, n2, &
660 INTEGER,
DIMENSION(2, 3) :: bounds
662 REAL(kind=
dp) :: density_cut, gradient_cut, tau_cut
663 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: drho, lap, rho, tau
664 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: taumat, xcpot
665 TYPE(section_vals_type),
POINTER :: xc_fun_section
666 TYPE(xc_derivative_set_type) :: deriv_set
667 TYPE(xc_derivative_type),
POINTER :: deriv
668 TYPE(xc_rho_cflags_type) :: needs
669 TYPE(xc_rho_set_type) :: rho_set
671 CALL timeset(routinen, handle)
673 cpassert(
ASSOCIATED(xc_section))
702 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
706 NULLIFY (rho, drho, tau)
708 ALLOCATE (rho(nr, 1))
709 CALL atom_density(rho(:, 1), pmat, basis, maxl, typ=
"RHO")
711 IF (needs%norm_drho)
THEN
712 ALLOCATE (drho(nr, 1))
713 CALL atom_density(drho(:, 1), pmat, basis, maxl, typ=
"DER")
716 ALLOCATE (tau(nr, 1))
717 CALL atom_density(tau(:, 1), pmat, basis, maxl, typ=
"KIN", rr=basis%grid%rad2)
719 IF (needs%laplace_rho)
THEN
720 ALLOCATE (lap(nr, 1))
721 CALL atom_density(lap(:, 1), pmat, basis, maxl, typ=
"LAP", rr=basis%grid%rad2)
724 CALL fill_rho_set(rho_set, nspins, needs, rho, drho, tau, lap, nr)
730 deriv_order=deriv_order)
735 fexc =
fourpi*integrate_grid(xcpot(:, 1, 1), basis%grid)
743 IF (needs%norm_drho)
THEN
755 ALLOCATE (taumat(n1, n2, 0:n3 - 1))
758 xcpot(:, 1, 1) = 0.5_dp*xcpot(:, 1, 1)
760 xcpot(:, 1, 1) = xcpot(:, 1, 1)/basis%grid%rad2(:)
763 xcmat(:, :, l) = xcmat(:, :, l) + real(l*(l + 1),
dp)*taumat(:, :, l)
771 IF (needs%laplace_rho)
THEN
781 CALL timestop(handle)
799 SUBROUTINE atom_vxc_lsd(basis, pmata, pmatb, maxl, xc_section, fexc, xcmata, xcmatb)
800 TYPE(atom_basis_type),
POINTER :: basis
801 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: pmata, pmatb
802 INTEGER,
INTENT(IN) :: maxl
803 TYPE(section_vals_type),
POINTER :: xc_section
804 REAL(kind=
dp),
INTENT(OUT) :: fexc
805 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: xcmata, xcmatb
807 CHARACTER(LEN=*),
PARAMETER :: routinen =
'atom_vxc_lsd'
809 INTEGER :: deriv_order, handle, l, myfun, n1, n2, &
811 INTEGER,
DIMENSION(2, 3) :: bounds
813 REAL(kind=
dp) :: density_cut, gradient_cut, tau_cut
814 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: drho, lap, rho, tau
815 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: taumat, xcpot
816 TYPE(section_vals_type),
POINTER :: xc_fun_section
817 TYPE(xc_derivative_set_type) :: deriv_set
818 TYPE(xc_derivative_type),
POINTER :: deriv
819 TYPE(xc_rho_cflags_type) :: needs
820 TYPE(xc_rho_set_type) :: rho_set
822 CALL timeset(routinen, handle)
824 cpassert(
ASSOCIATED(xc_section))
853 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
857 NULLIFY (rho, drho, tau)
858 IF (needs%rho_spin)
THEN
859 ALLOCATE (rho(nr, 2))
860 CALL atom_density(rho(:, 1), pmata, basis, maxl, typ=
"RHO")
861 CALL atom_density(rho(:, 2), pmatb, basis, maxl, typ=
"RHO")
863 IF (needs%norm_drho_spin)
THEN
864 ALLOCATE (drho(nr, 2))
865 CALL atom_density(drho(:, 1), pmata, basis, maxl, typ=
"DER")
866 CALL atom_density(drho(:, 2), pmatb, basis, maxl, typ=
"DER")
868 IF (needs%tau_spin)
THEN
869 ALLOCATE (tau(nr, 2))
870 CALL atom_density(tau(:, 1), pmata, basis, maxl, typ=
"KIN", rr=basis%grid%rad2)
871 CALL atom_density(tau(:, 2), pmatb, basis, maxl, typ=
"KIN", rr=basis%grid%rad2)
873 IF (needs%laplace_rho_spin)
THEN
874 ALLOCATE (lap(nr, 2))
875 CALL atom_density(lap(:, 1), pmata, basis, maxl, typ=
"LAP", rr=basis%grid%rad2)
876 CALL atom_density(lap(:, 2), pmatb, basis, maxl, typ=
"LAP", rr=basis%grid%rad2)
879 CALL fill_rho_set(rho_set, nspins, needs, rho, drho, tau, lap, nr)
885 deriv_order=deriv_order)
890 fexc =
fourpi*integrate_grid(xcpot(:, 1, 1), basis%grid)
892 IF (needs%rho_spin)
THEN
901 IF (needs%norm_drho_spin)
THEN
915 IF (
ASSOCIATED(deriv))
THEN
922 IF (needs%tau_spin)
THEN
926 ALLOCATE (taumat(n1, n2, 0:n3 - 1))
931 xcpot(:, 1, 1) = 0.5_dp*xcpot(:, 1, 1)
933 xcpot(:, 1, 1) = xcpot(:, 1, 1)/basis%grid%rad2(:)
936 xcmata(:, :, l) = xcmata(:, :, l) + real(l*(l + 1),
dp)*taumat(:, :, l)
942 xcpot(:, 1, 1) = 0.5_dp*xcpot(:, 1, 1)
944 xcpot(:, 1, 1) = xcpot(:, 1, 1)/basis%grid%rad2(:)
947 xcmatb(:, :, l) = xcmatb(:, :, l) + real(l*(l + 1),
dp)*taumat(:, :, l)
960 CALL timestop(handle)
978 SUBROUTINE atom_dpot_lda(basis0, pmat0, basis1, pmat1, maxl, functional, dfexc, linxpar)
979 TYPE(atom_basis_type),
POINTER :: basis0
980 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: pmat0
981 TYPE(atom_basis_type),
POINTER :: basis1
982 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: pmat1
983 INTEGER,
INTENT(IN) :: maxl
984 CHARACTER(LEN=*),
INTENT(IN) :: functional
985 REAL(kind=
dp),
INTENT(OUT) :: dfexc
986 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: linxpar
988 CHARACTER(LEN=*),
PARAMETER :: routinen =
'atom_dpot_lda'
989 REAL(kind=
dp),
PARAMETER :: alx = 0.20_dp, blx = -0.06_dp, &
990 fs = -0.75_dp*(3._dp/
pi)**(1._dp/3._dp)
992 INTEGER :: handle, ir, nr
993 REAL(kind=
dp) :: a, b, fx
994 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: delta, drho0, drho1, pot0, pot1, rho0, &
997 CALL timeset(routinen, handle)
1001 ALLOCATE (rho0(nr), drho0(nr))
1002 CALL atom_density(rho0, pmat0, basis0, maxl, typ=
"RHO")
1003 CALL atom_density(drho0, pmat0, basis0, maxl, typ=
"DER")
1005 ALLOCATE (rho1(nr), drho1(nr))
1006 CALL atom_density(rho1, pmat1, basis1, maxl, typ=
"RHO")
1008 CALL atom_density(drho1, pmat1, basis1, maxl, typ=
"DER")
1010 ALLOCATE (delta(nr))
1012 delta(1:nr) = fs*(rho0(1:nr)**fx - rho1(1:nr)**fx)
1014 SELECT CASE (trim(functional))
1016 IF (
PRESENT(linxpar))
THEN
1023 ALLOCATE (pot0(nr), pot1(nr))
1025 IF (rho0(ir) > 1.e-12_dp)
THEN
1026 pot0(ir) = 0.5_dp*drho0(ir)/(3._dp*
pi*
pi*rho0(ir)**fx)
1031 pot1(1:nr) = 1._dp + (a*pot0(1:nr)**2)/(1._dp + b*pot0(1:nr)**2)
1032 pot1(1:nr) = pot1(1:nr)*delta(1:nr)
1033 dfexc =
fourpi*integrate_grid(pot1(1:nr), basis0%grid)
1034 DEALLOCATE (pot0, pot1)
1036 cpabort(
"Unknown functional in atom_dpot_lda")
1039 DEALLOCATE (rho0, rho1, drho0, drho1, delta)
1041 CALL timestop(handle)
1060 SUBROUTINE fill_rho_set(rho_set, nspins, needs, rho, drho, tau, lap, na)
1062 TYPE(xc_rho_set_type),
INTENT(INOUT) :: rho_set
1063 INTEGER,
INTENT(IN) :: nspins
1064 TYPE(xc_rho_cflags_type),
INTENT(in) :: needs
1065 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho, drho, tau, lap
1066 INTEGER,
INTENT(IN) :: na
1068 REAL(kind=
dp),
PARAMETER :: f13 = (1.0_dp/3.0_dp)
1072 SELECT CASE (nspins)
1074 cpassert(.NOT. needs%rho_spin)
1075 cpassert(.NOT. needs%drho_spin)
1076 cpassert(.NOT. needs%norm_drho_spin)
1077 cpassert(.NOT. needs%rho_spin_1_3)
1078 cpassert(.NOT. needs%tau_spin)
1079 cpassert(.NOT. needs%drho)
1081 IF (needs%rho_1_3)
THEN
1083 rho_set%rho_1_3(ia, 1, 1) = max(rho(ia, 1), 0.0_dp)**f13
1085 rho_set%owns%rho_1_3 = .true.
1086 rho_set%has%rho_1_3 = .true.
1091 rho_set%rho(ia, 1, 1) = rho(ia, 1)
1093 rho_set%owns%rho = .true.
1094 rho_set%has%rho = .true.
1097 IF (needs%norm_drho)
THEN
1099 rho_set%norm_drho(ia, 1, 1) = drho(ia, 1)
1101 rho_set%owns%norm_drho = .true.
1102 rho_set%has%norm_drho = .true.
1105 cpassert(.NOT. needs%drho)
1106 cpassert(.NOT. needs%drho_spin)
1110 rho_set%rho(ia, 1, 1) = rho(ia, 1) + rho(ia, 2)
1112 rho_set%owns%rho = .true.
1113 rho_set%has%rho = .true.
1116 IF (needs%norm_drho)
THEN
1118 rho_set%norm_drho(ia, 1, 1) = drho(ia, 1) + drho(ia, 2)
1120 rho_set%owns%norm_drho = .true.
1121 rho_set%has%norm_drho = .true.
1124 IF (needs%rho_spin)
THEN
1126 rho_set%rhoa(ia, 1, 1) = rho(ia, 1)
1127 rho_set%rhob(ia, 1, 1) = rho(ia, 2)
1129 rho_set%owns%rho_spin = .true.
1130 rho_set%has%rho_spin = .true.
1133 IF (needs%rho_spin_1_3)
THEN
1135 rho_set%rhoa_1_3(ia, 1, 1) = max(rho(ia, 1), 0.0_dp)**f13
1136 rho_set%rhob_1_3(ia, 1, 1) = max(rho(ia, 2), 0.0_dp)**f13
1138 rho_set%owns%rho_1_3 = .true.
1139 rho_set%has%rho_1_3 = .true.
1142 IF (needs%norm_drho_spin)
THEN
1144 rho_set%norm_drhoa(ia, 1, 1) = drho(ia, 1)
1145 rho_set%norm_drhob(ia, 1, 1) = drho(ia, 2)
1147 rho_set%owns%norm_drho_spin = .true.
1148 rho_set%has%norm_drho_spin = .true.
1155 IF (nspins == 2)
THEN
1157 rho_set%tau(ia, 1, 1) = tau(ia, 1) + tau(ia, 2)
1159 rho_set%owns%tau = .true.
1160 rho_set%has%tau = .true.
1163 rho_set%tau(ia, 1, 1) = tau(ia, 1)
1165 rho_set%owns%tau = .true.
1166 rho_set%has%tau = .true.
1169 IF (needs%tau_spin)
THEN
1170 cpassert(nspins == 2)
1172 rho_set%tau_a(ia, 1, 1) = tau(ia, 1)
1173 rho_set%tau_b(ia, 1, 1) = tau(ia, 2)
1175 rho_set%owns%tau_spin = .true.
1176 rho_set%has%tau_spin = .true.
1180 IF (needs%laplace_rho)
THEN
1181 IF (nspins == 2)
THEN
1183 rho_set%laplace_rho(ia, 1, 1) = lap(ia, 1) + lap(ia, 2)
1185 rho_set%owns%laplace_rho = .true.
1186 rho_set%has%laplace_rho = .true.
1189 rho_set%laplace_rho(ia, 1, 1) = lap(ia, 1)
1191 rho_set%owns%laplace_rho = .true.
1192 rho_set%has%laplace_rho = .true.
1195 IF (needs%laplace_rho_spin)
THEN
1196 cpassert(nspins == 2)
1198 rho_set%laplace_rhoa(ia, 1, 1) = lap(ia, 1)
1199 rho_set%laplace_rhob(ia, 1, 1) = lap(ia, 2)
1201 rho_set%owns%laplace_rho_spin = .true.
1202 rho_set%has%laplace_rho_spin = .true.
1205 END SUBROUTINE fill_rho_set
1216 PURE SUBROUTINE lda_pade(rho, exc, vxc)
1218 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: rho
1219 REAL(
dp),
DIMENSION(:),
INTENT(OUT) :: exc, vxc
1221 REAL(kind=
dp),
PARAMETER :: a0 = 0.4581652932831429e+0_dp, a1 = 0.2217058676663745e+1_dp, &
1222 a2 = 0.7405551735357053e+0_dp, a3 = 0.1968227878617998e-1_dp, &
1223 b1 = 1.0000000000000000e+0_dp, b2 = 0.4504130959426697e+1_dp, &
1224 b3 = 0.1110667363742916e+1_dp, b4 = 0.2359291751427506e-1_dp, f13 = (1.0_dp/3.0_dp), &
1225 rsfac = 0.6203504908994000166680065_dp
1228 REAL(kind=
dp) :: depade, dpv, dq, epade, p, q, rs
1235 IF (rho(i) > 1.e-20_dp)
THEN
1236 rs = rsfac*rho(i)**(-f13)
1237 p = a0 + (a1 + (a2 + a3*rs)*rs)*rs
1238 q = (b1 + (b2 + (b3 + b4*rs)*rs)*rs)*rs
1241 dpv = a1 + (2.0_dp*a2 + 3.0_dp*a3*rs)*rs
1242 dq = b1 + (2.0_dp*b2 + (3.0_dp*b3 + 4.0_dp*b4*rs)*rs)*rs
1243 depade = f13*rs*(dpv*q - p*dq)/(q*q)
1245 exc(i) = epade*rho(i)
1246 vxc(i) = epade + depade
1250 END SUBROUTINE lda_pade
1263 PURE SUBROUTINE lsd_pade(rhoa, rhob, exc, vxca, vxcb)
1265 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: rhoa, rhob
1266 REAL(
dp),
DIMENSION(:),
INTENT(OUT) :: exc, vxca, vxcb
1268 REAL(kind=
dp),
PARAMETER :: a0 = 0.4581652932831429e+0_dp, a1 = 0.2217058676663745e+1_dp, &
1269 a2 = 0.7405551735357053e+0_dp, a3 = 0.1968227878617998e-1_dp, &
1270 b1 = 1.0000000000000000e+0_dp, b2 = 0.4504130959426697e+1_dp, &
1271 b3 = 0.1110667363742916e+1_dp, b4 = 0.2359291751427506e-1_dp, &
1272 da0 = 0.119086804055547e+0_dp, da1 = 0.6157402568883345e+0_dp, &
1273 da2 = 0.1574201515892867e+0_dp, da3 = 0.3532336663397157e-2_dp, &
1274 db1 = 0.0000000000000000e+0_dp, db2 = 0.2673612973836267e+0_dp, &
1275 db3 = 0.2052004607777787e+0_dp, db4 = 0.4200005045691381e-2_dp, f13 = (1.0_dp/3.0_dp), &
1276 f43 = (4.0_dp/3.0_dp)
1277 REAL(kind=
dp),
PARAMETER :: fxfac = 1.923661050931536319759455_dp, &
1278 rsfac = 0.6203504908994000166680065_dp
1281 REAL(kind=
dp) :: dc, dpv, dq, dr, dx, fa0, fa1, fa2, fa3, &
1282 fb1, fb2, fb3, fb4, fx1, fx2, p, q, &
1283 rhoab, rs, x, xp, xq
1293 rhoab = rhoa(i) + rhob(i)
1294 IF (rhoab > 1.e-20_dp)
THEN
1295 rs = rsfac*rhoab**(-f13)
1297 x = (rhoa(i) - rhob(i))/rhoab
1298 IF (x < -1.0_dp)
THEN
1300 fx2 = -f43*fxfac*2.0_dp**f13
1301 ELSE IF (x > 1.0_dp)
THEN
1303 fx2 = f43*fxfac*2.0_dp**f13
1305 fx1 = ((1.0_dp + x)**f43 + (1.0_dp - x)**f43 - 2.0_dp)*fxfac
1306 fx2 = ((1.0_dp + x)**f13 - (1.0_dp - x)**f13)*fxfac*f43
1318 p = fa0 + (fa1 + (fa2 + fa3*rs)*rs)*rs
1319 q = (fb1 + (fb2 + (fb3 + fb4*rs)*rs)*rs)*rs
1320 dpv = fa1 + (2.0_dp*fa2 + 3.0_dp*fa3*rs)*rs
1321 dq = fb1 + (2.0_dp*fb2 + (3.0_dp*fb3 + &
1322 4.0_dp*fb4*rs)*rs)*rs
1323 xp = da0 + (da1 + (da2 + da3*rs)*rs)*rs
1324 xq = (db1 + (db2 + (db3 + db4*rs)*rs)*rs)*rs
1326 dr = (dpv*q - p*dq)/(q*q)
1327 dx = 2.0_dp*(xp*q - p*xq)/(q*q)*fx2/rhoab
1328 dc = f13*rs*dr - p/q
1331 vxca(i) = dc - dx*rhob(i)
1332 vxcb(i) = dc + dx*rhoa(i)
1336 END SUBROUTINE lsd_pade
Define the atom type and its sub types.
Some basic routines for atomic calculations.
subroutine, public atom_core_density(corden, potential, typ, rr)
...
subroutine, public atom_density(density, pmat, basis, maxl, typ, rr)
Map the electron density on an atomic radial grid.
subroutine, public numpot_matrix(imat, cpot, basis, derivatives)
Calculate a potential matrix by integrating the potential on an atomic radial grid.
subroutine, public coulomb_potential_numeric(cpot, density, grid)
Numerically compute the Coulomb potential on an atomic radial grid.
routines that build the integrals of the Vxc potential calculated for the atomic code
subroutine, public atom_dpot_lda(basis0, pmat0, basis1, pmat1, maxl, functional, dfexc, linxpar)
Estimate the ADMM exchange energy correction term using a model exchange functional.
subroutine, public atom_vxc_lsd(basis, pmata, pmatb, maxl, xc_section, fexc, xcmata, xcmatb)
Alternative subroutine that calculates atomic exchange-correlation potential in spin-polarized case.
subroutine, public calculate_atom_vxc_lda(xcmat, atom, xc_section)
Calculate atomic exchange-correlation potential in spin-restricted case.
subroutine, public calculate_atom_ext_vxc(vxc, atom, lprint, xcmat)
ZMP subroutine for the scf external density from the external v_xc.
subroutine, public calculate_atom_zmp(ext_density, atom, lprint, xcmat)
ZMP subroutine for the calculation of the effective constraint potential in the atomic code.
subroutine, public calculate_atom_vxc_lsd(xcmata, xcmatb, atom, xc_section)
Calculate atomic exchange-correlation potential in spin-polarized case.
subroutine, public atom_vxc_lda(basis, pmat, maxl, xc_section, fexc, xcmat)
Alternative subroutine that calculates atomic exchange-correlation potential in spin-restricted case.
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
integer function, public get_unit_number(file_name)
Returns the first logical unit that is not preconnected.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), parameter, public fourpi
subroutine, public xc_rho_set_atom_update(rho_set, needs, nspins, bo)
...
Module with functions to handle derivative descriptors. derivative description are strings have the f...
integer, parameter, public deriv_norm_drho
integer, parameter, public deriv_norm_drhoa
integer, parameter, public deriv_rhob
integer, parameter, public deriv_rhoa
integer, parameter, public deriv_tau
integer, parameter, public deriv_tau_b
integer, parameter, public deriv_tau_a
integer, parameter, public deriv_rho
integer, parameter, public deriv_norm_drhob
represent a group ofunctional derivatives
subroutine, public xc_dset_zero_all(deriv_set)
...
type(xc_derivative_type) function, pointer, public xc_dset_get_derivative(derivative_set, description, allocate_deriv)
returns the requested xc_derivative
subroutine, public xc_dset_release(derivative_set)
releases a derivative set
subroutine, public xc_dset_create(derivative_set, pw_pool, local_bounds)
creates a derivative set object
Provides types for the management of the xc-functionals and their derivatives.
subroutine, public xc_derivative_get(deriv, split_desc, order, deriv_data, accept_null_data)
returns various information on the given derivative
type(xc_rho_cflags_type) function, public xc_functionals_get_needs(functionals, lsd, calc_potential)
...
subroutine, public xc_functionals_eval(functionals, lsd, rho_set, deriv_set, deriv_order)
...
subroutine, public xc_rho_set_create(rho_set, local_bounds, rho_cutoff, drho_cutoff, tau_cutoff)
allocates and does (minimal) initialization of a rho_set
subroutine, public xc_rho_set_release(rho_set, pw_pool)
releases the given rho_set