71#include "./base/base_uses.f90"
79 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_rho_atom_methods'
102 natom, nspins, tot_rho1_h, tot_rho1_s)
107 INTEGER,
DIMENSION(:),
INTENT(IN) :: atom_list
108 INTEGER,
INTENT(IN) :: natom, nspins
109 REAL(
dp),
DIMENSION(:),
INTENT(INOUT) :: tot_rho1_h, tot_rho1_s
111 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_atom'
113 INTEGER :: damax_iso_not0_local, handle, i, i1, i2, iat, iatom, icg, ipgf1, ipgf2, ir, &
114 iset1, iset2, iso, iso1, iso1_coeff, iso1_first, iso1_last, iso2, iso2_coeff, iso2_first, &
115 iso2_last, j, l, l_iso, l_sub, l_sum, lmax12, lmax_expansion, lmin12, m1s, m2s, &
116 max_iso_not0, max_iso_not0_local, max_npgf, max_s_harm, maxl, maxso, mepos, n1s, n2s, nr, &
117 nset, num_pe, size1, size2
118 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list, dacg_n_list
119 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list, dacg_list
120 INTEGER,
DIMENSION(2) :: bo
121 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, o2nindex
122 LOGICAL,
ALLOCATABLE,
DIMENSION(:, :) :: done_vgg
123 REAL(
dp) :: c1, c2, cpc_h, cpc_s, rho_h, rho_s, &
125 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: erf_zet12, g1, g2, gg0, int1, int2
126 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dgg, gg, gg_lm1
127 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: g_rad, vgg
128 REAL(
dp),
DIMENSION(:, :),
POINTER :: coeff_h, coeff_s, zet
129 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
130 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: my_cg_dxyz
135 CALL timeset(routinen, handle)
140 NULLIFY (harmonics, grid_atom)
141 NULLIFY (lmin, lmax, npgf, zet, my_cg, my_cg_dxyz, coeff_h, coeff_s)
143 CALL get_qs_kind(qs_kind, grid_atom=grid_atom, harmonics=harmonics)
144 CALL get_qs_kind(qs_kind, basis_set=basis_1c, basis_type=
"GAPW_1C")
147 maxl=maxl, npgf=npgf, nset=nset, zet=zet, &
152 max_iso_not0 = harmonics%max_iso_not0
153 max_s_harm = harmonics%max_s_harm
156 max_npgf = maxval(npgf(1:nset))
157 lmax_expansion =
indso(1, max_iso_not0)
159 num_pe = para_env%num_pe
160 mepos = para_env%mepos
163 my_cg => harmonics%my_CG
164 my_cg_dxyz => harmonics%my_CG_dxyz
166 ALLOCATE (g1(nr), g2(nr), gg0(nr), gg(nr, 0:2*maxl), dgg(nr, 0:2*maxl), gg_lm1(nr, 0:2*maxl))
167 ALLOCATE (erf_zet12(nr), vgg(nr, 0:2*maxl, 0:
indso(1, max_iso_not0)))
168 ALLOCATE (done_vgg(0:2*maxl, 0:
indso(1, max_iso_not0)))
169 ALLOCATE (int1(nr), int2(nr))
170 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm), &
171 dacg_list(2,
nsoset(maxl)**2, max_s_harm), dacg_n_list(max_s_harm))
172 ALLOCATE (g_rad(nr, max_npgf, nset))
175 DO ipgf1 = 1, npgf(iset1)
176 g_rad(1:nr, ipgf1, iset1) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
180 DO iat = bo(1), bo(2)
181 iatom = atom_list(iat)
183 IF (.NOT.
ASSOCIATED(rho_atom_set(iatom)%rho_rad_h(i)%r_coef))
THEN
184 CALL allocate_rho_atom_rad(rho_atom_set, iatom, i, nr, max_iso_not0)
186 CALL set2zero_rho_atom_rad(rho_atom_set, iatom, i)
196 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
197 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
198 cpassert(max_iso_not0_local <= max_iso_not0)
199 CALL get_none0_cg_list(my_cg_dxyz, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
200 max_s_harm, lmax_expansion, dacg_list, dacg_n_list, damax_iso_not0_local)
203 DO ipgf1 = 1, npgf(iset1)
204 iso1_first =
nsoset(lmin(iset1) - 1) + 1 + n1s*(ipgf1 - 1) + m1s
205 iso1_last =
nsoset(lmax(iset1)) + n1s*(ipgf1 - 1) + m1s
206 size1 = iso1_last - iso1_first + 1
207 iso1_first = o2nindex(iso1_first)
208 iso1_last = o2nindex(iso1_last)
209 i1 = iso1_last - iso1_first + 1
210 cpassert(size1 == i1)
211 i1 =
nsoset(lmin(iset1) - 1) + 1
213 g1(1:nr) = g_rad(1:nr, ipgf1, iset1)
216 DO ipgf2 = 1, npgf(iset2)
217 iso2_first =
nsoset(lmin(iset2) - 1) + 1 + n2s*(ipgf2 - 1) + m2s
218 iso2_last =
nsoset(lmax(iset2)) + n2s*(ipgf2 - 1) + m2s
219 size2 = iso2_last - iso2_first + 1
220 iso2_first = o2nindex(iso2_first)
221 iso2_last = o2nindex(iso2_last)
222 i2 = iso2_last - iso2_first + 1
223 cpassert(size2 == i2)
224 i2 =
nsoset(lmin(iset2) - 1) + 1
226 g2(1:nr) = g_rad(1:nr, ipgf2, iset2)
227 lmin12 = lmin(iset1) + lmin(iset2)
228 lmax12 = lmax(iset1) + lmax(iset2)
230 zet12 = zet(ipgf1, iset1) + zet(ipgf2, iset2)
231 root_zet12 = sqrt(zet(ipgf1, iset1) + zet(ipgf2, iset2))
233 erf_zet12(ir) = erf(root_zet12*grid_atom%rad(ir))
242 IF (lmin12 <= lmax_expansion)
THEN
243 IF (lmin12 == 0)
THEN
244 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
245 gg_lm1(1:nr, lmin12) = 0.0_dp
246 gg0(1:nr) = gg(1:nr, lmin12)
248 gg0(1:nr) = g1(1:nr)*g2(1:nr)
249 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
250 gg_lm1(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12 - 1)*g1(1:nr)*g2(1:nr)
254 IF (lmax12 > lmax_expansion) lmax12 = lmax_expansion
256 DO l = lmin12 + 1, lmax12
257 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(1:nr, l - 1)
258 gg_lm1(1:nr, l) = gg(1:nr, l - 1)
259 dgg(1:nr, l - 1) = -2.0_dp*(zet(ipgf1, iset1) + zet(ipgf2, iset2))*gg(1:nr, l)
262 dgg(1:nr, lmax12) = -2.0_dp*(zet(ipgf1, iset1) + &
263 zet(ipgf2, iset2))*grid_atom%rad(1:nr)*gg(1:nr, lmax12)
265 c2 = sqrt(
pi*
pi*
pi/(zet12*zet12*zet12))
267 DO iso = 1, max_iso_not0_local
268 l_iso =
indso(1, iso)
269 c1 =
fourpi/(2._dp*real(l_iso,
dp) + 1._dp)
270 DO icg = 1, cg_n_list(iso)
271 iso1 = cg_list(1, icg, iso)
272 iso2 = cg_list(2, icg, iso)
275 cpassert(l <= lmax_expansion)
276 IF (done_vgg(l, l_iso)) cycle
281 vgg(1:nr, l, l_iso) = erf_zet12(1:nr)*grid_atom%oorad2l(1:nr, 1)*c2
283 CALL whittaker_c0a(int1, grid_atom%rad, gg0, erf_zet12, zet12, l, l_iso, nr)
284 CALL whittaker_ci(int2, grid_atom%rad, gg0, zet12, l_sub, nr)
287 int2(ir) = grid_atom%rad2l(ir, l_iso)*int2(ir)
288 vgg(ir, l, l_iso) = c1*(int1(ir) + int2(ir))
291 done_vgg(l, l_iso) = .true.
296 DO iat = bo(1), bo(2)
297 iatom = atom_list(iat)
300 coeff_h => rho_atom_set(iatom)%cpc_h(i)%r_coef
301 coeff_s => rho_atom_set(iatom)%cpc_s(i)%r_coef
303 DO iso = 1, max_iso_not0_local
304 l_iso =
indso(1, iso)
305 DO icg = 1, cg_n_list(iso)
306 iso1 = cg_list(1, icg, iso)
307 iso2 = cg_list(2, icg, iso)
310 cpassert(l <= lmax_expansion)
311 iso1_coeff = iso1_first + iso1 - i1
312 iso2_coeff = iso2_first + iso2 - i2
313 cpc_h = coeff_h(iso1_coeff, iso2_coeff)*my_cg(iso1, iso2, iso)
314 cpc_s = coeff_s(iso1_coeff, iso2_coeff)*my_cg(iso1, iso2, iso)
316 rho_atom_set(iatom)%rho_rad_h(i)%r_coef(1:nr, iso) = &
317 rho_atom_set(iatom)%rho_rad_h(i)%r_coef(1:nr, iso) + &
320 rho_atom_set(iatom)%rho_rad_s(i)%r_coef(1:nr, iso) = &
321 rho_atom_set(iatom)%rho_rad_s(i)%r_coef(1:nr, iso) + &
324 rho_atom_set(iatom)%drho_rad_h(i)%r_coef(1:nr, iso) = &
325 rho_atom_set(iatom)%drho_rad_h(i)%r_coef(1:nr, iso) + &
328 rho_atom_set(iatom)%drho_rad_s(i)%r_coef(1:nr, iso) = &
329 rho_atom_set(iatom)%drho_rad_s(i)%r_coef(1:nr, iso) + &
332 rho_atom_set(iatom)%vrho_rad_h(i)%r_coef(1:nr, iso) = &
333 rho_atom_set(iatom)%vrho_rad_h(i)%r_coef(1:nr, iso) + &
334 vgg(1:nr, l, l_iso)*cpc_h
336 rho_atom_set(iatom)%vrho_rad_s(i)%r_coef(1:nr, iso) = &
337 rho_atom_set(iatom)%vrho_rad_s(i)%r_coef(1:nr, iso) + &
338 vgg(1:nr, l, l_iso)*cpc_s
344 DO iso = 1, max_iso_not0
345 l_iso =
indso(1, iso)
346 DO icg = 1, dacg_n_list(iso)
347 iso1 = dacg_list(1, icg, iso)
348 iso2 = dacg_list(2, icg, iso)
350 cpassert(l <= lmax_expansion)
351 iso1_coeff = iso1_first + iso1 - i1
352 iso2_coeff = iso2_first + iso2 - i2
353 cpc_h = coeff_h(iso1_coeff, iso2_coeff)
354 cpc_s = coeff_s(iso1_coeff, iso2_coeff)
356 rho_atom_set(iatom)%rho_rad_h_d(j, i)%r_coef(1:nr, iso) = &
357 rho_atom_set(iatom)%rho_rad_h_d(j, i)%r_coef(1:nr, iso) + &
358 gg_lm1(1:nr, l)*cpc_h*my_cg_dxyz(j, iso1, iso2, iso)
360 rho_atom_set(iatom)%rho_rad_s_d(j, i)%r_coef(1:nr, iso) = &
361 rho_atom_set(iatom)%rho_rad_s_d(j, i)%r_coef(1:nr, iso) + &
362 gg_lm1(1:nr, l)*cpc_s*my_cg_dxyz(j, iso1, iso2, iso)
378 DO iat = bo(1), bo(2)
379 iatom = atom_list(iat)
383 DO iso = 1, max_iso_not0
387 rho_h = rho_h + rho_atom_set(iatom)%rho_rad_h(i)%r_coef(ir, iso)*grid_atom%wr(ir)
388 rho_s = rho_s + rho_atom_set(iatom)%rho_rad_s(i)%r_coef(ir, iso)*grid_atom%wr(ir)
390 tot_rho1_h(i) = tot_rho1_h(i) + rho_h*harmonics%slm_int(iso)
391 tot_rho1_s(i) = tot_rho1_s(i) + rho_s*harmonics%slm_int(iso)
398 DEALLOCATE (g1, g2, gg0, gg, gg_lm1, dgg, vgg, done_vgg, erf_zet12, int1, int2, g_rad)
399 DEALLOCATE (cg_list, cg_n_list, dacg_list, dacg_n_list)
400 DEALLOCATE (o2nindex)
402 CALL timestop(handle)
429 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
435 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_atom_coeff'
437 INTEGER :: bo(2), handle, i, iac, iatom, ibc, icol, ikind, img, irow, ispin, jatom, jkind, &
438 kac, katom, kbc, kkind, len_cpc, len_pc1, max_gau, max_nsgf, mepos, n_cont_a, n_cont_b, &
439 nat_kind, natom, nimages, nkind, nsoctot, nspins, num_pe
440 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of, nsatbas_kind
441 INTEGER,
DIMENSION(3) :: cell_b
442 INTEGER,
DIMENSION(:),
POINTER :: a_list, list_a, list_b
443 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
444 LOGICAL :: dista, distab, distb, found, paw_atom
445 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: has_intac, paw_kind
446 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: proj_work1, proj_work2
447 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: p_matrix
448 REAL(kind=
dp) :: eps_cpc, factor, pmax
449 REAL(kind=
dp),
DIMENSION(3) :: rab
450 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: c_coeff_hh_a, c_coeff_hh_b, &
451 c_coeff_ss_a, c_coeff_ss_b, r_coef_h, &
453 TYPE(
alist_type),
POINTER :: alist_ac, alist_bc
460 DIMENSION(:),
POINTER :: nl_iterator
466 CALL timeset(routinen, handle)
469 dft_control=dft_control, &
470 atomic_kind_set=atomic_kind_set)
472 eps_cpc = dft_control%qs_control%gapw_control%eps_cpc
474 cpassert(
ASSOCIATED(qs_kind_set))
475 cpassert(
ASSOCIATED(rho_atom_set))
476 cpassert(
ASSOCIATED(oce))
477 cpassert(
ASSOCIATED(sab))
479 nspins = dft_control%nspins
480 nimages = dft_control%nimages
482 NULLIFY (cell_to_index)
483 IF (nimages > 1)
THEN
484 CALL get_qs_env(qs_env=qs_env, kpoints=kpoints)
489 CALL get_qs_kind_set(qs_kind_set, maxsgf=max_nsgf, maxgtops=max_gau, basis_type=
'GAPW_1C')
491 nkind =
SIZE(atomic_kind_set)
494 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=a_list, natom=nat_kind)
495 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
497 IF (.NOT. paw_atom) cycle
501 rho_atom_set(iatom)%cpc_h(ispin)%r_coef = 0.0_dp
502 rho_atom_set(iatom)%cpc_s(ispin)%r_coef = 0.0_dp
506 num_pe = para_env%num_pe
507 mepos = para_env%mepos
512 rho_atom_set(iatom)%ga_Vlocal_gb_h(ispin)%r_coef = 0.0_dp
513 rho_atom_set(iatom)%ga_Vlocal_gb_s(ispin)%r_coef = 0.0_dp
518 ALLOCATE (basis_set_list(nkind))
519 ALLOCATE (paw_kind(nkind), nsatbas_kind(nkind), has_intac(nkind*nkind))
520 paw_kind(:) = .false.
522 has_intac(:) = .false.
524 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_set_a)
525 IF (
ASSOCIATED(basis_set_a))
THEN
526 basis_set_list(ikind)%gto_basis_set => basis_set_a
528 NULLIFY (basis_set_list(ikind)%gto_basis_set)
530 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C", &
531 paw_atom=paw_kind(ikind))
534 DO ikind = 1, nkind*nkind
535 has_intac(ikind) =
ASSOCIATED(oce%intac(ikind)%alist)
538 len_pc1 = max_nsgf*max_gau
539 len_cpc = max_gau*max_gau
575 ALLOCATE (p_block_spin(nspins))
576 ALLOCATE (p_matrix(max_nsgf, max_nsgf))
577 ALLOCATE (proj_work1(len_pc1), proj_work2(len_cpc))
595 ikind=ikind, jkind=jkind, &
596 iatom=iatom, jatom=jatom, &
599 basis_set_a => basis_set_list(ikind)%gto_basis_set
600 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
601 basis_set_b => basis_set_list(jkind)%gto_basis_set
602 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
605 IF (iatom <= jatom)
THEN
613 IF (nimages > 1)
THEN
614 img = cell_to_index(cell_b(1), cell_b(2), cell_b(3))
622 row=irow, col=icol, block=p_block_spin(ispin)%r_coef, &
624 pmax = pmax + maxval(abs(p_block_spin(ispin)%r_coef))
628 IF (.NOT. paw_kind(kkind)) cycle
630 nsoctot = nsatbas_kind(kkind)
632 iac = ikind + nkind*(kkind - 1)
633 ibc = jkind + nkind*(kkind - 1)
634 IF (.NOT. has_intac(iac)) cycle
635 IF (.NOT. has_intac(ibc)) cycle
637 CALL get_alist(oce%intac(iac), alist_ac, iatom)
638 CALL get_alist(oce%intac(ibc), alist_bc, jatom)
639 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
640 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
642 DO kac = 1, alist_ac%nclist
643 DO kbc = 1, alist_bc%nclist
644 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
645 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
646 IF (pmax*alist_bc%clist(kbc)%maxac*alist_ac%clist(kac)%maxac < eps_cpc) cycle
648 n_cont_a = alist_ac%clist(kac)%nsgf_cnt
649 n_cont_b = alist_bc%clist(kbc)%nsgf_cnt
650 IF (n_cont_a == 0 .OR. n_cont_b == 0) cycle
652 list_a => alist_ac%clist(kac)%sgf_list
653 list_b => alist_bc%clist(kbc)%sgf_list
655 katom = alist_ac%clist(kac)%catom
657 IF (iatom == katom .AND. all(alist_ac%clist(kac)%cell == 0))
THEN
658 c_coeff_hh_a => alist_ac%clist(kac)%achint(:, :, 1)
659 c_coeff_ss_a => alist_ac%clist(kac)%acint(:, :, 1)
662 c_coeff_hh_a => alist_ac%clist(kac)%acint(:, :, 1)
663 c_coeff_ss_a => alist_ac%clist(kac)%acint(:, :, 1)
666 IF (jatom == katom .AND. all(alist_bc%clist(kbc)%cell == 0))
THEN
667 c_coeff_hh_b => alist_bc%clist(kbc)%achint(:, :, 1)
668 c_coeff_ss_b => alist_bc%clist(kbc)%acint(:, :, 1)
671 c_coeff_hh_b => alist_bc%clist(kbc)%acint(:, :, 1)
672 c_coeff_ss_b => alist_bc%clist(kbc)%acint(:, :, 1)
676 distab = dista .AND. distb
680 IF (iatom <= jatom)
THEN
682 SIZE(p_block_spin(ispin)%r_coef, 1), p_matrix,
SIZE(p_matrix, 1), &
683 list_a, n_cont_a, list_b, n_cont_b)
686 SIZE(p_block_spin(ispin)%r_coef, 1), p_matrix,
SIZE(p_matrix, 1), &
687 list_b, n_cont_b, list_a, n_cont_a)
691 IF (iatom == jatom) factor = 0.5_dp
693 r_coef_h => rho_atom_set(katom)%cpc_h(ispin)%r_coef
694 r_coef_s => rho_atom_set(katom)%cpc_s(ispin)%r_coef
697 IF (iatom <= jatom)
THEN
698 CALL proj_blk(c_coeff_hh_a, c_coeff_ss_a, n_cont_a, &
699 c_coeff_hh_b, c_coeff_ss_b, n_cont_b, &
700 p_matrix, max_nsgf, r_coef_h, r_coef_s, nsoctot, &
701 len_pc1, len_cpc, factor, distab, proj_work1, proj_work2)
703 CALL proj_blk(c_coeff_hh_b, c_coeff_ss_b, n_cont_b, &
704 c_coeff_hh_a, c_coeff_ss_a, n_cont_a, &
705 p_matrix, max_nsgf, r_coef_h, r_coef_s, nsoctot, &
706 len_pc1, len_cpc, factor, distab, proj_work1, proj_work2)
729 DEALLOCATE (p_block_spin, p_matrix, proj_work1, proj_work2)
737 ikind = kind_of(iatom)
740 IF (
ASSOCIATED(rho_atom_set(iatom)%cpc_h(ispin)%r_coef))
THEN
741 CALL para_env%sum(rho_atom_set(iatom)%cpc_h(ispin)%r_coef)
742 CALL para_env%sum(rho_atom_set(iatom)%cpc_s(ispin)%r_coef)
743 r_coef_h => rho_atom_set(iatom)%cpc_h(ispin)%r_coef
744 r_coef_s => rho_atom_set(iatom)%cpc_s(ispin)%r_coef
745 r_coef_h(:, :) = r_coef_h(:, :) + transpose(r_coef_h(:, :))
746 r_coef_s(:, :) = r_coef_s(:, :) + transpose(r_coef_s(:, :))
752 DEALLOCATE (kind_of, basis_set_list, paw_kind, nsatbas_kind, has_intac)
754 CALL timestop(handle)
768 SUBROUTINE init_rho_atom(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
772 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
776 CHARACTER(len=*),
PARAMETER :: routinen =
'init_rho_atom'
778 INTEGER :: handle, ikind, il, iso, iso1, iso2, l1, l1l2, l2, la, lc1, lc2, lcleb, ll, llmax, &
779 lmax_sphere, lp, m1, m2, max_s_harm, max_s_set, maxl, maxlgto, maxs, mm, mp, na, nat, &
780 natom, nr, nspins, quadrature
781 INTEGER,
DIMENSION(:),
POINTER :: atom_list
783 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rga
784 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
790 CALL timeset(routinen, handle)
792 NULLIFY (basis_1c_set)
793 NULLIFY (my_cg, grid_atom, harmonics, atom_list)
795 cpassert(
ASSOCIATED(atomic_kind_set))
796 cpassert(
ASSOCIATED(dft_control))
797 cpassert(
ASSOCIATED(para_env))
798 cpassert(
ASSOCIATED(qs_kind_set))
802 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto, basis_type=
"GAPW_1C")
804 nspins = dft_control%nspins
805 gapw_control => dft_control%qs_control%gapw_control
807 lmax_sphere = gapw_control%lmax_sphere
809 llmax = min(lmax_sphere, 2*maxlgto)
810 max_s_harm =
nsoset(llmax)
811 max_s_set =
nsoset(maxlgto)
813 lcleb = max(llmax, 2*maxlgto, 1)
817 CALL reallocate(my_cg, 1, max_s_set, 1, max_s_set, 1, max_s_harm)
819 ALLOCATE (rga(lcleb, 2))
829 IF (l1 + l2 > llmax)
THEN
836 IF (m1*m2 < 0 .OR. (m1*m2 == 0 .AND. (m1 < 0 .OR. m2 < 0)))
THEN
843 DO lp = mod(l1 + l2, 2), l1l2, 2
845 IF (abs(mp) <= lp)
THEN
847 iso =
nsoset(lp - 1) + lp + 1 + mp
849 iso =
nsoset(lp - 1) + lp + 1 - abs(mp)
851 my_cg(iso1, iso2, iso) = rga(il, 1)
853 IF (mp /= mm .AND. abs(mm) <= lp)
THEN
855 iso =
nsoset(lp - 1) + lp + 1 + mm
857 iso =
nsoset(lp - 1) + lp + 1 - abs(mm)
859 my_cg(iso1, iso2, iso) = rga(il, 2)
871 quadrature = gapw_control%quadrature
873 DO ikind = 1,
SIZE(atomic_kind_set)
874 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=nat)
877 grid_atom=grid_atom, &
878 harmonics=harmonics, &
879 ngrid_rad=nr, ngrid_ang=na)
886 grid_atom%ng_sphere = na
890 WRITE (*,
'(/,72("*"))')
891 WRITE (*,
'(T2,A,T66,I4)') &
892 "WARNING: the lebedev grid is built for angular momentum l up to ", la, &
893 " the max l of spherical harmonics is larger, l_max = ", llmax, &
894 " good integration is guaranteed only for l <= ", la
895 WRITE (*,
'(72("*"),/)')
903 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_1c_set, basis_type=
"GAPW_1C")
907 my_cg, na, llmax, maxs, max_s_harm, ll, grid_atom%wa, &
908 grid_atom%azi, grid_atom%pol)
909 CALL get_maxl_cg(harmonics, basis_1c_set, llmax, max_s_harm)
918 CALL timestop(handle)
934 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
938 CHARACTER(len=*),
PARAMETER :: routinen =
'allocate_rho_atom_internals'
940 INTEGER :: bo(2), handle, iat, iatom, ikind, ispin, &
941 max_iso_not0, maxso, mepos, nat, &
942 natom, nsatbas, nset, nsotot, nspins, &
944 INTEGER,
DIMENSION(:),
POINTER :: atom_list
949 CALL timeset(routinen, handle)
951 cpassert(
ASSOCIATED(atomic_kind_set))
952 cpassert(
ASSOCIATED(dft_control))
953 cpassert(
ASSOCIATED(para_env))
954 cpassert(
ASSOCIATED(qs_kind_set))
958 nspins = dft_control%nspins
960 IF (
ASSOCIATED(rho_atom_set))
THEN
963 ALLOCATE (rho_atom_set(natom))
965 DO ikind = 1,
SIZE(atomic_kind_set)
967 NULLIFY (atom_list, harmonics)
968 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=nat)
974 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
980 max_iso_not0 = harmonics%max_iso_not0
982 iatom = atom_list(iat)
985 ALLOCATE (rho_atom_set(iatom)%rho_rad_h(nspins))
986 ALLOCATE (rho_atom_set(iatom)%rho_rad_s(nspins))
987 ALLOCATE (rho_atom_set(iatom)%vrho_rad_h(nspins))
988 ALLOCATE (rho_atom_set(iatom)%vrho_rad_s(nspins))
990 ALLOCATE (rho_atom_set(iatom)%cpc_h(nspins), &
991 rho_atom_set(iatom)%cpc_s(nspins), &
992 rho_atom_set(iatom)%drho_rad_h(nspins), &
993 rho_atom_set(iatom)%drho_rad_s(nspins), &
994 rho_atom_set(iatom)%rho_rad_h_d(3, nspins), &
995 rho_atom_set(iatom)%rho_rad_s_d(3, nspins))
996 ALLOCATE (rho_atom_set(iatom)%int_scr_h(nspins), &
997 rho_atom_set(iatom)%int_scr_s(nspins))
1000 DO ispin = 1, nspins
1001 ALLOCATE (rho_atom_set(iatom)%cpc_h(ispin)%r_coef(1:nsatbas, 1:nsatbas), &
1002 rho_atom_set(iatom)%cpc_s(ispin)%r_coef(1:nsatbas, 1:nsatbas))
1003 ALLOCATE (rho_atom_set(iatom)%int_scr_h(ispin)%r_coef(1:nsatbas, 1:nsatbas), &
1004 rho_atom_set(iatom)%int_scr_s(ispin)%r_coef(1:nsatbas, 1:nsatbas))
1006 rho_atom_set(iatom)%cpc_h(ispin)%r_coef = 0.0_dp
1007 rho_atom_set(iatom)%cpc_s(ispin)%r_coef = 0.0_dp
1013 num_pe = para_env%num_pe
1014 mepos = para_env%mepos
1016 DO iat = bo(1), bo(2)
1017 iatom = atom_list(iat)
1018 ALLOCATE (rho_atom_set(iatom)%ga_Vlocal_gb_h(nspins), &
1019 rho_atom_set(iatom)%ga_Vlocal_gb_s(nspins))
1021 DO ispin = 1, nspins
1022 CALL reallocate(rho_atom_set(iatom)%ga_Vlocal_gb_h(ispin)%r_coef, &
1023 1, nsotot, 1, nsotot)
1024 CALL reallocate(rho_atom_set(iatom)%ga_Vlocal_gb_s(ispin)%r_coef, &
1025 1, nsotot, 1, nsotot)
1027 rho_atom_set(iatom)%ga_Vlocal_gb_h(ispin)%r_coef = 0.0_dp
1028 rho_atom_set(iatom)%ga_Vlocal_gb_s(ispin)%r_coef = 0.0_dp
1036 CALL timestop(handle)
1048 SUBROUTINE allocate_rho_atom_rad(rho_atom_set, iatom, ispin, nr, max_iso_not0)
1051 INTEGER,
INTENT(IN) :: iatom, ispin, nr, max_iso_not0
1053 CHARACTER(len=*),
PARAMETER :: routinen =
'allocate_rho_atom_rad'
1055 INTEGER :: handle, j
1057 CALL timeset(routinen, handle)
1059 ALLOCATE (rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef(1:nr, 1:max_iso_not0), &
1060 rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef(1:nr, 1:max_iso_not0), &
1061 rho_atom_set(iatom)%vrho_rad_h(ispin)%r_coef(1:nr, 1:max_iso_not0), &
1062 rho_atom_set(iatom)%vrho_rad_s(ispin)%r_coef(1:nr, 1:max_iso_not0))
1064 rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef = 0.0_dp
1065 rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef = 0.0_dp
1066 rho_atom_set(iatom)%vrho_rad_h(ispin)%r_coef = 0.0_dp
1067 rho_atom_set(iatom)%vrho_rad_s(ispin)%r_coef = 0.0_dp
1069 ALLOCATE (rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef(nr, max_iso_not0), &
1070 rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef(nr, max_iso_not0))
1071 rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef = 0.0_dp
1072 rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef = 0.0_dp
1075 ALLOCATE (rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef(nr, max_iso_not0), &
1076 rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef(nr, max_iso_not0))
1077 rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef = 0.0_dp
1078 rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef = 0.0_dp
1081 CALL timestop(handle)
1083 END SUBROUTINE allocate_rho_atom_rad
1091 SUBROUTINE set2zero_rho_atom_rad(rho_atom_set, iatom, ispin)
1094 INTEGER,
INTENT(IN) :: iatom, ispin
1098 rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef = 0.0_dp
1099 rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef = 0.0_dp
1101 rho_atom_set(iatom)%vrho_rad_h(ispin)%r_coef = 0.0_dp
1102 rho_atom_set(iatom)%vrho_rad_s(ispin)%r_coef = 0.0_dp
1104 rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef = 0.0_dp
1105 rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef = 0.0_dp
1108 rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef = 0.0_dp
1109 rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef = 0.0_dp
1112 END SUBROUTINE set2zero_rho_atom_rad
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
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)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
Defines the basic variable types.
integer, parameter, public dp
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered)
Retrieve information from a kpoint environment.
Generation of the spherical Lebedev grids. All Lebedev grids were generated with a precision of at le...
subroutine, public deallocate_lebedev_grids()
...
type(oh_grid), dimension(nlg), target, public lebedev_grid
integer function, public get_number_of_lebedev_grid(l, n)
Get the number of the Lebedev grid, which has the requested angular momentum quantnum number l or siz...
subroutine, public init_lebedev_grids()
Load the coordinates and weights of the nonredundant Lebedev grid points.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), parameter, public fourpi
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nsoset
integer, dimension(:, :), allocatable, public indso
subroutine, public get_paw_basis_info(basis_1c, o2nindex, n2oindex, nsatbas)
Return some info on the PAW basis derived from a GTO basis set.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public create_grid_atom(grid_atom, nr, na, llmax, ll, quadrature)
...
subroutine, public get_maxl_cg(harmonics, orb_basis, llmax, max_s_harm)
...
subroutine, public create_harmonics_atom(harmonics, my_cg, na, llmax, maxs, max_s_harm, ll, wa, azi, pol)
...
Define the quickstep kind type and their sub types.
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, 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, 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 get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
Routines for the construction of the coefficients for the expansion of the atomic densities rho1_hard...
subroutine, public proj_blk(h_a, s_a, na, h_b, s_b, nb, blk, ldb, proj_h, proj_s, nso, len1, len2, fac, distab, work1, work2)
Project a matrix block onto the local atomic functions.
subroutine, public calculate_rho_atom(para_env, rho_atom_set, qs_kind, atom_list, natom, nspins, tot_rho1_h, tot_rho1_s)
...
subroutine, public allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
subroutine, public init_rho_atom(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
subroutine, public calculate_rho_atom_coeff(qs_env, rho_ao, rho_atom_set, qs_kind_set, oce, sab, para_env)
...
subroutine, public deallocate_rho_atom_set(rho_atom_set)
...
General overlap type integrals containers.
subroutine, public alist_pre_align_blk(blk_in, ldin, blk_out, ldout, ilist, in, jlist, jn)
...
subroutine, public get_alist(sap_int, alist, atom)
...
Calculate spherical harmonics.
subroutine, public clebsch_gordon_init(l)
...
subroutine, public clebsch_gordon_deallocate()
...
All kind of helpful little routines.
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me
Calculates special integrals.
subroutine, public whittaker_c0a(wc, r, expa, erfa, alpha, l1, l2, n)
int(y^(2+l1+l2) * exp(-alpha*y*y),y=0..x) / x^(l2+1); wc(:) :: output r(:) :: coordinate expa(:) :: e...
subroutine, public whittaker_ci(wc, r, expa, alpha, l, n)
int(y^(l+1) * exp(-alpha*y*y),y=x..infinity);
Provides all information about an atomic kind.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.