37#include "./base/base_uses.f90"
43 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_operators'
62 eri_coulomb, eri_exchange, all_nu)
66 LOGICAL,
INTENT(IN),
OPTIONAL :: eri_coulomb, eri_exchange, all_nu
68 CHARACTER(len=*),
PARAMETER :: routinen =
'atom_int_setup'
70 INTEGER :: handle, i, ii, info, ipiv(1000), l, l1, &
71 l2, ll, lwork, m, m1, m2, mm1, mm2, n, &
72 n1, n2, nn1, nn2, nu, nx
73 REAL(kind=
dp) :: om, rc, ron, sc, x
74 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, w, work
75 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: omat, vmat
76 REAL(kind=
dp),
DIMENSION(:, :),
POINTER ::
eri
78 CALL timeset(routinen, handle)
80 IF (integrals%status == 0)
THEN
81 n = maxval(basis%nbas)
82 integrals%n = basis%nbas
84 IF (
PRESENT(eri_coulomb))
THEN
85 integrals%eri_coulomb = eri_coulomb
87 integrals%eri_coulomb = .false.
89 IF (
PRESENT(eri_exchange))
THEN
90 integrals%eri_exchange = eri_exchange
92 integrals%eri_exchange = .false.
94 IF (
PRESENT(all_nu))
THEN
95 integrals%all_nu = all_nu
97 integrals%all_nu = .false.
100 NULLIFY (integrals%ovlp, integrals%kin, integrals%core, integrals%conf)
101 DO ll = 1,
SIZE(integrals%ceri)
102 NULLIFY (integrals%ceri(ll)%int, integrals%eeri(ll)%int)
105 ALLOCATE (integrals%ovlp(n, n, 0:
lmat))
106 integrals%ovlp = 0._dp
108 ALLOCATE (integrals%kin(n, n, 0:
lmat))
109 integrals%kin = 0._dp
113 IF (
PRESENT(potential))
THEN
114 IF (potential%confinement)
THEN
115 ALLOCATE (integrals%conf(n, n, 0:
lmat))
116 integrals%conf = 0._dp
119 IF (potential%conf_type ==
poly_conf)
THEN
122 cpot(1:m) = (basis%grid%rad(1:m)/rc)**sc
128 IF (basis%grid%rad(i) < ron)
THEN
130 ELSEIF (basis%grid%rad(i) < rc)
THEN
131 x = (basis%grid%rad(i) - ron)/om
133 cpot(i) = -6._dp*x**5 + 15._dp*x**4 - 10._dp*x**3 + 1._dp
134 x = (rc - basis%grid%rad(i))**2/om/(basis%grid%rad(i) - ron)
148 SELECT CASE (basis%basis_type)
154 CALL sg_overlap(integrals%ovlp(1:n, 1:n, l), l, basis%am(1:n, l), basis%am(1:n, l))
155 CALL sg_kinetic(integrals%kin(1:n, 1:n, l), l, basis%am(1:n, l), basis%am(1:n, l))
157 IF (integrals%eri_coulomb)
THEN
161 nn1 = (n1*(n1 + 1))/2
164 nn2 = (n2*(n2 + 1))/2
165 IF (integrals%all_nu)
THEN
172 cpassert(ll <=
SIZE(integrals%ceri))
173 ALLOCATE (integrals%ceri(ll)%int(nn1, nn2))
174 integrals%ceri(ll)%int = 0._dp
175 eri => integrals%ceri(ll)%int
176 CALL sg_coulomb(
eri, nu, basis%am(1:n1, l1), l1, basis%am(1:n2, l2), l2)
181 IF (integrals%eri_exchange)
THEN
185 nn1 = (n1*(n1 + 1))/2
188 nn2 = (n2*(n2 + 1))/2
189 DO nu = abs(l1 - l2), l1 + l2, 2
191 cpassert(ll <=
SIZE(integrals%eeri))
192 ALLOCATE (integrals%eeri(ll)%int(nn1, nn2))
193 integrals%eeri(ll)%int = 0._dp
194 eri => integrals%eeri(ll)%int
195 CALL sg_exchange(
eri, nu, basis%am(1:n1, l1), l1, basis%am(1:n2, l2), l2)
204 IF (n > 0 .AND. m > 0)
THEN
205 ALLOCATE (omat(m, m))
207 CALL sg_overlap(omat(1:m, 1:m), l, basis%am(1:m, l), basis%am(1:m, l))
208 CALL contract2(integrals%ovlp(1:n, 1:n, l), omat(1:m, 1:m), basis%cm(1:m, 1:n, l))
209 CALL sg_kinetic(omat(1:m, 1:m), l, basis%am(1:m, l), basis%am(1:m, l))
210 CALL contract2(integrals%kin(1:n, 1:n, l), omat(1:m, 1:m), basis%cm(1:m, 1:n, l))
214 IF (integrals%eri_coulomb)
THEN
218 nn1 = (n1*(n1 + 1))/2
220 mm1 = (m1*(m1 + 1))/2
223 nn2 = (n2*(n2 + 1))/2
225 mm2 = (m2*(m2 + 1))/2
226 IF (integrals%all_nu)
THEN
233 cpassert(ll <=
SIZE(integrals%ceri))
234 ALLOCATE (integrals%ceri(ll)%int(nn1, nn2))
235 integrals%ceri(ll)%int = 0._dp
236 ALLOCATE (omat(mm1, mm2))
238 eri => integrals%ceri(ll)%int
239 CALL sg_coulomb(omat, nu, basis%am(1:m1, l1), l1, basis%am(1:m2, l2), l2)
240 CALL contract4(
eri, omat, basis%cm(1:m1, 1:n1, l1), basis%cm(1:m2, 1:n2, l2))
247 IF (integrals%eri_exchange)
THEN
251 nn1 = (n1*(n1 + 1))/2
253 mm1 = (m1*(m1 + 1))/2
256 nn2 = (n2*(n2 + 1))/2
258 mm2 = (m2*(m2 + 1))/2
259 DO nu = abs(l1 - l2), l1 + l2, 2
261 cpassert(ll <=
SIZE(integrals%eeri))
262 ALLOCATE (integrals%eeri(ll)%int(nn1, nn2))
263 integrals%eeri(ll)%int = 0._dp
264 ALLOCATE (omat(mm1, mm2))
266 eri => integrals%eeri(ll)%int
267 CALL sg_exchange(omat, nu, basis%am(1:m1, l1), l1, basis%am(1:m2, l2), l2)
268 CALL contract4(
eri, omat, basis%cm(1:m1, 1:n1, l1), basis%cm(1:m2, 1:n2, l2))
278 CALL sto_overlap(integrals%ovlp(1:n, 1:n, l), basis%ns(1:n, l), basis%as(1:n, l), &
279 basis%ns(1:n, l), basis%as(1:n, l))
280 CALL sto_kinetic(integrals%kin(1:n, 1:n, l), l, basis%ns(1:n, l), basis%as(1:n, l), &
281 basis%ns(1:n, l), basis%as(1:n, l))
283 cpassert(.NOT. integrals%eri_coulomb)
284 cpassert(.NOT. integrals%eri_exchange)
290 NULLIFY (integrals%utrans, integrals%uptrans)
291 n = maxval(basis%nbas)
292 ALLOCATE (integrals%utrans(n, n, 0:
lmat), integrals%uptrans(n, n, 0:
lmat))
293 integrals%utrans = 0._dp
294 integrals%uptrans = 0._dp
295 integrals%nne = integrals%n
297 ALLOCATE (omat(n, n), vmat(n, n), w(n), work(lwork))
301 omat(1:n, 1:n) = integrals%ovlp(1:n, 1:n, l)
302 CALL jacobi(omat(1:n, 1:n), w(1:n), vmat(1:n, 1:n))
303 omat(1:n, 1:n) = vmat(1:n, 1:n)
306 IF (w(i) > basis%eps_eig)
THEN
308 integrals%utrans(1:n, ii, l) = omat(1:n, i)/sqrt(w(i))
311 integrals%nne(l) = ii
313 omat(1:ii, 1:ii) = matmul(transpose(integrals%utrans(1:n, 1:ii, l)), integrals%utrans(1:n, 1:ii, l))
315 integrals%uptrans(i, i, l) = 1._dp
317 CALL dgesv(ii, ii, omat(1:ii, 1:ii), ii, ipiv, integrals%uptrans(1:ii, 1:ii, l), ii, info)
322 DEALLOCATE (omat, vmat, w, work)
325 CALL timestop(handle)
340 CHARACTER(len=*),
PARAMETER :: routinen =
'atom_ppint_setup'
342 INTEGER :: handle, i, ii, j, k, l, m, n
343 REAL(kind=
dp) :: al, alpha, rc
344 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, xmat
345 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: omat, spmat
346 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rad
348 CALL timeset(routinen, handle)
350 IF (integrals%ppstat == 0)
THEN
351 n = maxval(basis%nbas)
352 integrals%n = basis%nbas
354 NULLIFY (integrals%core, integrals%hnl)
356 ALLOCATE (integrals%hnl(n, n, 0:
lmat))
357 integrals%hnl = 0._dp
359 ALLOCATE (integrals%core(n, n, 0:
lmat))
360 integrals%core = 0._dp
362 ALLOCATE (integrals%clsd(n, n, 0:
lmat))
363 integrals%clsd = 0._dp
367 SELECT CASE (basis%basis_type)
372 SELECT CASE (potential%ppot_type)
376 CALL sg_nuclear(integrals%core(1:n, 1:n, l), l, basis%am(1:n, l), basis%am(1:n, l))
379 alpha = 1._dp/potential%gth_pot%rc/sqrt(2._dp)
382 ALLOCATE (omat(n, n), spmat(n, 5))
385 CALL sg_erf(omat(1:n, 1:n), l, alpha, basis%am(1:n, l), basis%am(1:n, l))
386 integrals%core(1:n, 1:n, l) = -potential%gth_pot%zion*omat(1:n, 1:n)
387 DO i = 1, potential%gth_pot%ncl
389 CALL sg_gpot(omat(1:n, 1:n), i - 1, potential%gth_pot%rc, l, basis%am(1:n, l), basis%am(1:n, l))
390 integrals%core(1:n, 1:n, l) = integrals%core(1:n, 1:n, l) + &
391 potential%gth_pot%cl(i)*omat(1:n, 1:n)
393 IF (potential%gth_pot%lpotextended)
THEN
394 DO k = 1, potential%gth_pot%nexp_lpot
395 DO i = 1, potential%gth_pot%nct_lpot(k)
397 CALL sg_gpot(omat(1:n, 1:n), i - 1, potential%gth_pot%alpha_lpot(k), l, &
398 basis%am(1:n, l), basis%am(1:n, l))
399 integrals%core(1:n, 1:n, l) = integrals%core(1:n, 1:n, l) + &
400 potential%gth_pot%cval_lpot(i, k)*omat(1:n, 1:n)
404 IF (potential%gth_pot%lsdpot)
THEN
405 DO k = 1, potential%gth_pot%nexp_lsd
406 DO i = 1, potential%gth_pot%nct_lsd(k)
408 CALL sg_gpot(omat(1:n, 1:n), i - 1, potential%gth_pot%alpha_lsd(k), l, &
409 basis%am(1:n, l), basis%am(1:n, l))
410 integrals%clsd(1:n, 1:n, l) = integrals%clsd(1:n, 1:n, l) + &
411 potential%gth_pot%cval_lsd(i, k)*omat(1:n, 1:n)
417 m = potential%gth_pot%nl(l)
419 CALL sg_proj_ol(spmat(1:n, i), l, basis%am(1:n, l), i - 1, potential%gth_pot%rcnl(l))
421 integrals%hnl(1:n, 1:n, l) = matmul(spmat(1:n, 1:m), &
422 matmul(potential%gth_pot%hnl(1:m, 1:m, l), transpose(spmat(1:n, 1:m))))
424 DEALLOCATE (omat, spmat)
427 CALL upfint_setup(integrals, basis, potential)
429 CALL sgpint_setup(integrals, basis, potential)
436 SELECT CASE (potential%ppot_type)
441 ALLOCATE (omat(m, m))
443 CALL sg_nuclear(omat(1:m, 1:m), l, basis%am(1:m, l), basis%am(1:m, l))
444 CALL contract2(integrals%core(1:n, 1:n, l), omat(1:m, 1:m), basis%cm(1:m, 1:n, l))
449 alpha = 1._dp/potential%gth_pot%rc/sqrt(2._dp)
453 IF (n > 0 .AND. m > 0)
THEN
454 ALLOCATE (omat(m, m), spmat(n, 5), xmat(m))
457 CALL sg_erf(omat(1:m, 1:m), l, alpha, basis%am(1:m, l), basis%am(1:m, l))
458 omat(1:m, 1:m) = -potential%gth_pot%zion*omat(1:m, 1:m)
459 CALL contract2(integrals%core(1:n, 1:n, l), omat(1:m, 1:m), basis%cm(1:m, 1:n, l))
460 DO i = 1, potential%gth_pot%ncl
462 CALL sg_gpot(omat(1:m, 1:m), i - 1, potential%gth_pot%rc, l, basis%am(1:m, l), basis%am(1:m, l))
463 omat(1:m, 1:m) = potential%gth_pot%cl(i)*omat(1:m, 1:m)
464 CALL contract2add(integrals%core(1:n, 1:n, l), omat(1:m, 1:m), basis%cm(1:m, 1:n, l))
466 IF (potential%gth_pot%lpotextended)
THEN
467 DO k = 1, potential%gth_pot%nexp_lpot
468 DO i = 1, potential%gth_pot%nct_lpot(k)
470 CALL sg_gpot(omat(1:m, 1:m), i - 1, potential%gth_pot%alpha_lpot(k), l, &
471 basis%am(1:m, l), basis%am(1:m, l))
472 omat(1:m, 1:m) = potential%gth_pot%cval_lpot(i, k)*omat(1:m, 1:m)
473 CALL contract2add(integrals%core(1:n, 1:n, l), omat(1:m, 1:m), basis%cm(1:m, 1:n, l))
477 IF (potential%gth_pot%lsdpot)
THEN
478 DO k = 1, potential%gth_pot%nexp_lsd
479 DO i = 1, potential%gth_pot%nct_lsd(k)
481 CALL sg_gpot(omat(1:m, 1:m), i - 1, potential%gth_pot%alpha_lsd(k), l, &
482 basis%am(1:m, l), basis%am(1:m, l))
483 omat(1:m, 1:m) = potential%gth_pot%cval_lsd(i, k)*omat(1:m, 1:m)
484 CALL contract2add(integrals%clsd(1:n, 1:n, l), omat(1:m, 1:m), basis%cm(1:m, 1:n, l))
490 k = potential%gth_pot%nl(l)
492 CALL sg_proj_ol(xmat(1:m), l, basis%am(1:m, l), i - 1, potential%gth_pot%rcnl(l))
493 spmat(1:n, i) = matmul(transpose(basis%cm(1:m, 1:n, l)), xmat(1:m))
496 integrals%hnl(1:n, 1:n, l) = matmul(spmat(1:n, 1:k), &
497 matmul(potential%gth_pot%hnl(1:k, 1:k, l), &
498 transpose(spmat(1:n, 1:k))))
500 DEALLOCATE (omat, spmat, xmat)
504 CALL upfint_setup(integrals, basis, potential)
506 CALL sgpint_setup(integrals, basis, potential)
513 SELECT CASE (potential%ppot_type)
517 CALL sto_nuclear(integrals%core(1:n, 1:n, l), basis%ns(1:n, l), basis%as(1:n, l), &
518 basis%ns(1:n, l), basis%as(1:n, l))
521 rad => basis%grid%rad
524 rc = potential%gth_pot%rc
525 alpha = 1._dp/rc/sqrt(2._dp)
528 integrals%core = 0._dp
530 cpot(i) = potential%gth_pot%zion*erfc(alpha*rad(i))/rad(i)
532 DO i = 1, potential%gth_pot%ncl
534 cpot(1:m) = cpot(1:m) + potential%gth_pot%cl(i)*(rad/rc)**ii*exp(-0.5_dp*(rad/rc)**2)
536 IF (potential%gth_pot%lpotextended)
THEN
537 DO k = 1, potential%gth_pot%nexp_lpot
538 al = potential%gth_pot%alpha_lpot(k)
539 DO i = 1, potential%gth_pot%nct_lpot(k)
541 cpot(1:m) = cpot(1:m) + potential%gth_pot%cval_lpot(i, k)*(rad/al)**ii*exp(-0.5_dp*(rad/al)**2)
548 ALLOCATE (omat(n, n))
550 CALL sto_nuclear(omat(1:n, 1:n), basis%ns(1:n, l), basis%as(1:n, l), &
551 basis%ns(1:n, l), basis%as(1:n, l))
552 integrals%core(1:n, 1:n, l) = integrals%core(1:n, 1:n, l) - potential%gth_pot%zion*omat(1:n, 1:n)
556 IF (potential%gth_pot%lsdpot)
THEN
558 DO k = 1, potential%gth_pot%nexp_lsd
559 al = potential%gth_pot%alpha_lsd(k)
560 DO i = 1, potential%gth_pot%nct_lsd(k)
562 cpot(:) = cpot + potential%gth_pot%cval_lsd(i, k)*(rad/al)**ii*exp(-0.5_dp*(rad/al)**2)
571 ALLOCATE (spmat(n, 5))
573 k = potential%gth_pot%nl(l)
575 rc = potential%gth_pot%rcnl(l)
576 cpot(:) =
sqrt2/sqrt(
gamma1(l + 2*i - 1))*rad**(l + 2*i - 2)*exp(-0.5_dp*(rad/rc)**2)/rc**(l + 2*i - 0.5_dp)
577 DO j = 1, basis%nbas(l)
581 integrals%hnl(1:n, 1:n, l) = matmul(spmat(1:n, 1:k), &
582 matmul(potential%gth_pot%hnl(1:k, 1:k, l), &
583 transpose(spmat(1:n, 1:k))))
589 CALL upfint_setup(integrals, basis, potential)
591 CALL sgpint_setup(integrals, basis, potential)
603 integrals%core = -potential%ecp_pot%zion*integrals%core
606 rad => basis%grid%rad
609 DO k = 1, potential%ecp_pot%nloc
610 n = potential%ecp_pot%nrloc(k)
611 alpha = potential%ecp_pot%bloc(k)
612 cpot(:) = cpot + potential%ecp_pot%aloc(k)*rad**(n - 2)*exp(-alpha*rad**2)
616 DO l = 0, min(potential%ecp_pot%lmax,
lmat)
618 DO k = 1, potential%ecp_pot%npot(l)
619 n = potential%ecp_pot%nrpot(k, l)
620 alpha = potential%ecp_pot%bpot(k, l)
621 cpot(:) = cpot + potential%ecp_pot%apot(k, l)*rad**(n - 2)*exp(-alpha*rad**2)
623 DO i = 1, basis%nbas(l)
624 DO j = i, basis%nbas(l)
625 integrals%hnl(i, j, l) =
integrate_grid(cpot, basis%bf(:, i, l), basis%bf(:, j, l), basis%grid)
626 integrals%hnl(j, i, l) = integrals%hnl(i, j, l)
635 CALL timestop(handle)
645 SUBROUTINE upfint_setup(integrals, basis, potential)
650 CHARACTER(len=4) :: ptype
651 INTEGER :: i, j, k1, k2, la, lb, m, n
652 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: spot
653 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: spmat
660 integrals%core = 0._dp
661 CALL numpot_matrix(integrals%core, potential%upf_pot%vlocal, gbasis, 0)
663 ptype = adjustl(trim(potential%upf_pot%pseudo_type))
664 IF (ptype(1:2) ==
"NC" .OR. ptype(1:2) ==
"US")
THEN
666 n = maxval(integrals%n(:))
667 m = potential%upf_pot%number_of_proj
668 ALLOCATE (spmat(n, m))
671 la = potential%upf_pot%lbeta(i)
672 DO j = 1, gbasis%nbas(la)
673 spmat(j, i) =
integrate_grid(potential%upf_pot%beta(:, i), gbasis%bf(:, j, la), gbasis%grid)
677 la = potential%upf_pot%lbeta(i)
679 lb = potential%upf_pot%lbeta(j)
681 DO k1 = 1, gbasis%nbas(la)
682 DO k2 = 1, gbasis%nbas(la)
683 integrals%hnl(k1, k2, la) = integrals%hnl(k1, k2, la) + &
684 spmat(k1, i)*potential%upf_pot%dion(i, j)*spmat(k2, j)
691 ELSE IF (ptype(1:2) ==
"SL")
THEN
693 DO la = 0, potential%upf_pot%l_max
694 IF (la == potential%upf_pot%l_local) cycle
695 m =
SIZE(potential%upf_pot%vsemi(:, la + 1))
697 spot(:) = potential%upf_pot%vsemi(:, la + 1) - potential%upf_pot%vlocal(:)
701 integrals%core(i, j, la) = integrals%core(i, j, la) + &
703 gbasis%bf(:, i, la), gbasis%bf(:, j, la), gbasis%grid)
704 integrals%core(j, i, la) = integrals%core(i, j, la)
710 cpabort(
"Pseudopotential type: ["//adjustl(trim(ptype))//
"] not known")
716 END SUBROUTINE upfint_setup
724 SUBROUTINE sgpint_setup(integrals, basis, potential)
729 INTEGER :: i, ia, j, l, m, n, na
730 REAL(kind=
dp) :: a, c, rc, zval
731 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot, pgauss
732 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: qmat
733 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rad
735 rad => basis%grid%rad
739 integrals%core = 0._dp
742 zval = potential%sgp_pot%zion
744 rc = rad(i)/potential%sgp_pot%ac_local/sqrt(2.0_dp)
745 cpot(i) = cpot(i) - zval/rad(i)*erf(rc)
747 DO i = 1, potential%sgp_pot%n_local
748 cpot(:) = cpot(:) + potential%sgp_pot%c_local(i)*exp(-potential%sgp_pot%a_local(i)*rad(:)**2)
754 integrals%hnl = 0.0_dp
755 IF (potential%sgp_pot%has_nonlocal)
THEN
756 ALLOCATE (pgauss(1:m))
757 n = potential%sgp_pot%n_nonlocal
759 DO l = 0, potential%sgp_pot%lmax
760 cpassert(l <= ubound(basis%nbas, 1))
761 IF (.NOT. potential%sgp_pot%is_nonlocal(l)) cycle
764 ALLOCATE (qmat(na, n))
768 a = potential%sgp_pot%a_nonlocal(j)
769 c = potential%sgp_pot%c_nonlocal(j, i, l)
770 pgauss(:) = pgauss(:) + c*exp(-a*rad(:)**2)*rad(:)**l
773 qmat(ia, i) = sum(basis%bf(:, ia, l)*pgauss(:)*basis%grid%wr(:))
779 integrals%hnl(i, j, l) = integrals%hnl(i, j, l) &
780 + qmat(i, ia)*qmat(j, ia)*potential%sgp_pot%h_nonlocal(ia, l)
782 integrals%hnl(j, i, l) = integrals%hnl(i, j, l)
790 END SUBROUTINE sgpint_setup
803 INTEGER,
INTENT(IN) :: reltyp
804 REAL(
dp),
INTENT(IN) :: zcore
805 REAL(
dp),
INTENT(IN),
OPTIONAL :: alpha
807 CHARACTER(len=*),
PARAMETER :: routinen =
'atom_relint_setup'
809 INTEGER :: dkhorder, handle, i, k1, k2, l, m, n, nl
811 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: cpot
812 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: modpot
813 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ener, sps
814 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: hmat, pvp,
sp, tp, vp, wfn
816 CALL timeset(routinen, handle)
838 NULLIFY (integrals%tzora, integrals%hdkh)
841 NULLIFY (integrals%hdkh)
843 IF (integrals%zorastat == 0)
THEN
844 n = maxval(basis%nbas)
845 ALLOCATE (integrals%tzora(n, n, 0:
lmat))
846 integrals%tzora = 0._dp
848 ALLOCATE (modpot(1:m), cpot(1:m))
852 cpot(1:m) = cpot(1:m)/basis%grid%rad2(1:m)
856 integrals%tzora(1:nl, 1:nl, l) = real(l*(l + 1),
dp)*integrals%tzora(1:nl, 1:nl, l)
858 cpot(1:m) = cpot(1:m)*basis%grid%rad2(1:m)
863 ALLOCATE (hmat(n, n, 0:
lmat), wfn(n, n, 0:
lmat), ener(n, 0:
lmat), pvp(n, n, 0:
lmat), sps(n, n))
864 hmat(:, :, :) = integrals%kin + integrals%tzora
868 CALL atom_solve(hmat, integrals%utrans, wfn, ener, basis%nbas, integrals%nne,
lmat)
871 cpot(1:m) = cpot(1:m)/basis%grid%rad2(1:m)
876 pvp(1:nl, 1:nl, l) = real(l*(l + 1),
dp)*pvp(1:nl, 1:nl, l)
878 cpot(1:m) = cpot(1:m)*basis%grid%rad2(1:m)
884 DO i = 1, integrals%nne(l)
885 IF (ener(i, l) < 0._dp)
THEN
886 ascal = sum(wfn(1:nl, i, l)*matmul(pvp(1:nl, 1:nl, l), wfn(1:nl, i, l)))
887 ener(i, l) = ener(i, l)*ascal/(1.0_dp + ascal)
897 DO i = 1, integrals%nne(l)
900 hmat(k1, k2, l) = hmat(k1, k2, l) + ener(i, l)*wfn(k1, i, l)*wfn(k2, i, l)
905 sps(1:nl, 1:nl) = matmul(integrals%ovlp(1:nl, 1:nl, l), &
906 matmul(hmat(1:nl, 1:nl, l), integrals%ovlp(1:nl, 1:nl, l)))
908 integrals%tzora(1:nl, 1:nl, l) = integrals%tzora(1:nl, 1:nl, l) - sps(1:nl, 1:nl)
911 DEALLOCATE (hmat, wfn, ener, pvp, sps)
914 DEALLOCATE (modpot, cpot)
916 integrals%zorastat = 1
922 NULLIFY (integrals%tzora)
924 IF (integrals%dkhstat == 0)
THEN
925 n = maxval(basis%nbas)
926 ALLOCATE (integrals%hdkh(n, n, 0:
lmat))
927 integrals%hdkh = 0._dp
929 m = maxval(basis%nprim)
930 ALLOCATE (tp(m, m, 0:
lmat),
sp(m, m, 0:
lmat), vp(m, m, 0:
lmat), pvp(m, m, 0:
lmat))
936 SELECT CASE (basis%basis_type)
944 CALL sg_kinetic(tp(1:m, 1:m, l), l, basis%am(1:m, l), basis%am(1:m, l))
945 CALL sg_overlap(
sp(1:m, 1:m, l), l, basis%am(1:m, l), basis%am(1:m, l))
946 IF (
PRESENT(alpha))
THEN
947 CALL sg_erfc(vp(1:m, 1:m, l), l, alpha, basis%am(1:m, l), basis%am(1:m, l))
949 CALL sg_nuclear(vp(1:m, 1:m, l), l, basis%am(1:m, l), basis%am(1:m, l))
951 CALL sg_kinnuc(pvp(1:m, 1:m, l), l, basis%am(1:m, l), basis%am(1:m, l))
952 vp(1:m, 1:m, l) = -zcore*vp(1:m, 1:m, l)
953 pvp(1:m, 1:m, l) = -zcore*pvp(1:m, 1:m, l)
963 CALL dkh_integrals(integrals, basis, dkhorder,
sp, tp, vp, pvp)
965 integrals%dkhstat = 1
967 DEALLOCATE (tp,
sp, vp, pvp)
970 cpassert(
ASSOCIATED(integrals%hdkh))
975 CALL timestop(handle)
989 SUBROUTINE dkh_integrals(integrals, basis, order, sp, tp, vp, pvp)
992 INTEGER,
INTENT(IN) :: order
993 REAL(
dp),
DIMENSION(:, :, 0:) ::
sp, tp, vp, pvp
996 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: hdkh
1000 hdkh => integrals%hdkh
1006 CALL dkh_atom_transformation(
sp(1:m, 1:m, l), vp(1:m, 1:m, l), tp(1:m, 1:m, l), pvp(1:m, 1:m, l), m, order)
1007 SELECT CASE (basis%basis_type)
1012 integrals%hdkh(1:n, 1:n, l) = tp(1:n, 1:n, l) + vp(1:n, 1:n, l)
1014 CALL contract2(integrals%hdkh(1:n, 1:n, l), tp(1:m, 1:m, l), basis%cm(1:m, 1:n, l))
1015 CALL contract2add(integrals%hdkh(1:n, 1:n, l), vp(1:m, 1:m, l), basis%cm(1:m, 1:n, l))
1022 integrals%hdkh(1:n, 1:n, l) = 0._dp
1026 END SUBROUTINE dkh_integrals
1035 REAL(kind=
dp),
DIMENSION(:, :, 0:),
INTENT(OUT) :: ovlap
1038 INTEGER :: i, j, l, ma, mb, na, nb
1040 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: omat
1042 ebas = (basis_a%basis_type == basis_b%basis_type)
1047 SELECT CASE (basis_a%basis_type)
1052 na = basis_a%nbas(l)
1053 nb = basis_b%nbas(l)
1054 CALL sg_overlap(ovlap(1:na, 1:nb, l), l, basis_a%am(1:na, l), basis_b%am(1:nb, l))
1058 na = basis_a%nbas(l)
1059 nb = basis_b%nbas(l)
1060 ma = basis_a%nprim(l)
1061 mb = basis_b%nprim(l)
1062 ALLOCATE (omat(ma, mb))
1063 CALL sg_overlap(omat(1:ma, 1:mb), l, basis_a%am(1:ma, l), basis_b%am(1:mb, l))
1064 ovlap(1:na, 1:nb, l) = matmul(transpose(basis_a%cm(1:ma, 1:na, l)), &
1065 matmul(omat(1:ma, 1:mb), basis_b%cm(1:mb, 1:nb, l)))
1070 na = basis_a%nbas(l)
1071 nb = basis_b%nbas(l)
1072 CALL sto_overlap(ovlap(1:na, 1:nb, l), basis_a%ns(1:na, l), basis_b%as(1:nb, l), &
1073 basis_a%ns(1:na, l), basis_b%as(1:nb, l))
1078 na = basis_a%nbas(l)
1079 nb = basis_b%nbas(l)
1082 ovlap(i, j, l) =
integrate_grid(basis_a%bf(:, i, l), basis_b%bf(:, j, l), basis_a%grid)
1090 na = basis_a%nbas(l)
1091 nb = basis_b%nbas(l)
1094 ovlap(i, j, l) =
integrate_grid(basis_a%bf(:, i, l), basis_b%bf(:, j, l), basis_a%grid)
1111 IF (
ASSOCIATED(integrals%ovlp))
THEN
1112 DEALLOCATE (integrals%ovlp)
1114 IF (
ASSOCIATED(integrals%kin))
THEN
1115 DEALLOCATE (integrals%kin)
1117 IF (
ASSOCIATED(integrals%conf))
THEN
1118 DEALLOCATE (integrals%conf)
1120 DO ll = 1,
SIZE(integrals%ceri)
1121 IF (
ASSOCIATED(integrals%ceri(ll)%int))
THEN
1122 DEALLOCATE (integrals%ceri(ll)%int)
1124 IF (
ASSOCIATED(integrals%eeri(ll)%int))
THEN
1125 DEALLOCATE (integrals%eeri(ll)%int)
1128 IF (
ASSOCIATED(integrals%utrans))
THEN
1129 DEALLOCATE (integrals%utrans)
1131 IF (
ASSOCIATED(integrals%uptrans))
THEN
1132 DEALLOCATE (integrals%uptrans)
1135 integrals%status = 0
1146 IF (
ASSOCIATED(integrals%hnl))
THEN
1147 DEALLOCATE (integrals%hnl)
1149 IF (
ASSOCIATED(integrals%core))
THEN
1150 DEALLOCATE (integrals%core)
1152 IF (
ASSOCIATED(integrals%clsd))
THEN
1153 DEALLOCATE (integrals%clsd)
1156 integrals%ppstat = 0
1167 IF (
ASSOCIATED(integrals%tzora))
THEN
1168 DEALLOCATE (integrals%tzora)
1170 IF (
ASSOCIATED(integrals%hdkh))
THEN
1171 DEALLOCATE (integrals%hdkh)
1174 integrals%zorastat = 0
1175 integrals%dkhstat = 0
1186 REAL(
dp),
DIMENSION(:),
INTENT(INOUT) :: modpot
1188 REAL(
dp),
INTENT(IN) :: zcore
1190 INTEGER :: i, ii, l, ll, n, z
1191 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: pot, rho
1195 ALLOCATE (rho(n), pot(n))
1200 state%multiplicity = -1
1202 DO l = 0, min(
lmat, ubound(
ptable(z)%e_conv, 1))
1203 IF (
ptable(z)%e_conv(l) /= 0)
THEN
1206 DO i = 1,
SIZE(state%occ, 2)
1207 ii =
ptable(z)%e_conv(l) - (i - 1)*ll
1209 state%occ(l, i) = ii
1212 state%occ(l, i) = ll
1218 modpot = -zcore/grid%rad(:)
1223 modpot = modpot + pot
1227 modpot = modpot + pot
1229 DEALLOCATE (rho, pot)
subroutine, public sg_kinnuc(umat, l, pa, pb)
...
subroutine, public sg_nuclear(umat, l, pa, pb)
...
subroutine, public sg_coulomb(eri, nu, pa, lab, pc, lcd)
...
subroutine, public sg_exchange(eri, nu, pa, lac, pb, lbd)
...
subroutine, public sg_erfc(umat, l, a, pa, pb)
...
subroutine, public sg_kinetic(kmat, l, pa, pb)
...
subroutine, public sto_nuclear(umat, na, pa, nb, pb)
...
subroutine, public sto_overlap(smat, na, pa, nb, pb)
...
subroutine, public sto_kinetic(kmat, l, na, pa, nb, pb)
...
subroutine, public sg_gpot(vpmat, k, rc, l, pa, pb)
...
subroutine, public sg_proj_ol(spmat, l, p, k, rc)
...
subroutine, public sg_erf(upmat, l, a, pa, pb)
...
subroutine, public sg_overlap(smat, l, pa, pb)
...
Calculate the atomic operator matrices.
subroutine, public atom_ppint_release(integrals)
Release memory allocated for atomic integrals (core electrons).
subroutine, public atom_int_setup(integrals, basis, potential, eri_coulomb, eri_exchange, all_nu)
Set up atomic integrals.
subroutine, public atom_relint_setup(integrals, basis, reltyp, zcore, alpha)
...
subroutine, public atom_relint_release(integrals)
Release memory allocated for atomic integrals (relativistic effects).
subroutine, public atom_basis_projection_overlap(ovlap, basis_a, basis_b)
Calculate overlap matrix between two atomic basis sets.
subroutine, public atom_ppint_setup(integrals, basis, potential)
...
subroutine, public calculate_model_potential(modpot, grid, zcore)
Calculate model potential. It is useful to guess atomic orbitals.
subroutine, public atom_int_release(integrals)
Release memory allocated for atomic integrals (valence electrons).
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
logical function, public atom_compare_grids(grid1, grid2)
...
integer, parameter, public lmat
subroutine, public release_atom_basis(basis)
...
subroutine, public atom_basis_gridrep(basis, gbasis, r, rab)
...
Some basic routines for atomic calculations.
subroutine, public slater_density(density1, density2, zcore, state, grid)
Calculate Slater density on a radial grid.
subroutine, public contract2(int, omat, cm)
Transform a matrix expressed in terms of a uncontracted basis set to a contracted one.
pure subroutine, public wigner_slater_functional(rho, vxc)
Calculate the functional derivative of the Wigner (correlation) - Slater (exchange) density functiona...
subroutine, public contract4(eri, omat, cm1, cm2)
Contract a matrix of Electron Repulsion Integrals (ERI-s).
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 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.
subroutine, public dkh_atom_transformation(s, v, h, pvp, n, dkh_order)
...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public sp
Definition of mathematical constants and functions.
real(kind=dp), dimension(0:maxfac), parameter, public gamma1
real(kind=dp), parameter, public sqrt2
Collection of simple mathematical functions and subroutines.
subroutine, public jacobi(a, d, v)
Jacobi matrix diagonalization. The eigenvalues are returned in vector d and the eigenvectors are retu...
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
Definition of physical constants:
real(kind=dp), parameter, public c_light_au
Provides all information about a basis set.
Provides all information on states and occupation.