24 lmat, no_pseudo, sgp_pseudo, upf_pseudo
56#include "./base/base_uses.f90"
62 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_utils'
84 MODULE PROCEDURE integrate_grid_function1, &
85 integrate_grid_function2, &
86 integrate_grid_function3
104 CHARACTER(LEN=default_string_length), &
105 DIMENSION(:),
POINTER :: ostring
106 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: occupation, wfnocc
107 INTEGER,
INTENT(OUT),
OPTIONAL :: multiplicity
109 CHARACTER(len=2) :: elem
110 CHARACTER(LEN=default_string_length) :: pstring
111 INTEGER :: i, i1, i2, ielem, is, jd, jf, jp, js, k, &
113 REAL(kind=
dp) :: e0, el, oo
117 cpassert(
ASSOCIATED(ostring))
118 cpassert(
SIZE(ostring) > 0)
126 IF (index(ostring(is),
"(") /= 0)
THEN
127 i1 = index(ostring(is),
"(")
128 i2 = index(ostring(is),
")")
129 cpassert((i2 - i1 - 1 > 0) .AND. (i2 - i1 - 1 < 3))
130 elem = ostring(is) (i1 + 1:i2 - 1)
131 IF (index(elem,
"HS") /= 0)
THEN
133 ELSE IF (index(elem,
"LS") /= 0)
THEN
143 IF (index(ostring(is),
"CORE") /= 0) is = is + 1
146 IF (index(ostring(is),
"none") /= 0) is = is + 1
149 IF (index(ostring(is),
"[") /= 0)
THEN
151 i1 = index(ostring(is),
"[")
152 i2 = index(ostring(is),
"]")
153 cpassert((i2 - i1 - 1 > 0) .AND. (i2 - i1 - 1 < 3))
154 elem = ostring(is) (i1 + 1:i2 - 1)
157 IF (elem ==
ptable(k)%symbol)
THEN
163 DO l = 0, min(
lmat, ubound(
ptable(ielem)%e_conv, 1))
164 el = 2._dp*(2._dp*real(l,
dp) + 1._dp)
165 e0 =
ptable(ielem)%e_conv(l)
167 occupation(l, k) = min(el, e0)
169 IF (e0 <= 0._dp)
EXIT
180 js = index(pstring,
"S")
181 jp = index(pstring,
"P")
182 jd = index(pstring,
"D")
183 jf = index(pstring,
"F")
184 cpassert(js + jp + jd + jf > 0)
186 cpassert(jp + jd + jf == 0)
187 READ (pstring(1:js - 1), *) n
188 READ (pstring(js + 1:), *) oo
190 cpassert(oo >= 0._dp)
191 cpassert(occupation(0, n) == 0)
192 occupation(0, n) = oo
195 cpassert(js + jd + jf == 0)
196 READ (pstring(1:jp - 1), *) n
197 READ (pstring(jp + 1:), *) oo
199 cpassert(oo >= 0._dp)
200 cpassert(occupation(1, n - 1) == 0)
201 occupation(1, n - 1) = oo
204 cpassert(js + jp + jf == 0)
205 READ (pstring(1:jd - 1), *) n
206 READ (pstring(jd + 1:), *) oo
208 cpassert(oo >= 0._dp)
209 cpassert(occupation(2, n - 2) == 0)
210 occupation(2, n - 2) = oo
213 cpassert(js + jp + jd == 0)
214 READ (pstring(1:jf - 1), *) n
215 READ (pstring(jf + 1:), *) oo
217 cpassert(oo >= 0._dp)
218 cpassert(occupation(3, n - 3) == 0)
219 occupation(3, n - 3) = oo
228 IF (occupation(l, i) /= 0._dp)
THEN
230 wfnocc(l, k) = occupation(l, i)
242 IF (wfnocc(l, i) /= 0._dp .AND. wfnocc(l, i) /= real(k,
dp))
THEN
250 IF (js == 0 .AND. mult == -2) mult = 1
251 IF (js == 0 .AND. mult == -3) mult = 1
258 k = nint(wfnocc(l, i))
259 IF (k > (2*l + 1)) k = 2*(2*l + 1) - k
260 IF (mult == -2) mult = k + 1
261 IF (mult == -3) mult = mod(k, 2) + 1
262 cpassert(mod(k + 1 - mult, 2) == 0)
264 IF (js > 1 .AND. mult /= -2)
THEN
270 IF (
PRESENT(multiplicity)) multiplicity = mult
282 REAL(kind=
dp),
DIMENSION(0:lmat, 10),
INTENT(IN) :: occupation
289 IF (sum(occupation(l, :)) /= 0._dp) maxl = l
302 REAL(kind=
dp),
DIMENSION(0:lmat, 10),
INTENT(IN) :: occupation
303 INTEGER,
DIMENSION(0:lmat) :: maxn
310 IF (occupation(l, k) /= 0._dp) maxn(l) = maxn(l) + 1
328 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: pmat
329 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: wfn
330 INTEGER,
DIMENSION(0:lmat),
INTENT(IN) :: nbas
331 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
332 INTEGER,
INTENT(IN) :: maxl
333 INTEGER,
DIMENSION(0:lmat),
INTENT(IN) :: maxn
335 INTEGER :: i, j, k, l, n
340 DO i = 1, min(n, maxn(l))
343 pmat(j, k, l) = pmat(j, k, l) + occ(l, i)*wfn(j, i, l)*wfn(k, i, l)
367 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density
368 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
370 INTEGER,
INTENT(IN) :: maxl
371 CHARACTER(LEN=*),
OPTIONAL :: typ
372 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: rr
374 CHARACTER(LEN=3) :: my_typ
375 INTEGER :: i, j, l, n
379 IF (
PRESENT(typ)) my_typ = typ(1:3)
380 IF (my_typ ==
"KIN")
THEN
381 cpassert(
PRESENT(rr))
390 IF (i /= j) ff = 2._dp*pmat(i, j, l)
391 IF (my_typ ==
"RHO")
THEN
392 density(:) = density(:) + ff*basis%bf(:, i, l)*basis%bf(:, j, l)
393 ELSE IF (my_typ ==
"DER")
THEN
394 density(:) = density(:) + ff*basis%dbf(:, i, l)*basis%bf(:, j, l) &
395 + ff*basis%bf(:, i, l)*basis%dbf(:, j, l)
396 ELSE IF (my_typ ==
"KIN")
THEN
397 density(:) = density(:) + 0.5_dp*ff*( &
398 basis%dbf(:, i, l)*basis%dbf(:, j, l) + &
399 REAL(l*(l + 1),
dp)*basis%bf(:, i, l)*basis%bf(:, j, l)/rr(:))
400 ELSE IF (my_typ ==
"LAP")
THEN
401 density(:) = density(:) + ff*basis%ddbf(:, i, l)*basis%bf(:, j, l) &
402 + ff*basis%bf(:, i, l)*basis%ddbf(:, j, l) &
403 + 2._dp*ff*basis%dbf(:, i, l)*basis%bf(:, j, l)/rr(:) &
404 + 2._dp*ff*basis%bf(:, i, l)*basis%dbf(:, j, l)/rr(:)
426 INTEGER :: extunit, i, k, l, n
429 CALL open_file(file_name=
atom%zmp_restart_file, file_status=
"UNKNOWN", &
430 file_form=
"FORMATTED", file_action=
"WRITE", &
433 n =
SIZE(
atom%orbitals%wfn, 2)
434 WRITE (extunit, *)
atom%basis%nbas
435 DO l = 0,
atom%state%maxl_occ
436 DO i = 1, min(n,
atom%state%maxn_occ(l))
437 DO k = 1,
atom%basis%nbas(l)
438 WRITE (extunit, *)
atom%orbitals%wfn(k, i, l)
459 LOGICAL,
INTENT(INOUT) :: doguess
460 INTEGER,
INTENT(IN) :: iw
462 INTEGER :: er, extunit, i, k, l, maxl, n
463 INTEGER,
DIMENSION(0:lmat) :: maxn, nbas
465 INQUIRE (file=
atom%zmp_restart_file, exist=
atom%doread)
467 IF (
atom%doread)
THEN
468 WRITE (iw, fmt=
"(' ZMP | Restart file found')")
470 CALL open_file(file_name=
atom%zmp_restart_file, file_status=
"OLD", &
471 file_form=
"FORMATTED", file_action=
"READ", &
474 READ (extunit, *, iostat=er) nbas
477 WRITE (iw, fmt=
"(' ZMP | ERROR! Restart file unreadable')")
478 WRITE (iw, fmt=
"(' ZMP | ERROR! Starting ZMP calculation form initial atomic guess')")
480 atom%doread = .false.
481 ELSE IF (nbas(1) .NE.
atom%basis%nbas(1))
THEN
482 WRITE (iw, fmt=
"(' ZMP | ERROR! Restart file contains a different basis set')")
483 WRITE (iw, fmt=
"(' ZMP | ERROR! Starting ZMP calculation form initial atomic guess')")
485 atom%doread = .false.
487 nbas =
atom%basis%nbas
488 maxl =
atom%state%maxl_occ
489 maxn =
atom%state%maxn_occ
490 n =
SIZE(
atom%orbitals%wfn, 2)
491 DO l = 0,
atom%state%maxl_occ
492 DO i = 1, min(n,
atom%state%maxn_occ(l))
493 DO k = 1,
atom%basis%nbas(l)
494 READ (extunit, *)
atom%orbitals%wfn(k, i, l)
502 WRITE (iw, fmt=
"(' ZMP | WARNING! Restart file not found')")
503 WRITE (iw, fmt=
"(' ZMP | WARNING! Starting ZMP calculation form initial atomic guess')")
517 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density
519 INTEGER,
INTENT(IN) :: iw
521 CHARACTER(LEN=default_string_length) :: filename
522 INTEGER :: extunit, ir, j, k, l, maxl_occ, maxnbas, &
526 REAL(kind=
dp),
ALLOCATABLE :: pmatread(:, :, :)
528 filename =
atom%ext_file
532 CALL open_file(file_name=filename, file_status=
"OLD", &
533 file_form=
"FORMATTED", file_action=
"READ", &
539 IF (nr .NE.
atom%basis%grid%nr)
THEN
540 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! External grid dimension ',I4,' differs from internal grid ',I4)") &
541 nr,
atom%basis%grid%nr
542 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Stopping ZMP calculation')")
547 READ (extunit, *) rr, density(ir)
548 IF (abs(rr -
atom%basis%grid%rad(ir)) .GT.
atom%zmpgrid_tol)
THEN
549 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Grid points do not coincide: ')")
550 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T20,"R_out[bohr]",T36,"R_in[bohr]",T61,"R_diff[bohr]")')
551 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T14,E24.15,T39,E24.15,T64,E24.15)') &
552 rr,
atom%basis%grid%rad(ir), abs(rr -
atom%basis%grid%rad(ir))
558 READ (extunit, *) maxl_occ
559 maxnbas = maxval(
atom%basis%nbas)
560 ALLOCATE (pmatread(maxnbas, maxnbas, 0:maxl_occ))
563 nbas =
atom%basis%nbas(l)
566 READ (extunit, *) (pmatread(j, k, l), j=1, k)
568 pmatread(k, j, l) = pmatread(j, k, l)
578 CALL open_file(file_name=
"rho_target.dat", file_status=
"UNKNOWN", &
579 file_form=
"FORMATTED", file_action=
"WRITE", unit_number=extunit)
581 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | Writing target density from density matrix')")
583 WRITE (extunit, fmt=
'("# Target density built from density matrix : ",A20)') filename
584 WRITE (extunit, fmt=
'("#",T10,"R[bohr]",T36,"Rho[au]")')
586 nr =
atom%basis%grid%nr
589 WRITE (extunit, fmt=
'(T1,E24.15,T26,E24.15)') &
590 atom%basis%grid%rad(ir), density(ir)
592 DEALLOCATE (pmatread)
608 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: vxc
610 INTEGER,
INTENT(IN) :: iw
612 CHARACTER(LEN=default_string_length) :: adum, filename
613 INTEGER :: extunit, ir, nr
616 filename =
atom%ext_vxc_file
619 CALL open_file(file_name=filename, file_status=
"OLD", &
620 file_form=
"FORMATTED", file_action=
"READ", &
624 READ (extunit, *) adum, nr
626 IF (nr .NE.
atom%basis%grid%nr)
THEN
627 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! External grid dimension ',I4,' differs from internal grid ',I4)") &
628 nr,
atom%basis%grid%nr
629 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Stopping ZMP calculation')")
633 READ (extunit, *) rr, vxc(ir)
634 IF (abs(rr -
atom%basis%grid%rad(ir)) .GT.
atom%zmpvxcgrid_tol)
THEN
635 IF (iw > 0)
WRITE (iw, fmt=
"(' ZMP | ERROR! Grid points do not coincide: ')")
636 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T20,"R_out[bohr]",T36,"R_in[bohr]",T61,"R_diff[bohr]")')
637 IF (iw > 0)
WRITE (iw, fmt=
'(" ZMP |",T14,E24.15,T39,E24.15,T64,E24.15)') &
638 rr,
atom%basis%grid%rad(ir), abs(rr -
atom%basis%grid%rad(ir))
654 REAL(kind=
dp),
INTENT(OUT) :: charge
655 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
656 REAL(kind=
dp),
INTENT(IN) :: rcov
657 INTEGER,
INTENT(IN) :: l
660 INTEGER :: i, j, m, n
662 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: den
665 m =
SIZE(basis%bf, 1)
672 den(1:m) = den(1:m) + ff*basis%bf(1:m, i, l)*basis%bf(1:m, j, l)
676 IF (basis%grid%rad(i) > rcov) den(i) = 0._dp
678 charge = sum(den(1:m)*basis%grid%wr(1:m))
694 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: corden
696 CHARACTER(LEN=*),
OPTIONAL :: typ
697 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rr
699 CHARACTER(LEN=3) :: my_typ
700 INTEGER :: i, j, m, n
702 REAL(kind=
dp) :: a, a2, cval, fb
703 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: fe, rc, rhoc, rval
706 IF (
PRESENT(typ)) my_typ = typ(1:3)
708 SELECT CASE (potential%ppot_type)
712 IF (potential%gth_pot%nlcc)
THEN
714 ALLOCATE (fe(m), rc(m))
715 n = potential%gth_pot%nexp_nlcc
717 a = potential%gth_pot%alpha_nlcc(i)
721 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
722 DO j = 1, potential%gth_pot%nct_nlcc(i)
723 cval = potential%gth_pot%cval_nlcc(j, i)
724 IF (my_typ ==
"RHO")
THEN
725 corden(:) = corden(:) + fe(:)*rc**(2*j - 2)*cval
726 ELSE IF (my_typ ==
"DER")
THEN
727 corden(:) = corden(:) - fe(:)*rc**(2*j - 1)*cval/a
729 corden(:) = corden(:) + real(2*j - 2,
dp)*fe(:)*rc**(2*j - 3)*cval/a
731 ELSE IF (my_typ ==
"LAP")
THEN
733 corden(:) = corden(:) - fb*fe(:)/rr(:)*rc**(2*j - 1)
734 corden(:) = corden(:) + fe(:)*rc**(2*j)*cval/a2
736 corden(:) = corden(:) + fb*real(2*j - 2,
dp)*fe(:)/rr(:)*rc**(2*j - 3)
737 corden(:) = corden(:) + real((2*j - 2)*(2*j - 3),
dp)*fe(:)*rc**(2*j - 4)*cval/a2
738 corden(:) = corden(:) - real(2*j - 2,
dp)*fe(:)*rc**(2*j - 2)*cval/a2
748 IF (potential%upf_pot%core_correction)
THEN
750 n = potential%upf_pot%mesh_size
752 IF (rr(1) > rr(m)) reverse = .true.
753 ALLOCATE (rhoc(m), rval(m))
756 rval(i) = rr(m - i + 1)
761 IF (my_typ ==
"RHO")
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 ==
"DER")
THEN
765 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
767 ELSE IF (my_typ ==
"LAP")
THEN
768 CALL spline3ders(potential%upf_pot%r(1:n), potential%upf_pot%rho_nlcc(1:n), rval(1:m), &
775 rval(i) = rr(m - i + 1)
776 corden(i) = corden(i) + rhoc(m - i + 1)
779 corden(1:m) = corden(1:m) + rhoc(1:m)
781 DEALLOCATE (rhoc, rval)
784 IF (potential%sgp_pot%has_nlcc)
THEN
785 cpabort(
"not implemented")
788 cpabort(
"Unknown PP type")
800 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: locpot
802 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rr
804 INTEGER :: i, j, m, n
806 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: fe, rc
809 ALLOCATE (fe(m), rc(m))
810 rc(:) = rr(:)/gthpot%rc
812 locpot(i) = -gthpot%zion*erf(rc(i)/sqrt(2._dp))/rr(i)
815 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
817 locpot(:) = locpot(:) + fe(:)*rc**(2*i - 2)*gthpot%cl(i)
819 IF (gthpot%lpotextended)
THEN
820 DO j = 1, gthpot%nexp_lpot
821 a = gthpot%alpha_lpot(j)
823 fe(:) = exp(-0.5_dp*rc(:)*rc(:))
824 n = gthpot%nct_lpot(j)
826 locpot(:) = locpot(:) + fe(:)*rc**(2*i - 2)*gthpot%cval_lpot(i, j)
843 REAL(kind=
dp),
INTENT(OUT) :: rmax
844 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
845 REAL(kind=
dp),
INTENT(IN) :: rcov
846 INTEGER,
INTENT(IN) :: l
851 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dorb
853 m =
SIZE(basis%bf, 1)
859 dorb(1:m) = dorb(1:m) + ff*basis%dbf(1:m, i, l)
863 IF (basis%grid%rad(i) < 2*rcov)
THEN
864 IF (dorb(i)*dorb(i + 1) < 0._dp)
THEN
865 rmax = max(rmax, basis%grid%rad(i))
882 INTEGER,
INTENT(OUT) :: node
883 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
884 REAL(kind=
dp),
INTENT(IN) :: rcov
885 INTEGER,
INTENT(IN) :: l
890 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: orb
893 m =
SIZE(basis%bf, 1)
899 orb(1:m) = orb(1:m) + ff*basis%bf(1:m, i, l)
902 IF (basis%grid%rad(i) < rcov)
THEN
903 IF (orb(i)*orb(i + 1) < 0._dp) node = node + 1
917 REAL(kind=
dp),
INTENT(OUT) ::
value
918 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wfn
924 m = maxval(minloc(basis%grid%rad))
927 value =
value + wfn(i)*basis%bf(m, i, 0)
944 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: hmat, umat
945 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: orb
946 REAL(kind=
dp),
DIMENSION(:, 0:),
INTENT(INOUT) :: ener
947 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nb, nv
948 INTEGER,
INTENT(IN) :: maxl
950 INTEGER :: info, l, lwork, m, n
951 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: w, work
952 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a
954 cpassert(all(nb >= nv))
960 IF (n > 0 .AND. m > 0)
THEN
962 ALLOCATE (a(n, n), w(n), work(lwork))
963 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)))
964 CALL lapack_ssyev(
"V",
"U", m, a(1:m, 1:m), m, w(1:m), work, lwork, info)
965 a(1:n, 1:m) = matmul(umat(1:n, 1:m, l), a(1:m, 1:m))
967 m = min(m,
SIZE(orb, 2))
968 orb(1:n, 1:m, l) = a(1:n, 1:m)
969 ener(1:m, l) = w(1:m)
971 DEALLOCATE (a, w, work)
983 FUNCTION prune_grid(fun, deps)
RESULT(nc)
984 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun
985 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: deps
989 REAL(kind=
dp) :: meps
992 IF (
PRESENT(deps)) meps = deps
997 IF (abs(fun(i)) > meps)
THEN
1003 END FUNCTION prune_grid
1013 PURE FUNCTION integrate_grid_function1(fun, grid)
RESULT(integral)
1014 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun
1016 REAL(kind=
dp) :: integral
1021 integral = sum(fun(1:nc)*grid%wr(1:nc))
1023 END FUNCTION integrate_grid_function1
1034 PURE FUNCTION integrate_grid_function2(fun1, fun2, grid)
RESULT(integral)
1035 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun1, fun2
1037 REAL(kind=
dp) :: integral
1041 nc = min(
SIZE(fun1),
SIZE(fun2))
1042 integral = sum(fun1(1:nc)*fun2(1:nc)*grid%wr(1:nc))
1044 END FUNCTION integrate_grid_function2
1056 PURE FUNCTION integrate_grid_function3(fun1, fun2, fun3, grid)
RESULT(integral)
1057 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: fun1, fun2, fun3
1059 REAL(kind=
dp) :: integral
1063 nc = min(
SIZE(fun1),
SIZE(fun2),
SIZE(fun3))
1064 integral = sum(fun1(1:nc)*fun2(1:nc)*fun3(1:nc)*grid%wr(1:nc))
1066 END FUNCTION integrate_grid_function3
1077 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: cpot
1078 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1082 REAL(
dp) :: int1, int2
1083 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1085 nc = min(
SIZE(cpot),
SIZE(density))
1091 cpot(nc:) = int1/r(nc:)
1095 cpassert(r(1) > r(nc))
1097 cpot(i) = int1/r(i) + int2
1098 int1 = int1 -
fourpi*density(i)*wr(i)
1099 int2 = int2 +
fourpi*density(i)*wr(i)/r(i)
1115 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: cpot
1116 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1119 INTEGER,
INTENT(IN) :: maxl
1121 INTEGER :: i, j, k, l, m, n
1122 REAL(kind=
dp) :: a, b, ff, oab, sab
1123 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: erfa, expa, z
1124 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: unp
1127 ALLOCATE (erfa(1:m), expa(1:m), z(1:m))
1132 IF (maxval(abs(pmat(:, :, l))) < 1.e-14_dp) cycle
1133 SELECT CASE (basis%basis_type)
1137 DO i = 1, basis%nbas(l)
1138 DO j = i, basis%nbas(l)
1139 IF (abs(pmat(i, j, l)) < 1.e-14_dp) cycle
1141 IF (i /= j) ff = 2._dp*ff
1145 oab =
rootpi/(a + b)**(l + 1.5_dp)*ff
1146 z(:) = sab*grid%rad(:)
1147 DO k = 1,
SIZE(erfa)
1148 erfa(k) = oab*erf(z(k))/grid%rad(k)
1150 expa(:) = exp(-z(:)**2)*ff/(a + b)**(l + 1)
1155 cpot(:) = cpot(:) + 0.25_dp*erfa(:)
1157 cpot(:) = cpot(:) + 0.375_dp*erfa(:) - 0.25_dp*expa(:)
1159 cpot(:) = cpot(:) + 0.9375_dp*erfa(:) - expa(:)*(0.875_dp + 0.25_dp*z(:)**2)
1161 cpot(:) = cpot(:) + 3.28125_dp*erfa(:) - expa(:)*(3.5625_dp + 1.375_dp*z(:)**2 + 0.25*z(:)**4)
1168 ALLOCATE (unp(n, n))
1170 unp(1:n, 1:n) = matmul(matmul(basis%cm(1:n, 1:m, l), pmat(1:m, 1:m, l)), &
1171 transpose(basis%cm(1:n, 1:m, l)))
1172 DO i = 1, basis%nprim(l)
1173 DO j = i, basis%nprim(l)
1174 IF (abs(unp(i, j)) < 1.e-14_dp) cycle
1176 IF (i /= j) ff = 2._dp*ff
1180 oab =
rootpi/(a + b)**(l + 1.5_dp)*ff
1181 z(:) = sab*grid%rad(:)
1182 DO k = 1,
SIZE(erfa)
1183 erfa(k) = oab*erf(z(k))/grid%rad(k)
1185 expa(:) = exp(-z(:)**2)*ff/(a + b)**(l + 1)
1190 cpot(:) = cpot(:) + 0.25_dp*erfa(:)
1192 cpot(:) = cpot(:) + 0.375_dp*erfa(:) - 0.25_dp*expa(:)
1194 cpot(:) = cpot(:) + 0.9375_dp*erfa(:) - expa(:)*(0.875_dp + 0.25_dp*z(:)**2)
1196 cpot(:) = cpot(:) + 3.28125_dp*erfa(:) - expa(:)*(3.5625_dp + 1.375_dp*z(:)**2 + 0.25*z(:)**4)
1204 DEALLOCATE (erfa, expa, z)
1220 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1222 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
1223 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: wfn
1227 INTEGER :: i, ia, ib, k, lad, lbc, lh, ll, nbas, &
1229 REAL(kind=
dp) :: almn
1230 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, nai, nbi, pot
1231 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: orb
1232 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1237 arho(ll) =
fac(ll)/
fac(lh)**2
1243 ALLOCATE (nai(nr), nbi(nr), cpot(nr), pot(nr))
1245 DO lad = 0, state%maxl_calc
1246 DO lbc = 0, state%maxl_occ
1247 norb = state%maxn_occ(lbc)
1248 nbas = basis%nbas(lbc)
1250 ALLOCATE (orb(nr, norb))
1254 orb(:, i) = orb(:, i) + wfn(k, i, lbc)*basis%bf(:, k, lbc)
1257 DO nu = abs(lad - lbc), lad + lbc, 2
1258 almn = arho(-lad + lbc + nu)*arho(lad - lbc + nu)*arho(lad + lbc - nu)/(real(lad + lbc + nu + 1,
dp) &
1259 *arho(lad + lbc + nu))
1262 DO ia = 1, basis%nbas(lad)
1264 nai(:) = orb(:, i)*basis%bf(:, ia, lad)
1266 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1267 CALL potential_coulomb_numeric(pot, nai, nu, basis%grid)
1268 cpot(:) = cpot(:) + pot(:)*hfx_pot%scale_coulomb
1270 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1271 IF (hfx_pot%do_gh)
THEN
1272 CALL potential_longrange_numeric_gh(pot, nai, nu, basis%grid, hfx_pot%omega, &
1273 hfx_pot%kernel(:, :, nu))
1275 CALL potential_longrange_numeric(pot, nai, nu, basis%grid, hfx_pot%omega, &
1276 hfx_pot%kernel(:, :, nu))
1278 cpot(:) = cpot(:) + pot(:)*hfx_pot%scale_longrange
1280 DO ib = 1, basis%nbas(lad)
1281 kmat(ia, ib, lad) = kmat(ia, ib, lad) + almn*occ(lbc, i)* &
1282 integrate_grid(cpot, orb(:, i), basis%bf(:, ib, lad), basis%grid)
1292 DEALLOCATE (nai, nbi, cpot)
1308 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1310 REAL(kind=
dp),
DIMENSION(0:, :),
INTENT(IN) :: occ
1311 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: wfn
1315 INTEGER :: i, ia, ib, k, lad, lbc, lh, ll, nbas, &
1317 REAL(kind=
dp) :: almn
1318 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, nai, nbi
1319 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: orb
1320 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: pot
1321 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1326 arho(ll) =
fac(ll)/
fac(lh)**2
1332 nbas = maxval(basis%nbas)
1333 ALLOCATE (pot(nr, nbas, nbas))
1334 ALLOCATE (nai(nr), nbi(nr), cpot(nr))
1336 DO lad = 0, state%maxl_calc
1337 DO lbc = 0, state%maxl_occ
1338 norb = state%maxn_occ(lbc)
1339 nbas = basis%nbas(lbc)
1341 ALLOCATE (orb(nr, norb))
1345 orb(:, i) = orb(:, i) + wfn(k, i, lbc)*basis%bf(:, k, lbc)
1348 DO nu = abs(lad - lbc), lad + lbc, 2
1349 almn = arho(-lad + lbc + nu)*arho(lad - lbc + nu) &
1350 *arho(lad + lbc - nu)/(real(lad + lbc + nu + 1,
dp)*arho(lad + lbc + nu))
1354 CALL potential_analytic(pot, lad, lbc, nu, basis, hfx_pot)
1355 DO ia = 1, basis%nbas(lad)
1359 cpot(:) = cpot(:) + pot(:, ia, k)*wfn(k, i, lbc)
1361 DO ib = 1, basis%nbas(lad)
1362 kmat(ia, ib, lad) = kmat(ia, ib, lad) + almn*occ(lbc, i)* &
1363 integrate_grid(cpot, orb(:, i), basis%bf(:, ib, lad), basis%grid)
1373 DEALLOCATE (nai, nbi, cpot)
1387 SUBROUTINE potential_coulomb_numeric(cpot, density, nu, grid)
1388 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1389 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1390 INTEGER,
INTENT(IN) :: nu
1394 REAL(
dp) :: int1, int2
1395 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1397 nc = min(
SIZE(cpot),
SIZE(density))
1403 cpot(nc:) = int1/r(nc:)**(nu + 1)
1406 cpassert(r(1) > r(nc))
1408 cpot(i) = int1/r(i)**(nu + 1) + int2*r(i)**nu
1409 int1 = int1 - r(i)**(nu)*density(i)*wr(i)
1410 int2 = int2 + density(i)*wr(i)/r(i)**(nu + 1)
1413 END SUBROUTINE potential_coulomb_numeric
1424 SUBROUTINE potential_longrange_numeric(cpot, density, nu, grid, omega, kernel)
1425 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1426 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1427 INTEGER,
INTENT(IN) :: nu
1429 REAL(kind=
dp),
INTENT(IN) :: omega
1430 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: kernel
1433 REAL(
dp),
DIMENSION(:),
POINTER :: r, wr
1434 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work_inp, work_out
1436 nc = min(
SIZE(cpot),
SIZE(density))
1440 ALLOCATE (work_inp(nc), work_out(nc))
1445 work_inp(:nc) = density(:nc)*wr(:nc)
1446 CALL dsymv(
'U', nc, 1.0_dp, kernel, nc, work_inp, 1, 0.0_dp, work_out, 1)
1449 work_inp(:nc) = work_out(:nc)*exp(-r(:nc)**2)/r(:nc)**2*wr(:nc)
1450 CALL dsymv(
'U', nc, 1.0_dp, kernel, nc, work_inp, 1, 0.0_dp, work_out, 1)
1452 cpot(:nc) = work_out(:nc)*(2.0_dp*real(nu,
dp) + 1.0_dp)*4.0_dp/
pi*omega
1454 END SUBROUTINE potential_longrange_numeric
1465 SUBROUTINE potential_longrange_numeric_gh(cpot, density, nu, grid, omega, kernel)
1466 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: cpot
1467 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: density
1468 INTEGER,
INTENT(IN) :: nu
1470 REAL(kind=
dp),
INTENT(IN) :: omega
1471 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: kernel
1473 INTEGER :: n_max, nc, nc_kernel, nr_kernel
1474 REAL(
dp),
DIMENSION(:),
POINTER :: wr
1475 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work_inp, work_out
1477 nc = min(
SIZE(cpot),
SIZE(density))
1480 nc_kernel =
SIZE(kernel, 1)
1481 nr_kernel =
SIZE(kernel, 2)
1482 n_max = max(nc, nc_kernel, nr_kernel)
1484 ALLOCATE (work_inp(n_max), work_out(n_max))
1489 work_inp(:nc) = density(:nc)*wr(:nc)
1490 CALL dgemv(
'T', nc_kernel, nr_kernel, 1.0_dp, kernel, nc_kernel, work_inp, 1, 0.0_dp, work_out, 1)
1493 work_inp(:nr_kernel) = work_out(:nr_kernel)
1494 CALL dgemv(
'N', nc_kernel, nr_kernel, 1.0_dp, kernel, nc_kernel, work_inp, 1, 0.0_dp, work_out, 1)
1496 cpot(:nc) = work_out(:nc)*(2.0_dp*real(nu,
dp) + 1.0_dp)*4.0_dp/
pi*omega
1498 END SUBROUTINE potential_longrange_numeric_gh
1513 SUBROUTINE potential_analytic(cpot, la, lb, nu, basis, hfx_pot)
1514 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(OUT) :: cpot
1515 INTEGER,
INTENT(IN) :: la, lb, nu
1519 INTEGER :: i, j, k, l, ll, m
1520 REAL(kind=
dp) :: a, b
1521 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: erfa, pot
1524 ALLOCATE (erfa(1:m))
1530 SELECT CASE (basis%basis_type)
1534 DO i = 1, basis%nbas(la)
1535 DO j = 1, basis%nbas(lb)
1539 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1540 CALL potential_coulomb_analytic(erfa, a, b, ll, nu, basis%grid%rad)
1542 cpot(:, i, j) = cpot(:, i, j) + erfa(:)*hfx_pot%scale_coulomb
1545 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1546 CALL potential_longrange_analytic(erfa, a, b, ll, nu, basis%grid%rad, hfx_pot%omega)
1548 cpot(:, i, j) = cpot(:, i, j) + erfa(:)*hfx_pot%scale_longrange
1555 DO i = 1, basis%nprim(la)
1556 DO j = 1, basis%nprim(lb)
1562 IF (hfx_pot%scale_coulomb /= 0.0_dp)
THEN
1563 CALL potential_coulomb_analytic(erfa, a, b, ll, nu, basis%grid%rad)
1565 pot(:) = pot(:) + erfa(:)*hfx_pot%scale_coulomb
1568 IF (hfx_pot%scale_longrange /= 0.0_dp)
THEN
1569 CALL potential_longrange_analytic(erfa, a, b, ll, nu, basis%grid%rad, hfx_pot%omega)
1571 pot(:) = pot(:) + erfa(:)*hfx_pot%scale_longrange
1574 DO k = 1, basis%nbas(la)
1575 DO l = 1, basis%nbas(lb)
1576 cpot(:, k, l) = cpot(:, k, l) + pot(:)*basis%cm(i, k, la)*basis%cm(j, l, lb)
1586 END SUBROUTINE potential_analytic
1597 SUBROUTINE potential_coulomb_analytic(erfa, a, b, ll, nu, rad)
1598 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: erfa
1599 REAL(kind=
dp),
INTENT(IN) :: a, b
1600 INTEGER,
INTENT(IN) :: ll, nu
1601 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rad
1604 REAL(kind=
dp) :: oab, sab
1605 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: expa, z
1608 ALLOCATE (expa(nr), z(nr))
1611 oab =
dfac(ll + nu + 1)*
rootpi/sab**(ll + 2)/2._dp**((ll + nu)/2 + 2)
1613 erfa(:) = oab*erf(z(:))/z(:)**(nu + 1)
1614 expa(:) = exp(-z(:)**2)/sab**(ll + 2)/2._dp**((ll + nu)/2 + 2)
1622 erfa(:) = erfa(:) - 6._dp*expa(:)/z(:)
1628 erfa(:) = erfa(:) - 2._dp*expa(:)
1630 erfa(:) = erfa(:) - expa(:)*(20._dp + 30._dp/z(:)**2)
1637 erfa(:) = erfa(:) - expa(:)*(12._dp*z(:) + 30._dp/z(:))
1639 erfa(:) = erfa(:) - expa(:)*(56._dp*z(:) + 140._dp/z(:) + 210._dp/z(:)**3)
1646 erfa(:) = erfa(:) - expa(:)*(4._dp*z(:)**2 + 14._dp)
1648 erfa(:) = erfa(:) - expa(:)*(40._dp*z(:)**2 + 140._dp + 210._dp/z(:)**2)
1650 erfa(:) = erfa(:) - expa(:)*(144._dp*z(:)**2 + 504._dp + 1260._dp/z(:)**2 + 1890._dp/z(:)**4)
1657 erfa(:) = erfa(:) - expa(:)*(24._dp*z(:)**3 + 108._dp*z(:) + 210._dp/z(:))
1659 erfa(:) = erfa(:) - expa(:)*(112._dp*z(:)**3 + 504._dp*z(:) + 1260._dp/z(:) + 1890._dp/z(:)**3)
1661 erfa(:) = erfa(:) - expa(:)*(352._dp*z(:)**3 + 1584._dp*z(:) + 5544._dp/z(:) + &
1662 13860._dp/z(:)**3 + 20790._dp/z(:)**5)
1669 erfa(:) = erfa(:) - expa(:)*(8._dp*z(:)**4 + 44._dp*z(:)**2 + 114._dp)
1671 erfa(:) = erfa(:) - expa(:)*(80._dp*z(:)**4 + 440._dp*z(:)**2 + 1260._dp + 1896._dp/z(:)**2)
1673 erfa(:) = erfa(:) - expa(:)*(288._dp*z(:)**4 + 1584._dp*z(:)**2 + 5544._dp + &
1674 13860._dp/z(:)**2 + 20790._dp/z(:)**4)
1676 erfa(:) = erfa(:) - expa(:)*(832._dp*z(:)**4 + 4576._dp*z(:)**2 + 20592._dp + &
1677 72072._dp/z(:)**2 + 180180._dp/z(:)**4 + 270270._dp/z(:)**6)
1681 DEALLOCATE (expa, z)
1683 END SUBROUTINE potential_coulomb_analytic
1695 PURE SUBROUTINE potential_longrange_analytic(erfa, a, b, ll, nu, rad, omega)
1696 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: erfa
1697 REAL(kind=
dp),
INTENT(IN) :: a, b
1698 INTEGER,
INTENT(IN) :: ll, nu
1699 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rad
1700 REAL(kind=
dp),
INTENT(IN) :: omega
1702 INTEGER :: i, lambda, nr
1703 REAL(kind=
dp) :: ab, oab, pab, prel, sab
1704 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: expa, z
1706 IF (mod(ll - nu, 2) == 0 .AND. ll >= nu .AND. nu >= 0)
THEN
1708 ALLOCATE (expa(nr), z(nr))
1710 lambda = (ll - nu)/2
1713 pab = omega**2*ab/(omega**2 + ab)
1715 z(:) = sqrt(pab)*rad(:)
1716 oab =
fac(lambda)/sqrt(ab)**(ll + 2)/4.0_dp*sqrt(prel)**(nu + 1)*(2.0_dp*real(nu, kind=
dp) + 1.0_dp)
1717 expa(:) = exp(-z(:)**2)
1718 lambda = (ll - nu)/2
1720 IF (lambda > 0)
THEN
1723 erfa = erfa + (-prel)**i/real(i, kind=
dp)*
binomial_gen(lambda + nu + 0.5_dp, lambda - i)* &
1724 assoc_laguerre(z, real(nu, kind=
dp) + 0.5_dp, i - 1)
1726 erfa = erfa*expa*z**nu
1728 erfa = erfa + 2.0_dp*
binomial_gen(lambda + nu + 0.5_dp, lambda)*znfn(z, expa, nu)
1730 erfa = 2.0_dp*znfn(z, expa, nu)
1735 DEALLOCATE (expa, z)
1741 END SUBROUTINE potential_longrange_analytic
1750 ELEMENTAL FUNCTION znfn(z, expa, n)
RESULT(res)
1752 REAL(kind=
dp),
INTENT(IN) :: z, expa
1753 INTEGER,
INTENT(IN) :: n
1754 REAL(kind=
dp) :: res
1757 REAL(kind=
dp) :: z_exp
1760 IF (abs(z) < 1.0e-20)
THEN
1761 res = z**n/(2.0_dp*real(n, kind=
dp) + 1.0_dp)
1762 ELSE IF (n == 0)
THEN
1763 res =
rootpi/2.0_dp*erf(z)/z
1765 res =
rootpi/4.0_dp*erf(z)/z**2 - expa/z/2.0_dp
1766 z_exp = -expa*0.5_dp
1769 res = (real(i, kind=
dp) - 0.5_dp)*res/z + z_exp
1786 ELEMENTAL FUNCTION assoc_laguerre(z, a, n)
RESULT(res)
1788 REAL(kind=
dp),
INTENT(IN) :: z, a
1789 INTEGER,
INTENT(IN) :: n
1790 REAL(kind=
dp) :: res
1793 REAL(kind=
dp) :: f0, f1
1797 ELSE IF (n == 1)
THEN
1798 res = a + 1.0_dp - z
1799 ELSE IF (n > 0)
THEN
1804 res = (2.0_dp + (a - 1.0_dp - z)/real(i,
dp))*f1 - (1.0_dp + (a - 1.0_dp)/real(i,
dp))*f0
1812 END FUNCTION assoc_laguerre
1823 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: opmat, pmat
1824 REAL(kind=
dp) :: trace
1840 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: imat
1841 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: cpot
1843 INTEGER,
INTENT(IN) :: derivatives
1845 INTEGER :: i, j, l, n
1847 SELECT CASE (derivatives)
1853 imat(i, j, l) = imat(i, j, l) + &
1854 integrate_grid(cpot, basis%bf(:, i, l), basis%bf(:, j, l), basis%grid)
1855 imat(j, i, l) = imat(i, j, l)
1864 imat(i, j, l) = imat(i, j, l) + &
1865 integrate_grid(cpot, basis%dbf(:, i, l), basis%bf(:, j, l), basis%grid)
1866 imat(i, j, l) = imat(i, j, l) + &
1867 integrate_grid(cpot, basis%bf(:, i, l), basis%dbf(:, j, l), basis%grid)
1868 imat(j, i, l) = imat(i, j, l)
1877 imat(i, j, l) = imat(i, j, l) + &
1878 integrate_grid(cpot, basis%dbf(:, i, l), basis%dbf(:, j, l), basis%grid)
1879 imat(j, i, l) = imat(i, j, l)
1900 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: jmat
1901 TYPE(
eri),
DIMENSION(:),
INTENT(IN) :: erint
1902 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1903 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nsize
1904 LOGICAL,
INTENT(IN),
OPTIONAL :: all_nu
1906 INTEGER :: i1, i2, ij1, ij2, j1, j2, l1, l2, ll, &
1908 LOGICAL :: have_all_nu
1909 REAL(kind=
dp) :: eint, f1, f2
1911 IF (
PRESENT(all_nu))
THEN
1912 have_all_nu = all_nu
1914 have_all_nu = .false.
1917 jmat(:, :, :) = 0._dp
1929 IF (i1 /= j1) f1 = 2._dp
1935 IF (i2 /= j2) f2 = 2._dp
1936 eint = erint(ll)%int(ij1, ij2)
1938 jmat(i1, j1, l1) = jmat(i1, j1, l1) + f2*pmat(i2, j2, l2)*eint
1940 jmat(i1, j1, l1) = jmat(i1, j1, l1) + f2*pmat(i2, j2, l2)*eint
1941 jmat(i2, j2, l2) = jmat(i2, j2, l2) + f1*pmat(i1, j1, l1)*eint
1947 IF (have_all_nu)
THEN
1957 jmat(j1, i1, l1) = jmat(i1, j1, l1)
1974 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(INOUT) :: kmat
1975 TYPE(
eri),
DIMENSION(:),
INTENT(IN) :: erint
1976 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: pmat
1977 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nsize
1979 INTEGER :: i1, i2, ij1, ij2, j1, j2, l1, l2, lh, &
1981 REAL(kind=
dp) :: almn, eint, f1, f2
1982 REAL(kind=
dp),
DIMENSION(0:maxfac) :: arho
1987 arho(ll) =
fac(ll)/
fac(lh)**2
1990 kmat(:, :, :) = 0._dp
1996 DO nu = abs(l1 - l2), l1 + l2, 2
1997 almn = arho(-l1 + l2 + nu)*arho(l1 - l2 + nu)*arho(l1 + l2 - nu)/(real(l1 + l2 + nu + 1,
dp)*arho(l1 + l2 + nu))
2005 IF (i1 /= j1) f1 = 2._dp
2011 IF (i2 /= j2) f2 = 2._dp
2012 eint = erint(ll)%int(ij1, ij2)
2014 kmat(i1, j1, l1) = kmat(i1, j1, l1) + f2*almn*pmat(i2, j2, l2)*eint
2016 kmat(i1, j1, l1) = kmat(i1, j1, l1) + f2*almn*pmat(i2, j2, l2)*eint
2017 kmat(i2, j2, l2) = kmat(i2, j2, l2) + f1*almn*pmat(i1, j1, l1)*eint
2030 kmat(j1, i1, l1) = kmat(i1, j1, l1)
2050 PURE SUBROUTINE err_matrix(emat, demax, kmat, pmat, umat, upmat, nval, nbs)
2051 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(OUT) :: emat
2052 REAL(kind=
dp),
INTENT(OUT) :: demax
2053 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(IN) :: kmat, pmat, umat, upmat
2054 INTEGER,
DIMENSION(0:),
INTENT(IN) :: nval, nbs
2057 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: tkmat, tpmat
2064 ALLOCATE (tkmat(1:m, 1:m), tpmat(1:m, 1:m))
2067 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)))
2068 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)))
2069 tpmat(1:m, 1:m) = matmul(upmat(1:m, 1:m, l), matmul(tpmat(1:m, 1:m), upmat(1:m, 1:m, l)))
2071 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))
2073 DEALLOCATE (tkmat, tpmat)
2076 demax = maxval(abs(emat))
2094 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: density1, density2
2095 INTEGER,
INTENT(IN) :: zcore
2099 INTEGER :: counter, i, l, mc, mm(0:
lmat), mo, n, ns
2100 INTEGER,
DIMENSION(lmat+1, 20) :: ne
2101 REAL(kind=
dp) :: a, pf
2109 mo = state%maxn_occ(l)
2110 IF (sum(state%core(l, :)) == 0)
THEN
2111 cpassert(ns >= l + mo)
2113 ne(l + 1, l + counter) = nint(state%occ(l, counter))
2117 cpassert(sum(state%occ(l, 1:mc)) == 0)
2118 cpassert(ns >= l + mc)
2120 ne(l + 1, l + counter) = nint(state%core(l, counter))
2122 cpassert(ns >= l + mc + mo)
2123 DO counter = mc + 1, mc + mo
2124 ne(l + 1, l + counter) = nint(state%occ(l, counter))
2131 DO l = 0, state%maxl_occ
2132 DO i = 1,
SIZE(state%occ, 2)
2133 IF (state%occ(l, i) > 0._dp)
THEN
2135 a =
srules(zcore, ne, n, l)
2136 pf = 1._dp/sqrt(
fac(2*n))*(2._dp*a)**(n + 0.5_dp)
2137 IF (state%multiplicity == -1)
THEN
2138 density1(:) = density1(:) + state%occ(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2140 density1(:) = density1(:) + state%occa(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2141 density2(:) = density2(:) + state%occb(l, i)/
fourpi*(grid%rad(:)**(n - 1)*exp(-a*grid%rad(:))*pf)**2
2159 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rho
2160 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: vxc
2163 REAL(kind=
dp) :: ec, ex, rs, vc, vx
2167 IF (rho(i) > 1.e-20_dp)
THEN
2169 ex = -0.7385588_dp*rho(i)**0.333333333_dp
2170 vx = 1.333333333_dp*ex
2171 rs = (3._dp/
fourpi/rho(i))**0.333333333_dp
2172 ec = -0.88_dp/(rs + 7.8_dp)
2173 vc = ec*(1._dp + rs/(3._dp*(rs + 7.8_dp)))
2189 INTEGER,
INTENT(IN) :: method, multiplicity
2190 LOGICAL :: consistent
2194 SELECT CASE (method)
2196 consistent = .false.
2198 consistent = (multiplicity == -1)
2200 consistent = (multiplicity /= -1)
2202 consistent = (multiplicity == -1)
2204 consistent = (multiplicity /= -1)
2206 consistent = .false.
2220 REAL(kind=
dp),
INTENT(OUT) :: rho0
2222 INTEGER :: m0, m1, m2, method, nr
2223 LOGICAL :: nlcc, spinpol
2224 REAL(kind=
dp) :: d0, d1, d2, r0, r1, r2, w0, w1
2225 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: xfun
2226 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rho
2228 method =
atom%method_type
2229 SELECT CASE (method)
2240 nr =
atom%basis%grid%nr
2243 nlcc =
atom%potential%gth_pot%nlcc
2245 nlcc =
atom%potential%upf_pot%core_correction
2247 nlcc =
atom%potential%sgp_pot%has_nlcc
2253 m0 = maxval(minloc(
atom%basis%grid%rad))
2257 ELSE IF (m0 == 1)
THEN
2261 cpabort(
"GRID Definition incompatible")
2263 r0 =
atom%basis%grid%rad(m0)
2264 r1 =
atom%basis%grid%rad(m1)
2265 r2 =
atom%basis%grid%rad(m2)
2270 ALLOCATE (rho(nr, 2))
2276 rho(:, 1) = rho(:, 1) + 0.5_dp*xfun(:)
2277 rho(:, 2) = rho(:, 2) + 0.5_dp*xfun(:)
2279 rho(:, 1) = rho(:, 1) + rho(:, 2)
2281 ALLOCATE (rho(nr, 1))
2291 rho0 = w0*d0 + w1*d1
2292 rho0 = max(rho0, 0.0_dp)
2311 REAL(kind=
dp) :: crad
2312 INTEGER,
INTENT(IN) :: iw
2316 REAL(kind=
dp),
DIMENSION(10) :: cnum, rad
2318 WRITE (iw,
'(/,A,F8.4)')
" Basis Set Condition Numbers: 2*covalent radius=", 2*crad
2323 ci = 2.0_dp*(0.85_dp + i*0.05_dp)
2326 WRITE (iw,
'(A,F15.3,T50,A,F14.4)')
" Lattice constant:", &
2327 rad(i),
"Condition number:", cnum(i)
2331 WRITE (iw,
'(A,A,T50,A,F14.4)')
" Lattice constant:", &
2332 " Inf",
"Condition number:", cnum(i)
2346 INTEGER,
INTENT(IN) :: zv, iw
2348 INTEGER :: i, j, l, ll, m, n, nbas, nl, nr
2349 INTEGER,
DIMENSION(0:lmat) ::
nelem, nlmax, nlmin
2350 INTEGER,
DIMENSION(lmat+1, 7) :: ne
2351 REAL(kind=
dp) :: al, c1, c2, pf
2352 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sfun
2353 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: bmat
2354 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: omat
2355 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: sint
2356 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: snl
2357 REAL(kind=
dp),
DIMENSION(2) :: sse
2358 REAL(kind=
dp),
DIMENSION(lmat+1, 7) :: sexp
2366 IF (
nelem(l) >= ll)
THEN
2369 ELSE IF (
nelem(l) > 0)
THEN
2370 ne(l + 1, i) =
nelem(l)
2383 IF (ne(l + 1, i) > 0)
THEN
2387 nlmax(l) = max(nlmax(l), nlmin(l) + 1)
2396 sexp(l + 1, i) =
srules(zv, ne, i, l)
2397 IF (ne(l + 1, i - l) > 0)
THEN
2398 sse(1) = max(sse(1), sexp(l + 1, i))
2399 sse(2) = min(sse(2), sexp(l + 1, i))
2403 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))
2407 nbas = maxval(basis%nbas)
2408 ALLOCATE (omat(nbas, nbas, 0:
lmat))
2409 nr =
SIZE(basis%bf, 1)
2410 ALLOCATE (sfun(nr), sint(10, 2, nbas, 0:
lmat))
2418 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
2419 sfun(1:nr) = pf*basis%grid%rad(1:nr)**(nl - 1)*exp(-al*basis%grid%rad(1:nr))
2420 DO j = 1, basis%nbas(l)
2421 sint(i, 1, j, l) = sum(sfun(1:nr)*basis%bf(1:nr, j, l)*basis%grid%wr(1:nr))
2424 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
2425 sfun(1:nr) = pf*basis%grid%rad(1:nr)**(nl - 1)*exp(-al*basis%grid%rad(1:nr))
2426 DO j = 1, basis%nbas(l)
2427 sint(i, 2, j, l) = sum(sfun(1:nr)*basis%bf(1:nr, j, l)*basis%grid%wr(1:nr))
2436 SELECT CASE (basis%basis_type)
2440 CALL sg_overlap(omat(1:n, 1:n, l), l, basis%am(1:n, l), basis%am(1:n, l))
2442 ALLOCATE (bmat(m, m))
2443 CALL sg_overlap(bmat(1:m, 1:m), l, basis%am(1:m, l), basis%am(1:m, l))
2444 CALL contract2(omat(1:n, 1:n, l), bmat(1:m, 1:m), basis%cm(1:m, 1:n, l))
2447 CALL sto_overlap(omat(1:n, 1:n, l), basis%ns(1:n, l), basis%as(1:n, l), &
2448 basis%ns(1:n, l), basis%as(1:n, l))
2455 WRITE (iw,
'(/,A)')
" Basis Set Completeness Estimates"
2459 WRITE (iw,
'(A,I3)')
" L-quantum number: ", l
2460 WRITE (iw,
'(A,T31,A,I2,T61,A,I2)')
" Slater Exponent",
"Completeness n-qm=", nlmin(l), &
2461 "Completeness n-qm=", nlmax(l)
2463 c1 = dot_product(sint(i, 1, 1:n, l), matmul(omat(1:n, 1:n, l), sint(i, 1, 1:n, l)))
2464 c2 = dot_product(sint(i, 2, 1:n, l), matmul(omat(1:n, 1:n, l), sint(i, 2, 1:n, l)))
2465 WRITE (iw,
"(T6,F14.6,T41,F10.6,T71,F10.6)") snl(l, i), c1, c2
2469 DEALLOCATE (omat, sfun, sint)
2481 REAL(kind=
dp),
INTENT(IN) :: rad
2482 REAL(kind=
dp),
INTENT(OUT) :: cnum
2484 INTEGER :: ia, ib,
imax, info, ix, iy, iz, ja, jb, &
2485 ka, kb, l, la, lb, lwork, na, nb, &
2487 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: ibptr
2488 REAL(kind=
dp) :: r1, r2, reps, rmax
2489 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: weig, work
2490 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat
2491 REAL(kind=
dp),
DIMENSION(2*lmat+1, 2*lmat+1) :: sab
2492 REAL(kind=
dp),
DIMENSION(3) :: rab
2493 REAL(kind=
dp),
DIMENSION(:),
POINTER :: zeta, zetb
2500 nbas = nbas + basis%nbas(l)*(2*l + 1)
2503 ALLOCATE (smat(nbas, nbas), ibptr(nbas, 0:
lmat))
2508 DO ia = 1, basis%nbas(l)
2509 ibptr(ia, l) = na + 1
2515 IF (basis%basis_type ==
gto_basis .OR. &
2518 na = basis%nprim(la)
2521 zeta => basis%am(:, la)
2523 nb = basis%nprim(lb)
2526 zetb => basis%am(:, lb)
2529 IF (rad < 0.1_dp)
THEN
2534 rmax = max(2._dp*r1, 2._dp*r2)
2535 imax = int(rmax/rad) + 1
2542 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) + sab(1:nna, 1:nnb)
2544 DO ka = 1, basis%nbas(la)
2545 DO kb = 1, basis%nbas(lb)
2548 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) + &
2549 sab(1:nna, 1:nnb)*basis%cm(ia, ka, la)*basis%cm(ib, kb, lb)
2560 CALL overlap_ab_s(la, zeta(ia), lb, zetb(ib), rab, sab)
2564 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = smat(ja:ja + nna - 1, jb:jb + nnb - 1) &
2567 DO ka = 1, basis%nbas(la)
2568 DO kb = 1, basis%nbas(lb)
2571 smat(ja:ja + nna - 1, jb:jb + nnb - 1) = &
2572 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)
2586 cpabort(
"Condition number not available for this basis type")
2590 lwork = max(nbas*nbas, nbas + 100)
2591 ALLOCATE (weig(nbas), work(lwork))
2593 CALL lapack_ssyev(
"N",
"U", nbas, smat, nbas, weig, work, lwork, info)
2595 IF (weig(1) < 0.0_dp)
THEN
2598 cnum = abs(weig(nbas)/weig(1))
2602 DEALLOCATE (smat, ibptr, weig, work)
2613 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: int
2614 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm
2616 CHARACTER(len=*),
PARAMETER :: routinen =
'contract2'
2618 INTEGER :: handle, m, n
2620 CALL timeset(routinen, handle)
2625 int(1:n, 1:n) = matmul(transpose(cm(1:m, 1:n)), matmul(omat(1:m, 1:m), cm(1:m, 1:n)))
2627 CALL timestop(handle)
2639 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: int
2640 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm
2642 CHARACTER(len=*),
PARAMETER :: routinen =
'contract2add'
2644 INTEGER :: handle, m, n
2646 CALL timeset(routinen, handle)
2651 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)))
2653 CALL timestop(handle)
2665 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) ::
eri
2666 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: omat, cm1, cm2
2668 CHARACTER(len=*),
PARAMETER :: routinen =
'contract4'
2670 INTEGER :: handle, i1, i2, m1, m2, mm1, mm2, n1, &
2672 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: amat, atran, bmat, btran, hint
2674 CALL timeset(routinen, handle)
2685 ALLOCATE (amat(m1, m1), atran(n1, n1), bmat(m2, m2), btran(n2, n2))
2686 ALLOCATE (hint(mm1, nn2))
2689 CALL iunpack(bmat(1:m2, 1:m2), omat(i1, 1:mm2), m2)
2690 CALL contract2(btran(1:n2, 1:n2), bmat(1:m2, 1:m2), cm2(1:m2, 1:n2))
2691 CALL ipack(btran(1:n2, 1:n2), hint(i1, 1:nn2), n2)
2695 CALL iunpack(amat(1:m1, 1:m1), hint(1:mm1, i2), m1)
2696 CALL contract2(atran(1:n1, 1:n1), amat(1:m1, 1:m1), cm1(1:m1, 1:n1))
2697 CALL ipack(atran(1:n1, 1:n1),
eri(1:nn1, i2), n1)
2700 DEALLOCATE (amat, atran, bmat, btran)
2703 CALL timestop(handle)
2713 PURE SUBROUTINE ipack(mat, vec, n)
2714 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: mat
2715 REAL(
dp),
DIMENSION(:),
INTENT(INOUT) :: vec
2716 INTEGER,
INTENT(IN) :: n
2728 END SUBROUTINE ipack
2736 PURE SUBROUTINE iunpack(mat, vec, n)
2737 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: mat
2738 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: vec
2739 INTEGER,
INTENT(IN) :: n
2752 END SUBROUTINE iunpack
static int imax(int x, int y)
Returns the larger of two given integer (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
Interface to the LAPACK F77 library.
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.
subroutine, public invmat_symm(a, cholesky_triangle)
returns inverse of real symmetric, positive definite matrix
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)*....
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.