58#include "./base/base_uses.f90"
64 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_kind_orbitals'
93 density, wavefunction, wfninfo, confine, xc_section, nocc, &
94 which_l, which_n, proj_shell_charge, ao_coef)
98 INTEGER,
INTENT(IN),
OPTIONAL :: iunit
99 REAL(kind=
dp),
DIMENSION(:, :, :),
OPTIONAL, &
100 POINTER :: pmat, fmat
101 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: density
102 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: wavefunction, wfninfo
103 LOGICAL,
INTENT(IN),
OPTIONAL :: confine
105 INTEGER,
DIMENSION(:),
OPTIONAL :: nocc
106 INTEGER,
INTENT(IN),
OPTIONAL :: which_l, which_n
107 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: proj_shell_charge(4)
108 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT), &
109 OPTIONAL,
POINTER :: ao_coef
111 INTEGER :: i, ii, j, k, k1, k2, l, ll, m, mb, mo, &
112 nr, nset, nsgf, projector_index, &
114 INTEGER,
DIMENSION(0:lmat) :: nbb
115 INTEGER,
DIMENSION(0:lmat, 10) :: ncalc, ncore,
nelem
116 INTEGER,
DIMENSION(0:lmat, 100) :: set_index, shell_index
117 INTEGER,
DIMENSION(:),
POINTER :: nshell
118 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, ls
119 LOGICAL :: ecp_semi_local, ghost, has_pp, uks
120 REAL(kind=
dp) :: ok, qleft, scal, take, zeff
121 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: occupation_neutral
122 REAL(kind=
dp),
DIMENSION(0:lmat, 10, 2) :: edelta
133 IF (
PRESENT(ao_coef) .OR.
PRESENT(which_l) .OR. &
134 PRESENT(which_n) .OR.
PRESENT(proj_shell_charge))
THEN
135 IF (.NOT.
PRESENT(ao_coef) .OR. .NOT.
PRESENT(which_l) .OR. &
136 .NOT.
PRESENT(which_n) .OR. .NOT.
PRESENT(proj_shell_charge))
THEN
137 cpabort(
"ao_coef, which_l, which_n, and proj_shell_charge must be provided together")
144 IF (
PRESENT(xc_section))
THEN
145 atom%xc_section => xc_section
147 NULLIFY (
atom%xc_section)
151 NULLIFY (all_potential, gth_potential, sgp_potential, orb_basis_set)
153 basis_set=orb_basis_set, &
155 all_potential=all_potential, &
156 gth_potential=gth_potential, &
157 sgp_potential=sgp_potential)
159 has_pp =
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential)
171 ALLOCATE (potential, integrals)
173 IF (
PRESENT(confine))
THEN
174 potential%confinement = confine
176 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
177 potential%confinement = .true.
179 potential%confinement = .false.
183 potential%acon = 0.1_dp
184 potential%rcon = 2.0_dp*
ptable(z)%vdw_radius*
bohr
185 potential%scon = 2.0_dp
187 IF (
ASSOCIATED(gth_potential))
THEN
191 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
192 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
193 CALL get_potential(sgp_potential, ecp_semi_local=ecp_semi_local)
194 IF (
ALLOCATED(sgp_potential%upf_data))
THEN
196 potential%upf_pot = sgp_potential%upf_data
197 ELSE IF (ecp_semi_local)
THEN
199 CALL ecp_potential_conversion(sgp_potential, potential%ecp_pot)
200 potential%ecp_pot%symbol =
ptable(z)%symbol
204 potential%sgp_pot%symbol =
ptable(z)%symbol
207 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
221 atom%optimization%damping = 0.2_dp
222 atom%optimization%eps_scf = 1.e-6_dp
223 atom%optimization%eps_diis = 100._dp
224 atom%optimization%max_iter = 50
225 atom%optimization%n_diis = 5
234 rks=
PRESENT(ao_coef))
237 IF (sum(abs(edelta)) > 0.0_dp)
THEN
245 ALLOCATE (
atom%state)
247 atom%state%core = 0._dp
249 atom%state%occ = 0._dp
252 edelta(0:
lmat, 1:7, 1) + edelta(0:
lmat, 1:7, 2)
256 atom%state%occupation = 0._dp
260 IF (ncalc(l, i) > 0)
THEN
263 atom%state%occupation(l, k) = real(ncalc(l, i),
dp) + &
264 edelta(l, i, 1) + edelta(l, i, 2)
265 atom%state%occa(l, k) = 0.5_dp*real(ncalc(l, i),
dp) + edelta(l, i, 1)
266 atom%state%occb(l, k) = 0.5_dp*real(ncalc(l, i),
dp) + edelta(l, i, 2)
268 atom%state%occupation(l, k) = real(ncalc(l, i),
dp)
272 ok = real(2*l + 1, kind=
dp)
275 atom%state%occ(l, i) = min(
atom%state%occ(l, i), 2.0_dp*ok)
276 atom%state%occa(l, i) = min(
atom%state%occa(l, i), ok)
277 atom%state%occb(l, i) = min(
atom%state%occb(l, i), ok)
278 atom%state%occupation(l, i) =
atom%state%occa(l, i) +
atom%state%occb(l, i)
282 atom%state%occ(l, i) = min(
atom%state%occ(l, i), 2.0_dp*ok)
283 atom%state%occupation(l, i) = min(
atom%state%occupation(l, i), 2.0_dp*ok)
288 IF (
PRESENT(proj_shell_charge))
THEN
290 occupation_neutral(0:
lmat, 1:10) =
atom%state%occupation(0:
lmat, 1:10)
292 CALL cp_abort(__location__,
"proj_shell_charge in"// &
293 " calculate_atomic_orbitals is implemented only for RKS")
295 DO l = 0, min(3,
lmat)
296 qleft = proj_shell_charge(l + 1)
297 IF (qleft > 0.0_dp)
THEN
300 IF (
atom%state%occupation(l, k) > 0.0_dp)
THEN
301 take = min(qleft,
atom%state%occupation(l, k))
302 atom%state%occupation(l, k) =
atom%state%occupation(l, k) - take
304 IF (qleft <= 1.0e-12_dp)
EXIT
307 IF (qleft > 1.0e-10_dp)
THEN
308 CALL cp_abort(__location__,
"proj_shell_charge removes"// &
309 " more electrons than available in this angular channel")
312 qleft = proj_shell_charge(l + 1)
314 IF (
atom%state%occ(l, k) > 0.0_dp)
THEN
315 take = min(qleft,
atom%state%occ(l, k))
316 atom%state%occ(l, k) =
atom%state%occ(l, k) - take
318 IF (qleft <= 1.0e-12_dp)
EXIT
321 ELSE IF (qleft < 0.0_dp)
THEN
322 CALL cp_abort(__location__,
"Negative proj_shell_charge"// &
323 " is not supported in this implementation")
329 atom%state%multiplicity = nint(abs(sum(
atom%state%occa -
atom%state%occb)) + 1)
331 atom%state%multiplicity = -1
336 IF (
PRESENT(proj_shell_charge))
THEN
340 atom%state%maxl_calc =
atom%state%maxl_occ
341 atom%state%maxn_calc =
atom%state%maxn_occ
345 IF (
PRESENT(nocc) .AND. ghost)
THEN
347 ELSE IF (
PRESENT(nocc))
THEN
352 IF (
atom%state%occa(l, k) > 0.0_dp)
THEN
353 nocc(1) = nocc(1) + 2*l + 1
355 IF (
atom%state%occb(l, k) > 0.0_dp)
THEN
356 nocc(2) = nocc(2) + 2*l + 1
359 IF (
atom%state%occupation(l, k) > 0.0_dp)
THEN
360 nocc(1) = nocc(1) + 2*l + 1
361 nocc(2) = nocc(2) + 2*l + 1
376 NULLIFY (integrals%tzora, integrals%hdkh)
381 mo = maxval(
atom%state%maxn_calc)
382 mb = maxval(
atom%basis%nbas)
386 IF (.NOT. ghost)
THEN
387 IF (
PRESENT(iunit))
THEN
393 IF (
PRESENT(pmat))
THEN
396 nset=nset, nshell=nshell, l=ls, nsgf=nsgf, first_sgf=first_sgf)
408 shell_index(l, k) = j
413 IF (
ASSOCIATED(pmat))
THEN
416 ALLOCATE (pmat(nsgf, nsgf, 2))
418 IF (.NOT. ghost)
THEN
421 DO k1 = 1,
atom%basis%nbas(l)
422 DO k2 = 1,
atom%basis%nbas(l)
423 scal = sqrt(
atom%integrals%ovlp(k1, k1, l)*
atom%integrals%ovlp(k2, k2, l))/real(2*l + 1, kind=
dp)
424 i = first_sgf(shell_index(l, k1), set_index(l, k1))
425 j = first_sgf(shell_index(l, k2), set_index(l, k2))
428 pmat(i + m, j + m, 1) =
atom%orbitals%pmata(k1, k2, l)*scal
429 pmat(i + m, j + m, 2) =
atom%orbitals%pmatb(k1, k2, l)*scal
433 pmat(i + m, j + m, 1) =
atom%orbitals%pmat(k1, k2, l)*scal
440 pmat(:, :, 1) = pmat(:, :, 1) + pmat(:, :, 2)
441 pmat(:, :, 2) = pmat(:, :, 1) - 2.0_dp*pmat(:, :, 2)
446 IF (
PRESENT(fmat))
THEN
450 nset=nset, nshell=nshell, l=ls, nsgf=nsgf, first_sgf=first_sgf)
462 shell_index(l, k) = j
466 IF (uks) cpabort(
"calculate_atomic_orbitals: only RKS is implemented")
467 IF (
ASSOCIATED(fmat)) cpabort(
"fmat already associated")
468 IF (.NOT.
ASSOCIATED(
atom%fmat)) cpabort(
"atom%fmat not associated")
469 ALLOCATE (fmat(nsgf, nsgf, 1))
471 IF (.NOT. ghost)
THEN
474 DO k1 = 1,
atom%basis%nbas(l)
475 DO k2 = 1,
atom%basis%nbas(l)
476 scal = sqrt(
atom%integrals%ovlp(k1, k1, l)*
atom%integrals%ovlp(k2, k2, l))
477 i = first_sgf(shell_index(l, k1), set_index(l, k1))
478 j = first_sgf(shell_index(l, k2), set_index(l, k2))
480 fmat(i + m, j + m, 1) =
atom%fmat%op(k1, k2, l)/scal
490 IF (
PRESENT(density))
THEN
491 IF (
ASSOCIATED(density))
DEALLOCATE (density)
492 ALLOCATE (density(nr))
500 IF (
PRESENT(wavefunction))
THEN
501 cpassert(
PRESENT(wfninfo))
502 IF (
ASSOCIATED(wavefunction))
DEALLOCATE (wavefunction)
503 IF (
ASSOCIATED(wfninfo))
DEALLOCATE (wfninfo)
504 mo = sum(
atom%state%maxn_occ)
505 ALLOCATE (wavefunction(nr, mo), wfninfo(2, mo))
506 wavefunction = 0.0_dp
507 IF (.NOT. ghost)
THEN
510 DO i = 1,
atom%state%maxn_occ(l)
511 IF (
atom%state%occupation(l, i) > 0.0_dp)
THEN
513 wfninfo(1, ii) =
atom%state%occupation(l, i)
514 wfninfo(2, ii) = real(l,
dp)
515 DO j = 1,
atom%basis%nbas(l)
516 wavefunction(:, ii) = wavefunction(:, ii) + &
517 atom%orbitals%wfn(j, i, l)*basis%bf(:, j, l)
526 IF (
PRESENT(ao_coef))
THEN
527 cpassert(
PRESENT(which_l))
528 cpassert(
PRESENT(which_n))
529 cpassert(which_l >= 0 .AND. which_l <=
lmat)
530 valence_n = count(ncore(which_l, :) > 0) + which_l + 1
531 projector_index = which_n - valence_n + 1
532 IF (projector_index < 1 .OR. projector_index >
SIZE(
atom%orbitals%wfn, 2))
THEN
533 CALL cp_abort(__location__, &
534 "The requested tensorial atomic projector N is outside "// &
535 "the available orbital range for the selected L.")
537 IF (
ASSOCIATED(ao_coef))
DEALLOCATE (ao_coef)
538 ALLOCATE (ao_coef(
SIZE(
atom%orbitals%wfn(:, 1, which_l))))
539 ao_coef(:) =
atom%orbitals%wfn(:, projector_index, which_l)
540 IF (maxval(abs(ao_coef)) <= 100.0_dp*epsilon(1.0_dp))
THEN
541 CALL cp_abort(__location__, &
542 "The requested atomic projector is zero. Check the "// &
543 "specified N and L quantum numbers.")
545 DO j = 1,
SIZE(ao_coef(:))
546 ao_coef(j) = ao_coef(j)*sqrt(
atom%integrals%ovlp(j, j, which_l))
558 DEALLOCATE (potential, basis, integrals)
574 optbasis, allelectron, confine)
575 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: density
578 INTEGER,
INTENT(IN) :: ngto
579 INTEGER,
INTENT(IN),
OPTIONAL :: iunit
580 LOGICAL,
INTENT(IN),
OPTIONAL :: optbasis, allelectron, confine
582 INTEGER,
PARAMETER :: num_gto = 40
584 INTEGER :: i, ii, iw, k, l, ll, m, mb, mo, ngp, nn, &
585 nr, quadtype, relativistic, z
586 INTEGER,
DIMENSION(0:lmat) :: starti
587 INTEGER,
DIMENSION(0:lmat, 10) :: ncalc, ncore,
nelem
588 INTEGER,
DIMENSION(:),
POINTER :: econf
589 LOGICAL :: do_basopt, ecp_semi_local, monovalent
590 REAL(kind=
dp) :: al, aval, cc, cval, ear, rk, xx, zeff
591 REAL(kind=
dp),
DIMENSION(num_gto+2) :: results
606 NULLIFY (all_potential, gth_potential)
608 all_potential=all_potential, &
609 gth_potential=gth_potential, &
610 sgp_potential=sgp_potential, &
611 monovalent=monovalent)
613 IF (
PRESENT(iunit))
THEN
619 IF (
PRESENT(allelectron))
THEN
620 IF (allelectron)
THEN
621 NULLIFY (gth_potential)
627 IF (
PRESENT(optbasis))
THEN
631 cpassert(ngto <= num_gto)
633 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
643 pp_calc=(
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential)), &
645 relativistic=relativistic, &
649 ALLOCATE (potential, basis, integrals)
651 IF (
PRESENT(confine))
THEN
652 potential%confinement = confine
654 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
655 potential%confinement = .true.
657 potential%confinement = .false.
661 potential%acon = 200._dp
662 potential%rcon = 4.0_dp
663 potential%scon = 8.0_dp
665 IF (
ASSOCIATED(gth_potential))
THEN
669 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
670 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
671 CALL get_potential(sgp_potential, ecp_semi_local=ecp_semi_local)
672 IF (
ALLOCATED(sgp_potential%upf_data))
THEN
674 potential%upf_pot = sgp_potential%upf_data
675 ELSE IF (ecp_semi_local)
THEN
677 CALL ecp_potential_conversion(sgp_potential, potential%ecp_pot)
678 potential%ecp_pot%symbol =
ptable(z)%symbol
682 potential%sgp_pot%symbol =
ptable(z)%symbol
685 CALL set_atom(
atom, zcore=nint(zeff), potential=potential)
700 NULLIFY (basis%am, basis%cm, basis%as, basis%ns, basis%bf, basis%dbf, basis%ddbf)
703 basis%eps_eig = 1.e-12_dp
706 basis%nprim = basis%nbas
707 m = maxval(basis%nbas)
708 ALLOCATE (basis%am(m, 0:
lmat))
711 DO i = 1, basis%nbas(l)
712 ll = i - 1 + starti(l)
713 basis%am(i, l) = aval*cval**(ll)
717 basis%geometrical = .true.
724 m = maxval(basis%nbas)
725 ALLOCATE (basis%bf(nr, m, 0:
lmat))
726 ALLOCATE (basis%dbf(nr, m, 0:
lmat))
727 ALLOCATE (basis%ddbf(nr, m, 0:
lmat))
732 DO i = 1, basis%nbas(l)
735 rk = basis%grid%rad(k)
736 ear = exp(-al*basis%grid%rad(k)**2)
737 basis%bf(k, i, l) = rk**l*ear
738 basis%dbf(k, i, l) = (real(l,
dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear
739 basis%ddbf(k, i, l) = (real(l*(l - 1),
dp)*rk**(l - 2) - &
740 2._dp*al*real(2*l + 1,
dp)*rk**(l) + 4._dp*al**2*rk**(l + 2))*ear
748 atom%optimization%damping = 0.2_dp
749 atom%optimization%eps_scf = 1.e-6_dp
750 atom%optimization%eps_diis = 100._dp
751 atom%optimization%max_iter = 50
752 atom%optimization%n_diis = 5
760 ELSE IF (
ASSOCIATED(gth_potential))
THEN
763 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
767 DO l = 0, min(
lmat, ubound(
ptable(z)%e_conv, 1))
782 ncalc =
nelem - ncore
785 IF (qs_kind%ghost .OR. qs_kind%floating)
THEN
791 ALLOCATE (
atom%state)
793 atom%state%core = 0._dp
795 atom%state%occ = 0._dp
797 atom%state%occupation = 0._dp
798 atom%state%multiplicity = -1
802 IF (ncalc(l, i) > 0)
THEN
804 atom%state%occupation(l, k) = real(ncalc(l, i),
dp)
811 atom%state%maxl_calc =
atom%state%maxl_occ
812 atom%state%maxn_calc =
atom%state%maxn_occ
822 NULLIFY (integrals%tzora, integrals%hdkh)
827 mo = maxval(
atom%state%maxn_calc)
828 mb = maxval(
atom%basis%nbas)
839 density(i, 1) = xx*cc**i
840 density(i, 2) = results(2 + i)
844 density(1:ngto, 2) = results(1:ngto)
855 DEALLOCATE (potential, basis, integrals)
870 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rtmat
872 INTEGER :: i, ii, ipgf, j, k, k1, k2, l, ll, m, n, &
873 ngp, nj, nn, nr, ns, nset, nsgf, &
874 quadtype, relativistic, z
875 INTEGER,
DIMENSION(0:lmat, 10) :: ncalc, ncore,
nelem
876 INTEGER,
DIMENSION(0:lmat, 100) :: set_index, shell_index
877 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nshell
878 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, last_sgf, ls
879 REAL(kind=
dp) :: al, alpha, ear, prefac, rk, zeff
880 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: omat
881 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: zet
882 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: gcc
891 IF (rel_control%rel_method ==
rel_none)
RETURN
893 NULLIFY (all_potential, orb_basis_set)
894 CALL get_qs_kind(qs_kind, basis_set=orb_basis_set, all_potential=all_potential)
896 cpassert(
ASSOCIATED(orb_basis_set))
898 IF (
ASSOCIATED(all_potential))
THEN
905 NULLIFY (
atom%xc_section)
906 NULLIFY (
atom%orbitals)
908 alpha = sqrt(all_potential%alpha_core_charge)
911 SELECT CASE (rel_control%rel_method)
913 cpabort(
"Unknown relativistic method for calculate_atomic_relkin")
915 SELECT CASE (rel_control%rel_DKH_order)
917 cpabort(
"Unknown DKH order for calculate_atomic_relkin")
928 SELECT CASE (rel_control%rel_zora_type)
930 cpabort(
"Unknown ZORA type for calculate_atomic_relkin")
932 cpabort(
"ZORA full not yet implemented in calculate_atomic_relkin")
943 relativistic=relativistic, &
947 ALLOCATE (potential, basis, integrals)
953 nset=nset, nshell=nshell, npgf=npgf, lmin=lmin, lmax=lmax, l=ls, nsgf=nsgf, zet=zet, gcc=gcc, &
954 first_sgf=first_sgf, last_sgf=last_sgf)
964 NULLIFY (basis%am, basis%cm, basis%as, basis%ns, basis%bf, basis%dbf, basis%ddbf)
966 basis%eps_eig = 1.e-12_dp
974 DO j = lmin(i), min(lmax(i),
lmat)
975 basis%nprim(j) = basis%nprim(j) + npgf(i)
980 basis%nbas(l) = basis%nbas(l) + 1
984 shell_index(l, k) = j
989 nj = maxval(basis%nprim)
990 ns = maxval(basis%nbas)
991 ALLOCATE (basis%am(nj, 0:
lmat))
993 ALLOCATE (basis%cm(nj, ns, 0:
lmat))
999 IF (j >= lmin(i) .AND. j <= lmax(i))
THEN
1000 DO ipgf = 1, npgf(i)
1001 basis%am(nj + ipgf, j) = zet(ipgf, i)
1003 DO ii = 1, nshell(i)
1004 IF (ls(ii, i) == j)
THEN
1006 DO ipgf = 1, npgf(i)
1007 basis%cm(nj + ipgf, ns, j) = gcc(ipgf, ii, i)
1019 prefac = 2.0_dp*sqrt(
pi/
dfac(2*j + 1))
1020 DO ipgf = 1, basis%nprim(j)
1021 DO ii = 1, basis%nbas(j)
1022 basis%cm(ipgf, ii, j) = prefac*basis%cm(ipgf, ii, j)
1029 m = maxval(basis%nbas)
1030 ALLOCATE (basis%bf(nr, m, 0:
lmat))
1031 ALLOCATE (basis%dbf(nr, m, 0:
lmat))
1032 ALLOCATE (basis%ddbf(nr, m, 0:
lmat))
1038 DO i = 1, basis%nprim(l)
1041 rk = basis%grid%rad(k)
1042 ear = exp(-al*basis%grid%rad(k)**2)
1043 DO j = 1, basis%nbas(l)
1044 basis%bf(k, j, l) = basis%bf(k, j, l) + rk**l*ear*basis%cm(i, j, l)
1045 basis%dbf(k, j, l) = basis%dbf(k, j, l) &
1046 + (real(l,
dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear*basis%cm(i, j, l)
1047 basis%ddbf(k, j, l) = basis%ddbf(k, j, l) + &
1048 (real(l*(l - 1),
dp)*rk**(l - 2) - 2._dp*al*real(2*l + 1,
dp)* &
1049 rk**(l) + 4._dp*al**2*rk**(l + 2))*ear*basis%cm(i, j, l)
1058 atom%optimization%damping = 0.2_dp
1059 atom%optimization%eps_scf = 1.e-6_dp
1060 atom%optimization%eps_diis = 100._dp
1061 atom%optimization%max_iter = 50
1062 atom%optimization%n_diis = 5
1068 DO l = 0, min(
lmat, ubound(
ptable(z)%e_conv, 1))
1083 ncalc =
nelem - ncore
1085 IF (qs_kind%ghost .OR. qs_kind%floating)
THEN
1091 ALLOCATE (
atom%state)
1093 atom%state%core = 0._dp
1095 atom%state%occ = 0._dp
1097 atom%state%occupation = 0._dp
1098 atom%state%multiplicity = -1
1102 IF (ncalc(l, i) > 0)
THEN
1104 atom%state%occupation(l, k) = real(ncalc(l, i),
dp)
1111 atom%state%maxl_calc =
atom%state%maxl_occ
1112 atom%state%maxn_calc =
atom%state%maxn_occ
1120 NULLIFY (integrals%tzora, integrals%hdkh)
1126 integrals%core = 0.0_dp
1130 ALLOCATE (omat(m, m))
1132 CALL sg_erfc(omat(1:m, 1:m), l, alpha, basis%am(1:m, l), basis%am(1:m, l))
1133 integrals%core(1:n, 1:n, l) = matmul(transpose(basis%cm(1:m, 1:n, l)), &
1134 matmul(omat(1:m, 1:m), basis%cm(1:m, 1:n, l)))
1140 IF (
ASSOCIATED(rtmat))
THEN
1143 ALLOCATE (rtmat(nsgf, nsgf))
1147 DO k1 = 1, basis%nbas(l)
1148 DO k2 = 1, basis%nbas(l)
1149 i = first_sgf(shell_index(l, k1), set_index(l, k1))
1150 j = first_sgf(shell_index(l, k2), set_index(l, k2))
1151 SELECT CASE (
atom%relativistic)
1153 cpabort(
"Unknown relativistic type for calculate_atomic_relkin")
1156 rtmat(i + m, j + m) = integrals%tzora(k1, k2, l)
1160 rtmat(i + m, j + m) = integrals%hdkh(k1, k2, l) - integrals%kin(k1, k2, l) + &
1161 atom%zcore*integrals%core(k1, k2, l)
1169 rtmat(k1, k2) = 0.5_dp*(rtmat(k1, k2) + rtmat(k2, k1))
1170 rtmat(k2, k1) = rtmat(k1, k2)
1182 DEALLOCATE (potential, basis, integrals)
1186 IF (
ASSOCIATED(rtmat))
THEN
1204 INTEGER :: i, j, l, lm, n, ne, nexp_lpot, nexp_lsd, &
1206 INTEGER,
DIMENSION(:),
POINTER :: nct_lpot, nct_lsd, nct_nlcc, nppnl, &
1208 LOGICAL :: lpot_present, lsd_present, nlcc_present, &
1210 REAL(kind=
dp) :: ac, zeff
1211 REAL(kind=
dp),
DIMENSION(:),
POINTER :: alpha_lpot, alpha_lsd, alpha_nlcc, ap, ce
1212 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cval_lpot, cval_lsd, cval_nlcc
1213 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: hp, kp
1217 elec_conf=ppeconf, &
1218 alpha_core_charge=ac, &
1227 gth_atompot%zion = zeff
1228 gth_atompot%rc = sqrt(0.5_dp/ac)
1229 gth_atompot%ncl = ne
1230 gth_atompot%cl(:) = 0._dp
1231 IF (ac > 0._dp)
THEN
1233 gth_atompot%cl(i) = ce(i)/(2._dp*ac)**(i - 1)
1237 gth_atompot%lpotextended = .false.
1238 gth_atompot%lsdpot = .false.
1239 gth_atompot%nlcc = .false.
1240 gth_atompot%nexp_lpot = 0
1241 gth_atompot%nexp_lsd = 0
1242 gth_atompot%nexp_nlcc = 0
1244 lpot_present=lpot_present, &
1245 lsd_present=lsd_present, &
1246 nlcc_present=nlcc_present)
1247 IF (lpot_present)
THEN
1249 nexp_lpot=nexp_lpot, &
1250 alpha_lpot=alpha_lpot, &
1251 nct_lpot=nct_lpot, &
1252 cval_lpot=cval_lpot)
1253 gth_atompot%lpotextended = .true.
1254 gth_atompot%nexp_lpot = nexp_lpot
1255 gth_atompot%alpha_lpot(1:nexp_lpot) = sqrt(0.5_dp/alpha_lpot(1:nexp_lpot))
1256 gth_atompot%nct_lpot(1:nexp_lpot) = nct_lpot(1:nexp_lpot)
1260 gth_atompot%cval_lpot(i, j) = cval_lpot(i, j)/(2._dp*ac)**(i - 1)
1264 IF (lsd_present)
THEN
1266 nexp_lsd=nexp_lsd, &
1267 alpha_lsd=alpha_lsd, &
1270 gth_atompot%lsdpot = .true.
1271 gth_atompot%nexp_lsd = nexp_lsd
1272 gth_atompot%alpha_lsd(1:nexp_lsd) = sqrt(0.5_dp/alpha_lsd(1:nexp_lsd))
1273 gth_atompot%nct_lsd(1:nexp_lsd) = nct_lsd(1:nexp_lsd)
1277 gth_atompot%cval_lsd(i, j) = cval_lsd(i, j)/(2._dp*ac)**(i - 1)
1283 gth_atompot%nl(:) = 0
1284 gth_atompot%rcnl(:) = 0._dp
1285 gth_atompot%hnl(:, :, :) = 0._dp
1288 gth_atompot%nl(l) = n
1289 gth_atompot%rcnl(l) = sqrt(0.5_dp/ap(l))
1290 gth_atompot%hnl(1:n, 1:n, l) = hp(1:n, 1:n, l)
1295 gth_atompot%soc = soc_present
1296 gth_atompot%knl = 0.0_dp
1297 IF (soc_present)
THEN
1300 gth_atompot%knl(1:n, 1:n, l) = kp(1:n, 1:n, l)
1304 IF (nlcc_present)
THEN
1306 nexp_nlcc=nexp_nlcc, &
1307 alpha_nlcc=alpha_nlcc, &
1308 nct_nlcc=nct_nlcc, &
1309 cval_nlcc=cval_nlcc)
1310 gth_atompot%nlcc = .true.
1311 gth_atompot%nexp_nlcc = nexp_nlcc
1312 gth_atompot%alpha_nlcc(1:nexp_nlcc) = alpha_nlcc(1:nexp_nlcc)
1313 gth_atompot%nct_nlcc(1:nexp_nlcc) = nct_nlcc(1:nexp_nlcc)
1314 gth_atompot%cval_nlcc(1:4, 1:nexp_nlcc) = cval_nlcc(1:4, 1:nexp_nlcc)
1329 INTEGER,
DIMENSION(:),
POINTER :: ppeconf
1330 LOGICAL :: nlcc_present
1331 REAL(kind=
dp) :: ac, zeff
1332 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ap, ce
1333 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hhp
1334 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: ccp
1337 name=sgp_atompot%pname, &
1339 elec_conf=ppeconf, &
1340 core_charge_radius=ac)
1341 sgp_atompot%zion = zeff
1342 sgp_atompot%ac_local = ac
1343 sgp_atompot%econf(0:3) = ppeconf(0:3)
1345 is_nonlocal=sgp_atompot%is_nonlocal, &
1346 n_nonlocal=n, a_nonlocal=ap, h_nonlocal=hhp, c_nonlocal=ccp)
1348 sgp_atompot%has_nonlocal = any(sgp_atompot%is_nonlocal)
1349 sgp_atompot%lmax = lm
1350 IF (sgp_atompot%has_nonlocal)
THEN
1351 cpassert(n <=
SIZE(sgp_atompot%a_nonlocal))
1352 sgp_atompot%n_nonlocal = n
1353 sgp_atompot%a_nonlocal(1:n) = ap(1:n)
1354 sgp_atompot%h_nonlocal(1:n, 0:lm) = hhp(1:n, 0:lm)
1357 sgp_atompot%c_nonlocal(1:n, 1:n, 0:lm) = sqrt(
fourpi)*ccp(1:n, 1:n, 0:lm)
1360 CALL get_potential(sgp_potential, n_local=n, a_local=ap, c_local=ce)
1361 cpassert(n <=
SIZE(sgp_atompot%a_local))
1362 sgp_atompot%n_local = n
1363 sgp_atompot%a_local(1:n) = ap(1:n)
1364 sgp_atompot%c_local(1:n) = ce(1:n)
1367 n_nlcc=n, a_nlcc=ap, c_nlcc=ce)
1368 IF (nlcc_present)
THEN
1369 sgp_atompot%has_nlcc = .true.
1370 cpassert(n <=
SIZE(sgp_atompot%a_nlcc))
1371 sgp_atompot%n_nlcc = n
1372 sgp_atompot%a_nlcc(1:n) = ap(1:n)
1373 sgp_atompot%c_nlcc(1:n) = ce(1:n)
1375 sgp_atompot%has_nlcc = .false.
1385 SUBROUTINE ecp_potential_conversion(sgp_potential, ecp_atompot)
1389 INTEGER,
DIMENSION(:),
POINTER :: ppeconf
1390 LOGICAL :: ecp_local, ecp_semi_local
1391 REAL(kind=
dp) :: zeff
1393 CALL get_potential(sgp_potential, ecp_local=ecp_local, ecp_semi_local=ecp_semi_local)
1394 cpassert(ecp_semi_local .AND. ecp_local)
1396 name=ecp_atompot%pname, &
1399 ecp_atompot%zion = zeff
1400 ecp_atompot%econf(0:3) = ppeconf(0:3)
1403 CALL get_potential(sgp_potential, nloc=ecp_atompot%nloc, nrloc=ecp_atompot%nrloc, &
1404 aloc=ecp_atompot%aloc, bloc=ecp_atompot%bloc)
1406 CALL get_potential(sgp_potential, npot=ecp_atompot%npot, nrpot=ecp_atompot%nrpot, &
1407 apot=ecp_atompot%apot, bpot=ecp_atompot%bpot)
1409 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).
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.
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