24 lmat, no_pseudo, sgp_pseudo, upf_pseudo
54#include "./base/base_uses.f90"
60 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_utils'
82 MODULE PROCEDURE integrate_grid_function1, &
83 integrate_grid_function2, &
84 integrate_grid_function3
102 CHARACTER(LEN=default_string_length), &
103 DIMENSION(:),
POINTER :: ostring
104 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: occupation, wfnocc
105 INTEGER,
INTENT(OUT),
OPTIONAL :: multiplicity
107 CHARACTER(len=2) :: elem
108 CHARACTER(LEN=default_string_length) :: pstring
109 INTEGER :: i, i1, i2, ielem, is, jd, jf, jp, js, k, &
111 REAL(kind=
dp) :: e0, el, oo
115 cpassert(
ASSOCIATED(ostring))
116 cpassert(
SIZE(ostring) > 0)
124 IF (index(ostring(is),
"(") /= 0)
THEN
125 i1 = index(ostring(is),
"(")
126 i2 = index(ostring(is),
")")
127 cpassert((i2 - i1 - 1 > 0) .AND. (i2 - i1 - 1 < 3))
128 elem = ostring(is) (i1 + 1:i2 - 1)
129 IF (index(elem,
"HS") /= 0)
THEN
131 ELSE IF (index(elem,
"LS") /= 0)
THEN
141 IF (index(ostring(is),
"CORE") /= 0) is = is + 1
144 IF (index(ostring(is),
"none") /= 0) is = is + 1
147 IF (index(ostring(is),
"[") /= 0)
THEN
149 i1 = index(ostring(is),
"[")
150 i2 = index(ostring(is),
"]")
151 cpassert((i2 - i1 - 1 > 0) .AND. (i2 - i1 - 1 < 3))
152 elem = ostring(is) (i1 + 1:i2 - 1)
155 IF (elem ==
ptable(k)%symbol)
THEN
161 DO l = 0, min(
lmat, ubound(
ptable(ielem)%e_conv, 1))
162 el = 2._dp*(2._dp*real(l,
dp) + 1._dp)
163 e0 =
ptable(ielem)%e_conv(l)
165 occupation(l, k) = min(el, e0)
167 IF (e0 <= 0._dp)
EXIT
178 js = index(pstring,
"S")
179 jp = index(pstring,
"P")
180 jd = index(pstring,
"D")
181 jf = index(pstring,
"F")
182 cpassert(js + jp + jd + jf > 0)
184 cpassert(jp + jd + jf == 0)
185 READ (pstring(1:js - 1), *) n
186 READ (pstring(js + 1:), *) oo
188 cpassert(oo >= 0._dp)
189 cpassert(occupation(0, n) == 0)
190 occupation(0, n) = oo
193 cpassert(js + jd + jf == 0)
194 READ (pstring(1:jp - 1), *) n
195 READ (pstring(jp + 1:), *) oo
197 cpassert(oo >= 0._dp)
198 cpassert(occupation(1, n - 1) == 0)
199 occupation(1, n - 1) = oo
202 cpassert(js + jp + jf == 0)
203 READ (pstring(1:jd - 1), *) n
204 READ (pstring(jd + 1:), *) oo
206 cpassert(oo >= 0._dp)
207 cpassert(occupation(2, n - 2) == 0)
208 occupation(2, n - 2) = oo
211 cpassert(js + jp + jd == 0)
212 READ (pstring(1:jf - 1), *) n
213 READ (pstring(jf + 1:), *) oo
215 cpassert(oo >= 0._dp)
216 cpassert(occupation(3, n - 3) == 0)
217 occupation(3, n - 3) = oo
226 IF (occupation(l, i) /= 0._dp)
THEN
228 wfnocc(l, k) = occupation(l, i)
240 IF (wfnocc(l, i) /= 0._dp .AND. wfnocc(l, i) /= real(k,
dp))
THEN
248 IF (js == 0 .AND. mult == -2) mult = 1
249 IF (js == 0 .AND. mult == -3) mult = 1
256 k = nint(wfnocc(l, i))
257 IF (k > (2*l + 1)) k = 2*(2*l + 1) - k
258 IF (mult == -2) mult = k + 1
259 IF (mult == -3) mult = mod(k, 2) + 1
260 cpassert(mod(k + 1 - mult, 2) == 0)
262 IF (js > 1 .AND. mult /= -2)
THEN
268 IF (
PRESENT(multiplicity)) multiplicity = mult
280 REAL(kind=
dp),
DIMENSION(0:lmat, 10),
INTENT(IN) :: occupation
287 IF (sum(occupation(l, :)) /= 0._dp) maxl = l
300 REAL(kind=
dp),
DIMENSION(0:lmat, 10),
INTENT(IN) :: occupation
301 INTEGER,
DIMENSION(0:lmat) :: maxn
308 IF (occupation(l, k) /= 0._dp) maxn(l) = maxn(l) + 1
326 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: pmat
327 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: wfn
328 INTEGER,
DIMENSION(0:lmat),
INTENT(IN) :: nbas
329 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
330 INTEGER,
INTENT(IN) :: maxl
331 INTEGER,
DIMENSION(0:lmat),
INTENT(IN) :: maxn
333 INTEGER :: i, j, k, l, n
338 DO i = 1, min(n, maxn(l))
341 pmat(j, k, l) = pmat(j, k, l) + occ(l, i)*wfn(j, i, l)*wfn(k, i, l)
365 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density
366 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
368 INTEGER,
INTENT(IN) :: maxl
369 CHARACTER(LEN=*),
OPTIONAL :: typ
370 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: rr
372 CHARACTER(LEN=3) :: my_typ
373 INTEGER :: i, j, l, n
377 IF (
PRESENT(typ)) my_typ = typ(1:3)
379 IF (my_typ ==
"KIN" .OR. my_typ ==
"LAP")
THEN
380 cpassert(
PRESENT(rr))
389 IF (i /= j) ff = 2._dp*pmat(i, j, l)
390 IF (my_typ ==
"RHO")
THEN
391 density(:) = density(:) + ff*basis%bf(:, i, l)*basis%bf(:, j, l)
392 ELSE IF (my_typ ==
"DER")
THEN
393 density(:) = density(:) + ff*basis%dbf(:, i, l)*basis%bf(:, j, l) &
394 + ff*basis%bf(:, i, l)*basis%dbf(:, j, l)
395 ELSE IF (my_typ ==
"KIN")
THEN
396 density(:) = density(:) + 0.5_dp*ff*( &
397 basis%dbf(:, i, l)*basis%dbf(:, j, l) + &
398 REAL(l*(l + 1),
dp)*basis%bf(:, i, l)*basis%bf(:, j, l)/rr(:))
399 ELSE IF (my_typ ==
"LAP")
THEN
400 density(:) = density(:) + ff*basis%ddbf(:, i, l)*basis%bf(:, j, l) &
401 + ff*basis%bf(:, i, l)*basis%ddbf(:, j, l) &
402 + 2._dp*ff*basis%dbf(:, i, l)*basis%dbf(:, j, l) &
403 + 2._dp*ff*basis%dbf(:, i, l)*basis%bf(:, j, l)/sqrt(rr(:)) &
404 + 2._dp*ff*basis%bf(:, i, l)*basis%dbf(:, j, l)/sqrt(rr(:))
406 cpabort(
"Unknown matrix type specified. Check the code!")
426 INTEGER :: extunit, i, k, l, n
428 CALL open_file(file_name=
atom%zmp_restart_file, file_status=
"UNKNOWN", &
429 file_form=
"FORMATTED", file_action=
"WRITE", &
432 n =
SIZE(
atom%orbitals%wfn, 2)
433 WRITE (extunit, *)
atom%basis%nbas
434 DO l = 0,
atom%state%maxl_occ
435 DO i = 1, min(n,
atom%state%maxn_occ(l))
436 DO k = 1,
atom%basis%nbas(l)
437 WRITE (extunit, *)
atom%orbitals%wfn(k, i, l)
458 LOGICAL,
INTENT(INOUT) :: doguess
459 INTEGER,
INTENT(IN) :: iw
461 INTEGER :: er, extunit, i, k, l, maxl, n
462 INTEGER,
DIMENSION(0:lmat) :: maxn, nbas
464 INQUIRE (file=
atom%zmp_restart_file, exist=
atom%doread)
466 IF (
atom%doread)
THEN
467 WRITE (iw, fmt=
"(' ZMP | Restart file found')")
468 CALL open_file(file_name=
atom%zmp_restart_file, file_status=
"OLD", &
469 file_form=
"FORMATTED", file_action=
"READ", &
472 READ (extunit, *, iostat=er) nbas
475 WRITE (iw, fmt=
"(' ZMP | ERROR! Restart file unreadable')")
476 WRITE (iw, fmt=
"(' ZMP | ERROR! Starting ZMP calculation form initial atomic guess')")
478 atom%doread = .false.
479 ELSE IF (nbas(1) /=
atom%basis%nbas(1))
THEN
480 WRITE (iw, fmt=
"(' ZMP | ERROR! Restart file contains a different basis set')")
481 WRITE (iw, fmt=
"(' ZMP | ERROR! Starting ZMP calculation form initial atomic guess')")
483 atom%doread = .false.
485 nbas =
atom%basis%nbas
486 maxl =
atom%state%maxl_occ
487 maxn =
atom%state%maxn_occ
488 n =
SIZE(
atom%orbitals%wfn, 2)
489 DO l = 0,
atom%state%maxl_occ
490 DO i = 1, min(n,
atom%state%maxn_occ(l))
491 DO k = 1,
atom%basis%nbas(l)
492 READ (extunit, *)
atom%orbitals%wfn(k, i, l)
500 WRITE (iw, fmt=
"(' ZMP | WARNING! Restart file not found')")
501 WRITE (iw, fmt=
"(' ZMP | WARNING! Starting ZMP calculation form initial atomic guess')")
515 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density
517 INTEGER,
INTENT(IN) :: iw
519 CHARACTER(LEN=default_string_length) :: filename
520 INTEGER :: extunit, ir, j, k, l, maxl_occ, maxnbas, &
524 REAL(kind=
dp),
ALLOCATABLE :: pmatread(:, :, :)
526 filename =
atom%ext_file
529 CALL open_file(file_name=filename, file_status=
"OLD", &
530 file_form=
"FORMATTED", file_action=
"READ", &
536 IF (nr /=
atom%basis%grid%nr)
THEN
537 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! External grid dimension ',I4,' differs from internal grid ',I4)") &
538 nr,
atom%basis%grid%nr
539 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Stopping ZMP calculation')")
540 cpabort(
"Unable to continue reading external density file")
544 READ (extunit, *) rr, density(ir)
545 IF (abs(rr -
atom%basis%grid%rad(ir)) >
atom%zmpgrid_tol)
THEN
546 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Grid points do not coincide: ')")
547 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T20,"R_out[bohr]",T36,"R_in[bohr]",T61,"R_diff[bohr]")')
548 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T14,E24.15,T39,E24.15,T64,E24.15)') &
549 rr,
atom%basis%grid%rad(ir), abs(rr -
atom%basis%grid%rad(ir))
550 cpabort(
"Unable to continue reading external density file")
555 READ (extunit, *) maxl_occ
556 maxnbas = maxval(
atom%basis%nbas)
557 ALLOCATE (pmatread(maxnbas, maxnbas, 0:maxl_occ))
560 nbas =
atom%basis%nbas(l)
563 READ (extunit, *) (pmatread(j, k, l), j=1, k)
565 pmatread(k, j, l) = pmatread(j, k, l)
574 CALL open_file(file_name=
"rho_target.dat", file_status=
"UNKNOWN", &
575 file_form=
"FORMATTED", file_action=
"WRITE", unit_number=extunit)
577 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | Writing target density from density matrix')")
579 WRITE (extunit, fmt=
'("# Target density built from density matrix : ",A20)') filename
580 WRITE (extunit, fmt=
'("#",T10,"R[bohr]",T36,"Rho[au]")')
582 nr =
atom%basis%grid%nr
585 WRITE (extunit, fmt=
'(T1,E24.15,T26,E24.15)') &
586 atom%basis%grid%rad(ir), density(ir)
588 DEALLOCATE (pmatread)
604 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: vxc
606 INTEGER,
INTENT(IN) :: iw
608 CHARACTER(LEN=default_string_length) :: adum, filename
609 INTEGER :: extunit, ir, nr
612 filename =
atom%ext_vxc_file
614 CALL open_file(file_name=filename, file_status=
"OLD", &
615 file_form=
"FORMATTED", file_action=
"READ", &
619 READ (extunit, *) adum, nr
621 IF (nr /=
atom%basis%grid%nr)
THEN
622 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! External grid dimension ',I4,' differs from internal grid ',I4)") &
623 nr,
atom%basis%grid%nr
624 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Stopping ZMP calculation')")
625 cpabort(
"Unable to continue reading external v_xc file")
628 READ (extunit, *) rr, vxc(ir)
629 IF (abs(rr -
atom%basis%grid%rad(ir)) >
atom%zmpvxcgrid_tol)
THEN
630 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Grid points do not coincide: ')")
631 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T20,"R_out[bohr]",T36,"R_in[bohr]",T61,"R_diff[bohr]")')
632 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T14,E24.15,T39,E24.15,T64,E24.15)') &
633 rr,
atom%basis%grid%rad(ir), abs(rr -
atom%basis%grid%rad(ir))
634 cpabort(
"Unable to continue reading external v_xc file")
649 REAL(kind=
dp),
INTENT(OUT) :: charge
650 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
651 REAL(kind=
dp),
INTENT(IN) :: rcov
652 INTEGER,
INTENT(IN) :: l
655 INTEGER :: i, j, m, n
657 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: den
660 m =
SIZE(basis%bf, 1)
667 den(1:m) = den(1:m) + ff*basis%bf(1:m, i, l)*basis%bf(1:m, j, l)
671 IF (basis%grid%rad(i) > rcov) den(i) = 0._dp
673 charge = sum(den(1:m)*basis%grid%wr(1:m))
689 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: corden
691 CHARACTER(LEN=*),
OPTIONAL :: typ
692 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rr
694 CHARACTER(LEN=3) :: my_typ
695 INTEGER :: i, j, m, n
697 REAL(kind=
dp) :: a, a2, cval, fb
698 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: fe, rc, rhoc, rval
701 IF (
PRESENT(typ)) my_typ = typ(1:3)
703 SELECT CASE (potential%ppot_type)
707 IF (potential%gth_pot%nlcc)
THEN
709 ALLOCATE (fe(m), rc(m))
710 n = potential%gth_pot%nexp_nlcc
712 a = potential%gth_pot%alpha_nlcc(i)
716 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
717 DO j = 1, potential%gth_pot%nct_nlcc(i)
718 cval = potential%gth_pot%cval_nlcc(j, i)
719 IF (my_typ ==
"RHO")
THEN
720 corden(:) = corden(:) + fe(:)*rc**(2*j - 2)*cval
721 ELSE IF (my_typ ==
"DER")
THEN
722 corden(:) = corden(:) - fe(:)*rc**(2*j - 1)*cval/a
724 corden(:) = corden(:) + real(2*j - 2,
dp)*fe(:)*rc**(2*j - 3)*cval/a
726 ELSE IF (my_typ ==
"LAP")
THEN
728 corden(:) = corden(:) - fb*fe(:)/rr(:)*rc**(2*j - 1)
729 corden(:) = corden(:) + fe(:)*rc**(2*j)*cval/a2
731 corden(:) = corden(:) + fb*real(2*j - 2,
dp)*fe(:)/rr(:)*rc**(2*j - 3)
732 corden(:) = corden(:) + real((2*j - 2)*(2*j - 3),
dp)*fe(:)*rc**(2*j - 4)*cval/a2
733 corden(:) = corden(:) - real(2*j - 2,
dp)*fe(:)*rc**(2*j - 2)*cval/a2
736 CALL cp_abort(__location__, &
737 "Only <RHO>, <DER>, <LAP> are supported as <my_typ> "// &
738 "in atom_core_density, found <"//trim(my_typ)//
">")
745 IF (potential%upf_pot%core_correction)
THEN
747 n = potential%upf_pot%mesh_size
749 IF (rr(1) > rr(m)) reverse = .true.
750 ALLOCATE (rhoc(m), rval(m))
753 rval(i) = rr(m - i + 1)
758 IF (my_typ ==
"RHO")
THEN
759 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
761 ELSE IF (my_typ ==
"DER")
THEN
762 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
764 ELSE IF (my_typ ==
"LAP")
THEN
765 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
768 CALL cp_abort(__location__, &
769 "Only <RHO>, <DER>, <LAP> are supported as <my_typ> "// &
770 "in atom_core_density, found <"//trim(my_typ)//
">")
774 rval(i) = rr(m - i + 1)
775 corden(i) = corden(i) + rhoc(m - i + 1)
778 corden(1:m) = corden(1:m) + rhoc(1:m)
780 DEALLOCATE (rhoc, rval)
783 IF (potential%sgp_pot%has_nlcc)
THEN
786 DO i = 1, potential%sgp_pot%n_nlcc
787 a = potential%sgp_pot%a_nlcc(i)
788 cval = potential%sgp_pot%c_nlcc(i)
789 fe(:) = cval*exp(-a*rr(:)**2)
792 corden(:) = corden(:) + fe(:)
794 corden(:) = corden(:) - 2.0_dp*a*rr(:)*fe(:)
796 corden(:) = corden(:) + (4.0_dp*a*a*rr(:)**2 - 6.0_dp*a)*fe(:)
798 cpabort(
"Only RHO, DER, and LAP are supported in atom_core_density")
804 cpabort(
"Unknown PP type")
816 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: locpot
818 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rr
820 INTEGER :: i, j, m, n
822 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: fe, rc
825 ALLOCATE (fe(m), rc(m))
826 rc(:) = rr(:)/gthpot%rc
828 locpot(i) = -gthpot%zion*erf(rc(i)/sqrt(2._dp))/rr(i)
831 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
833 locpot(:) = locpot(:) + fe(:)*rc**(2*i - 2)*gthpot%cl(i)
835 IF (gthpot%lpotextended)
THEN
836 DO j = 1, gthpot%nexp_lpot
837 a = gthpot%alpha_lpot(j)
839 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
840 n = gthpot%nct_lpot(j)
842 locpot(:) = locpot(:) + fe(:)*rc**(2*i - 2)*gthpot%cval_lpot(i, j)
859 REAL(kind=
dp),
INTENT(OUT) :: rmax
860 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
861 REAL(kind=
dp),
INTENT(IN) :: rcov
862 INTEGER,
INTENT(IN) :: l
867 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dorb
869 m =
SIZE(basis%bf, 1)
875 dorb(1:m) = dorb(1:m) + ff*basis%dbf(1:m, i, l)
879 IF (basis%grid%rad(i) < 2*rcov)
THEN
880 IF (dorb(i)*dorb(i + 1) < 0._dp)
THEN
881 rmax = max(rmax, basis%grid%rad(i))
898 INTEGER,
INTENT(OUT) :: node
899 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
900 REAL(kind=
dp),
INTENT(IN) :: rcov
901 INTEGER,
INTENT(IN) :: l
906 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: orb
909 m =
SIZE(basis%bf, 1)
915 orb(1:m) = orb(1:m) + ff*basis%bf(1:m, i, l)
918 IF (basis%grid%rad(i) < rcov)
THEN
919 IF (orb(i)*orb(i + 1) < 0._dp) node = node + 1
933 REAL(kind=
dp),
INTENT(OUT) ::
value
934 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
940 m = maxval(minloc(basis%grid%rad))
943 value =
value + wfn(i)*basis%bf(m, i, 0)
960 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: hmat, umat
961 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: orb
962 REAL(kind=
dp),
DIMENSION(:, 0:),
INTENT(INOUT) :: ener
963 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nb, nv
964 INTEGER,
INTENT(IN) :: maxl
966 INTEGER :: info, l, lwork, m, n
967 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: w, work
968 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a
970 cpassert(all(nb >= nv))
976 IF (n > 0 .AND. m > 0)
THEN
978 ALLOCATE (a(n, n), w(n), work(lwork))
979 a(1:m, 1:m) = matmul(transpose(umat(1:n, 1:m, l)), matmul(hmat(1:n, 1:n, l), umat(1:n, 1:m, l)))
980 CALL dsyev(
"V",
"U", m, a(1:m, 1:m), m, w(1:m), work, lwork, info)
981 a(1:n, 1:m) = matmul(umat(1:n, 1:m, l), a(1:m, 1:m))
983 m = min(m,
SIZE(orb, 2))
984 orb(1:n, 1:m, l) = a(1:n, 1:m)
985 ener(1:m, l) = w(1:m)
987 DEALLOCATE (a, w, work)
999 FUNCTION prune_grid(fun, deps)
RESULT(nc)
1000 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun
1001 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: deps
1005 REAL(kind=
dp) :: meps
1008 IF (
PRESENT(deps)) meps = deps
1013 IF (abs(fun(i)) > meps)
THEN
1019 END FUNCTION prune_grid
1029 PURE FUNCTION integrate_grid_function1(fun, grid)
RESULT(integral)
1030 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun
1032 REAL(kind=
dp) :: integral
1037 integral = sum(fun(1:nc)*grid%wr(1:nc))
1039 END FUNCTION integrate_grid_function1
1050 PURE FUNCTION integrate_grid_function2(fun1, fun2, grid)
RESULT(integral)
1051 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun1, fun2
1053 REAL(kind=
dp) :: integral
1057 nc = min(
SIZE(fun1),
SIZE(fun2))
1058 integral = sum(fun1(1:nc)*fun2(1:nc)*grid%wr(1:nc))
1060 END FUNCTION integrate_grid_function2
1072 PURE FUNCTION integrate_grid_function3(fun1, fun2, fun3, grid)
RESULT(integral)
1073 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun1, fun2, fun3
1075 REAL(kind=
dp) :: integral
1079 nc = min(
SIZE(fun1),
SIZE(fun2),
SIZE(fun3))
1080 integral = sum(fun1(1:nc)*fun2(1:nc)*fun3(1:nc)*grid%wr(1:nc))
1082 END FUNCTION integrate_grid_function3
1093 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: cpot
1094 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1098 REAL(
dp) :: int1, int2
1099 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1101 nc = min(
SIZE(cpot),
SIZE(density))
1107 cpot(nc:) = int1/r(nc:)
1111 cpassert(r(1) > r(nc))
1113 cpot(i) = int1/r(i) + int2
1114 int1 = int1 -
fourpi*density(i)*wr(i)
1115 int2 = int2 +
fourpi*density(i)*wr(i)/r(i)
1131 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: cpot
1132 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1135 INTEGER,
INTENT(IN) :: maxl
1137 INTEGER :: i, j, k, l, m, n
1138 REAL(kind=
dp) :: a, b, ff, oab, sab
1139 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: erfa, expa, z
1140 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: unp
1143 ALLOCATE (erfa(1:m), expa(1:m), z(1:m))
1148 IF (maxval(abs(pmat(:, :, l))) < 1.e-14_dp) cycle
1149 SELECT CASE (basis%basis_type)
1151 cpabort(
"Unknown basis type for coulomb_potential_analytic")
1153 DO i = 1, basis%nbas(l)
1154 DO j = i, basis%nbas(l)
1155 IF (abs(pmat(i, j, l)) < 1.e-14_dp) cycle
1157 IF (i /= j) ff = 2._dp*ff
1161 oab =
rootpi/(a + b)**(l + 1.5_dp)*ff
1162 z(:) = sab*grid%rad(:)
1163 DO k = 1,
SIZE(erfa)
1164 erfa(k) = oab*erf(z(k))/grid%rad(k)
1166 expa(:) = exp(-z(:)**2)*ff/(a + b)**(l + 1)
1169 cpot(:) = cpot(:) + 0.25_dp*erfa(:)
1171 cpot(:) = cpot(:) + 0.375_dp*erfa(:) - 0.25_dp*expa(:)
1173 cpot(:) = cpot(:) + 0.9375_dp*erfa(:) - expa(:)*(0.875_dp + 0.25_dp*z(:)**2)
1175 cpot(:) = cpot(:) + 3.28125_dp*erfa(:) - expa(:)*(3.5625_dp + 1.375_dp*z(:)**2 + 0.25_dp*z(:)**4)
1177 cpabort(
"Invalid l number for GTO specified. Check the code!")
1184 ALLOCATE (unp(n, n))
1186 unp(1:n, 1:n) = matmul(matmul(basis%cm(1:n, 1:m, l), pmat(1:m, 1:m, l)), &
1187 transpose(basis%cm(1:n, 1:m, l)))
1188 DO i = 1, basis%nprim(l)
1189 DO j = i, basis%nprim(l)
1190 IF (abs(unp(i, j)) < 1.e-14_dp) cycle
1192 IF (i /= j) ff = 2._dp*ff
1196 oab =
rootpi/(a + b)**(l + 1.5_dp)*ff
1197 z(:) = sab*grid%rad(:)
1198 DO k = 1,
SIZE(erfa)
1199 erfa(k) = oab*erf(z(k))/grid%rad(k)
1201 expa(:) = exp(-z(:)**2)*ff/(a + b)**(l + 1)
1204 cpot(:) = cpot(:) + 0.25_dp*erfa(:)
1206 cpot(:) = cpot(:) + 0.375_dp*erfa(:) - 0.25_dp*expa(:)
1208 cpot(:) = cpot(:) + 0.9375_dp*erfa(:) - expa(:)*(0.875_dp + 0.25_dp*z(:)**2)
1210 cpot(:) = cpot(:) + 3.28125_dp*erfa(:) - expa(:)*(3.5625_dp + 1.375_dp*z(:)**2 + 0.25_dp*z(:)**4)
1212 cpabort(
"Invalid l number for CGTO specified. Check the code!")
1220 DEALLOCATE (erfa, expa, z)
1236 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1238 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
1239 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: wfn
1243 INTEGER :: i, ia, ib, k, lad, lbc, lh, ll, nbas, &
1245 REAL(kind=
dp) :: almn
1246 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, nai, nbi, pot
1247 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: orb
1248 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1253 arho(ll) =
fac(ll)/
fac(lh)**2
1259 ALLOCATE (nai(nr), nbi(nr), cpot(nr), pot(nr))
1261 DO lad = 0, state%maxl_calc
1262 DO lbc = 0, state%maxl_occ
1263 norb = state%maxn_occ(lbc)
1264 nbas = basis%nbas(lbc)
1266 ALLOCATE (orb(nr, norb))
1270 orb(:, i) = orb(:, i) + wfn(k, i, lbc)*basis%bf(:, k, lbc)
1273 DO nu = abs(lad - lbc), lad + lbc, 2
1274 almn = arho(-lad + lbc + nu)*arho(lad - lbc + nu)*arho(lad + lbc - nu)/(real(lad + lbc + nu + 1,
dp) &
1275 *arho(lad + lbc + nu))
1278 DO ia = 1, basis%nbas(lad)
1280 nai(:) = orb(:, i)*basis%bf(:, ia, lad)
1282 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1283 CALL potential_coulomb_numeric(pot, nai, nu, basis%grid)
1284 cpot(:) = cpot(:) + pot(:)*hfx_pot%scale_coulomb
1286 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1287 IF (hfx_pot%do_gh)
THEN
1288 CALL potential_longrange_numeric_gh(pot, nai, nu, basis%grid, hfx_pot%omega, &
1289 hfx_pot%kernel(:, :, nu))
1291 CALL potential_longrange_numeric(pot, nai, nu, basis%grid, hfx_pot%omega, &
1292 hfx_pot%kernel(:, :, nu))
1294 cpot(:) = cpot(:) + pot(:)*hfx_pot%scale_longrange
1296 DO ib = 1, basis%nbas(lad)
1297 kmat(ia, ib, lad) = kmat(ia, ib, lad) + almn*occ(lbc, i)* &
1298 integrate_grid(cpot, orb(:, i), basis%bf(:, ib, lad), basis%grid)
1308 DEALLOCATE (nai, nbi, cpot)
1324 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1326 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
1327 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: wfn
1331 INTEGER :: i, ia, ib, k, lad, lbc, lh, ll, nbas, &
1333 REAL(kind=
dp) :: almn
1334 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, nai, nbi
1335 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: orb
1336 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: pot
1337 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1342 arho(ll) =
fac(ll)/
fac(lh)**2
1348 nbas = maxval(basis%nbas)
1349 ALLOCATE (pot(nr, nbas, nbas))
1350 ALLOCATE (nai(nr), nbi(nr), cpot(nr))
1352 DO lad = 0, state%maxl_calc
1353 DO lbc = 0, state%maxl_occ
1354 norb = state%maxn_occ(lbc)
1355 nbas = basis%nbas(lbc)
1357 ALLOCATE (orb(nr, norb))
1361 orb(:, i) = orb(:, i) + wfn(k, i, lbc)*basis%bf(:, k, lbc)
1364 DO nu = abs(lad - lbc), lad + lbc, 2
1365 almn = arho(-lad + lbc + nu)*arho(lad - lbc + nu) &
1366 *arho(lad + lbc - nu)/(real(lad + lbc + nu + 1,
dp)*arho(lad + lbc + nu))
1370 CALL potential_analytic(pot, lad, lbc, nu, basis, hfx_pot)
1371 DO ia = 1, basis%nbas(lad)
1375 cpot(:) = cpot(:) + pot(:, ia, k)*wfn(k, i, lbc)
1377 DO ib = 1, basis%nbas(lad)
1378 kmat(ia, ib, lad) = kmat(ia, ib, lad) + almn*occ(lbc, i)* &
1379 integrate_grid(cpot, orb(:, i), basis%bf(:, ib, lad), basis%grid)
1389 DEALLOCATE (nai, nbi, cpot)
1403 SUBROUTINE potential_coulomb_numeric(cpot, density, nu, grid)
1404 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1405 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1406 INTEGER,
INTENT(IN) :: nu
1410 REAL(
dp) :: int1, int2
1411 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1413 nc = min(
SIZE(cpot),
SIZE(density))
1419 cpot(nc:) = int1/r(nc:)**(nu + 1)
1422 cpassert(r(1) > r(nc))
1424 cpot(i) = int1/r(i)**(nu + 1) + int2*r(i)**nu
1425 int1 = int1 - r(i)**(nu)*density(i)*wr(i)
1426 int2 = int2 + density(i)*wr(i)/r(i)**(nu + 1)
1429 END SUBROUTINE potential_coulomb_numeric
1440 SUBROUTINE potential_longrange_numeric(cpot, density, nu, grid, omega, kernel)
1441 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1442 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1443 INTEGER,
INTENT(IN) :: nu
1445 REAL(kind=
dp),
INTENT(IN) :: omega
1446 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: kernel
1449 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1450 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work_inp, work_out
1452 nc = min(
SIZE(cpot),
SIZE(density))
1456 ALLOCATE (work_inp(nc), work_out(nc))
1461 work_inp(:nc) = density(:nc)*wr(:nc)
1462 CALL dsymv(
'U', nc, 1.0_dp, kernel, nc, work_inp, 1, 0.0_dp, work_out, 1)
1465 work_inp(:nc) = work_out(:nc)*exp(-r(:nc)**2)/r(:nc)**2*wr(:nc)
1466 CALL dsymv(
'U', nc, 1.0_dp, kernel, nc, work_inp, 1, 0.0_dp, work_out, 1)
1468 cpot(:nc) = work_out(:nc)*(2.0_dp*real(nu,
dp) + 1.0_dp)*4.0_dp/
pi*omega
1470 END SUBROUTINE potential_longrange_numeric
1481 SUBROUTINE potential_longrange_numeric_gh(cpot, density, nu, grid, omega, kernel)
1482 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1483 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1484 INTEGER,
INTENT(IN) :: nu
1486 REAL(kind=
dp),
INTENT(IN) :: omega
1487 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: kernel
1489 INTEGER :: n_max, nc, nc_kernel, nr_kernel
1490 REAL(
dp),
DIMENSION(:),
POINTER :: wr
1491 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work_inp, work_out
1493 nc = min(
SIZE(cpot),
SIZE(density))
1496 nc_kernel =
SIZE(kernel, 1)
1497 nr_kernel =
SIZE(kernel, 2)
1498 n_max = max(nc, nc_kernel, nr_kernel)
1500 ALLOCATE (work_inp(n_max), work_out(n_max))
1505 work_inp(:nc) = density(:nc)*wr(:nc)
1506 CALL dgemv(
'T', nc_kernel, nr_kernel, 1.0_dp, kernel, nc_kernel, work_inp, 1, 0.0_dp, work_out, 1)
1509 work_inp(:nr_kernel) = work_out(:nr_kernel)
1510 CALL dgemv(
'N', nc_kernel, nr_kernel, 1.0_dp, kernel, nc_kernel, work_inp, 1, 0.0_dp, work_out, 1)
1512 cpot(:nc) = work_out(:nc)*(2.0_dp*real(nu,
dp) + 1.0_dp)*4.0_dp/
pi*omega
1514 END SUBROUTINE potential_longrange_numeric_gh
1529 SUBROUTINE potential_analytic(cpot, la, lb, nu, basis, hfx_pot)
1530 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(OUT) :: cpot
1531 INTEGER,
INTENT(IN) :: la, lb, nu
1535 INTEGER :: i, j, k, l, ll, m
1536 REAL(kind=
dp) :: a, b
1537 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: erfa, pot
1540 ALLOCATE (erfa(1:m))
1546 SELECT CASE (basis%basis_type)
1548 cpabort(
"Unknown basis type for potential_analytic")
1550 DO i = 1, basis%nbas(la)
1551 DO j = 1, basis%nbas(lb)
1555 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1556 CALL potential_coulomb_analytic(erfa, a, b, ll, nu, basis%grid%rad)
1558 cpot(:, i, j) = cpot(:, i, j) + erfa(:)*hfx_pot%scale_coulomb
1561 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1562 CALL potential_longrange_analytic(erfa, a, b, ll, nu, basis%grid%rad, hfx_pot%omega)
1564 cpot(:, i, j) = cpot(:, i, j) + erfa(:)*hfx_pot%scale_longrange
1571 DO i = 1, basis%nprim(la)
1572 DO j = 1, basis%nprim(lb)
1578 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1579 CALL potential_coulomb_analytic(erfa, a, b, ll, nu, basis%grid%rad)
1581 pot(:) = pot(:) + erfa(:)*hfx_pot%scale_coulomb
1584 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1585 CALL potential_longrange_analytic(erfa, a, b, ll, nu, basis%grid%rad, hfx_pot%omega)
1587 pot(:) = pot(:) + erfa(:)*hfx_pot%scale_longrange
1590 DO k = 1, basis%nbas(la)
1591 DO l = 1, basis%nbas(lb)
1592 cpot(:, k, l) = cpot(:, k, l) + pot(:)*basis%cm(i, k, la)*basis%cm(j, l, lb)
1602 END SUBROUTINE potential_analytic
1613 SUBROUTINE potential_coulomb_analytic(erfa, a, b, ll, nu, rad)
1614 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: erfa
1615 REAL(kind=
dp),
INTENT(IN) :: a, b
1616 INTEGER,
INTENT(IN) :: ll, nu
1617 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rad
1620 REAL(kind=
dp) :: oab, sab
1621 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: expa, z
1624 ALLOCATE (expa(nr), z(nr))
1627 oab =
dfac(ll + nu + 1)*
rootpi/sab**(ll + 2)/2._dp**((ll + nu)/2 + 2)
1629 erfa(:) = oab*erf(z(:))/z(:)**(nu + 1)
1630 expa(:) = exp(-z(:)**2)/sab**(ll + 2)/2._dp**((ll + nu)/2 + 2)
1633 CALL cp_abort(__location__, &
1634 "Only 0, 1, 2, 3, 4, 5, 6 are supported as the value of ll")
1639 erfa(:) = erfa(:) - 6._dp*expa(:)/z(:)
1643 CALL cp_abort(__location__, &
1644 "Only 0, 2 are supported as the value of nu when ll = 2")
1646 erfa(:) = erfa(:) - 2._dp*expa(:)
1648 erfa(:) = erfa(:) - expa(:)*(20._dp + 30._dp/z(:)**2)
1653 CALL cp_abort(__location__, &
1654 "Only 1, 3 are supported as the value of nu when ll = 3")
1656 erfa(:) = erfa(:) - expa(:)*(12._dp*z(:) + 30._dp/z(:))
1658 erfa(:) = erfa(:) - expa(:)*(56._dp*z(:) + 140._dp/z(:) + 210._dp/z(:)**3)
1663 CALL cp_abort(__location__, &
1664 "Only 0, 2, 4 are supported as the value of nu when ll = 4")
1666 erfa(:) = erfa(:) - expa(:)*(4._dp*z(:)**2 + 14._dp)
1668 erfa(:) = erfa(:) - expa(:)*(40._dp*z(:)**2 + 140._dp + 210._dp/z(:)**2)
1670 erfa(:) = erfa(:) - expa(:)*(144._dp*z(:)**2 + 504._dp + 1260._dp/z(:)**2 + 1890._dp/z(:)**4)
1675 CALL cp_abort(__location__, &
1676 "Only 1, 3, 5 are supported as the value of nu when ll = 5")
1678 erfa(:) = erfa(:) - expa(:)*(24._dp*z(:)**3 + 108._dp*z(:) + 210._dp/z(:))
1680 erfa(:) = erfa(:) - expa(:)*(112._dp*z(:)**3 + 504._dp*z(:) + 1260._dp/z(:) + 1890._dp/z(:)**3)
1682 erfa(:) = erfa(:) - expa(:)*(352._dp*z(:)**3 + 1584._dp*z(:) + 5544._dp/z(:) + &
1683 13860._dp/z(:)**3 + 20790._dp/z(:)**5)
1688 CALL cp_abort(__location__, &
1689 "Only 0, 2, 4, 6 are supported as the value of nu when ll = 6")
1691 erfa(:) = erfa(:) - expa(:)*(8._dp*z(:)**4 + 44._dp*z(:)**2 + 114._dp)
1693 erfa(:) = erfa(:) - expa(:)*(80._dp*z(:)**4 + 440._dp*z(:)**2 + 1260._dp + 1896._dp/z(:)**2)
1695 erfa(:) = erfa(:) - expa(:)*(288._dp*z(:)**4 + 1584._dp*z(:)**2 + 5544._dp + &
1696 13860._dp/z(:)**2 + 20790._dp/z(:)**4)
1698 erfa(:) = erfa(:) - expa(:)*(832._dp*z(:)**4 + 4576._dp*z(:)**2 + 20592._dp + &
1699 72072._dp/z(:)**2 + 180180._dp/z(:)**4 + 270270._dp/z(:)**6)
1703 DEALLOCATE (expa, z)
1705 END SUBROUTINE potential_coulomb_analytic
1717 PURE SUBROUTINE potential_longrange_analytic(erfa, a, b, ll, nu, rad, omega)
1718 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: erfa
1719 REAL(kind=
dp),
INTENT(IN) :: a, b
1720 INTEGER,
INTENT(IN) :: ll, nu
1721 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rad
1722 REAL(kind=
dp),
INTENT(IN) :: omega
1724 INTEGER :: i, lambda, nr
1725 REAL(kind=
dp) :: ab, oab, pab, prel, sab
1726 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: expa, z
1728 IF (mod(ll - nu, 2) == 0 .AND. ll >= nu .AND. nu >= 0)
THEN
1730 ALLOCATE (expa(nr), z(nr))
1732 lambda = (ll - nu)/2
1735 pab = omega**2*ab/(omega**2 + ab)
1737 z(:) = sqrt(pab)*rad(:)
1738 oab =
fac(lambda)/sqrt(ab)**(ll + 2)/4.0_dp*sqrt(prel)**(nu + 1)*(2.0_dp*real(nu, kind=
dp) + 1.0_dp)
1739 expa(:) = exp(-z(:)**2)
1740 lambda = (ll - nu)/2
1742 IF (lambda > 0)
THEN
1745 erfa = erfa + (-prel)**i/real(i, kind=
dp)*
binomial_gen(lambda + nu + 0.5_dp, lambda - i)* &
1746 assoc_laguerre(z, real(nu, kind=
dp) + 0.5_dp, i - 1)
1748 erfa = erfa*expa*z**nu
1750 erfa = erfa + 2.0_dp*
binomial_gen(lambda + nu + 0.5_dp, lambda)*znfn(z, expa, nu)
1752 erfa = 2.0_dp*znfn(z, expa, nu)
1757 DEALLOCATE (expa, z)
1763 END SUBROUTINE potential_longrange_analytic
1772 ELEMENTAL FUNCTION znfn(z, expa, n)
RESULT(res)
1774 REAL(kind=
dp),
INTENT(IN) :: z, expa
1775 INTEGER,
INTENT(IN) :: n
1776 REAL(kind=
dp) :: res
1778 REAL(kind=
dp),
PARAMETER :: z_thre = 1.0e-20_dp
1781 REAL(kind=
dp) :: z_exp
1784 IF (abs(z) < z_thre)
THEN
1785 res = z**n/(2.0_dp*real(n, kind=
dp) + 1.0_dp)
1786 ELSE IF (n == 0)
THEN
1787 res =
rootpi/2.0_dp*erf(z)/z
1789 res =
rootpi/4.0_dp*erf(z)/z**2 - expa/z/2.0_dp
1790 z_exp = -expa*0.5_dp
1793 res = (real(i, kind=
dp) - 0.5_dp)*res/z + z_exp
1810 ELEMENTAL FUNCTION assoc_laguerre(z, a, n)
RESULT(res)
1812 REAL(kind=
dp),
INTENT(IN) :: z, a
1813 INTEGER,
INTENT(IN) :: n
1814 REAL(kind=
dp) :: res
1817 REAL(kind=
dp) :: f0, f1
1821 ELSE IF (n == 1)
THEN
1822 res = a + 1.0_dp - z
1823 ELSE IF (n > 0)
THEN
1828 res = (2.0_dp + (a - 1.0_dp - z)/real(i,
dp))*f1 - (1.0_dp + (a - 1.0_dp)/real(i,
dp))*f0
1836 END FUNCTION assoc_laguerre
1847 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: opmat, pmat
1848 REAL(kind=
dp) :: trace
1864 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: imat
1865 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: cpot
1867 INTEGER,
INTENT(IN) :: derivatives
1869 INTEGER :: i, j, l, n
1871 SELECT CASE (derivatives)
1877 imat(i, j, l) = imat(i, j, l) + &
1878 integrate_grid(cpot, basis%bf(:, i, l), basis%bf(:, j, l), basis%grid)
1879 imat(j, i, l) = imat(i, j, l)
1888 imat(i, j, l) = imat(i, j, l) + &
1889 integrate_grid(cpot, basis%dbf(:, i, l), basis%bf(:, j, l), basis%grid)
1890 imat(i, j, l) = imat(i, j, l) + &
1891 integrate_grid(cpot, basis%bf(:, i, l), basis%dbf(:, j, l), basis%grid)
1892 imat(j, i, l) = imat(i, j, l)
1901 imat(i, j, l) = imat(i, j, l) + &
1902 integrate_grid(cpot, basis%dbf(:, i, l), basis%dbf(:, j, l), basis%grid)
1903 imat(j, i, l) = imat(i, j, l)
1908 cpabort(
"Only 0, 1, 2 are supported as the value of derivatives")
1924 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: jmat
1925 TYPE(
eri),
DIMENSION(:),
INTENT(IN) :: erint
1926 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1927 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nsize
1928 LOGICAL,
INTENT(IN),
OPTIONAL :: all_nu
1930 INTEGER :: i1, i2, ij1, ij2, j1, j2, l1, l2, ll, &
1932 LOGICAL :: have_all_nu
1933 REAL(kind=
dp) :: eint, f1, f2
1935 IF (
PRESENT(all_nu))
THEN
1936 have_all_nu = all_nu
1938 have_all_nu = .false.
1941 jmat(:, :, :) = 0._dp
1953 IF (i1 /= j1) f1 = 2._dp
1959 IF (i2 /= j2) f2 = 2._dp
1960 eint = erint(ll)%int(ij1, ij2)
1962 jmat(i1, j1, l1) = jmat(i1, j1, l1) + f2*pmat(i2, j2, l2)*eint
1964 jmat(i1, j1, l1) = jmat(i1, j1, l1) + f2*pmat(i2, j2, l2)*eint
1965 jmat(i2, j2, l2) = jmat(i2, j2, l2) + f1*pmat(i1, j1, l1)*eint
1971 IF (have_all_nu)
THEN
1981 jmat(j1, i1, l1) = jmat(i1, j1, l1)
1998 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1999 TYPE(
eri),
DIMENSION(:),
INTENT(IN) :: erint
2000 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
2001 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nsize
2003 INTEGER :: i1, i2, ij1, ij2, j1, j2, l1, l2, lh, &
2005 REAL(kind=
dp) :: almn, eint, f1, f2
2006 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
2011 arho(ll) =
fac(ll)/
fac(lh)**2
2014 kmat(:, :, :) = 0._dp
2020 DO nu = abs(l1 - l2), l1 + l2, 2
2021 almn = arho(-l1 + l2 + nu)*arho(l1 - l2 + nu)*arho(l1 + l2 - nu)/(real(l1 + l2 + nu + 1,
dp)*arho(l1 + l2 + nu))
2029 IF (i1 /= j1) f1 = 2._dp
2035 IF (i2 /= j2) f2 = 2._dp
2036 eint = erint(ll)%int(ij1, ij2)
2038 kmat(i1, j1, l1) = kmat(i1, j1, l1) + f2*almn*pmat(i2, j2, l2)*eint
2040 kmat(i1, j1, l1) = kmat(i1, j1, l1) + f2*almn*pmat(i2, j2, l2)*eint
2041 kmat(i2, j2, l2) = kmat(i2, j2, l2) + f1*almn*pmat(i1, j1, l1)*eint
2054 kmat(j1, i1, l1) = kmat(i1, j1, l1)
2074 PURE SUBROUTINE err_matrix(emat, demax, kmat, pmat, umat, upmat, nval, nbs)
2075 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(OUT) :: emat
2076 REAL(kind=
dp),
INTENT(OUT) :: demax
2077 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: kmat, pmat, umat, upmat
2078 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nval, nbs
2081 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: tkmat, tpmat
2088 ALLOCATE (tkmat(1:m, 1:m), tpmat(1:m, 1:m))
2091 tkmat(1:m, 1:m) = matmul(transpose(umat(1:n, 1:m, l)), matmul(kmat(1:n, 1:n, l), umat(1:n, 1:m, l)))
2092 tpmat(1:m, 1:m) = matmul(transpose(umat(1:n, 1:m, l)), matmul(pmat(1:n, 1:n, l), umat(1:n, 1:m, l)))
2093 tpmat(1:m, 1:m) = matmul(upmat(1:m, 1:m, l), matmul(tpmat(1:m, 1:m), upmat(1:m, 1:m, l)))
2095 emat(1:m, 1:m, l) = matmul(tkmat(1:m, 1:m), tpmat(1:m, 1:m)) - matmul(tpmat(1:m, 1:m), tkmat(1:m, 1:m))
2097 DEALLOCATE (tkmat, tpmat)
2100 demax = maxval(abs(emat))
2118 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density1, density2
2119 INTEGER,
INTENT(IN) :: zcore
2123 INTEGER :: counter, i, l, mc, mm(0:
lmat), mo, n, ns
2124 INTEGER,
DIMENSION(lmat+1, 20) :: ne
2125 REAL(kind=
dp) :: a, pf
2133 mo = state%maxn_occ(l)
2134 IF (sum(state%core(l, :)) == 0)
THEN
2135 cpassert(ns >= l + mo)
2137 ne(l + 1, l + counter) = nint(state%occ(l, counter))
2141 cpassert(sum(state%occ(l, 1:mc)) == 0)
2142 cpassert(ns >= l + mc)
2144 ne(l + 1, l + counter) = nint(state%core(l, counter))
2146 cpassert(ns >= l + mc + mo)
2147 DO counter = mc + 1, mc + mo
2148 ne(l + 1, l + counter) = nint(state%occ(l, counter))
2155 DO l = 0, state%maxl_occ
2156 DO i = 1,
SIZE(state%occ, 2)
2157 IF (state%occ(l, i) > 0._dp)
THEN
2159 a =
srules(zcore, ne, n, l)
2160 pf = 1._dp/sqrt(
fac(2*n))*(2._dp*a)**(n + 0.5_dp)
2161 IF (state%multiplicity == -1)
THEN
2162 density1(:) = density1(:) + state%occ(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2164 density1(:) = density1(:) + state%occa(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2165 density2(:) = density2(:) + state%occb(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2183 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rho
2184 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: vxc
2187 REAL(kind=
dp) :: ec, ex, rs, vc, vx
2191 IF (rho(i) > 1.e-20_dp)
THEN
2193 ex = -0.7385588_dp*rho(i)**0.333333333_dp
2194 vx = 1.333333333_dp*ex
2195 rs = (3._dp/
fourpi/rho(i))**0.333333333_dp
2196 ec = -0.88_dp/(rs + 7.8_dp)
2197 vc = ec*(1._dp + rs/(3._dp*(rs + 7.8_dp)))
2213 INTEGER,
INTENT(IN) :: method, multiplicity
2214 LOGICAL :: consistent
2218 SELECT CASE (method)
2220 consistent = .false.
2222 consistent = (multiplicity == -1)
2224 consistent = (multiplicity /= -1)
2226 consistent = (multiplicity == -1)
2228 consistent = (multiplicity /= -1)
2230 consistent = .false.
2244 REAL(kind=
dp),
INTENT(OUT) :: rho0
2246 INTEGER :: m0, m1, m2, method, nr
2247 LOGICAL :: nlcc, spinpol
2248 REAL(kind=
dp) :: d0, d1, d2, r0, r1, r2, w0, w1
2249 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: xfun
2250 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rho
2252 method =
atom%method_type
2253 SELECT CASE (method)
2259 cpabort(
"ROHF not yet implemented for get_rho0")
2261 cpabort(
"Unknown method for get_rho0")
2264 nr =
atom%basis%grid%nr
2267 nlcc =
atom%potential%gth_pot%nlcc
2269 nlcc =
atom%potential%upf_pot%core_correction
2271 nlcc =
atom%potential%sgp_pot%has_nlcc
2277 m0 = maxval(minloc(
atom%basis%grid%rad))
2281 ELSE IF (m0 == 1)
THEN
2285 cpabort(
"GRID Definition incompatible")
2287 r0 =
atom%basis%grid%rad(m0)
2288 r1 =
atom%basis%grid%rad(m1)
2289 r2 =
atom%basis%grid%rad(m2)
2294 ALLOCATE (rho(nr, 2))
2300 rho(:, 1) = rho(:, 1) + 0.5_dp*xfun(:)
2301 rho(:, 2) = rho(:, 2) + 0.5_dp*xfun(:)
2303 rho(:, 1) = rho(:, 1) + rho(:, 2)
2305 ALLOCATE (rho(nr, 1))
2315 rho0 = w0*d0 + w1*d1
2316 rho0 = max(rho0, 0.0_dp)
2335 REAL(kind=
dp) :: crad
2336 INTEGER,
INTENT(IN) :: iw
2340 REAL(kind=
dp),
DIMENSION(10) :: cnum, rad
2342 WRITE (iw,
'(/,A,F8.4)')
" Basis Set Condition Numbers: 2*covalent radius=", 2*crad
2347 ci = 2.0_dp*(0.85_dp + i*0.05_dp)
2350 WRITE (iw,
'(A,F15.3,T50,A,F14.4)')
" Lattice constant:", &
2351 rad(i),
"Condition number:", cnum(i)
2355 WRITE (iw,
'(A,A,T50,A,F14.4)')
" Lattice constant:", &
2356 " Inf",
"Condition number:", cnum(i)
2370 INTEGER,
INTENT(IN) :: zv, iw
2372 INTEGER :: i, j, l, ll, m, n, nbas, nl, nr
2373 INTEGER,
DIMENSION(0:lmat) ::
nelem, nlmax, nlmin
2374 INTEGER,
DIMENSION(lmat+1, 7) :: ne
2375 REAL(kind=
dp) :: al, c1, c2, pf
2376 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sfun
2377 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: bmat
2378 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: omat
2379 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: sint
2380 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: snl
2381 REAL(kind=
dp),
DIMENSION(2) :: sse
2382 REAL(kind=
dp),
DIMENSION(lmat+1, 7) :: sexp
2390 IF (
nelem(l) >= ll)
THEN
2393 ELSE IF (
nelem(l) > 0)
THEN
2394 ne(l + 1, i) =
nelem(l)
2407 IF (ne(l + 1, i) > 0)
THEN
2411 nlmax(l) = max(nlmax(l), nlmin(l) + 1)
2420 sexp(l + 1, i) =
srules(zv, ne, i, l)
2421 IF (ne(l + 1, i - l) > 0)
THEN
2422 sse(1) = max(sse(1), sexp(l + 1, i))
2423 sse(2) = min(sse(2), sexp(l + 1, i))
2427 snl(l, i) = abs(2._dp*sse(1) - 0.5_dp*sse(2))/9._dp*real(i - 1, kind=
dp) + 0.5_dp*min(sse(1), sse(2))
2431 nbas = maxval(basis%nbas)
2432 ALLOCATE (omat(nbas, nbas, 0:
lmat))
2433 nr =
SIZE(basis%bf, 1)
2434 ALLOCATE (sfun(nr), sint(10, 2, nbas, 0:
lmat))
2442 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
2443 sfun(1:nr) = pf*basis%grid%rad(1:nr)**(nl - 1)*exp(-al*basis%grid%rad(1:nr))
2444 DO j = 1, basis%nbas(l)
2445 sint(i, 1, j, l) = sum(sfun(1:nr)*basis%bf(1:nr, j, l)*basis%grid%wr(1:nr))
2448 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
2449 sfun(1:nr) = pf*basis%grid%rad(1:nr)**(nl - 1)*exp(-al*basis%grid%rad(1:nr))
2450 DO j = 1, basis%nbas(l)
2451 sint(i, 2, j, l) = sum(sfun(1:nr)*basis%bf(1:nr, j, l)*basis%grid%wr(1:nr))
2460 SELECT CASE (basis%basis_type)
2462 cpabort(
"Unknown basis type for atom_completeness")
2464 CALL sg_overlap(omat(1:n, 1:n, l), l, basis%am(1:n, l), basis%am(1:n, l))
2466 ALLOCATE (bmat(m, m))
2467 CALL sg_overlap(bmat(1:m, 1:m), l, basis%am(1:m, l), basis%am(1:m, l))
2468 CALL contract2(omat(1:n, 1:n, l), bmat(1:m, 1:m), basis%cm(1:m, 1:n, l))
2471 CALL sto_overlap(omat(1:n, 1:n, l), basis%ns(1:n, l), basis%as(1:n, l), &
2472 basis%ns(1:n, l), basis%as(1:n, l))
2474 cpabort(
"Numerical basis not yet implemented for atom_completeness")
2479 WRITE (iw,
'(/,A)')
" Basis Set Completeness Estimates"
2483 WRITE (iw,
'(A,I3)')
" L-quantum number: ", l
2484 WRITE (iw,
'(A,T31,A,I2,T61,A,I2)')
" Slater Exponent",
"Completeness n-qm=", nlmin(l), &
2485 "Completeness n-qm=", nlmax(l)
2487 c1 = dot_product(sint(i, 1, 1:n, l), matmul(omat(1:n, 1:n, l), sint(i, 1, 1:n, l)))
2488 c2 = dot_product(sint(i, 2, 1:n, l), matmul(omat(1:n, 1:n, l), sint(i, 2, 1:n, l)))
2489 WRITE (iw,
"(T6,F14.6,T41,F10.6,T71,F10.6)") snl(l, i), c1, c2
2493 DEALLOCATE (omat, sfun, sint)
2505 REAL(kind=
dp),
INTENT(IN) :: rad
2506 REAL(kind=
dp),
INTENT(OUT) :: cnum
2508 INTEGER :: ia, ib,
imax, info, ix, iy, iz, ja, jb, &
2509 ka, kb, l, la, lb, lwork, na, nb, &
2511 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: ibptr
2512 REAL(kind=
dp) :: r1, r2, reps, rmax
2513 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: weig, work
2514 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat
2515 REAL(kind=
dp),
DIMENSION(2*lmat+1, 2*lmat+1) :: sab
2516 REAL(kind=
dp),
DIMENSION(3) :: rab
2517 REAL(kind=
dp),
DIMENSION(:),
POINTER :: zeta, zetb
2524 nbas = nbas + basis%nbas(l)*(2*l + 1)
2527 ALLOCATE (smat(nbas, nbas), ibptr(nbas, 0:
lmat))
2532 DO ia = 1, basis%nbas(l)
2533 ibptr(ia, l) = na + 1
2539 IF (basis%basis_type ==
gto_basis .OR. &
2542 na = basis%nprim(la)
2545 zeta => basis%am(:, la)
2547 nb = basis%nprim(lb)
2550 zetb => basis%am(:, lb)
2553 IF (rad < 0.1_dp)
THEN
2558 rmax = max(2._dp*r1, 2._dp*r2)
2559 imax = int(rmax/rad) + 1
2566 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) + sab(1:nna, 1:nnb)
2567 ELSE IF (basis%basis_type ==
cgto_basis)
THEN
2568 DO ka = 1, basis%nbas(la)
2569 DO kb = 1, basis%nbas(lb)
2572 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) + &
2573 sab(1:nna, 1:nnb)*basis%cm(ia, ka, la)*basis%cm(ib, kb, lb)
2584 CALL overlap_ab_s(la, zeta(ia), lb, zetb(ib), rab, sab)
2588 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) &
2590 ELSE IF (basis%basis_type ==
cgto_basis)
THEN
2591 DO ka = 1, basis%nbas(la)
2592 DO kb = 1, basis%nbas(lb)
2595 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = &
2596 smat(ja:ja + nna - 1, jb:jb + nnb - 1) + &
2597 sab(1:nna, 1:nnb)*basis%cm(ia, ka, la)*basis%cm(ib, kb, lb)
2610 cpabort(
"Condition number not available for this basis type")
2614 lwork = max(nbas*nbas, nbas + 100)
2615 ALLOCATE (weig(nbas), work(lwork))
2617 CALL dsyev(
"N",
"U", nbas, smat, nbas, weig, work, lwork, info)
2619 IF (weig(1) < 0.0_dp)
THEN
2622 cnum = abs(weig(nbas)/weig(1))
2626 DEALLOCATE (smat, ibptr, weig, work)
2637 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: int
2638 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm
2640 CHARACTER(len=*),
PARAMETER :: routinen =
'contract2'
2642 INTEGER :: handle, m, n
2644 CALL timeset(routinen, handle)
2649 int(1:n, 1:n) = matmul(transpose(cm(1:m, 1:n)), matmul(omat(1:m, 1:m), cm(1:m, 1:n)))
2651 CALL timestop(handle)
2663 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: int
2664 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm
2666 CHARACTER(len=*),
PARAMETER :: routinen =
'contract2add'
2668 INTEGER :: handle, m, n
2670 CALL timeset(routinen, handle)
2675 int(1:n, 1:n) = int(1:n, 1:n) + matmul(transpose(cm(1:m, 1:n)), matmul(omat(1:m, 1:m), cm(1:m, 1:n)))
2677 CALL timestop(handle)
2689 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) ::
eri
2690 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm1, cm2
2692 CHARACTER(len=*),
PARAMETER :: routinen =
'contract4'
2694 INTEGER :: handle, i1, i2, m1, m2, mm1, mm2, n1, &
2696 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: amat, atran, bmat, btran, hint
2698 CALL timeset(routinen, handle)
2709 ALLOCATE (amat(m1, m1), atran(n1, n1), bmat(m2, m2), btran(n2, n2))
2710 ALLOCATE (hint(mm1, nn2))
2713 CALL iunpack(bmat(1:m2, 1:m2), omat(i1, 1:mm2), m2)
2714 CALL contract2(btran(1:n2, 1:n2), bmat(1:m2, 1:m2), cm2(1:m2, 1:n2))
2715 CALL ipack(btran(1:n2, 1:n2), hint(i1, 1:nn2), n2)
2719 CALL iunpack(amat(1:m1, 1:m1), hint(1:mm1, i2), m1)
2720 CALL contract2(atran(1:n1, 1:n1), amat(1:m1, 1:m1), cm1(1:m1, 1:n1))
2721 CALL ipack(atran(1:n1, 1:n1),
eri(1:nn1, i2), n1)
2724 DEALLOCATE (amat, atran, bmat, btran)
2727 CALL timestop(handle)
2737 PURE SUBROUTINE ipack(mat, vec, n)
2738 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: mat
2739 REAL(
dp),
DIMENSION(:),
INTENT(INOUT) :: vec
2740 INTEGER,
INTENT(IN) :: n
2752 END SUBROUTINE ipack
2760 PURE SUBROUTINE iunpack(mat, vec, n)
2761 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: mat
2762 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: vec
2763 INTEGER,
INTENT(IN) :: n
2776 END SUBROUTINE iunpack
static int imax(int x, int y)
Returns the larger of two given integers (missing from the C standard).
subroutine, public sto_overlap(smat, na, pa, nb, pb)
...
subroutine, public sg_overlap(smat, l, pa, pb)
...
Calculation of the overlap integrals over Cartesian Gaussian-type functions.
subroutine, public overlap_ab_s(la, zeta, lb, zetb, rab, sab)
Calculation of the two-center overlap integrals [a|b] over Spherical Gaussian-type functions.
subroutine, public overlap_ab_sp(la, zeta, lb, zetb, alat, sab)
Calculation of the overlap integrals [a|b] over cubic periodic Spherical Gaussian-type functions.
All kind of helpful little routines.
real(kind=dp) function, public exp_radius(l, alpha, threshold, prefactor, epsabs, epsrel, rlow)
The radius of a primitive Gaussian function for a given threshold is calculated. g(r) = prefactor*r**...
Define the atom type and its sub types.
integer, parameter, public num_basis
integer, parameter, public cgto_basis
integer, parameter, public gto_basis
integer, parameter, public sto_basis
integer, parameter, public lmat
Some basic routines for atomic calculations.
subroutine, public slater_density(density1, density2, zcore, state, grid)
Calculate Slater density on a radial grid.
subroutine, public atom_condnumber(basis, crad, iw)
Print condition numbers of the given atomic basis set.
pure subroutine, public atom_denmat(pmat, wfn, nbas, occ, maxl, maxn)
Calculate a density matrix using atomic orbitals.
pure subroutine, public atom_local_potential(locpot, gthpot, rr)
...
subroutine, public contract2(int, omat, cm)
Transform a matrix expressed in terms of a uncontracted basis set to a contracted one.
subroutine, public atom_read_external_vxc(vxc, atom, iw)
ZMP subroutine to read external v_xc in the atomic code.
pure subroutine, public eeri_contract(kmat, erint, pmat, nsize)
Contract exchange Electron Repulsion Integrals.
pure subroutine, public atom_orbital_charge(charge, wfn, rcov, l, basis)
...
pure logical function, public atom_consistent_method(method, multiplicity)
Check that the atomic multiplicity is consistent with the electronic structure method.
subroutine, public atom_core_density(corden, potential, typ, rr)
...
pure integer function, dimension(0:lmat), public get_maxn_occ(occupation)
Return the maximum principal quantum number of occupied orbitals.
subroutine, public exchange_semi_analytic(kmat, state, occ, wfn, basis, hfx_pot)
Calculate the exchange potential semi-analytically.
pure subroutine, public ceri_contract(jmat, erint, pmat, nsize, all_nu)
Contract Coulomb Electron Repulsion Integrals.
subroutine, public coulomb_potential_analytic(cpot, pmat, basis, grid, maxl)
Analytically compute the Coulomb potential on an atomic radial grid.
pure subroutine, public err_matrix(emat, demax, kmat, pmat, umat, upmat, nval, nbs)
Calculate the error matrix for each angular momentum.
subroutine, public atom_density(density, pmat, basis, maxl, typ, rr)
Map the electron density on an atomic radial grid.
pure subroutine, public wigner_slater_functional(rho, vxc)
Calculate the functional derivative of the Wigner (correlation) - Slater (exchange) density functiona...
subroutine, public atom_read_zmp_restart(atom, doguess, iw)
ZMP subroutine to read external restart file.
subroutine, public atom_basis_condnum(basis, rad, cnum)
Calculate the condition number of the given atomic basis set.
subroutine, public contract4(eri, omat, cm1, cm2)
Contract a matrix of Electron Repulsion Integrals (ERI-s).
subroutine, public exchange_numeric(kmat, state, occ, wfn, basis, hfx_pot)
Calculate the exchange potential numerically.
pure real(kind=dp) function, public atom_trace(opmat, pmat)
Compute Trace[opmat * pmat] == Trace[opmat * pmat^T] .
pure subroutine, public atom_orbital_max(rmax, wfn, rcov, l, basis)
...
subroutine, public atom_read_external_density(density, atom, iw)
ZMP subroutine to read external density from linear grid of density matrix.
subroutine, public numpot_matrix(imat, cpot, basis, derivatives)
Calculate a potential matrix by integrating the potential on an atomic radial grid.
subroutine, public atom_solve(hmat, umat, orb, ener, nb, nv, maxl)
Solve the generalised eigenproblem for every angular momentum.
subroutine, public get_rho0(atom, rho0)
Calculate the total electron density at R=0.
subroutine, public atom_completeness(basis, zv, iw)
Estimate completeness of the given atomic basis set.
subroutine, public atom_write_zmp_restart(atom)
ZMP subroutine to write external restart file.
subroutine, public atom_set_occupation(ostring, occupation, wfnocc, multiplicity)
Set occupation of atomic orbitals.
subroutine, public contract2add(int, omat, cm)
Same as contract2(), but add the new contracted matrix to the old one instead of overwriting it.
subroutine, public coulomb_potential_numeric(cpot, density, grid)
Numerically compute the Coulomb potential on an atomic radial grid.
pure subroutine, public atom_orbital_nodes(node, wfn, rcov, l, basis)
...
pure integer function, public get_maxl_occ(occupation)
Return the maximum orbital quantum number of occupied orbitals.
pure subroutine, public atom_wfnr0(value, wfn, basis)
...
pure real(dp) function, public srules(z, ne, n, l)
...
Utility routines to open and close files.
subroutine, public open_file(file_name, unit_number, file_status, file_form, file_action, file_position, file_pad, file_access, debug)
Opens a file and returns its logical unit number.
subroutine, public close_file(unit_number, file_status)
Closes an open file given by its logical unit number.
sums arrays of real/complex numbers with much reduced round-off as compared to a naive implementation...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), dimension(-1:2 *maxfac+1), parameter, public dfac
real(kind=dp), parameter, public rootpi
real(kind=dp), parameter, public fourpi
integer, parameter, public maxfac
real(kind=dp), dimension(0:maxfac), parameter, public fac
Collection of simple mathematical functions and subroutines.
elemental real(kind=dp) function, public binomial_gen(z, k)
The generalized binomial coefficient z over k for 0 <= k <= n is calculated. (z) z*(z-1)*....
subroutine, public invmat_symm(a, potrf, uplo)
returns inverse of real symmetric, positive definite matrix
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
subroutine, public deallocate_orbital_pointers()
Deallocate the orbital pointers.
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
integer, parameter, public nelem
Definition of physical constants:
real(kind=dp), parameter, public bohr
Simple splines Splines are fully specified by the interpolation points, except that at the ends,...
subroutine, public spline3ders(x, y, xnew, ynew, dynew, d2ynew)
...
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Provides all information about a basis set.
Provides all information about a pseudopotential.
Provides info about hartree-fock exchange (For now, we only support potentials that can be represente...
Provides all information on states and occupation.
Provides all information about an atomic kind.