24 lmat, no_pseudo, sgp_pseudo, upf_pseudo
55#include "./base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_utils'
83 MODULE PROCEDURE integrate_grid_function1, &
84 integrate_grid_function2, &
85 integrate_grid_function3
103 CHARACTER(LEN=default_string_length), &
104 DIMENSION(:),
POINTER :: ostring
105 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: occupation, wfnocc
106 INTEGER,
INTENT(OUT),
OPTIONAL :: multiplicity
108 CHARACTER(len=2) :: elem
109 CHARACTER(LEN=default_string_length) :: pstring
110 INTEGER :: i, i1, i2, ielem, is, jd, jf, jp, js, k, &
112 REAL(kind=
dp) :: e0, el, oo
116 cpassert(
ASSOCIATED(ostring))
117 cpassert(
SIZE(ostring) > 0)
125 IF (index(ostring(is),
"(") /= 0)
THEN
126 i1 = index(ostring(is),
"(")
127 i2 = index(ostring(is),
")")
128 cpassert((i2 - i1 - 1 > 0) .AND. (i2 - i1 - 1 < 3))
129 elem = ostring(is) (i1 + 1:i2 - 1)
130 IF (index(elem,
"HS") /= 0)
THEN
132 ELSE IF (index(elem,
"LS") /= 0)
THEN
142 IF (index(ostring(is),
"CORE") /= 0) is = is + 1
145 IF (index(ostring(is),
"none") /= 0) is = is + 1
148 IF (index(ostring(is),
"[") /= 0)
THEN
150 i1 = index(ostring(is),
"[")
151 i2 = index(ostring(is),
"]")
152 cpassert((i2 - i1 - 1 > 0) .AND. (i2 - i1 - 1 < 3))
153 elem = ostring(is) (i1 + 1:i2 - 1)
156 IF (elem ==
ptable(k)%symbol)
THEN
162 DO l = 0, min(
lmat, ubound(
ptable(ielem)%e_conv, 1))
163 el = 2._dp*(2._dp*real(l,
dp) + 1._dp)
164 e0 =
ptable(ielem)%e_conv(l)
166 occupation(l, k) = min(el, e0)
168 IF (e0 <= 0._dp)
EXIT
179 js = index(pstring,
"S")
180 jp = index(pstring,
"P")
181 jd = index(pstring,
"D")
182 jf = index(pstring,
"F")
183 cpassert(js + jp + jd + jf > 0)
185 cpassert(jp + jd + jf == 0)
186 READ (pstring(1:js - 1), *) n
187 READ (pstring(js + 1:), *) oo
189 cpassert(oo >= 0._dp)
190 cpassert(occupation(0, n) == 0)
191 occupation(0, n) = oo
194 cpassert(js + jd + jf == 0)
195 READ (pstring(1:jp - 1), *) n
196 READ (pstring(jp + 1:), *) oo
198 cpassert(oo >= 0._dp)
199 cpassert(occupation(1, n - 1) == 0)
200 occupation(1, n - 1) = oo
203 cpassert(js + jp + jf == 0)
204 READ (pstring(1:jd - 1), *) n
205 READ (pstring(jd + 1:), *) oo
207 cpassert(oo >= 0._dp)
208 cpassert(occupation(2, n - 2) == 0)
209 occupation(2, n - 2) = oo
212 cpassert(js + jp + jd == 0)
213 READ (pstring(1:jf - 1), *) n
214 READ (pstring(jf + 1:), *) oo
216 cpassert(oo >= 0._dp)
217 cpassert(occupation(3, n - 3) == 0)
218 occupation(3, n - 3) = oo
227 IF (occupation(l, i) /= 0._dp)
THEN
229 wfnocc(l, k) = occupation(l, i)
241 IF (wfnocc(l, i) /= 0._dp .AND. wfnocc(l, i) /= real(k,
dp))
THEN
249 IF (js == 0 .AND. mult == -2) mult = 1
250 IF (js == 0 .AND. mult == -3) mult = 1
257 k = nint(wfnocc(l, i))
258 IF (k > (2*l + 1)) k = 2*(2*l + 1) - k
259 IF (mult == -2) mult = k + 1
260 IF (mult == -3) mult = mod(k, 2) + 1
261 cpassert(mod(k + 1 - mult, 2) == 0)
263 IF (js > 1 .AND. mult /= -2)
THEN
269 IF (
PRESENT(multiplicity)) multiplicity = mult
281 REAL(kind=
dp),
DIMENSION(0:lmat, 10),
INTENT(IN) :: occupation
288 IF (sum(occupation(l, :)) /= 0._dp) maxl = l
301 REAL(kind=
dp),
DIMENSION(0:lmat, 10),
INTENT(IN) :: occupation
302 INTEGER,
DIMENSION(0:lmat) :: maxn
309 IF (occupation(l, k) /= 0._dp) maxn(l) = maxn(l) + 1
327 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: pmat
328 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: wfn
329 INTEGER,
DIMENSION(0:lmat),
INTENT(IN) :: nbas
330 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
331 INTEGER,
INTENT(IN) :: maxl
332 INTEGER,
DIMENSION(0:lmat),
INTENT(IN) :: maxn
334 INTEGER :: i, j, k, l, n
339 DO i = 1, min(n, maxn(l))
342 pmat(j, k, l) = pmat(j, k, l) + occ(l, i)*wfn(j, i, l)*wfn(k, i, l)
366 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density
367 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
369 INTEGER,
INTENT(IN) :: maxl
370 CHARACTER(LEN=*),
OPTIONAL :: typ
371 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: rr
373 CHARACTER(LEN=3) :: my_typ
374 INTEGER :: i, j, l, n
378 IF (
PRESENT(typ)) my_typ = typ(1:3)
379 IF (my_typ ==
"KIN")
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%bf(:, j, l)/rr(:) &
403 + 2._dp*ff*basis%bf(:, i, l)*basis%dbf(:, j, l)/rr(:)
405 cpabort(
"Unknown matrix type specified. Check the code!")
425 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')")
469 CALL open_file(file_name=
atom%zmp_restart_file, file_status=
"OLD", &
470 file_form=
"FORMATTED", file_action=
"READ", &
473 READ (extunit, *, iostat=er) nbas
476 WRITE (iw, fmt=
"(' ZMP | ERROR! Restart file unreadable')")
477 WRITE (iw, fmt=
"(' ZMP | ERROR! Starting ZMP calculation form initial atomic guess')")
479 atom%doread = .false.
480 ELSE IF (nbas(1) /=
atom%basis%nbas(1))
THEN
481 WRITE (iw, fmt=
"(' ZMP | ERROR! Restart file contains a different basis set')")
482 WRITE (iw, fmt=
"(' ZMP | ERROR! Starting ZMP calculation form initial atomic guess')")
484 atom%doread = .false.
486 nbas =
atom%basis%nbas
487 maxl =
atom%state%maxl_occ
488 maxn =
atom%state%maxn_occ
489 n =
SIZE(
atom%orbitals%wfn, 2)
490 DO l = 0,
atom%state%maxl_occ
491 DO i = 1, min(n,
atom%state%maxn_occ(l))
492 DO k = 1,
atom%basis%nbas(l)
493 READ (extunit, *)
atom%orbitals%wfn(k, i, l)
501 WRITE (iw, fmt=
"(' ZMP | WARNING! Restart file not found')")
502 WRITE (iw, fmt=
"(' ZMP | WARNING! Starting ZMP calculation form initial atomic guess')")
516 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density
518 INTEGER,
INTENT(IN) :: iw
520 CHARACTER(LEN=default_string_length) :: filename
521 INTEGER :: extunit, ir, j, k, l, maxl_occ, maxnbas, &
525 REAL(kind=
dp),
ALLOCATABLE :: pmatread(:, :, :)
527 filename =
atom%ext_file
531 CALL open_file(file_name=filename, file_status=
"OLD", &
532 file_form=
"FORMATTED", file_action=
"READ", &
538 IF (nr /=
atom%basis%grid%nr)
THEN
539 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! External grid dimension ',I4,' differs from internal grid ',I4)") &
540 nr,
atom%basis%grid%nr
541 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Stopping ZMP calculation')")
542 cpabort(
"Unable to continue reading external density file")
546 READ (extunit, *) rr, density(ir)
547 IF (abs(rr -
atom%basis%grid%rad(ir)) >
atom%zmpgrid_tol)
THEN
548 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Grid points do not coincide: ')")
549 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T20,"R_out[bohr]",T36,"R_in[bohr]",T61,"R_diff[bohr]")')
550 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T14,E24.15,T39,E24.15,T64,E24.15)') &
551 rr,
atom%basis%grid%rad(ir), abs(rr -
atom%basis%grid%rad(ir))
552 cpabort(
"Unable to continue reading external density file")
557 READ (extunit, *) maxl_occ
558 maxnbas = maxval(
atom%basis%nbas)
559 ALLOCATE (pmatread(maxnbas, maxnbas, 0:maxl_occ))
562 nbas =
atom%basis%nbas(l)
565 READ (extunit, *) (pmatread(j, k, l), j=1, k)
567 pmatread(k, j, l) = pmatread(j, k, l)
577 CALL open_file(file_name=
"rho_target.dat", file_status=
"UNKNOWN", &
578 file_form=
"FORMATTED", file_action=
"WRITE", unit_number=extunit)
580 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | Writing target density from density matrix')")
582 WRITE (extunit, fmt=
'("# Target density built from density matrix : ",A20)') filename
583 WRITE (extunit, fmt=
'("#",T10,"R[bohr]",T36,"Rho[au]")')
585 nr =
atom%basis%grid%nr
588 WRITE (extunit, fmt=
'(T1,E24.15,T26,E24.15)') &
589 atom%basis%grid%rad(ir), density(ir)
591 DEALLOCATE (pmatread)
607 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: vxc
609 INTEGER,
INTENT(IN) :: iw
611 CHARACTER(LEN=default_string_length) :: adum, filename
612 INTEGER :: extunit, ir, nr
615 filename =
atom%ext_vxc_file
618 CALL open_file(file_name=filename, file_status=
"OLD", &
619 file_form=
"FORMATTED", file_action=
"READ", &
623 READ (extunit, *) adum, nr
625 IF (nr /=
atom%basis%grid%nr)
THEN
626 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! External grid dimension ',I4,' differs from internal grid ',I4)") &
627 nr,
atom%basis%grid%nr
628 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Stopping ZMP calculation')")
629 cpabort(
"Unable to continue reading external v_xc file")
632 READ (extunit, *) rr, vxc(ir)
633 IF (abs(rr -
atom%basis%grid%rad(ir)) >
atom%zmpvxcgrid_tol)
THEN
634 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Grid points do not coincide: ')")
635 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T20,"R_out[bohr]",T36,"R_in[bohr]",T61,"R_diff[bohr]")')
636 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T14,E24.15,T39,E24.15,T64,E24.15)') &
637 rr,
atom%basis%grid%rad(ir), abs(rr -
atom%basis%grid%rad(ir))
638 cpabort(
"Unable to continue reading external v_xc file")
653 REAL(kind=
dp),
INTENT(OUT) :: charge
654 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
655 REAL(kind=
dp),
INTENT(IN) :: rcov
656 INTEGER,
INTENT(IN) :: l
659 INTEGER :: i, j, m, n
661 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: den
664 m =
SIZE(basis%bf, 1)
671 den(1:m) = den(1:m) + ff*basis%bf(1:m, i, l)*basis%bf(1:m, j, l)
675 IF (basis%grid%rad(i) > rcov) den(i) = 0._dp
677 charge = sum(den(1:m)*basis%grid%wr(1:m))
693 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: corden
695 CHARACTER(LEN=*),
OPTIONAL :: typ
696 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rr
698 CHARACTER(LEN=3) :: my_typ
699 INTEGER :: i, j, m, n
701 REAL(kind=
dp) :: a, a2, cval, fb
702 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: fe, rc, rhoc, rval
705 IF (
PRESENT(typ)) my_typ = typ(1:3)
707 SELECT CASE (potential%ppot_type)
711 IF (potential%gth_pot%nlcc)
THEN
713 ALLOCATE (fe(m), rc(m))
714 n = potential%gth_pot%nexp_nlcc
716 a = potential%gth_pot%alpha_nlcc(i)
720 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
721 DO j = 1, potential%gth_pot%nct_nlcc(i)
722 cval = potential%gth_pot%cval_nlcc(j, i)
723 IF (my_typ ==
"RHO")
THEN
724 corden(:) = corden(:) + fe(:)*rc**(2*j - 2)*cval
725 ELSE IF (my_typ ==
"DER")
THEN
726 corden(:) = corden(:) - fe(:)*rc**(2*j - 1)*cval/a
728 corden(:) = corden(:) + real(2*j - 2,
dp)*fe(:)*rc**(2*j - 3)*cval/a
730 ELSE IF (my_typ ==
"LAP")
THEN
732 corden(:) = corden(:) - fb*fe(:)/rr(:)*rc**(2*j - 1)
733 corden(:) = corden(:) + fe(:)*rc**(2*j)*cval/a2
735 corden(:) = corden(:) + fb*real(2*j - 2,
dp)*fe(:)/rr(:)*rc**(2*j - 3)
736 corden(:) = corden(:) + real((2*j - 2)*(2*j - 3),
dp)*fe(:)*rc**(2*j - 4)*cval/a2
737 corden(:) = corden(:) - real(2*j - 2,
dp)*fe(:)*rc**(2*j - 2)*cval/a2
740 CALL cp_abort(__location__, &
741 "Only <RHO>, <DER>, <LAP> are supported as <my_typ> "// &
742 "in atom_core_density, found <"//trim(my_typ)//
">")
749 IF (potential%upf_pot%core_correction)
THEN
751 n = potential%upf_pot%mesh_size
753 IF (rr(1) > rr(m)) reverse = .true.
754 ALLOCATE (rhoc(m), rval(m))
757 rval(i) = rr(m - i + 1)
762 IF (my_typ ==
"RHO")
THEN
763 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
765 ELSE IF (my_typ ==
"DER")
THEN
766 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
768 ELSE IF (my_typ ==
"LAP")
THEN
769 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
772 CALL cp_abort(__location__, &
773 "Only <RHO>, <DER>, <LAP> are supported as <my_typ> "// &
774 "in atom_core_density, found <"//trim(my_typ)//
">")
778 rval(i) = rr(m - i + 1)
779 corden(i) = corden(i) + rhoc(m - i + 1)
782 corden(1:m) = corden(1:m) + rhoc(1:m)
784 DEALLOCATE (rhoc, rval)
787 IF (potential%sgp_pot%has_nlcc)
THEN
788 cpabort(
"not implemented")
791 cpabort(
"Unknown PP type")
803 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: locpot
805 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rr
807 INTEGER :: i, j, m, n
809 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: fe, rc
812 ALLOCATE (fe(m), rc(m))
813 rc(:) = rr(:)/gthpot%rc
815 locpot(i) = -gthpot%zion*erf(rc(i)/sqrt(2._dp))/rr(i)
818 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
820 locpot(:) = locpot(:) + fe(:)*rc**(2*i - 2)*gthpot%cl(i)
822 IF (gthpot%lpotextended)
THEN
823 DO j = 1, gthpot%nexp_lpot
824 a = gthpot%alpha_lpot(j)
826 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
827 n = gthpot%nct_lpot(j)
829 locpot(:) = locpot(:) + fe(:)*rc**(2*i - 2)*gthpot%cval_lpot(i, j)
846 REAL(kind=
dp),
INTENT(OUT) :: rmax
847 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
848 REAL(kind=
dp),
INTENT(IN) :: rcov
849 INTEGER,
INTENT(IN) :: l
854 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dorb
856 m =
SIZE(basis%bf, 1)
862 dorb(1:m) = dorb(1:m) + ff*basis%dbf(1:m, i, l)
866 IF (basis%grid%rad(i) < 2*rcov)
THEN
867 IF (dorb(i)*dorb(i + 1) < 0._dp)
THEN
868 rmax = max(rmax, basis%grid%rad(i))
885 INTEGER,
INTENT(OUT) :: node
886 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
887 REAL(kind=
dp),
INTENT(IN) :: rcov
888 INTEGER,
INTENT(IN) :: l
893 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: orb
896 m =
SIZE(basis%bf, 1)
902 orb(1:m) = orb(1:m) + ff*basis%bf(1:m, i, l)
905 IF (basis%grid%rad(i) < rcov)
THEN
906 IF (orb(i)*orb(i + 1) < 0._dp) node = node + 1
920 REAL(kind=
dp),
INTENT(OUT) ::
value
921 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
927 m = maxval(minloc(basis%grid%rad))
930 value =
value + wfn(i)*basis%bf(m, i, 0)
947 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: hmat, umat
948 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: orb
949 REAL(kind=
dp),
DIMENSION(:, 0:),
INTENT(INOUT) :: ener
950 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nb, nv
951 INTEGER,
INTENT(IN) :: maxl
953 INTEGER :: info, l, lwork, m, n
954 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: w, work
955 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a
957 cpassert(all(nb >= nv))
963 IF (n > 0 .AND. m > 0)
THEN
965 ALLOCATE (a(n, n), w(n), work(lwork))
966 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)))
967 CALL dsyev(
"V",
"U", m, a(1:m, 1:m), m, w(1:m), work, lwork, info)
968 a(1:n, 1:m) = matmul(umat(1:n, 1:m, l), a(1:m, 1:m))
970 m = min(m,
SIZE(orb, 2))
971 orb(1:n, 1:m, l) = a(1:n, 1:m)
972 ener(1:m, l) = w(1:m)
974 DEALLOCATE (a, w, work)
986 FUNCTION prune_grid(fun, deps)
RESULT(nc)
987 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun
988 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: deps
992 REAL(kind=
dp) :: meps
995 IF (
PRESENT(deps)) meps = deps
1000 IF (abs(fun(i)) > meps)
THEN
1006 END FUNCTION prune_grid
1016 PURE FUNCTION integrate_grid_function1(fun, grid)
RESULT(integral)
1017 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun
1019 REAL(kind=
dp) :: integral
1024 integral = sum(fun(1:nc)*grid%wr(1:nc))
1026 END FUNCTION integrate_grid_function1
1037 PURE FUNCTION integrate_grid_function2(fun1, fun2, grid)
RESULT(integral)
1038 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun1, fun2
1040 REAL(kind=
dp) :: integral
1044 nc = min(
SIZE(fun1),
SIZE(fun2))
1045 integral = sum(fun1(1:nc)*fun2(1:nc)*grid%wr(1:nc))
1047 END FUNCTION integrate_grid_function2
1059 PURE FUNCTION integrate_grid_function3(fun1, fun2, fun3, grid)
RESULT(integral)
1060 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun1, fun2, fun3
1062 REAL(kind=
dp) :: integral
1066 nc = min(
SIZE(fun1),
SIZE(fun2),
SIZE(fun3))
1067 integral = sum(fun1(1:nc)*fun2(1:nc)*fun3(1:nc)*grid%wr(1:nc))
1069 END FUNCTION integrate_grid_function3
1080 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: cpot
1081 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1085 REAL(
dp) :: int1, int2
1086 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1088 nc = min(
SIZE(cpot),
SIZE(density))
1094 cpot(nc:) = int1/r(nc:)
1098 cpassert(r(1) > r(nc))
1100 cpot(i) = int1/r(i) + int2
1101 int1 = int1 -
fourpi*density(i)*wr(i)
1102 int2 = int2 +
fourpi*density(i)*wr(i)/r(i)
1118 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: cpot
1119 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1122 INTEGER,
INTENT(IN) :: maxl
1124 INTEGER :: i, j, k, l, m, n
1125 REAL(kind=
dp) :: a, b, ff, oab, sab
1126 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: erfa, expa, z
1127 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: unp
1130 ALLOCATE (erfa(1:m), expa(1:m), z(1:m))
1135 IF (maxval(abs(pmat(:, :, l))) < 1.e-14_dp) cycle
1136 SELECT CASE (basis%basis_type)
1138 cpabort(
"Unknown basis type for coulomb_potential_analytic")
1140 DO i = 1, basis%nbas(l)
1141 DO j = i, basis%nbas(l)
1142 IF (abs(pmat(i, j, l)) < 1.e-14_dp) cycle
1144 IF (i /= j) ff = 2._dp*ff
1148 oab =
rootpi/(a + b)**(l + 1.5_dp)*ff
1149 z(:) = sab*grid%rad(:)
1150 DO k = 1,
SIZE(erfa)
1151 erfa(k) = oab*erf(z(k))/grid%rad(k)
1153 expa(:) = exp(-z(:)**2)*ff/(a + b)**(l + 1)
1156 cpot(:) = cpot(:) + 0.25_dp*erfa(:)
1158 cpot(:) = cpot(:) + 0.375_dp*erfa(:) - 0.25_dp*expa(:)
1160 cpot(:) = cpot(:) + 0.9375_dp*erfa(:) - expa(:)*(0.875_dp + 0.25_dp*z(:)**2)
1162 cpot(:) = cpot(:) + 3.28125_dp*erfa(:) - expa(:)*(3.5625_dp + 1.375_dp*z(:)**2 + 0.25*z(:)**4)
1164 cpabort(
"Invalid l number for GTO specified. Check the code!")
1171 ALLOCATE (unp(n, n))
1173 unp(1:n, 1:n) = matmul(matmul(basis%cm(1:n, 1:m, l), pmat(1:m, 1:m, l)), &
1174 transpose(basis%cm(1:n, 1:m, l)))
1175 DO i = 1, basis%nprim(l)
1176 DO j = i, basis%nprim(l)
1177 IF (abs(unp(i, j)) < 1.e-14_dp) cycle
1179 IF (i /= j) ff = 2._dp*ff
1183 oab =
rootpi/(a + b)**(l + 1.5_dp)*ff
1184 z(:) = sab*grid%rad(:)
1185 DO k = 1,
SIZE(erfa)
1186 erfa(k) = oab*erf(z(k))/grid%rad(k)
1188 expa(:) = exp(-z(:)**2)*ff/(a + b)**(l + 1)
1191 cpot(:) = cpot(:) + 0.25_dp*erfa(:)
1193 cpot(:) = cpot(:) + 0.375_dp*erfa(:) - 0.25_dp*expa(:)
1195 cpot(:) = cpot(:) + 0.9375_dp*erfa(:) - expa(:)*(0.875_dp + 0.25_dp*z(:)**2)
1197 cpot(:) = cpot(:) + 3.28125_dp*erfa(:) - expa(:)*(3.5625_dp + 1.375_dp*z(:)**2 + 0.25*z(:)**4)
1199 cpabort(
"Invalid l number for CGTO specified. Check the code!")
1207 DEALLOCATE (erfa, expa, z)
1223 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1225 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
1226 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: wfn
1230 INTEGER :: i, ia, ib, k, lad, lbc, lh, ll, nbas, &
1232 REAL(kind=
dp) :: almn
1233 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, nai, nbi, pot
1234 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: orb
1235 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1240 arho(ll) =
fac(ll)/
fac(lh)**2
1246 ALLOCATE (nai(nr), nbi(nr), cpot(nr), pot(nr))
1248 DO lad = 0, state%maxl_calc
1249 DO lbc = 0, state%maxl_occ
1250 norb = state%maxn_occ(lbc)
1251 nbas = basis%nbas(lbc)
1253 ALLOCATE (orb(nr, norb))
1257 orb(:, i) = orb(:, i) + wfn(k, i, lbc)*basis%bf(:, k, lbc)
1260 DO nu = abs(lad - lbc), lad + lbc, 2
1261 almn = arho(-lad + lbc + nu)*arho(lad - lbc + nu)*arho(lad + lbc - nu)/(real(lad + lbc + nu + 1,
dp) &
1262 *arho(lad + lbc + nu))
1265 DO ia = 1, basis%nbas(lad)
1267 nai(:) = orb(:, i)*basis%bf(:, ia, lad)
1269 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1270 CALL potential_coulomb_numeric(pot, nai, nu, basis%grid)
1271 cpot(:) = cpot(:) + pot(:)*hfx_pot%scale_coulomb
1273 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1274 IF (hfx_pot%do_gh)
THEN
1275 CALL potential_longrange_numeric_gh(pot, nai, nu, basis%grid, hfx_pot%omega, &
1276 hfx_pot%kernel(:, :, nu))
1278 CALL potential_longrange_numeric(pot, nai, nu, basis%grid, hfx_pot%omega, &
1279 hfx_pot%kernel(:, :, nu))
1281 cpot(:) = cpot(:) + pot(:)*hfx_pot%scale_longrange
1283 DO ib = 1, basis%nbas(lad)
1284 kmat(ia, ib, lad) = kmat(ia, ib, lad) + almn*occ(lbc, i)* &
1285 integrate_grid(cpot, orb(:, i), basis%bf(:, ib, lad), basis%grid)
1295 DEALLOCATE (nai, nbi, cpot)
1311 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1313 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
1314 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: wfn
1318 INTEGER :: i, ia, ib, k, lad, lbc, lh, ll, nbas, &
1320 REAL(kind=
dp) :: almn
1321 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, nai, nbi
1322 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: orb
1323 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: pot
1324 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1329 arho(ll) =
fac(ll)/
fac(lh)**2
1335 nbas = maxval(basis%nbas)
1336 ALLOCATE (pot(nr, nbas, nbas))
1337 ALLOCATE (nai(nr), nbi(nr), cpot(nr))
1339 DO lad = 0, state%maxl_calc
1340 DO lbc = 0, state%maxl_occ
1341 norb = state%maxn_occ(lbc)
1342 nbas = basis%nbas(lbc)
1344 ALLOCATE (orb(nr, norb))
1348 orb(:, i) = orb(:, i) + wfn(k, i, lbc)*basis%bf(:, k, lbc)
1351 DO nu = abs(lad - lbc), lad + lbc, 2
1352 almn = arho(-lad + lbc + nu)*arho(lad - lbc + nu) &
1353 *arho(lad + lbc - nu)/(real(lad + lbc + nu + 1,
dp)*arho(lad + lbc + nu))
1357 CALL potential_analytic(pot, lad, lbc, nu, basis, hfx_pot)
1358 DO ia = 1, basis%nbas(lad)
1362 cpot(:) = cpot(:) + pot(:, ia, k)*wfn(k, i, lbc)
1364 DO ib = 1, basis%nbas(lad)
1365 kmat(ia, ib, lad) = kmat(ia, ib, lad) + almn*occ(lbc, i)* &
1366 integrate_grid(cpot, orb(:, i), basis%bf(:, ib, lad), basis%grid)
1376 DEALLOCATE (nai, nbi, cpot)
1390 SUBROUTINE potential_coulomb_numeric(cpot, density, nu, grid)
1391 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1392 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1393 INTEGER,
INTENT(IN) :: nu
1397 REAL(
dp) :: int1, int2
1398 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1400 nc = min(
SIZE(cpot),
SIZE(density))
1406 cpot(nc:) = int1/r(nc:)**(nu + 1)
1409 cpassert(r(1) > r(nc))
1411 cpot(i) = int1/r(i)**(nu + 1) + int2*r(i)**nu
1412 int1 = int1 - r(i)**(nu)*density(i)*wr(i)
1413 int2 = int2 + density(i)*wr(i)/r(i)**(nu + 1)
1416 END SUBROUTINE potential_coulomb_numeric
1427 SUBROUTINE potential_longrange_numeric(cpot, density, nu, grid, omega, kernel)
1428 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1429 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1430 INTEGER,
INTENT(IN) :: nu
1432 REAL(kind=
dp),
INTENT(IN) :: omega
1433 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: kernel
1436 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1437 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work_inp, work_out
1439 nc = min(
SIZE(cpot),
SIZE(density))
1443 ALLOCATE (work_inp(nc), work_out(nc))
1448 work_inp(:nc) = density(:nc)*wr(:nc)
1449 CALL dsymv(
'U', nc, 1.0_dp, kernel, nc, work_inp, 1, 0.0_dp, work_out, 1)
1452 work_inp(:nc) = work_out(:nc)*exp(-r(:nc)**2)/r(:nc)**2*wr(:nc)
1453 CALL dsymv(
'U', nc, 1.0_dp, kernel, nc, work_inp, 1, 0.0_dp, work_out, 1)
1455 cpot(:nc) = work_out(:nc)*(2.0_dp*real(nu,
dp) + 1.0_dp)*4.0_dp/
pi*omega
1457 END SUBROUTINE potential_longrange_numeric
1468 SUBROUTINE potential_longrange_numeric_gh(cpot, density, nu, grid, omega, kernel)
1469 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1470 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1471 INTEGER,
INTENT(IN) :: nu
1473 REAL(kind=
dp),
INTENT(IN) :: omega
1474 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: kernel
1476 INTEGER :: n_max, nc, nc_kernel, nr_kernel
1477 REAL(
dp),
DIMENSION(:),
POINTER :: wr
1478 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work_inp, work_out
1480 nc = min(
SIZE(cpot),
SIZE(density))
1483 nc_kernel =
SIZE(kernel, 1)
1484 nr_kernel =
SIZE(kernel, 2)
1485 n_max = max(nc, nc_kernel, nr_kernel)
1487 ALLOCATE (work_inp(n_max), work_out(n_max))
1492 work_inp(:nc) = density(:nc)*wr(:nc)
1493 CALL dgemv(
'T', nc_kernel, nr_kernel, 1.0_dp, kernel, nc_kernel, work_inp, 1, 0.0_dp, work_out, 1)
1496 work_inp(:nr_kernel) = work_out(:nr_kernel)
1497 CALL dgemv(
'N', nc_kernel, nr_kernel, 1.0_dp, kernel, nc_kernel, work_inp, 1, 0.0_dp, work_out, 1)
1499 cpot(:nc) = work_out(:nc)*(2.0_dp*real(nu,
dp) + 1.0_dp)*4.0_dp/
pi*omega
1501 END SUBROUTINE potential_longrange_numeric_gh
1516 SUBROUTINE potential_analytic(cpot, la, lb, nu, basis, hfx_pot)
1517 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(OUT) :: cpot
1518 INTEGER,
INTENT(IN) :: la, lb, nu
1522 INTEGER :: i, j, k, l, ll, m
1523 REAL(kind=
dp) :: a, b
1524 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: erfa, pot
1527 ALLOCATE (erfa(1:m))
1533 SELECT CASE (basis%basis_type)
1535 cpabort(
"Unknown basis type for potential_analytic")
1537 DO i = 1, basis%nbas(la)
1538 DO j = 1, basis%nbas(lb)
1542 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1543 CALL potential_coulomb_analytic(erfa, a, b, ll, nu, basis%grid%rad)
1545 cpot(:, i, j) = cpot(:, i, j) + erfa(:)*hfx_pot%scale_coulomb
1548 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1549 CALL potential_longrange_analytic(erfa, a, b, ll, nu, basis%grid%rad, hfx_pot%omega)
1551 cpot(:, i, j) = cpot(:, i, j) + erfa(:)*hfx_pot%scale_longrange
1558 DO i = 1, basis%nprim(la)
1559 DO j = 1, basis%nprim(lb)
1565 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1566 CALL potential_coulomb_analytic(erfa, a, b, ll, nu, basis%grid%rad)
1568 pot(:) = pot(:) + erfa(:)*hfx_pot%scale_coulomb
1571 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1572 CALL potential_longrange_analytic(erfa, a, b, ll, nu, basis%grid%rad, hfx_pot%omega)
1574 pot(:) = pot(:) + erfa(:)*hfx_pot%scale_longrange
1577 DO k = 1, basis%nbas(la)
1578 DO l = 1, basis%nbas(lb)
1579 cpot(:, k, l) = cpot(:, k, l) + pot(:)*basis%cm(i, k, la)*basis%cm(j, l, lb)
1589 END SUBROUTINE potential_analytic
1600 SUBROUTINE potential_coulomb_analytic(erfa, a, b, ll, nu, rad)
1601 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: erfa
1602 REAL(kind=
dp),
INTENT(IN) :: a, b
1603 INTEGER,
INTENT(IN) :: ll, nu
1604 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rad
1607 REAL(kind=
dp) :: oab, sab
1608 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: expa, z
1611 ALLOCATE (expa(nr), z(nr))
1614 oab =
dfac(ll + nu + 1)*
rootpi/sab**(ll + 2)/2._dp**((ll + nu)/2 + 2)
1616 erfa(:) = oab*erf(z(:))/z(:)**(nu + 1)
1617 expa(:) = exp(-z(:)**2)/sab**(ll + 2)/2._dp**((ll + nu)/2 + 2)
1620 CALL cp_abort(__location__, &
1621 "Only 0, 1, 2, 3, 4, 5, 6 are supported as the value of ll")
1626 erfa(:) = erfa(:) - 6._dp*expa(:)/z(:)
1630 CALL cp_abort(__location__, &
1631 "Only 0, 2 are supported as the value of nu when ll = 2")
1633 erfa(:) = erfa(:) - 2._dp*expa(:)
1635 erfa(:) = erfa(:) - expa(:)*(20._dp + 30._dp/z(:)**2)
1640 CALL cp_abort(__location__, &
1641 "Only 1, 3 are supported as the value of nu when ll = 3")
1643 erfa(:) = erfa(:) - expa(:)*(12._dp*z(:) + 30._dp/z(:))
1645 erfa(:) = erfa(:) - expa(:)*(56._dp*z(:) + 140._dp/z(:) + 210._dp/z(:)**3)
1650 CALL cp_abort(__location__, &
1651 "Only 0, 2, 4 are supported as the value of nu when ll = 4")
1653 erfa(:) = erfa(:) - expa(:)*(4._dp*z(:)**2 + 14._dp)
1655 erfa(:) = erfa(:) - expa(:)*(40._dp*z(:)**2 + 140._dp + 210._dp/z(:)**2)
1657 erfa(:) = erfa(:) - expa(:)*(144._dp*z(:)**2 + 504._dp + 1260._dp/z(:)**2 + 1890._dp/z(:)**4)
1662 CALL cp_abort(__location__, &
1663 "Only 1, 3, 5 are supported as the value of nu when ll = 5")
1665 erfa(:) = erfa(:) - expa(:)*(24._dp*z(:)**3 + 108._dp*z(:) + 210._dp/z(:))
1667 erfa(:) = erfa(:) - expa(:)*(112._dp*z(:)**3 + 504._dp*z(:) + 1260._dp/z(:) + 1890._dp/z(:)**3)
1669 erfa(:) = erfa(:) - expa(:)*(352._dp*z(:)**3 + 1584._dp*z(:) + 5544._dp/z(:) + &
1670 13860._dp/z(:)**3 + 20790._dp/z(:)**5)
1675 CALL cp_abort(__location__, &
1676 "Only 0, 2, 4, 6 are supported as the value of nu when ll = 6")
1678 erfa(:) = erfa(:) - expa(:)*(8._dp*z(:)**4 + 44._dp*z(:)**2 + 114._dp)
1680 erfa(:) = erfa(:) - expa(:)*(80._dp*z(:)**4 + 440._dp*z(:)**2 + 1260._dp + 1896._dp/z(:)**2)
1682 erfa(:) = erfa(:) - expa(:)*(288._dp*z(:)**4 + 1584._dp*z(:)**2 + 5544._dp + &
1683 13860._dp/z(:)**2 + 20790._dp/z(:)**4)
1685 erfa(:) = erfa(:) - expa(:)*(832._dp*z(:)**4 + 4576._dp*z(:)**2 + 20592._dp + &
1686 72072._dp/z(:)**2 + 180180._dp/z(:)**4 + 270270._dp/z(:)**6)
1690 DEALLOCATE (expa, z)
1692 END SUBROUTINE potential_coulomb_analytic
1704 PURE SUBROUTINE potential_longrange_analytic(erfa, a, b, ll, nu, rad, omega)
1705 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: erfa
1706 REAL(kind=
dp),
INTENT(IN) :: a, b
1707 INTEGER,
INTENT(IN) :: ll, nu
1708 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rad
1709 REAL(kind=
dp),
INTENT(IN) :: omega
1711 INTEGER :: i, lambda, nr
1712 REAL(kind=
dp) :: ab, oab, pab, prel, sab
1713 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: expa, z
1715 IF (mod(ll - nu, 2) == 0 .AND. ll >= nu .AND. nu >= 0)
THEN
1717 ALLOCATE (expa(nr), z(nr))
1719 lambda = (ll - nu)/2
1722 pab = omega**2*ab/(omega**2 + ab)
1724 z(:) = sqrt(pab)*rad(:)
1725 oab =
fac(lambda)/sqrt(ab)**(ll + 2)/4.0_dp*sqrt(prel)**(nu + 1)*(2.0_dp*real(nu, kind=
dp) + 1.0_dp)
1726 expa(:) = exp(-z(:)**2)
1727 lambda = (ll - nu)/2
1729 IF (lambda > 0)
THEN
1732 erfa = erfa + (-prel)**i/real(i, kind=
dp)*
binomial_gen(lambda + nu + 0.5_dp, lambda - i)* &
1733 assoc_laguerre(z, real(nu, kind=
dp) + 0.5_dp, i - 1)
1735 erfa = erfa*expa*z**nu
1737 erfa = erfa + 2.0_dp*
binomial_gen(lambda + nu + 0.5_dp, lambda)*znfn(z, expa, nu)
1739 erfa = 2.0_dp*znfn(z, expa, nu)
1744 DEALLOCATE (expa, z)
1750 END SUBROUTINE potential_longrange_analytic
1759 ELEMENTAL FUNCTION znfn(z, expa, n)
RESULT(res)
1761 REAL(kind=
dp),
INTENT(IN) :: z, expa
1762 INTEGER,
INTENT(IN) :: n
1763 REAL(kind=
dp) :: res
1766 REAL(kind=
dp) :: z_exp
1769 IF (abs(z) < 1.0e-20)
THEN
1770 res = z**n/(2.0_dp*real(n, kind=
dp) + 1.0_dp)
1771 ELSE IF (n == 0)
THEN
1772 res =
rootpi/2.0_dp*erf(z)/z
1774 res =
rootpi/4.0_dp*erf(z)/z**2 - expa/z/2.0_dp
1775 z_exp = -expa*0.5_dp
1778 res = (real(i, kind=
dp) - 0.5_dp)*res/z + z_exp
1795 ELEMENTAL FUNCTION assoc_laguerre(z, a, n)
RESULT(res)
1797 REAL(kind=
dp),
INTENT(IN) :: z, a
1798 INTEGER,
INTENT(IN) :: n
1799 REAL(kind=
dp) :: res
1802 REAL(kind=
dp) :: f0, f1
1806 ELSE IF (n == 1)
THEN
1807 res = a + 1.0_dp - z
1808 ELSE IF (n > 0)
THEN
1813 res = (2.0_dp + (a - 1.0_dp - z)/real(i,
dp))*f1 - (1.0_dp + (a - 1.0_dp)/real(i,
dp))*f0
1821 END FUNCTION assoc_laguerre
1832 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: opmat, pmat
1833 REAL(kind=
dp) :: trace
1849 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: imat
1850 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: cpot
1852 INTEGER,
INTENT(IN) :: derivatives
1854 INTEGER :: i, j, l, n
1856 SELECT CASE (derivatives)
1862 imat(i, j, l) = imat(i, j, l) + &
1863 integrate_grid(cpot, basis%bf(:, i, l), basis%bf(:, j, l), basis%grid)
1864 imat(j, i, l) = imat(i, j, l)
1873 imat(i, j, l) = imat(i, j, l) + &
1874 integrate_grid(cpot, basis%dbf(:, i, l), basis%bf(:, j, l), basis%grid)
1875 imat(i, j, l) = imat(i, j, l) + &
1876 integrate_grid(cpot, basis%bf(:, i, l), basis%dbf(:, j, l), basis%grid)
1877 imat(j, i, l) = imat(i, j, l)
1886 imat(i, j, l) = imat(i, j, l) + &
1887 integrate_grid(cpot, basis%dbf(:, i, l), basis%dbf(:, j, l), basis%grid)
1888 imat(j, i, l) = imat(i, j, l)
1893 cpabort(
"Only 0, 1, 2 are supported as the value of derivatives")
1909 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: jmat
1910 TYPE(
eri),
DIMENSION(:),
INTENT(IN) :: erint
1911 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1912 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nsize
1913 LOGICAL,
INTENT(IN),
OPTIONAL :: all_nu
1915 INTEGER :: i1, i2, ij1, ij2, j1, j2, l1, l2, ll, &
1917 LOGICAL :: have_all_nu
1918 REAL(kind=
dp) :: eint, f1, f2
1920 IF (
PRESENT(all_nu))
THEN
1921 have_all_nu = all_nu
1923 have_all_nu = .false.
1926 jmat(:, :, :) = 0._dp
1938 IF (i1 /= j1) f1 = 2._dp
1944 IF (i2 /= j2) f2 = 2._dp
1945 eint = erint(ll)%int(ij1, ij2)
1947 jmat(i1, j1, l1) = jmat(i1, j1, l1) + f2*pmat(i2, j2, l2)*eint
1949 jmat(i1, j1, l1) = jmat(i1, j1, l1) + f2*pmat(i2, j2, l2)*eint
1950 jmat(i2, j2, l2) = jmat(i2, j2, l2) + f1*pmat(i1, j1, l1)*eint
1956 IF (have_all_nu)
THEN
1966 jmat(j1, i1, l1) = jmat(i1, j1, l1)
1983 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1984 TYPE(
eri),
DIMENSION(:),
INTENT(IN) :: erint
1985 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1986 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nsize
1988 INTEGER :: i1, i2, ij1, ij2, j1, j2, l1, l2, lh, &
1990 REAL(kind=
dp) :: almn, eint, f1, f2
1991 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1996 arho(ll) =
fac(ll)/
fac(lh)**2
1999 kmat(:, :, :) = 0._dp
2005 DO nu = abs(l1 - l2), l1 + l2, 2
2006 almn = arho(-l1 + l2 + nu)*arho(l1 - l2 + nu)*arho(l1 + l2 - nu)/(real(l1 + l2 + nu + 1,
dp)*arho(l1 + l2 + nu))
2014 IF (i1 /= j1) f1 = 2._dp
2020 IF (i2 /= j2) f2 = 2._dp
2021 eint = erint(ll)%int(ij1, ij2)
2023 kmat(i1, j1, l1) = kmat(i1, j1, l1) + f2*almn*pmat(i2, j2, l2)*eint
2025 kmat(i1, j1, l1) = kmat(i1, j1, l1) + f2*almn*pmat(i2, j2, l2)*eint
2026 kmat(i2, j2, l2) = kmat(i2, j2, l2) + f1*almn*pmat(i1, j1, l1)*eint
2039 kmat(j1, i1, l1) = kmat(i1, j1, l1)
2059 PURE SUBROUTINE err_matrix(emat, demax, kmat, pmat, umat, upmat, nval, nbs)
2060 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(OUT) :: emat
2061 REAL(kind=
dp),
INTENT(OUT) :: demax
2062 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: kmat, pmat, umat, upmat
2063 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nval, nbs
2066 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: tkmat, tpmat
2073 ALLOCATE (tkmat(1:m, 1:m), tpmat(1:m, 1:m))
2076 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)))
2077 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)))
2078 tpmat(1:m, 1:m) = matmul(upmat(1:m, 1:m, l), matmul(tpmat(1:m, 1:m), upmat(1:m, 1:m, l)))
2080 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))
2082 DEALLOCATE (tkmat, tpmat)
2085 demax = maxval(abs(emat))
2103 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density1, density2
2104 INTEGER,
INTENT(IN) :: zcore
2108 INTEGER :: counter, i, l, mc, mm(0:
lmat), mo, n, ns
2109 INTEGER,
DIMENSION(lmat+1, 20) :: ne
2110 REAL(kind=
dp) :: a, pf
2118 mo = state%maxn_occ(l)
2119 IF (sum(state%core(l, :)) == 0)
THEN
2120 cpassert(ns >= l + mo)
2122 ne(l + 1, l + counter) = nint(state%occ(l, counter))
2126 cpassert(sum(state%occ(l, 1:mc)) == 0)
2127 cpassert(ns >= l + mc)
2129 ne(l + 1, l + counter) = nint(state%core(l, counter))
2131 cpassert(ns >= l + mc + mo)
2132 DO counter = mc + 1, mc + mo
2133 ne(l + 1, l + counter) = nint(state%occ(l, counter))
2140 DO l = 0, state%maxl_occ
2141 DO i = 1,
SIZE(state%occ, 2)
2142 IF (state%occ(l, i) > 0._dp)
THEN
2144 a =
srules(zcore, ne, n, l)
2145 pf = 1._dp/sqrt(
fac(2*n))*(2._dp*a)**(n + 0.5_dp)
2146 IF (state%multiplicity == -1)
THEN
2147 density1(:) = density1(:) + state%occ(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2149 density1(:) = density1(:) + state%occa(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2150 density2(:) = density2(:) + state%occb(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2168 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rho
2169 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: vxc
2172 REAL(kind=
dp) :: ec, ex, rs, vc, vx
2176 IF (rho(i) > 1.e-20_dp)
THEN
2178 ex = -0.7385588_dp*rho(i)**0.333333333_dp
2179 vx = 1.333333333_dp*ex
2180 rs = (3._dp/
fourpi/rho(i))**0.333333333_dp
2181 ec = -0.88_dp/(rs + 7.8_dp)
2182 vc = ec*(1._dp + rs/(3._dp*(rs + 7.8_dp)))
2198 INTEGER,
INTENT(IN) :: method, multiplicity
2199 LOGICAL :: consistent
2203 SELECT CASE (method)
2205 consistent = .false.
2207 consistent = (multiplicity == -1)
2209 consistent = (multiplicity /= -1)
2211 consistent = (multiplicity == -1)
2213 consistent = (multiplicity /= -1)
2215 consistent = .false.
2229 REAL(kind=
dp),
INTENT(OUT) :: rho0
2231 INTEGER :: m0, m1, m2, method, nr
2232 LOGICAL :: nlcc, spinpol
2233 REAL(kind=
dp) :: d0, d1, d2, r0, r1, r2, w0, w1
2234 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: xfun
2235 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rho
2237 method =
atom%method_type
2238 SELECT CASE (method)
2244 cpabort(
"ROHF not yet implemented for get_rho0")
2246 cpabort(
"Unknown method for get_rho0")
2249 nr =
atom%basis%grid%nr
2252 nlcc =
atom%potential%gth_pot%nlcc
2254 nlcc =
atom%potential%upf_pot%core_correction
2256 nlcc =
atom%potential%sgp_pot%has_nlcc
2262 m0 = maxval(minloc(
atom%basis%grid%rad))
2266 ELSE IF (m0 == 1)
THEN
2270 cpabort(
"GRID Definition incompatible")
2272 r0 =
atom%basis%grid%rad(m0)
2273 r1 =
atom%basis%grid%rad(m1)
2274 r2 =
atom%basis%grid%rad(m2)
2279 ALLOCATE (rho(nr, 2))
2285 rho(:, 1) = rho(:, 1) + 0.5_dp*xfun(:)
2286 rho(:, 2) = rho(:, 2) + 0.5_dp*xfun(:)
2288 rho(:, 1) = rho(:, 1) + rho(:, 2)
2290 ALLOCATE (rho(nr, 1))
2300 rho0 = w0*d0 + w1*d1
2301 rho0 = max(rho0, 0.0_dp)
2320 REAL(kind=
dp) :: crad
2321 INTEGER,
INTENT(IN) :: iw
2325 REAL(kind=
dp),
DIMENSION(10) :: cnum, rad
2327 WRITE (iw,
'(/,A,F8.4)')
" Basis Set Condition Numbers: 2*covalent radius=", 2*crad
2332 ci = 2.0_dp*(0.85_dp + i*0.05_dp)
2335 WRITE (iw,
'(A,F15.3,T50,A,F14.4)')
" Lattice constant:", &
2336 rad(i),
"Condition number:", cnum(i)
2340 WRITE (iw,
'(A,A,T50,A,F14.4)')
" Lattice constant:", &
2341 " Inf",
"Condition number:", cnum(i)
2355 INTEGER,
INTENT(IN) :: zv, iw
2357 INTEGER :: i, j, l, ll, m, n, nbas, nl, nr
2358 INTEGER,
DIMENSION(0:lmat) ::
nelem, nlmax, nlmin
2359 INTEGER,
DIMENSION(lmat+1, 7) :: ne
2360 REAL(kind=
dp) :: al, c1, c2, pf
2361 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sfun
2362 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: bmat
2363 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: omat
2364 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: sint
2365 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: snl
2366 REAL(kind=
dp),
DIMENSION(2) :: sse
2367 REAL(kind=
dp),
DIMENSION(lmat+1, 7) :: sexp
2375 IF (
nelem(l) >= ll)
THEN
2378 ELSE IF (
nelem(l) > 0)
THEN
2379 ne(l + 1, i) =
nelem(l)
2392 IF (ne(l + 1, i) > 0)
THEN
2396 nlmax(l) = max(nlmax(l), nlmin(l) + 1)
2405 sexp(l + 1, i) =
srules(zv, ne, i, l)
2406 IF (ne(l + 1, i - l) > 0)
THEN
2407 sse(1) = max(sse(1), sexp(l + 1, i))
2408 sse(2) = min(sse(2), sexp(l + 1, i))
2412 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))
2416 nbas = maxval(basis%nbas)
2417 ALLOCATE (omat(nbas, nbas, 0:
lmat))
2418 nr =
SIZE(basis%bf, 1)
2419 ALLOCATE (sfun(nr), sint(10, 2, nbas, 0:
lmat))
2427 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
2428 sfun(1:nr) = pf*basis%grid%rad(1:nr)**(nl - 1)*exp(-al*basis%grid%rad(1:nr))
2429 DO j = 1, basis%nbas(l)
2430 sint(i, 1, j, l) = sum(sfun(1:nr)*basis%bf(1:nr, j, l)*basis%grid%wr(1:nr))
2433 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
2434 sfun(1:nr) = pf*basis%grid%rad(1:nr)**(nl - 1)*exp(-al*basis%grid%rad(1:nr))
2435 DO j = 1, basis%nbas(l)
2436 sint(i, 2, j, l) = sum(sfun(1:nr)*basis%bf(1:nr, j, l)*basis%grid%wr(1:nr))
2445 SELECT CASE (basis%basis_type)
2447 cpabort(
"Unknown basis type for atom_completeness")
2449 CALL sg_overlap(omat(1:n, 1:n, l), l, basis%am(1:n, l), basis%am(1:n, l))
2451 ALLOCATE (bmat(m, m))
2452 CALL sg_overlap(bmat(1:m, 1:m), l, basis%am(1:m, l), basis%am(1:m, l))
2453 CALL contract2(omat(1:n, 1:n, l), bmat(1:m, 1:m), basis%cm(1:m, 1:n, l))
2456 CALL sto_overlap(omat(1:n, 1:n, l), basis%ns(1:n, l), basis%as(1:n, l), &
2457 basis%ns(1:n, l), basis%as(1:n, l))
2459 cpabort(
"Numerical basis not yet implemented for atom_completeness")
2464 WRITE (iw,
'(/,A)')
" Basis Set Completeness Estimates"
2468 WRITE (iw,
'(A,I3)')
" L-quantum number: ", l
2469 WRITE (iw,
'(A,T31,A,I2,T61,A,I2)')
" Slater Exponent",
"Completeness n-qm=", nlmin(l), &
2470 "Completeness n-qm=", nlmax(l)
2472 c1 = dot_product(sint(i, 1, 1:n, l), matmul(omat(1:n, 1:n, l), sint(i, 1, 1:n, l)))
2473 c2 = dot_product(sint(i, 2, 1:n, l), matmul(omat(1:n, 1:n, l), sint(i, 2, 1:n, l)))
2474 WRITE (iw,
"(T6,F14.6,T41,F10.6,T71,F10.6)") snl(l, i), c1, c2
2478 DEALLOCATE (omat, sfun, sint)
2490 REAL(kind=
dp),
INTENT(IN) :: rad
2491 REAL(kind=
dp),
INTENT(OUT) :: cnum
2493 INTEGER :: ia, ib,
imax, info, ix, iy, iz, ja, jb, &
2494 ka, kb, l, la, lb, lwork, na, nb, &
2496 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: ibptr
2497 REAL(kind=
dp) :: r1, r2, reps, rmax
2498 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: weig, work
2499 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat
2500 REAL(kind=
dp),
DIMENSION(2*lmat+1, 2*lmat+1) :: sab
2501 REAL(kind=
dp),
DIMENSION(3) :: rab
2502 REAL(kind=
dp),
DIMENSION(:),
POINTER :: zeta, zetb
2509 nbas = nbas + basis%nbas(l)*(2*l + 1)
2512 ALLOCATE (smat(nbas, nbas), ibptr(nbas, 0:
lmat))
2517 DO ia = 1, basis%nbas(l)
2518 ibptr(ia, l) = na + 1
2524 IF (basis%basis_type ==
gto_basis .OR. &
2527 na = basis%nprim(la)
2530 zeta => basis%am(:, la)
2532 nb = basis%nprim(lb)
2535 zetb => basis%am(:, lb)
2538 IF (rad < 0.1_dp)
THEN
2543 rmax = max(2._dp*r1, 2._dp*r2)
2544 imax = int(rmax/rad) + 1
2551 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) + sab(1:nna, 1:nnb)
2553 DO ka = 1, basis%nbas(la)
2554 DO kb = 1, basis%nbas(lb)
2557 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) + &
2558 sab(1:nna, 1:nnb)*basis%cm(ia, ka, la)*basis%cm(ib, kb, lb)
2569 CALL overlap_ab_s(la, zeta(ia), lb, zetb(ib), rab, sab)
2573 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) &
2576 DO ka = 1, basis%nbas(la)
2577 DO kb = 1, basis%nbas(lb)
2580 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = &
2581 smat(ja:ja + nna - 1, jb:jb + nnb - 1) + &
2582 sab(1:nna, 1:nnb)*basis%cm(ia, ka, la)*basis%cm(ib, kb, lb)
2595 cpabort(
"Condition number not available for this basis type")
2599 lwork = max(nbas*nbas, nbas + 100)
2600 ALLOCATE (weig(nbas), work(lwork))
2602 CALL dsyev(
"N",
"U", nbas, smat, nbas, weig, work, lwork, info)
2604 IF (weig(1) < 0.0_dp)
THEN
2607 cnum = abs(weig(nbas)/weig(1))
2611 DEALLOCATE (smat, ibptr, weig, work)
2622 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: int
2623 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm
2625 CHARACTER(len=*),
PARAMETER :: routinen =
'contract2'
2627 INTEGER :: handle, m, n
2629 CALL timeset(routinen, handle)
2634 int(1:n, 1:n) = matmul(transpose(cm(1:m, 1:n)), matmul(omat(1:m, 1:m), cm(1:m, 1:n)))
2636 CALL timestop(handle)
2648 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: int
2649 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm
2651 CHARACTER(len=*),
PARAMETER :: routinen =
'contract2add'
2653 INTEGER :: handle, m, n
2655 CALL timeset(routinen, handle)
2660 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)))
2662 CALL timestop(handle)
2674 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) ::
eri
2675 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm1, cm2
2677 CHARACTER(len=*),
PARAMETER :: routinen =
'contract4'
2679 INTEGER :: handle, i1, i2, m1, m2, mm1, mm2, n1, &
2681 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: amat, atran, bmat, btran, hint
2683 CALL timeset(routinen, handle)
2694 ALLOCATE (amat(m1, m1), atran(n1, n1), bmat(m2, m2), btran(n2, n2))
2695 ALLOCATE (hint(mm1, nn2))
2698 CALL iunpack(bmat(1:m2, 1:m2), omat(i1, 1:mm2), m2)
2699 CALL contract2(btran(1:n2, 1:n2), bmat(1:m2, 1:m2), cm2(1:m2, 1:n2))
2700 CALL ipack(btran(1:n2, 1:n2), hint(i1, 1:nn2), n2)
2704 CALL iunpack(amat(1:m1, 1:m1), hint(1:mm1, i2), m1)
2705 CALL contract2(atran(1:n1, 1:n1), amat(1:m1, 1:m1), cm1(1:m1, 1:n1))
2706 CALL ipack(atran(1:n1, 1:n1),
eri(1:nn1, i2), n1)
2709 DEALLOCATE (amat, atran, bmat, btran)
2712 CALL timestop(handle)
2722 PURE SUBROUTINE ipack(mat, vec, n)
2723 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: mat
2724 REAL(
dp),
DIMENSION(:),
INTENT(INOUT) :: vec
2725 INTEGER,
INTENT(IN) :: n
2737 END SUBROUTINE ipack
2745 PURE SUBROUTINE iunpack(mat, vec, n)
2746 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: mat
2747 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: vec
2748 INTEGER,
INTENT(IN) :: n
2761 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. 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.
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.