58#include "./base/base_uses.f90"
64 CHARACTER(LEN=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_kind_orbitals'
103 density, wavefunction, wfninfo, confine, xc_section, nocc, &
104 which_l, which_n, proj_shell_charge, ao_coef)
108 INTEGER,
INTENT(IN),
OPTIONAL :: iunit
109 REAL(kind=
dp),
DIMENSION(:, :, :),
OPTIONAL, &
110 POINTER :: pmat, fmat
111 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: density
112 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: wavefunction, wfninfo
113 LOGICAL,
INTENT(IN),
OPTIONAL :: confine
115 INTEGER,
DIMENSION(:),
OPTIONAL :: nocc
116 INTEGER,
INTENT(IN),
OPTIONAL :: which_l, which_n
117 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: proj_shell_charge(4)
118 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT), &
119 OPTIONAL,
POINTER :: ao_coef
121 INTEGER :: i, ii, j, k, k1, k2, l, ll, m, mb, mo, &
122 nr, nset, nsgf, projector_index, &
124 INTEGER,
DIMENSION(0:lmat) :: nbb
125 INTEGER,
DIMENSION(0:lmat, 10) :: ncalc, ncore,
nelem
126 INTEGER,
DIMENSION(0:lmat, 100) :: set_index, shell_index
127 INTEGER,
DIMENSION(:),
POINTER :: nshell
128 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, ls
129 LOGICAL :: ecp_semi_local, ghost, has_pp, uks
130 REAL(kind=
dp) :: ok, qleft, scal, take, zeff
131 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: occupation_neutral
132 REAL(kind=
dp),
DIMENSION(0:lmat, 10, 2) :: edelta
143 IF (
PRESENT(ao_coef) .OR.
PRESENT(which_l) .OR. &
144 PRESENT(which_n) .OR.
PRESENT(proj_shell_charge))
THEN
145 IF (.NOT.
PRESENT(ao_coef) .OR. .NOT.
PRESENT(which_l) .OR. &
146 .NOT.
PRESENT(which_n) .OR. .NOT.
PRESENT(proj_shell_charge))
THEN
147 cpabort(
"ao_coef, which_l, which_n, and proj_shell_charge must be provided together")
154 IF (
PRESENT(xc_section))
THEN
155 atom%xc_section => xc_section
157 NULLIFY (
atom%xc_section)
161 NULLIFY (all_potential, gth_potential, sgp_potential, orb_basis_set)
163 basis_set=orb_basis_set, &
165 all_potential=all_potential, &
166 gth_potential=gth_potential, &
167 sgp_potential=sgp_potential)
169 has_pp =
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential)
181 ALLOCATE (potential, integrals)
183 IF (
PRESENT(confine))
THEN
184 potential%confinement = confine
186 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
187 potential%confinement = .true.
189 potential%confinement = .false.
193 potential%acon = 0.1_dp
194 potential%rcon = 2.0_dp*
ptable(z)%vdw_radius*
bohr
195 potential%scon = 2.0_dp
197 IF (
ASSOCIATED(gth_potential))
THEN
201 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
202 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
203 CALL get_potential(sgp_potential, ecp_semi_local=ecp_semi_local)
204 IF (
ALLOCATED(sgp_potential%upf_data))
THEN
206 potential%upf_pot = sgp_potential%upf_data
207 ELSE IF (ecp_semi_local)
THEN
209 CALL ecp_potential_conversion(sgp_potential, potential%ecp_pot)
210 potential%ecp_pot%symbol =
ptable(z)%symbol
214 potential%sgp_pot%symbol =
ptable(z)%symbol
217 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
240 rks=
PRESENT(ao_coef))
243 IF (sum(abs(edelta)) > 0.0_dp)
THEN
251 ALLOCATE (
atom%state)
253 atom%state%core = 0._dp
255 atom%state%occ = 0._dp
258 edelta(0:
lmat, 1:7, 1) + edelta(0:
lmat, 1:7, 2)
262 atom%state%occupation = 0._dp
266 IF (ncalc(l, i) > 0)
THEN
269 atom%state%occupation(l, k) = real(ncalc(l, i),
dp) + &
270 edelta(l, i, 1) + edelta(l, i, 2)
271 atom%state%occa(l, k) = 0.5_dp*real(ncalc(l, i),
dp) + edelta(l, i, 1)
272 atom%state%occb(l, k) = 0.5_dp*real(ncalc(l, i),
dp) + edelta(l, i, 2)
274 atom%state%occupation(l, k) = real(ncalc(l, i),
dp)
278 ok = real(2*l + 1, kind=
dp)
281 atom%state%occ(l, i) = min(
atom%state%occ(l, i), 2.0_dp*ok)
282 atom%state%occa(l, i) = min(
atom%state%occa(l, i), ok)
283 atom%state%occb(l, i) = min(
atom%state%occb(l, i), ok)
284 atom%state%occupation(l, i) =
atom%state%occa(l, i) +
atom%state%occb(l, i)
288 atom%state%occ(l, i) = min(
atom%state%occ(l, i), 2.0_dp*ok)
289 atom%state%occupation(l, i) = min(
atom%state%occupation(l, i), 2.0_dp*ok)
294 IF (
PRESENT(proj_shell_charge))
THEN
296 occupation_neutral(0:
lmat, 1:10) =
atom%state%occupation(0:
lmat, 1:10)
298 CALL cp_abort(__location__,
"proj_shell_charge in"// &
299 " calculate_atomic_orbitals is implemented only for RKS")
301 DO l = 0, min(3,
lmat)
302 qleft = proj_shell_charge(l + 1)
303 IF (qleft > 0.0_dp)
THEN
306 IF (
atom%state%occupation(l, k) > 0.0_dp)
THEN
307 take = min(qleft,
atom%state%occupation(l, k))
308 atom%state%occupation(l, k) =
atom%state%occupation(l, k) - take
310 IF (qleft <= 1.0e-12_dp)
EXIT
313 IF (qleft > 1.0e-10_dp)
THEN
314 CALL cp_abort(__location__,
"proj_shell_charge removes"// &
315 " more electrons than available in this angular channel")
318 qleft = proj_shell_charge(l + 1)
320 IF (
atom%state%occ(l, k) > 0.0_dp)
THEN
321 take = min(qleft,
atom%state%occ(l, k))
322 atom%state%occ(l, k) =
atom%state%occ(l, k) - take
324 IF (qleft <= 1.0e-12_dp)
EXIT
327 ELSE IF (qleft < 0.0_dp)
THEN
328 CALL cp_abort(__location__,
"Negative proj_shell_charge"// &
329 " is not supported in this implementation")
335 atom%state%multiplicity = nint(abs(sum(
atom%state%occa -
atom%state%occb)) + 1)
337 atom%state%multiplicity = -1
342 IF (
PRESENT(proj_shell_charge))
THEN
346 atom%state%maxl_calc =
atom%state%maxl_occ
347 atom%state%maxn_calc =
atom%state%maxn_occ
351 IF (
PRESENT(nocc) .AND. ghost)
THEN
353 ELSE IF (
PRESENT(nocc))
THEN
358 IF (
atom%state%occa(l, k) > 0.0_dp)
THEN
359 nocc(1) = nocc(1) + 2*l + 1
361 IF (
atom%state%occb(l, k) > 0.0_dp)
THEN
362 nocc(2) = nocc(2) + 2*l + 1
365 IF (
atom%state%occupation(l, k) > 0.0_dp)
THEN
366 nocc(1) = nocc(1) + 2*l + 1
367 nocc(2) = nocc(2) + 2*l + 1
382 NULLIFY (integrals%tzora, integrals%hdkh)
387 mo = maxval(
atom%state%maxn_calc)
388 mb = maxval(
atom%basis%nbas)
392 IF (.NOT. ghost)
THEN
393 IF (
PRESENT(iunit))
THEN
399 IF (
PRESENT(pmat))
THEN
402 nset=nset, nshell=nshell, l=ls, nsgf=nsgf, first_sgf=first_sgf)
414 shell_index(l, k) = j
419 IF (
ASSOCIATED(pmat))
THEN
422 ALLOCATE (pmat(nsgf, nsgf, 2))
424 IF (.NOT. ghost)
THEN
427 DO k1 = 1,
atom%basis%nbas(l)
428 DO k2 = 1,
atom%basis%nbas(l)
429 scal = sqrt(
atom%integrals%ovlp(k1, k1, l)*
atom%integrals%ovlp(k2, k2, l))/real(2*l + 1, kind=
dp)
430 i = first_sgf(shell_index(l, k1), set_index(l, k1))
431 j = first_sgf(shell_index(l, k2), set_index(l, k2))
434 pmat(i + m, j + m, 1) =
atom%orbitals%pmata(k1, k2, l)*scal
435 pmat(i + m, j + m, 2) =
atom%orbitals%pmatb(k1, k2, l)*scal
439 pmat(i + m, j + m, 1) =
atom%orbitals%pmat(k1, k2, l)*scal
446 pmat(:, :, 1) = pmat(:, :, 1) + pmat(:, :, 2)
447 pmat(:, :, 2) = pmat(:, :, 1) - 2.0_dp*pmat(:, :, 2)
452 IF (
PRESENT(fmat))
THEN
456 nset=nset, nshell=nshell, l=ls, nsgf=nsgf, first_sgf=first_sgf)
468 shell_index(l, k) = j
472 IF (uks) cpabort(
"calculate_atomic_orbitals: only RKS is implemented")
473 IF (
ASSOCIATED(fmat)) cpabort(
"fmat already associated")
474 IF (.NOT.
ASSOCIATED(
atom%fmat)) cpabort(
"atom%fmat not associated")
475 ALLOCATE (fmat(nsgf, nsgf, 1))
477 IF (.NOT. ghost)
THEN
480 DO k1 = 1,
atom%basis%nbas(l)
481 DO k2 = 1,
atom%basis%nbas(l)
482 scal = sqrt(
atom%integrals%ovlp(k1, k1, l)*
atom%integrals%ovlp(k2, k2, l))
483 i = first_sgf(shell_index(l, k1), set_index(l, k1))
484 j = first_sgf(shell_index(l, k2), set_index(l, k2))
486 fmat(i + m, j + m, 1) =
atom%fmat%op(k1, k2, l)/scal
496 IF (
PRESENT(density))
THEN
497 IF (
ASSOCIATED(density))
DEALLOCATE (density)
498 ALLOCATE (density(nr))
506 IF (
PRESENT(wavefunction))
THEN
507 cpassert(
PRESENT(wfninfo))
508 IF (
ASSOCIATED(wavefunction))
DEALLOCATE (wavefunction)
509 IF (
ASSOCIATED(wfninfo))
DEALLOCATE (wfninfo)
510 mo = sum(
atom%state%maxn_occ)
511 ALLOCATE (wavefunction(nr, mo), wfninfo(2, mo))
512 wavefunction = 0.0_dp
513 IF (.NOT. ghost)
THEN
516 DO i = 1,
atom%state%maxn_occ(l)
517 IF (
atom%state%occupation(l, i) > 0.0_dp)
THEN
519 wfninfo(1, ii) =
atom%state%occupation(l, i)
520 wfninfo(2, ii) = real(l,
dp)
521 DO j = 1,
atom%basis%nbas(l)
522 wavefunction(:, ii) = wavefunction(:, ii) + &
523 atom%orbitals%wfn(j, i, l)*basis%bf(:, j, l)
532 IF (
PRESENT(ao_coef))
THEN
533 cpassert(
PRESENT(which_l))
534 cpassert(
PRESENT(which_n))
535 cpassert(which_l >= 0 .AND. which_l <=
lmat)
536 valence_n = count(ncore(which_l, :) > 0) + which_l + 1
537 projector_index = which_n - valence_n + 1
538 IF (projector_index < 1 .OR. projector_index >
SIZE(
atom%orbitals%wfn, 2))
THEN
539 CALL cp_abort(__location__, &
540 "The requested tensorial atomic projector N is outside "// &
541 "the available orbital range for the selected L.")
543 IF (
ASSOCIATED(ao_coef))
DEALLOCATE (ao_coef)
544 ALLOCATE (ao_coef(
SIZE(
atom%orbitals%wfn(:, 1, which_l))))
545 ao_coef(:) =
atom%orbitals%wfn(:, projector_index, which_l)
546 IF (maxval(abs(ao_coef)) <= 100.0_dp*epsilon(1.0_dp))
THEN
547 CALL cp_abort(__location__, &
548 "The requested atomic projector is zero. Check the "// &
549 "specified N and L quantum numbers.")
551 DO j = 1,
SIZE(ao_coef(:))
552 ao_coef(j) = ao_coef(j)*sqrt(
atom%integrals%ovlp(j, j, which_l))
564 DEALLOCATE (potential, basis, integrals)
580 optbasis, allelectron, confine)
581 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: density
584 INTEGER,
INTENT(IN) :: ngto
585 INTEGER,
INTENT(IN),
OPTIONAL :: iunit
586 LOGICAL,
INTENT(IN),
OPTIONAL :: optbasis, allelectron, confine
588 INTEGER,
PARAMETER :: num_gto = 40
590 INTEGER :: i, ii, iw, k, l, ll, m, mb, mo, ngp, nn, &
591 nr, quadtype, relativistic, z
592 INTEGER,
DIMENSION(0:lmat) :: starti
593 INTEGER,
DIMENSION(0:lmat, 10) :: ncalc, ncore,
nelem
594 INTEGER,
DIMENSION(:),
POINTER :: econf
595 LOGICAL :: do_basopt, ecp_semi_local, monovalent
596 REAL(kind=
dp) :: al, aval, cc, cval, ear, rk, xx, zeff
597 REAL(kind=
dp),
DIMENSION(num_gto+2) :: results
612 NULLIFY (all_potential, gth_potential)
614 all_potential=all_potential, &
615 gth_potential=gth_potential, &
616 sgp_potential=sgp_potential, &
617 monovalent=monovalent)
619 IF (
PRESENT(iunit))
THEN
625 IF (
PRESENT(allelectron))
THEN
626 IF (allelectron)
THEN
627 NULLIFY (gth_potential)
633 IF (
PRESENT(optbasis))
THEN
637 cpassert(ngto <= num_gto)
639 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
649 pp_calc=(
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential)), &
651 relativistic=relativistic, &
655 ALLOCATE (potential, basis, integrals)
657 IF (
PRESENT(confine))
THEN
658 potential%confinement = confine
660 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
661 potential%confinement = .true.
663 potential%confinement = .false.
667 potential%acon = 200._dp
668 potential%rcon = 4.0_dp
669 potential%scon = 8.0_dp
671 IF (
ASSOCIATED(gth_potential))
THEN
675 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
676 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
677 CALL get_potential(sgp_potential, ecp_semi_local=ecp_semi_local)
678 IF (
ALLOCATED(sgp_potential%upf_data))
THEN
680 potential%upf_pot = sgp_potential%upf_data
681 ELSE IF (ecp_semi_local)
THEN
683 CALL ecp_potential_conversion(sgp_potential, potential%ecp_pot)
684 potential%ecp_pot%symbol =
ptable(z)%symbol
688 potential%sgp_pot%symbol =
ptable(z)%symbol
691 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
706 NULLIFY (basis%am, basis%cm, basis%as, basis%ns, basis%bf, basis%dbf, basis%ddbf)
709 basis%eps_eig = 1.e-12_dp
712 basis%nprim = basis%nbas
713 m = maxval(basis%nbas)
714 ALLOCATE (basis%am(m, 0:
lmat))
717 DO i = 1, basis%nbas(l)
718 ll = i - 1 + starti(l)
719 basis%am(i, l) = aval*cval**(ll)
723 basis%geometrical = .true.
730 m = maxval(basis%nbas)
731 ALLOCATE (basis%bf(nr, m, 0:
lmat))
732 ALLOCATE (basis%dbf(nr, m, 0:
lmat))
733 ALLOCATE (basis%ddbf(nr, m, 0:
lmat))
738 DO i = 1, basis%nbas(l)
741 rk = basis%grid%rad(k)
742 ear = exp(-al*basis%grid%rad(k)**2)
743 basis%bf(k, i, l) = rk**l*ear
744 basis%dbf(k, i, l) = (real(l,
dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear
745 basis%ddbf(k, i, l) = (real(l*(l - 1),
dp)*rk**(l - 2) - &
746 2._dp*al*real(2*l + 1,
dp)*rk**(l) + 4._dp*al**2*rk**(l + 2))*ear
762 ELSE IF (
ASSOCIATED(gth_potential))
THEN
765 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
769 DO l = 0, min(
lmat, ubound(
ptable(z)%e_conv, 1))
784 ncalc =
nelem - ncore
787 IF (qs_kind%ghost .OR. qs_kind%floating)
THEN
793 ALLOCATE (
atom%state)
795 atom%state%core = 0._dp
797 atom%state%occ = 0._dp
799 atom%state%occupation = 0._dp
800 atom%state%multiplicity = -1
804 IF (ncalc(l, i) > 0)
THEN
806 atom%state%occupation(l, k) = real(ncalc(l, i),
dp)
813 atom%state%maxl_calc =
atom%state%maxl_occ
814 atom%state%maxn_calc =
atom%state%maxn_occ
824 NULLIFY (integrals%tzora, integrals%hdkh)
829 mo = maxval(
atom%state%maxn_calc)
830 mb = maxval(
atom%basis%nbas)
841 density(i, 1) = xx*cc**i
842 density(i, 2) = results(2 + i)
846 density(1:ngto, 2) = results(1:ngto)
857 DEALLOCATE (potential, basis, integrals)
872 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rtmat
874 INTEGER :: i, ii, ipgf, j, k, k1, k2, l, ll, m, n, &
875 ngp, nj, nn, nr, ns, nset, nsgf, &
876 quadtype, relativistic, z
877 INTEGER,
DIMENSION(0:lmat, 10) :: ncalc, ncore,
nelem
878 INTEGER,
DIMENSION(0:lmat, 100) :: set_index, shell_index
879 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nshell
880 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, last_sgf, ls
881 REAL(kind=
dp) :: al, alpha, ear, prefac, rk, zeff
882 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: omat
883 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: zet
884 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: gcc
893 IF (rel_control%rel_method ==
rel_none)
RETURN
895 NULLIFY (all_potential, orb_basis_set)
896 CALL get_qs_kind(qs_kind, basis_set=orb_basis_set, all_potential=all_potential)
898 cpassert(
ASSOCIATED(orb_basis_set))
900 IF (
ASSOCIATED(all_potential))
THEN
907 NULLIFY (
atom%xc_section)
908 NULLIFY (
atom%orbitals)
910 alpha = sqrt(all_potential%alpha_core_charge)
913 SELECT CASE (rel_control%rel_method)
915 cpabort(
"Unknown relativistic method for calculate_atomic_relkin")
917 SELECT CASE (rel_control%rel_DKH_order)
919 cpabort(
"Unknown DKH order for calculate_atomic_relkin")
930 SELECT CASE (rel_control%rel_zora_type)
932 cpabort(
"Unknown ZORA type for calculate_atomic_relkin")
934 cpabort(
"ZORA full not yet implemented in calculate_atomic_relkin")
945 relativistic=relativistic, &
949 ALLOCATE (potential, basis, integrals)
955 nset=nset, nshell=nshell, npgf=npgf, lmin=lmin, lmax=lmax, l=ls, nsgf=nsgf, zet=zet, gcc=gcc, &
956 first_sgf=first_sgf, last_sgf=last_sgf)
966 NULLIFY (basis%am, basis%cm, basis%as, basis%ns, basis%bf, basis%dbf, basis%ddbf)
968 basis%eps_eig = 1.e-12_dp
976 DO j = lmin(i), min(lmax(i),
lmat)
977 basis%nprim(j) = basis%nprim(j) + npgf(i)
982 basis%nbas(l) = basis%nbas(l) + 1
986 shell_index(l, k) = j
991 nj = maxval(basis%nprim)
992 ns = maxval(basis%nbas)
993 ALLOCATE (basis%am(nj, 0:
lmat))
995 ALLOCATE (basis%cm(nj, ns, 0:
lmat))
1001 IF (j >= lmin(i) .AND. j <= lmax(i))
THEN
1002 DO ipgf = 1, npgf(i)
1003 basis%am(nj + ipgf, j) = zet(ipgf, i)
1005 DO ii = 1, nshell(i)
1006 IF (ls(ii, i) == j)
THEN
1008 DO ipgf = 1, npgf(i)
1009 basis%cm(nj + ipgf, ns, j) = gcc(ipgf, ii, i)
1021 prefac = 2.0_dp*sqrt(
pi/
dfac(2*j + 1))
1022 DO ipgf = 1, basis%nprim(j)
1023 DO ii = 1, basis%nbas(j)
1024 basis%cm(ipgf, ii, j) = prefac*basis%cm(ipgf, ii, j)
1031 m = maxval(basis%nbas)
1032 ALLOCATE (basis%bf(nr, m, 0:
lmat))
1033 ALLOCATE (basis%dbf(nr, m, 0:
lmat))
1034 ALLOCATE (basis%ddbf(nr, m, 0:
lmat))
1040 DO i = 1, basis%nprim(l)
1043 rk = basis%grid%rad(k)
1044 ear = exp(-al*basis%grid%rad(k)**2)
1045 DO j = 1, basis%nbas(l)
1046 basis%bf(k, j, l) = basis%bf(k, j, l) + rk**l*ear*basis%cm(i, j, l)
1047 basis%dbf(k, j, l) = basis%dbf(k, j, l) &
1048 + (real(l,
dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear*basis%cm(i, j, l)
1049 basis%ddbf(k, j, l) = basis%ddbf(k, j, l) + &
1050 (real(l*(l - 1),
dp)*rk**(l - 2) - 2._dp*al*real(2*l + 1,
dp)* &
1051 rk**(l) + 4._dp*al**2*rk**(l + 2))*ear*basis%cm(i, j, l)
1066 DO l = 0, min(
lmat, ubound(
ptable(z)%e_conv, 1))
1081 ncalc =
nelem - ncore
1083 IF (qs_kind%ghost .OR. qs_kind%floating)
THEN
1089 ALLOCATE (
atom%state)
1091 atom%state%core = 0._dp
1093 atom%state%occ = 0._dp
1095 atom%state%occupation = 0._dp
1096 atom%state%multiplicity = -1
1100 IF (ncalc(l, i) > 0)
THEN
1102 atom%state%occupation(l, k) = real(ncalc(l, i),
dp)
1109 atom%state%maxl_calc =
atom%state%maxl_occ
1110 atom%state%maxn_calc =
atom%state%maxn_occ
1118 NULLIFY (integrals%tzora, integrals%hdkh)
1124 integrals%core = 0.0_dp
1128 ALLOCATE (omat(m, m))
1130 CALL sg_erfc(omat(1:m, 1:m), l, alpha, basis%am(1:m, l), basis%am(1:m, l))
1131 integrals%core(1:n, 1:n, l) = matmul(transpose(basis%cm(1:m, 1:n, l)), &
1132 matmul(omat(1:m, 1:m), basis%cm(1:m, 1:n, l)))
1138 IF (
ASSOCIATED(rtmat))
THEN
1141 ALLOCATE (rtmat(nsgf, nsgf))
1145 DO k1 = 1, basis%nbas(l)
1146 DO k2 = 1, basis%nbas(l)
1147 i = first_sgf(shell_index(l, k1), set_index(l, k1))
1148 j = first_sgf(shell_index(l, k2), set_index(l, k2))
1149 SELECT CASE (
atom%relativistic)
1151 cpabort(
"Unknown relativistic type for calculate_atomic_relkin")
1154 rtmat(i + m, j + m) = integrals%tzora(k1, k2, l)
1158 rtmat(i + m, j + m) = integrals%hdkh(k1, k2, l) - integrals%kin(k1, k2, l) + &
1159 atom%zcore*integrals%core(k1, k2, l)
1167 rtmat(k1, k2) = 0.5_dp*(rtmat(k1, k2) + rtmat(k2, k1))
1168 rtmat(k2, k1) = rtmat(k1, k2)
1180 DEALLOCATE (potential, basis, integrals)
1184 IF (
ASSOCIATED(rtmat))
THEN
1202 INTEGER :: i, j, l, lm, n, ne, nexp_lpot, nexp_lsd, &
1204 INTEGER,
DIMENSION(:),
POINTER :: nct_lpot, nct_lsd, nct_nlcc, nppnl, &
1206 LOGICAL :: lpot_present, lsd_present, nlcc_present, &
1208 REAL(kind=
dp) :: ac, zeff
1209 REAL(kind=
dp),
DIMENSION(:),
POINTER :: alpha_lpot, alpha_lsd, alpha_nlcc, ap, ce
1210 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cval_lpot, cval_lsd, cval_nlcc
1211 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: hp, kp
1215 elec_conf=ppeconf, &
1216 alpha_core_charge=ac, &
1225 gth_atompot%zion = zeff
1226 gth_atompot%rc = sqrt(0.5_dp/ac)
1227 gth_atompot%ncl = ne
1228 gth_atompot%cl(:) = 0._dp
1229 IF (ac > 0._dp)
THEN
1231 gth_atompot%cl(i) = ce(i)/(2._dp*ac)**(i - 1)
1235 gth_atompot%lpotextended = .false.
1236 gth_atompot%lsdpot = .false.
1237 gth_atompot%nlcc = .false.
1238 gth_atompot%nexp_lpot = 0
1239 gth_atompot%nexp_lsd = 0
1240 gth_atompot%nexp_nlcc = 0
1242 lpot_present=lpot_present, &
1243 lsd_present=lsd_present, &
1244 nlcc_present=nlcc_present)
1245 IF (lpot_present)
THEN
1247 nexp_lpot=nexp_lpot, &
1248 alpha_lpot=alpha_lpot, &
1249 nct_lpot=nct_lpot, &
1250 cval_lpot=cval_lpot)
1251 gth_atompot%lpotextended = .true.
1252 gth_atompot%nexp_lpot = nexp_lpot
1253 gth_atompot%alpha_lpot(1:nexp_lpot) = sqrt(0.5_dp/alpha_lpot(1:nexp_lpot))
1254 gth_atompot%nct_lpot(1:nexp_lpot) = nct_lpot(1:nexp_lpot)
1258 gth_atompot%cval_lpot(i, j) = cval_lpot(i, j)/(2._dp*ac)**(i - 1)
1262 IF (lsd_present)
THEN
1264 nexp_lsd=nexp_lsd, &
1265 alpha_lsd=alpha_lsd, &
1268 gth_atompot%lsdpot = .true.
1269 gth_atompot%nexp_lsd = nexp_lsd
1270 gth_atompot%alpha_lsd(1:nexp_lsd) = sqrt(0.5_dp/alpha_lsd(1:nexp_lsd))
1271 gth_atompot%nct_lsd(1:nexp_lsd) = nct_lsd(1:nexp_lsd)
1275 gth_atompot%cval_lsd(i, j) = cval_lsd(i, j)/(2._dp*ac)**(i - 1)
1281 gth_atompot%nl(:) = 0
1282 gth_atompot%rcnl(:) = 0._dp
1283 gth_atompot%hnl(:, :, :) = 0._dp
1286 gth_atompot%nl(l) = n
1287 gth_atompot%rcnl(l) = sqrt(0.5_dp/ap(l))
1288 gth_atompot%hnl(1:n, 1:n, l) = hp(1:n, 1:n, l)
1293 gth_atompot%soc = soc_present
1294 gth_atompot%knl = 0.0_dp
1295 IF (soc_present)
THEN
1298 gth_atompot%knl(1:n, 1:n, l) = kp(1:n, 1:n, l)
1302 IF (nlcc_present)
THEN
1304 nexp_nlcc=nexp_nlcc, &
1305 alpha_nlcc=alpha_nlcc, &
1306 nct_nlcc=nct_nlcc, &
1307 cval_nlcc=cval_nlcc)
1308 gth_atompot%nlcc = .true.
1309 gth_atompot%nexp_nlcc = nexp_nlcc
1310 gth_atompot%alpha_nlcc(1:nexp_nlcc) = alpha_nlcc(1:nexp_nlcc)
1311 gth_atompot%nct_nlcc(1:nexp_nlcc) = nct_nlcc(1:nexp_nlcc)
1312 gth_atompot%cval_nlcc(1:4, 1:nexp_nlcc) = cval_nlcc(1:4, 1:nexp_nlcc)
1327 INTEGER,
DIMENSION(:),
POINTER :: ppeconf
1328 LOGICAL :: nlcc_present
1329 REAL(kind=
dp) :: ac, zeff
1330 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ap, ce
1331 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hhp
1332 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: ccp
1335 name=sgp_atompot%pname, &
1337 elec_conf=ppeconf, &
1338 core_charge_radius=ac)
1339 sgp_atompot%zion = zeff
1340 sgp_atompot%ac_local = ac
1341 sgp_atompot%econf(0:3) = ppeconf(0:3)
1343 is_nonlocal=sgp_atompot%is_nonlocal, &
1344 n_nonlocal=n, a_nonlocal=ap, h_nonlocal=hhp, c_nonlocal=ccp)
1346 sgp_atompot%has_nonlocal = any(sgp_atompot%is_nonlocal)
1347 sgp_atompot%lmax = lm
1348 IF (sgp_atompot%has_nonlocal)
THEN
1349 cpassert(n <=
SIZE(sgp_atompot%a_nonlocal))
1350 sgp_atompot%n_nonlocal = n
1351 sgp_atompot%a_nonlocal(1:n) = ap(1:n)
1352 sgp_atompot%h_nonlocal(1:n, 0:lm) = hhp(1:n, 0:lm)
1355 sgp_atompot%c_nonlocal(1:n, 1:n, 0:lm) = sqrt(
fourpi)*ccp(1:n, 1:n, 0:lm)
1358 CALL get_potential(sgp_potential, n_local=n, a_local=ap, c_local=ce)
1359 cpassert(n <=
SIZE(sgp_atompot%a_local))
1360 sgp_atompot%n_local = n
1361 sgp_atompot%a_local(1:n) = ap(1:n)
1362 sgp_atompot%c_local(1:n) = ce(1:n)
1365 n_nlcc=n, a_nlcc=ap, c_nlcc=ce)
1366 IF (nlcc_present)
THEN
1367 sgp_atompot%has_nlcc = .true.
1368 cpassert(n <=
SIZE(sgp_atompot%a_nlcc))
1369 sgp_atompot%n_nlcc = n
1370 sgp_atompot%a_nlcc(1:n) = ap(1:n)
1371 sgp_atompot%c_nlcc(1:n) = ce(1:n)
1373 sgp_atompot%has_nlcc = .false.
1383 SUBROUTINE ecp_potential_conversion(sgp_potential, ecp_atompot)
1387 INTEGER,
DIMENSION(:),
POINTER :: ppeconf
1388 LOGICAL :: ecp_local, ecp_semi_local
1389 REAL(kind=
dp) :: zeff
1391 CALL get_potential(sgp_potential, ecp_local=ecp_local, ecp_semi_local=ecp_semi_local)
1392 cpassert(ecp_semi_local .AND. ecp_local)
1394 name=ecp_atompot%pname, &
1397 ecp_atompot%zion = zeff
1398 ecp_atompot%econf(0:3) = ppeconf(0:3)
1401 CALL get_potential(sgp_potential, nloc=ecp_atompot%nloc, nrloc=ecp_atompot%nrloc, &
1402 aloc=ecp_atompot%aloc, bloc=ecp_atompot%bloc)
1404 CALL get_potential(sgp_potential, npot=ecp_atompot%npot, nrpot=ecp_atompot%nrpot, &
1405 apot=ecp_atompot%apot, bpot=ecp_atompot%bpot)
1407 END SUBROUTINE ecp_potential_conversion
subroutine, public sg_erfc(umat, l, a, pa, pb)
...
subroutine, public calculate_atom(atom, iw, noguess, converged)
General routine to perform electronic structure atomic calculations.
routines that fit parameters for /from atomic calculations
subroutine, public atom_fit_density(atom, num_gto, norder, iunit, agto, powell_section, results)
Fit the atomic electron density using a geometrical Gaussian basis set.
calculate the orbitals for a given atomic kind type
subroutine, public calculate_atomic_relkin(atomic_kind, qs_kind, rel_control, rtmat)
...
subroutine, public sgp_potential_conversion(sgp_potential, sgp_atompot)
...
subroutine, public calculate_atomic_density(density, atomic_kind, qs_kind, ngto, iunit, optbasis, allelectron, confine)
...
subroutine, public gth_potential_conversion(gth_potential, gth_atompot)
...
subroutine, public calculate_atomic_orbitals(atomic_kind, qs_kind, agrid, iunit, pmat, fmat, density, wavefunction, wfninfo, confine, xc_section, nocc, which_l, which_n, proj_shell_charge, ao_coef)
...
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_ppint_setup(integrals, basis, potential)
...
subroutine, public atom_int_release(integrals)
Release memory allocated for atomic integrals (valence electrons).
Optimizer for the atomic code.
subroutine, public set_kind_basis_atomic(basis, orb_basis_set, has_pp, agrid, cp2k_norm)
...
Define the atom type and its sub types.
subroutine, public create_atom_type(atom)
...
integer, parameter, public cgto_basis
integer, parameter, public gto_basis
subroutine, public release_atom_type(atom)
...
subroutine, public release_atom_potential(potential)
...
integer, parameter, public lmat
subroutine, public set_atom(atom, basis, state, integrals, orbitals, potential, zcore, pp_calc, do_zmp, doread, read_vxc, method_type, relativistic, coulomb_integral_type, exchange_integral_type, fmat)
...
subroutine, public release_atom_basis(basis)
...
subroutine, public create_atom_orbs(orbs, mbas, mo)
...
subroutine, public clementi_geobas(zval, cval, aval, ngto, ival)
...
Some basic routines for atomic calculations.
pure integer function, dimension(0:lmat), public get_maxn_occ(occupation)
Return the maximum principal quantum number of occupied orbitals.
subroutine, public atom_density(density, pmat, basis, maxl, typ, rr)
Map the electron density on an atomic radial grid.
pure integer function, public get_maxl_occ(occupation)
Return the maximum orbital quantum number of occupied orbitals.
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
Definition of the atomic potential types.
Defines the basic variable types.
integer, parameter, public dp
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 fourpi
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
subroutine, public allocate_grid_atom(grid_atom)
Initialize components of the grid_atom_type structure.
subroutine, public create_grid_atom(grid_atom, nr, na, llmax, ll, quadrature)
...
Define the quickstep kind type and their sub types.
subroutine, public set_pseudo_state(econf, z, ncalc, ncore, nelem)
...
logical function, public has_nlcc(qs_kind_set)
finds if a given qs run needs to use nlcc
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public init_atom_electronic_state(atomic_kind, qs_kind, ncalc, ncore, nelem, edelta, rks)
...
parameters that control a relativistic calculation
Provides all information about a basis set.
Provides all information about a pseudopotential.
Information on optimization procedure.
Holds atomic orbitals and energies.
Provides all information about an atomic kind.
Provides all information about an atomic kind.
Provides all information about a quickstep kind.
contains the parameters needed by a relativistic calculation