37 dbcsr_type_no_symmetry, dbcsr_type_symmetric
42 USE dbt_api,
ONLY: dbt_destroy,&
44 dbt_iterator_blocks_left,&
45 dbt_iterator_next_block,&
134#include "./base/base_uses.f90"
140 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xas_tdp_atom'
166 LOGICAL,
OPTIONAL :: ltddfpt
168 CHARACTER(len=*),
PARAMETER :: routinen =
'init_xas_atom_env'
170 INTEGER :: handle, ikind, natom, nex_atoms, &
171 nex_kinds, nkind, nspins
174 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
176 NULLIFY (qs_kind_set, particle_set)
178 CALL timeset(routinen, handle)
181 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, natom=natom, particle_set=particle_set)
183 nkind =
SIZE(qs_kind_set)
184 nex_kinds = xas_tdp_env%nex_kinds
185 nex_atoms = xas_tdp_env%nex_atoms
186 do_xc = xas_tdp_control%do_xc
187 IF (
PRESENT(ltddfpt))
THEN
188 IF (ltddfpt) do_xc = .false.
190 nspins = 1;
IF (xas_tdp_control%do_uks .OR. xas_tdp_control%do_roks) nspins = 2
192 xas_atom_env%nspins = nspins
193 xas_atom_env%ri_radius = xas_tdp_control%ri_radius
194 ALLOCATE (xas_atom_env%grid_atom_set(nkind))
195 ALLOCATE (xas_atom_env%harmonics_atom_set(nkind))
196 ALLOCATE (xas_atom_env%ri_sphi_so(nkind))
197 ALLOCATE (xas_atom_env%orb_sphi_so(nkind))
199 ALLOCATE (xas_atom_env%gr(nkind))
200 ALLOCATE (xas_atom_env%ga(nkind))
201 ALLOCATE (xas_atom_env%dgr1(nkind))
202 ALLOCATE (xas_atom_env%dgr2(nkind))
203 ALLOCATE (xas_atom_env%dga1(nkind))
204 ALLOCATE (xas_atom_env%dga2(nkind))
207 xas_atom_env%excited_atoms => xas_tdp_env%ex_atom_indices
208 xas_atom_env%excited_kinds => xas_tdp_env%ex_kind_indices
215 NULLIFY (xas_atom_env%orb_sphi_so(ikind)%array, xas_atom_env%ri_sphi_so(ikind)%array)
216 CALL compute_sphi_so(ikind,
"ORB", xas_atom_env%orb_sphi_so(ikind)%array, qs_env)
217 IF (any(xas_atom_env%excited_kinds == ikind))
THEN
218 CALL compute_sphi_so(ikind,
"RI_XAS", xas_atom_env%ri_sphi_so(ikind)%array, qs_env)
223 IF (do_xc .AND. (.NOT. xas_tdp_control%xps_only))
THEN
227 CALL timestop(handle)
243 CHARACTER(len=default_string_length), &
244 DIMENSION(:, :),
POINTER :: grid_info
245 LOGICAL,
INTENT(IN) :: do_xc
248 CHARACTER(LEN=default_string_length) :: kind_name
249 INTEGER :: igrid, ikind, il, iso, iso1, iso2, l1, l1l2, l2, la, lc1, lc2, lcleb, ll, llmax, &
250 lp, m1, m2, max_s_harm, max_s_set, maxl, maxlgto, maxs, mm, mp, na, nr, quadrature, stat
251 REAL(
dp) :: kind_radius
252 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rga
253 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
259 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
261 NULLIFY (my_cg, qs_kind_set, tmp_basis, grid_atom, harmonics, qs_control, dft_control)
264 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
266 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto, basis_type=
"RI_XAS")
270 qs_control => dft_control%qs_control
274 max_s_harm =
nsoset(llmax)
275 max_s_set =
nsoset(maxlgto)
280 CALL reallocate(my_cg, 1, max_s_set, 1, max_s_set, 1, max_s_harm)
282 ALLOCATE (rga(lcleb, 2))
292 IF (l1 + l2 > llmax)
THEN
299 IF (m1*m2 < 0 .OR. (m1*m2 == 0 .AND. (m1 < 0 .OR. m2 < 0)))
THEN
306 DO lp = mod(l1 + l2, 2), l1l2, 2
308 IF (abs(mp) <= lp)
THEN
310 iso =
nsoset(lp - 1) + lp + 1 + mp
312 iso =
nsoset(lp - 1) + lp + 1 - abs(mp)
314 my_cg(iso1, iso2, iso) = rga(il, 1)
316 IF (mp /= mm .AND. abs(mm) <= lp)
THEN
318 iso =
nsoset(lp - 1) + lp + 1 + mm
320 iso =
nsoset(lp - 1) + lp + 1 - abs(mm)
322 my_cg(iso1, iso2, iso) = rga(il, 2)
334 quadrature = qs_control%gapw_control%quadrature
336 DO ikind = 1,
SIZE(xas_atom_env%grid_atom_set)
339 NULLIFY (xas_atom_env%grid_atom_set(ikind)%grid_atom)
340 NULLIFY (xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom)
344 NULLIFY (grid_atom, harmonics)
345 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
346 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
349 CALL get_qs_kind(qs_kind_set(ikind), ngrid_rad=nr, ngrid_ang=na, name=kind_name)
352 IF (any(grid_info == kind_name))
THEN
353 DO igrid = 1,
SIZE(grid_info, 1)
354 IF (grid_info(igrid, 1) == kind_name)
THEN
357 READ (grid_info(igrid, 2), *, iostat=stat) na
358 IF (stat /= 0) cpabort(
"The 'na' value for the GRID keyword must be an integer")
359 READ (grid_info(igrid, 3), *, iostat=stat) nr
360 IF (stat /= 0) cpabort(
"The 'nr' value for the GRID keyword must be an integer")
364 ELSE IF (do_xc .AND. any(xas_atom_env%excited_kinds == ikind))
THEN
366 cpwarn(
"The default (and possibly small) GAPW grid is being used for one excited KIND")
372 grid_atom%ng_sphere = na
376 IF (any(xas_atom_env%excited_kinds == ikind) .AND. do_xc)
THEN
377 CALL get_qs_kind(qs_kind_set(ikind), basis_set=tmp_basis, basis_type=
"RI_XAS")
379 CALL get_qs_kind(qs_kind_set(ikind), basis_set=tmp_basis, basis_type=
"ORB")
381 CALL get_gto_basis_set(gto_basis_set=tmp_basis, maxl=maxl, kind_radius=kind_radius)
388 my_cg, na, llmax, maxs, max_s_harm, ll, grid_atom%wa, &
389 grid_atom%azi, grid_atom%pol)
390 CALL get_maxl_cg(harmonics, tmp_basis, llmax, max_s_harm)
409 REAL(
dp),
INTENT(IN) :: max_radius
411 INTEGER :: first_ir, ir, llmax_p1, na, new_nr, nr
414 na = grid_atom%ng_sphere
415 llmax_p1 =
SIZE(grid_atom%rad2l, 2) - 1
419 IF (grid_atom%rad(ir) < max_radius)
THEN
424 new_nr = nr - first_ir + 1
427 grid_atom%nr = new_nr
429 grid_atom%rad(1:new_nr) = grid_atom%rad(first_ir:nr)
430 grid_atom%rad2(1:new_nr) = grid_atom%rad2(first_ir:nr)
431 grid_atom%wr(1:new_nr) = grid_atom%wr(first_ir:nr)
432 grid_atom%weight(:, 1:new_nr) = grid_atom%weight(:, first_ir:nr)
433 grid_atom%rad2l(1:new_nr, :) = grid_atom%rad2l(first_ir:nr, :)
434 grid_atom%oorad2l(1:new_nr, :) = grid_atom%oorad2l(first_ir:nr, :)
439 CALL reallocate(grid_atom%weight, 1, na, 1, new_nr)
440 CALL reallocate(grid_atom%rad2l, 1, new_nr, 0, llmax_p1)
441 CALL reallocate(grid_atom%oorad2l, 1, new_nr, 0, llmax_p1)
455 INTEGER,
INTENT(IN) :: ikind
456 CHARACTER(len=*),
INTENT(IN) :: basis_type
457 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi_so
460 INTEGER :: ico, ipgf, iset, iso, l, lx, ly, lz, &
461 maxso, nset, sgfi, start_c, start_s
462 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
463 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
465 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi
467 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
469 NULLIFY (basis, lmax, lmin, npgf, nsgf_set, qs_kind_set, first_sgf, sphi)
471 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
472 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=basis_type)
473 CALL get_gto_basis_set(basis, lmax=lmax, nset=nset, npgf=npgf, maxso=maxso, lmin=lmin, &
474 nsgf_set=nsgf_set, sphi=sphi, first_sgf=first_sgf)
476 ALLOCATE (sphi_so(maxso, sum(nsgf_set)))
480 sgfi = first_sgf(1, iset)
481 DO ipgf = 1, npgf(iset)
482 start_s = (ipgf - 1)*
nsoset(lmax(iset))
483 start_c = (ipgf - 1)*
ncoset(lmax(iset))
484 DO l = lmin(iset), lmax(iset)
493 sphi_so(start_s +
nsoset(l - 1) + iso, sgfi:sgfi + nsgf_set(iset) - 1) = &
494 sphi_so(start_s +
nsoset(l - 1) + iso, sgfi:sgfi + nsgf_set(iset) - 1) + &
495 factor*sphi(start_c +
ncoset(l - 1) + ico, sgfi:sgfi + nsgf_set(iset) - 1)
516 SUBROUTINE find_neighbors(base_atoms, mat_s, radius, qs_env, all_neighbors, neighbor_set)
518 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: base_atoms
522 INTEGER,
DIMENSION(:),
OPTIONAL,
POINTER :: all_neighbors
524 POINTER :: neighbor_set
526 INTEGER :: i, iat, ibase, iblk, jblk, mepos, natom, &
528 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: blk_to_base, inb, who_is_there
529 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: n_neighbors
530 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_base_atom
531 REAL(
dp) :: dist2, rad2, ri(3), rij(3), rj(3)
538 NULLIFY (particle_set, para_env, my_neighbor_set, cell)
541 CALL get_qs_env(qs_env, para_env=para_env, natom=natom, particle_set=particle_set, cell=cell)
542 mepos = para_env%mepos
543 nbase =
SIZE(base_atoms)
545 ALLOCATE (my_neighbor_set(nbase))
548 ALLOCATE (blk_to_base(natom), is_base_atom(natom))
549 blk_to_base = 0; is_base_atom = .false.
551 blk_to_base(base_atoms(ibase)) = ibase
552 is_base_atom(base_atoms(ibase)) = .true.
556 ALLOCATE (n_neighbors(nbase, 0:para_env%num_pe - 1))
565 IF (iblk == jblk) cycle
568 ri =
pbc(particle_set(iblk)%r, cell)
569 rj =
pbc(particle_set(jblk)%r, cell)
570 rij =
pbc(ri, rj, cell)
572 IF (dist2 > rad2) cycle
574 IF (is_base_atom(iblk))
THEN
575 ibase = blk_to_base(iblk)
576 n_neighbors(ibase, mepos) = n_neighbors(ibase, mepos) + 1
578 IF (is_base_atom(jblk))
THEN
579 ibase = blk_to_base(jblk)
580 n_neighbors(ibase, mepos) = n_neighbors(ibase, mepos) + 1
585 CALL para_env%sum(n_neighbors)
589 ALLOCATE (my_neighbor_set(ibase)%array(sum(n_neighbors(ibase, :))))
590 my_neighbor_set(ibase)%array = 0
595 ALLOCATE (inb(nbase))
600 IF (iblk == jblk) cycle
603 ri =
pbc(particle_set(iblk)%r, cell)
604 rj =
pbc(particle_set(jblk)%r, cell)
605 rij =
pbc(ri, rj, cell)
607 IF (dist2 > rad2) cycle
609 IF (is_base_atom(iblk))
THEN
610 ibase = blk_to_base(iblk)
611 my_neighbor_set(ibase)%array(sum(n_neighbors(ibase, 0:mepos - 1)) + inb(ibase)) = jblk
612 inb(ibase) = inb(ibase) + 1
614 IF (is_base_atom(jblk))
THEN
615 ibase = blk_to_base(jblk)
616 my_neighbor_set(ibase)%array(sum(n_neighbors(ibase, 0:mepos - 1)) + inb(ibase)) = iblk
617 inb(ibase) = inb(ibase) + 1
625 CALL para_env%sum(my_neighbor_set(ibase)%array)
629 IF (
PRESENT(all_neighbors))
THEN
630 ALLOCATE (who_is_there(natom))
634 who_is_there(base_atoms(ibase)) = 1
635 DO nb = 1,
SIZE(my_neighbor_set(ibase)%array)
636 who_is_there(my_neighbor_set(ibase)%array(nb)) = 1
640 ALLOCATE (all_neighbors(natom))
643 IF (who_is_there(iat) == 1)
THEN
645 all_neighbors(i) = iat
652 IF (
PRESENT(neighbor_set))
THEN
653 neighbor_set => my_neighbor_set
656 DEALLOCATE (my_neighbor_set(ibase)%array)
658 DEALLOCATE (my_neighbor_set)
661 END SUBROUTINE find_neighbors
675 SUBROUTINE get_exat_ri_sinv(ri_sinv, whole_s, neighbors, idx_to_nb, basis_set_ri, qs_env)
678 INTEGER,
DIMENSION(:),
INTENT(IN) :: neighbors, idx_to_nb
682 CHARACTER(len=*),
PARAMETER :: routinen =
'get_exat_ri_sinv'
684 INTEGER :: blk, dest, group_handle, handle, iat, &
685 ikind, inb, ir, is, jat, jnb, natom, &
686 nnb, npcols, nprows, source, tag
687 INTEGER,
DIMENSION(:),
POINTER :: col_dist, nsgf, row_dist
688 INTEGER,
DIMENSION(:, :),
POINTER :: pgrid
689 LOGICAL :: found_risinv, found_whole
690 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_neighbor
691 REAL(
dp) :: ri(3), rij(3), rj(3)
692 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: radius
693 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_risinv, block_whole
695 TYPE(
cp_2d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: recv_buff, send_buff
705 NULLIFY (pgrid, dbcsr_dist, row_dist, col_dist, nsgf, particle_set, block_whole, block_risinv)
706 NULLIFY (cell, para_env, blacs_env)
708 CALL timeset(routinen, handle)
710 CALL get_qs_env(qs_env, dbcsr_dist=dbcsr_dist, particle_set=particle_set, natom=natom, &
711 para_env=para_env, blacs_env=blacs_env, cell=cell)
712 nnb =
SIZE(neighbors)
713 ALLOCATE (nsgf(nnb), is_neighbor(natom), radius(nnb))
714 is_neighbor = .false.
717 ikind = particle_set(iat)%atomic_kind%kind_number
718 CALL get_gto_basis_set(basis_set_ri(ikind)%gto_basis_set, nsgf=nsgf(inb), kind_radius=radius(inb))
719 is_neighbor(iat) = .true.
724 CALL group%set_handle(group_handle)
726 ALLOCATE (row_dist(nnb), col_dist(nnb))
728 row_dist(inb) =
modulo(nprows - inb, nprows)
729 col_dist(inb) =
modulo(npcols - inb, npcols)
735 CALL dbcsr_create(matrix=ri_sinv, name=
"RI_SINV", matrix_type=dbcsr_type_symmetric, &
736 dist=sinv_dist, row_blk_size=nsgf, col_blk_size=nsgf)
739 ri =
pbc(particle_set(neighbors(inb))%r, cell)
743 rj =
pbc(particle_set(neighbors(jnb))%r, cell)
744 rij =
pbc(ri, rj, cell)
745 IF (sum(rij**2) > (radius(inb) + radius(jnb))**2) cycle
748 IF (para_env%mepos == blk)
THEN
749 ALLOCATE (block_risinv(nsgf(inb), nsgf(jnb)))
750 block_risinv = 0.0_dp
752 DEALLOCATE (block_risinv)
759 DEALLOCATE (row_dist, col_dist)
763 ALLOCATE (send_buff(nnb**2), recv_buff(nnb**2))
764 ALLOCATE (send_req(nnb**2), recv_req(nnb**2))
775 IF (.NOT. found_whole) cycle
776 IF (.NOT. is_neighbor(iat)) cycle
777 IF (.NOT. is_neighbor(jat)) cycle
784 IF (found_risinv)
THEN
785 CALL dcopy(nsgf(inb)*nsgf(jnb), block_whole, 1, block_risinv, 1)
791 send_buff(is)%array => block_whole
792 tag = natom*inb + jnb
793 CALL group%isend(msgin=send_buff(is)%array, dest=dest, request=send_req(is), tag=tag)
807 IF (.NOT. found_risinv) cycle
814 IF (para_env%mepos == source) cycle
816 tag = natom*inb + jnb
818 recv_buff(ir)%array => block_risinv
819 CALL group%irecv(msgout=recv_buff(ir)%array, source=source, request=recv_req(ir), &
834 IF (found_risinv)
THEN
848 CALL timestop(handle)
850 END SUBROUTINE get_exat_ri_sinv
868 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_density_coeffs'
870 INTEGER :: exat, handle, i, iat, iatom, iex, inb, &
871 ind(3), ispin, jatom, jnb, katom, &
872 natom, nex, nkind, nnb, nspins, &
874 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: blk_size_orb, blk_size_ri, idx_to_nb, &
876 INTEGER,
DIMENSION(:),
POINTER :: all_ri_atoms
877 LOGICAL :: pmat_found, pmat_foundt, sinv_found, &
878 sinv_foundt, tensor_found, unique
879 REAL(
dp) :: factor, prefac
880 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: work2
881 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: work1
882 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: t_block
883 REAL(
dp),
DIMENSION(:, :),
POINTER :: pmat_block, pmat_blockt, sinv_block, &
887 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: overlap, rho_ao
890 TYPE(dbt_iterator_type) :: iter
891 TYPE(dbt_type) :: pqx
896 POINTER :: ab_list, ac_list, sab_ri
898 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
901 NULLIFY (qs_kind_set, basis_set_ri, basis_set_orb, ac_list, rho, rho_ao, sab_ri, ri_mats)
902 NULLIFY (particle_set, para_env, all_ri_atoms, overlap, pmat_blockt)
903 NULLIFY (blacs_env, pmat_block, ab_list, dbcsr_dist, sinv_block, sinv_blockt)
913 CALL timeset(routinen, handle)
915 CALL get_qs_env(qs_env, nkind=nkind, qs_kind_set=qs_kind_set, rho=rho, &
916 natom=natom, particle_set=particle_set, dbcsr_dist=dbcsr_dist, &
917 para_env=para_env, blacs_env=blacs_env)
918 nspins = xas_atom_env%nspins
919 nex =
SIZE(xas_atom_env%excited_atoms)
923 ALLOCATE (basis_set_ri(nkind))
924 ALLOCATE (basis_set_orb(nkind))
931 ri_mats => overlap(1)%matrix
935 CALL find_neighbors(xas_atom_env%excited_atoms, ri_mats, xas_atom_env%ri_radius, &
936 qs_env, all_neighbors=all_ri_atoms, neighbor_set=xas_atom_env%exat_neighbors)
939 factor = 0.5_dp;
IF (nspins == 2) factor = 1.0_dp
944 ALLOCATE (blk_size_ri(natom))
945 CALL get_particle_set(particle_set, qs_kind_set, nsgf=blk_size_ri, basis=basis_set_ri)
946 ALLOCATE (xas_atom_env%ri_dcoeff(natom, nspins, nex))
950 NULLIFY (xas_atom_env%ri_dcoeff(iat, ispin, iex)%array)
951 IF ((.NOT. any(xas_atom_env%exat_neighbors(iex)%array == iat)) &
952 .AND. (.NOT. xas_atom_env%excited_atoms(iex) == iat)) cycle
953 ALLOCATE (xas_atom_env%ri_dcoeff(iat, ispin, iex)%array(blk_size_ri(iat)))
954 xas_atom_env%ri_dcoeff(iat, ispin, iex)%array = 0.0_dp
960 IF (output_unit > 0)
THEN
961 WRITE (output_unit, fmt=
"(/,T7,A,/,T7,A)") &
962 "Excited atom, natoms in RI_REGION:", &
963 "---------------------------------"
969 ALLOCATE (blk_size_orb(natom))
970 CALL get_particle_set(particle_set, qs_kind_set, nsgf=blk_size_orb, basis=basis_set_orb)
975 exat = xas_atom_env%excited_atoms(iex)
976 nnb = 1 +
SIZE(xas_atom_env%exat_neighbors(iex)%array)
977 ALLOCATE (neighbors(nnb))
979 neighbors(2:nnb) = xas_atom_env%exat_neighbors(iex)%array(:)
983 ALLOCATE (idx_to_nb(natom))
986 idx_to_nb(neighbors(inb)) = inb
989 IF (output_unit > 0)
THEN
990 WRITE (output_unit, fmt=
"(T7,I12,I21)") &
998 qs_env, excited_atoms=neighbors)
1003 CALL create_pqx_tensor(pqx, ab_list, ac_list, dbcsr_dist, blk_size_orb, blk_size_orb, &
1005 CALL fill_pqx_tensor(pqx, ab_list, ac_list, basis_set_orb, basis_set_orb, basis_set_ri, &
1010 CALL get_exat_ri_sinv(ri_sinv, ri_mats, neighbors, idx_to_nb, basis_set_ri, qs_env)
1020 CALL dbt_iterator_start(iter, pqx)
1021 DO WHILE (dbt_iterator_blocks_left(iter))
1022 CALL dbt_iterator_next_block(iter, ind)
1023 CALL dbt_get_block(pqx, ind, t_block, tensor_found)
1028 inb = idx_to_nb(katom)
1032 IF (iatom == jatom) prefac = 1.0_dp
1034 DO ispin = 1, nspins
1037 CALL dbcsr_get_block_p(rho_ao(ispin)%matrix, iatom, jatom, pmat_block, pmat_found)
1038 CALL dbcsr_get_block_p(rho_ao(ispin)%matrix, jatom, iatom, pmat_blockt, pmat_foundt)
1039 IF ((.NOT. pmat_found) .AND. (.NOT. pmat_foundt)) cycle
1041 ALLOCATE (work1(blk_size_ri(katom), 1))
1045 IF (pmat_found)
THEN
1046 DO i = 1, blk_size_ri(katom)
1047 work1(i, 1) = prefac*sum(pmat_block(:, :)*t_block(:, :, i))
1050 DO i = 1, blk_size_ri(katom)
1051 work1(i, 1) = prefac*sum(transpose(pmat_blockt(:, :))*t_block(:, :, i))
1058 ri_at = neighbors(jnb)
1063 IF ((.NOT. sinv_found) .AND. (.NOT. sinv_foundt)) cycle
1066 ALLOCATE (work2(
SIZE(xas_atom_env%ri_dcoeff(ri_at, ispin, iex)%array)))
1069 IF (sinv_found)
THEN
1070 DO i = 1, blk_size_ri(katom)
1071 work2(:) = work2(:) + factor*work1(i, 1)*sinv_block(i, :)
1074 DO i = 1, blk_size_ri(katom)
1075 work2(:) = work2(:) + factor*work1(i, 1)*sinv_blockt(:, i)
1078 DO i = 1,
SIZE(work2)
1080 xas_atom_env%ri_dcoeff(ri_at, ispin, iex)%array(i) = &
1081 xas_atom_env%ri_dcoeff(ri_at, ispin, iex)%array(i) + work2(i)
1090 DEALLOCATE (t_block)
1092 CALL dbt_iterator_stop(iter)
1097 CALL dbt_destroy(pqx)
1100 DEALLOCATE (neighbors, idx_to_nb)
1106 DO ispin = 1, nspins
1108 IF ((.NOT. any(xas_atom_env%exat_neighbors(iex)%array == iat)) &
1109 .AND. (.NOT. xas_atom_env%excited_atoms(iex) == iat)) cycle
1110 CALL para_env%sum(xas_atom_env%ri_dcoeff(iat, ispin, iex)%array)
1117 DEALLOCATE (basis_set_ri, basis_set_orb, all_ri_atoms)
1119 CALL timestop(handle)
1135 SUBROUTINE put_density_on_atomic_grid(rho_set, ri_dcoeff, atom_kind, do_gga, batch_info, &
1136 xas_atom_env, qs_env)
1140 INTEGER,
INTENT(IN) :: atom_kind
1141 LOGICAL,
INTENT(IN) :: do_gga
1146 CHARACTER(len=*),
PARAMETER :: routinen =
'put_density_on_atomic_grid'
1148 INTEGER :: dir, handle, ipgf, iset, iso, iso_proc, &
1149 ispin, maxso, n, na, nr, nset, nsgfi, &
1150 nsoi, nspins, sgfi, starti
1151 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
1152 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
1153 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: so
1154 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dso
1155 REAL(
dp),
DIMENSION(:, :),
POINTER :: dgr1, dgr2, ga, gr, ri_sphi_so, zet
1156 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dga1, dga2, rhoa, rhob
1160 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1162 NULLIFY (grid_atom, ri_basis, qs_kind_set, lmax, npgf, zet, nsgf_set, ri_sphi_so)
1163 NULLIFY (lmin, first_sgf, rhoa, rhob, ga, gr, dgr1, dgr2, dga1, dga2, ri_dcoeff_so)
1165 CALL timeset(routinen, handle)
1173 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
1174 CALL get_qs_kind(qs_kind_set(atom_kind), basis_set=ri_basis, basis_type=
"RI_XAS")
1175 CALL get_gto_basis_set(ri_basis, lmax=lmax, npgf=npgf, zet=zet, nset=nset, nsgf_set=nsgf_set, &
1176 first_sgf=first_sgf, lmin=lmin, maxso=maxso)
1179 grid_atom => xas_atom_env%grid_atom_set(atom_kind)%grid_atom
1180 na = grid_atom%ng_sphere
1183 nspins = xas_atom_env%nspins
1184 ri_sphi_so => xas_atom_env%ri_sphi_so(atom_kind)%array
1187 rhoa => rho_set%rhoa
1188 rhob => rho_set%rhob
1189 rhoa = 0.0_dp; rhob = 0.0_dp;
1192 rho_set%drhoa(dir)%array = 0.0_dp
1193 rho_set%drhob(dir)%array = 0.0_dp
1198 ga => xas_atom_env%ga(atom_kind)%array
1199 gr => xas_atom_env%gr(atom_kind)%array
1201 dga1 => xas_atom_env%dga1(atom_kind)%array
1202 dga2 => xas_atom_env%dga2(atom_kind)%array
1203 dgr1 => xas_atom_env%dgr1(atom_kind)%array
1204 dgr2 => xas_atom_env%dgr2(atom_kind)%array
1206 dga1 => xas_atom_env%dga1(atom_kind)%array
1207 dga2 => xas_atom_env%dga2(atom_kind)%array
1208 dgr1 => xas_atom_env%dgr1(atom_kind)%array
1209 dgr2 => xas_atom_env%dgr2(atom_kind)%array
1213 ALLOCATE (ri_dcoeff_so(nspins))
1214 DO ispin = 1, nspins
1215 ALLOCATE (ri_dcoeff_so(ispin)%array(nset*maxso))
1216 ri_dcoeff_so(ispin)%array = 0.0_dp
1220 sgfi = first_sgf(1, iset)
1221 nsoi = npgf(iset)*
nsoset(lmax(iset))
1222 nsgfi = nsgf_set(iset)
1224 CALL dgemv(
'N', nsoi, nsgfi, 1.0_dp, ri_sphi_so(1:nsoi, sgfi:sgfi + nsgfi - 1), nsoi, &
1225 ri_dcoeff(ispin)%array(sgfi:sgfi + nsgfi - 1), 1, 0.0_dp, &
1226 ri_dcoeff_so(ispin)%array((iset - 1)*maxso + 1:(iset - 1)*maxso + nsoi), 1)
1232 ALLOCATE (so(na, nr))
1233 IF (do_gga)
ALLOCATE (dso(na, nr, 3))
1236 DO iso_proc = 1, batch_info%nso_proc(atom_kind)
1237 iset = batch_info%so_proc_info(atom_kind)%array(1, iso_proc)
1238 ipgf = batch_info%so_proc_info(atom_kind)%array(2, iso_proc)
1239 iso = batch_info%so_proc_info(atom_kind)%array(3, iso_proc)
1242 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
1245 CALL dgemm(
'N',
'T', na, nr, 1, 1.0_dp, ga(:, iso_proc:iso_proc), na, &
1246 gr(:, iso_proc:iso_proc), nr, 0.0_dp, so(:, :), na)
1252 CALL dgemm(
'N',
'T', na, nr, 1, 1.0_dp, dga1(:, iso_proc:iso_proc, dir), na, &
1253 dgr1(:, iso_proc:iso_proc), nr, 0.0_dp, dso(:, :, dir), na)
1254 CALL dgemm(
'N',
'T', na, nr, 1, 1.0_dp, dga2(:, iso_proc:iso_proc, dir), na, &
1255 dgr2(:, iso_proc:iso_proc), nr, 1.0_dp, dso(:, :, dir), na)
1260 CALL daxpy(n, ri_dcoeff_so(1)%array(starti + iso), so, 1, rhoa(:, :, 1), 1)
1262 IF (nspins == 2)
THEN
1263 CALL daxpy(n, ri_dcoeff_so(2)%array(starti + iso), so, 1, rhob(:, :, 1), 1)
1270 CALL daxpy(n, ri_dcoeff_so(1)%array(starti + iso), dso(:, :, dir), &
1271 1, rho_set%drhoa(dir)%array(:, :, 1), 1)
1273 IF (nspins == 2)
THEN
1274 CALL daxpy(n, ri_dcoeff_so(2)%array(starti + iso), dso(:, :, dir), &
1275 1, rho_set%drhob(dir)%array(:, :, 1), 1)
1283 IF (nspins == 1)
THEN
1284 CALL dcopy(n, rhoa(:, :, 1), 1, rhob(:, :, 1), 1)
1288 CALL dcopy(n, rho_set%drhoa(dir)%array(:, :, 1), 1, rho_set%drhob(dir)%array(:, :, 1), 1)
1296 DO ispin = 1, nspins
1297 DEALLOCATE (ri_dcoeff_so(ispin)%array)
1299 DEALLOCATE (ri_dcoeff_so)
1301 CALL timestop(handle)
1303 END SUBROUTINE put_density_on_atomic_grid
1322 SUBROUTINE put_density_on_other_grid(rho_set, ri_dcoeff, source_iat, source_ikind, target_iat, &
1323 target_ikind, sr, er, do_gga, xas_atom_env, qs_env)
1327 INTEGER,
INTENT(IN) :: source_iat, source_ikind, target_iat, &
1328 target_ikind, sr, er
1329 LOGICAL,
INTENT(IN) :: do_gga
1333 CHARACTER(len=*),
PARAMETER :: routinen =
'put_density_on_other_grid'
1335 INTEGER :: dir, handle, ia, ico, ipgf, ir, iset, &
1336 isgf, lx, ly, lz, n, na, nr, nset, &
1338 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
1339 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
1341 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sgf
1342 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) ::
co, dsgf, pos
1343 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: dco
1344 REAL(
dp),
DIMENSION(3) :: rs, rst, rt
1345 REAL(
dp),
DIMENSION(:, :),
POINTER :: ri_sphi, zet
1346 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rhoa, rhob
1352 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1354 NULLIFY (qs_kind_set, ri_basis, lmax, npgf, nsgf_set, lmin, zet, first_sgf, grid_atom)
1355 NULLIFY (harmonics, rhoa, rhob, particle_set, cell, ri_sphi)
1362 CALL timeset(routinen, handle)
1365 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, particle_set=particle_set, cell=cell)
1367 CALL get_qs_kind(qs_kind_set(source_ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
1368 CALL get_gto_basis_set(ri_basis, lmax=lmax, npgf=npgf, zet=zet, nset=nset, nsgf_set=nsgf_set, &
1369 first_sgf=first_sgf, lmin=lmin, sphi=ri_sphi)
1372 grid_atom => xas_atom_env%grid_atom_set(target_ikind)%grid_atom
1373 harmonics => xas_atom_env%harmonics_atom_set(target_ikind)%harmonics_atom
1374 na = grid_atom%ng_sphere
1377 nspins = xas_atom_env%nspins
1380 rhoa => rho_set%rhoa
1381 rhob => rho_set%rhob
1384 rs =
pbc(particle_set(source_iat)%r, cell)
1385 rt =
pbc(particle_set(target_iat)%r, cell)
1386 rst =
pbc(rs, rt, cell)
1389 ALLOCATE (pos(na, sr:er, 4))
1395 pos(ia, ir, 1:3) = harmonics%a(:, ia)*grid_atom%rad(ir) + rst
1396 pos(ia, ir, 4) = pos(ia, ir, 1)**2 + pos(ia, ir, 2)**2 + pos(ia, ir, 3)**2
1405 ALLOCATE (
co(na, sr:er, npgf(iset)*
ncoset(lmax(iset))))
1406 IF (do_gga)
ALLOCATE (dco(na, sr:er, 3, npgf(iset)*
ncoset(lmax(iset))))
1415 co(ia, ir, :) = 0.0_dp
1417 dco(ia, ir, :, :) = 0.0_dp
1423 DO ipgf = 1, npgf(iset)
1424 start = (ipgf - 1)*
ncoset(lmax(iset))
1427 DO ico =
ncoset(lmin(iset) - 1) + 1,
ncoset(lmax(iset))
1436 rmom = exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1437 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1438 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1439 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1440 co(ia, ir, start + ico) = rmom
1457 rmom = -2.0_dp*pos(ia, ir, 1)*zet(ipgf, iset)*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1458 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1459 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1460 dco(ia, ir, 1, start + ico) = rmom
1472 rmom = (lx*pos(ia, ir, 1)**(lx - 1) - 2.0_dp*pos(ia, ir, 1)**(lx + 1)* &
1473 zet(ipgf, iset))*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1475 rmom = (1.0_dp - 2.0_dp*pos(ia, ir, 1)**2*zet(ipgf, iset))* &
1476 exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1478 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1479 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1480 dco(ia, ir, 1, start + ico) = rmom
1495 rmom = -2.0_dp*pos(ia, ir, 2)*zet(ipgf, iset)*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1496 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1497 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1498 dco(ia, ir, 2, start + ico) = rmom
1510 rmom = (ly*pos(ia, ir, 2)**(ly - 1) - 2.0_dp*pos(ia, ir, 2)**(ly + 1)*zet(ipgf, iset)) &
1511 *exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1513 rmom = (1.0_dp - 2.0_dp*pos(ia, ir, 2)**2*zet(ipgf, iset)) &
1514 *exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1516 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1517 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1518 dco(ia, ir, 2, start + ico) = rmom
1533 rmom = -2.0_dp*pos(ia, ir, 3)*zet(ipgf, iset)*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1534 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1535 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1536 dco(ia, ir, 3, start + ico) = rmom
1548 rmom = (lz*pos(ia, ir, 3)**(lz - 1) - 2.0_dp*pos(ia, ir, 3)**(lz + 1)* &
1549 zet(ipgf, iset))*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1551 rmom = (1.0_dp - 2.0_dp*pos(ia, ir, 3)**2*zet(ipgf, iset))* &
1552 exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1554 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1555 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1556 dco(ia, ir, 3, start + ico) = rmom
1574 ALLOCATE (sgf(na, sr:er))
1575 IF (do_gga)
ALLOCATE (dsgf(na, sr:er, 3))
1576 sgfi = first_sgf(1, iset) - 1
1578 DO isgf = 1, nsgf_set(iset)
1580 IF (do_gga) dsgf = 0.0_dp
1582 DO ipgf = 1, npgf(iset)
1583 start = (ipgf - 1)*
ncoset(lmax(iset))
1584 DO ico =
ncoset(lmin(iset) - 1) + 1,
ncoset(lmax(iset))
1585 CALL daxpy(n, ri_sphi(start + ico, sgfi + isgf),
co(:, sr:er, start + ico), 1, sgf(:, sr:er), 1)
1590 CALL daxpy(n, ri_dcoeff(1)%array(sgfi + isgf), sgf(:, sr:er), 1, rhoa(:, sr:er, 1), 1)
1592 IF (nspins == 2)
THEN
1593 CALL daxpy(n, ri_dcoeff(2)%array(sgfi + isgf), sgf(:, sr:er), 1, rhob(:, sr:er, 1), 1)
1599 DO ipgf = 1, npgf(iset)
1600 start = (ipgf - 1)*
ncoset(lmax(iset))
1601 DO ico =
ncoset(lmin(iset) - 1) + 1,
ncoset(lmax(iset))
1603 CALL daxpy(n, ri_sphi(start + ico, sgfi + isgf), dco(:, sr:er, dir, start + ico), &
1604 1, dsgf(:, sr:er, dir), 1)
1610 CALL daxpy(n, ri_dcoeff(1)%array(sgfi + isgf), dsgf(:, sr:er, dir), 1, &
1611 rho_set%drhoa(dir)%array(:, sr:er, 1), 1)
1613 IF (nspins == 2)
THEN
1614 CALL daxpy(n, ri_dcoeff(2)%array(sgfi + isgf), dsgf(:, sr:er, dir), 1, &
1615 rho_set%drhob(dir)%array(:, sr:er, 1), 1)
1622 DEALLOCATE (
co, sgf)
1623 IF (do_gga)
DEALLOCATE (dco, dsgf)
1627 IF (nspins == 1)
THEN
1628 CALL dcopy(n, rhoa(:, sr:er, 1), 1, rhob(:, sr:er, 1), 1)
1632 CALL dcopy(n, rho_set%drhoa(dir)%array(:, sr:er, 1), 1, rho_set%drhob(dir)%array(:, sr:er, 1), 1)
1637 CALL timestop(handle)
1639 END SUBROUTINE put_density_on_other_grid
1648 SUBROUTINE compute_norm_drho(rho_set, atom_kind, xas_atom_env)
1651 INTEGER,
INTENT(IN) :: atom_kind
1654 INTEGER :: dir, ia, ir, n, na, nr, nspins
1656 na = xas_atom_env%grid_atom_set(atom_kind)%grid_atom%ng_sphere
1657 nr = xas_atom_env%grid_atom_set(atom_kind)%grid_atom%nr
1659 nspins = xas_atom_env%nspins
1661 rho_set%norm_drhoa = 0.0_dp
1662 rho_set%norm_drhob = 0.0_dp
1663 rho_set%norm_drho = 0.0_dp
1668 rho_set%norm_drhoa(ia, ir, 1) = rho_set%norm_drhoa(ia, ir, 1) &
1669 + rho_set%drhoa(dir)%array(ia, ir, 1)**2
1673 rho_set%norm_drhoa = sqrt(rho_set%norm_drhoa)
1675 IF (nspins == 1)
THEN
1677 CALL dcopy(n, rho_set%norm_drhoa(:, :, 1), 1, rho_set%norm_drhob(:, :, 1), 1)
1682 rho_set%norm_drhob(ia, ir, 1) = rho_set%norm_drhob(ia, ir, 1) &
1683 + rho_set%drhob(dir)%array(ia, ir, 1)**2
1687 rho_set%norm_drhob = sqrt(rho_set%norm_drhob)
1693 rho_set%norm_drho(ia, ir, 1) = rho_set%norm_drho(ia, ir, 1) + &
1694 (rho_set%drhoa(dir)%array(ia, ir, 1) + &
1695 rho_set%drhob(dir)%array(ia, ir, 1))**2
1699 rho_set%norm_drho = sqrt(rho_set%norm_drho)
1701 END SUBROUTINE compute_norm_drho
1712 SUBROUTINE precompute_so_dso(do_gga, batch_info, xas_atom_env, qs_env)
1714 LOGICAL,
INTENT(IN) :: do_gga
1719 CHARACTER(len=*),
PARAMETER :: routinen =
'precompute_so_dso'
1721 INTEGER :: bo(2), dir, handle, ikind, ipgf, iset, &
1722 iso, iso_proc, l, maxso, n, na, nkind, &
1723 nr, nset, nso_proc, nsotot, starti
1724 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
1725 INTEGER,
DIMENSION(:, :),
POINTER :: so_proc_info
1726 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: rexp
1727 REAL(
dp),
DIMENSION(:, :),
POINTER :: dgr1, dgr2, ga, gr, slm, zet
1728 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dga1, dga2, dslm_dxyz
1733 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1735 NULLIFY (qs_kind_set, harmonics, grid_atom, slm, dslm_dxyz, ri_basis, lmax, lmin, npgf)
1736 NULLIFY (nsgf_set, zet, para_env, so_proc_info)
1738 CALL timeset(routinen, handle)
1740 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, para_env=para_env)
1741 nkind =
SIZE(qs_kind_set)
1743 ALLOCATE (batch_info%so_proc_info(nkind))
1744 ALLOCATE (batch_info%nso_proc(nkind))
1745 ALLOCATE (batch_info%so_bo(2, nkind))
1749 NULLIFY (xas_atom_env%ga(ikind)%array)
1750 NULLIFY (xas_atom_env%gr(ikind)%array)
1751 NULLIFY (xas_atom_env%dga1(ikind)%array)
1752 NULLIFY (xas_atom_env%dga2(ikind)%array)
1753 NULLIFY (xas_atom_env%dgr1(ikind)%array)
1754 NULLIFY (xas_atom_env%dgr2(ikind)%array)
1756 NULLIFY (batch_info%so_proc_info(ikind)%array)
1758 IF (.NOT. any(xas_atom_env%excited_kinds == ikind)) cycle
1761 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
1762 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
1764 na = grid_atom%ng_sphere
1768 slm => harmonics%slm
1769 dslm_dxyz => harmonics%dslm_dxyz
1772 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
1774 nsgf_set=nsgf_set, lmin=lmin, maxso=maxso)
1778 bo =
get_limit(nsotot, batch_info%batch_size, batch_info%ipe)
1779 nso_proc = bo(2) - bo(1) + 1
1780 batch_info%so_bo(:, ikind) = bo
1781 batch_info%nso_proc(ikind) = nso_proc
1784 ALLOCATE (batch_info%so_proc_info(ikind)%array(3, nso_proc))
1785 so_proc_info => batch_info%so_proc_info(ikind)%array
1788 DO ipgf = 1, npgf(iset)
1789 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
1790 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
1793 IF (starti + iso < bo(1) .OR. starti + iso > bo(2)) cycle
1794 iso_proc = starti + iso - bo(1) + 1
1795 so_proc_info(1, iso_proc) = iset
1796 so_proc_info(2, iso_proc) = ipgf
1797 so_proc_info(3, iso_proc) = iso
1804 ALLOCATE (xas_atom_env%ga(ikind)%array(na, nso_proc))
1805 ALLOCATE (xas_atom_env%gr(ikind)%array(nr, nso_proc))
1806 xas_atom_env%ga(ikind)%array = 0.0_dp; xas_atom_env%gr(ikind)%array = 0.0_dp
1808 ALLOCATE (xas_atom_env%dga1(ikind)%array(na, nso_proc, 3))
1809 ALLOCATE (xas_atom_env%dgr1(ikind)%array(nr, nso_proc))
1810 ALLOCATE (xas_atom_env%dga2(ikind)%array(na, nso_proc, 3))
1811 ALLOCATE (xas_atom_env%dgr2(ikind)%array(nr, nso_proc))
1812 xas_atom_env%dga1(ikind)%array = 0.0_dp; xas_atom_env%dgr1(ikind)%array = 0.0_dp
1813 xas_atom_env%dga2(ikind)%array = 0.0_dp; xas_atom_env%dgr2(ikind)%array = 0.0_dp
1816 ga => xas_atom_env%ga(ikind)%array
1817 gr => xas_atom_env%gr(ikind)%array
1818 dga1 => xas_atom_env%dga1(ikind)%array
1819 dga2 => xas_atom_env%dga2(ikind)%array
1820 dgr1 => xas_atom_env%dgr1(ikind)%array
1821 dgr2 => xas_atom_env%dgr2(ikind)%array
1825 DO iso_proc = 1, nso_proc
1826 iset = so_proc_info(1, iso_proc)
1827 ipgf = so_proc_info(2, iso_proc)
1828 iso = so_proc_info(3, iso_proc)
1836 rexp(1:nr) = exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
1837 gr(1:nr, iso_proc) = grid_atom%rad(1:nr)**l*rexp(1:nr)
1840 ga(1:na, iso_proc) = slm(1:na, iso)
1849 dgr1(1:nr, iso_proc) = grid_atom%rad(1:nr)**(l - 1)*rexp(1:nr)
1850 dgr2(1:nr, iso_proc) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1)*rexp(1:nr)
1854 dga1(1:na, iso_proc, dir) = dslm_dxyz(dir, 1:na, iso)
1855 dga2(1:na, iso_proc, dir) = harmonics%a(dir, 1:na)*slm(1:na, iso)
1864 CALL timestop(handle)
1866 END SUBROUTINE precompute_so_dso
1885 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_fxc_atoms'
1887 INTEGER :: batch_size, dir, er, ex_bo(2), handle, i, iatom, ibatch, iex, ikind, inb, ipe, &
1888 mepos, na, natom, nb, nb_bo(2), nbatch, nbk, nex_atom, nr, num_pe, sr
1889 INTEGER,
DIMENSION(2, 3) :: bounds
1890 INTEGER,
DIMENSION(:),
POINTER :: exat_neighbors
1891 LOGICAL :: do_gga, do_sc, do_sf
1897 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1903 NULLIFY (particle_set, qs_kind_set, dft_control, para_env, exat_neighbors)
1904 NULLIFY (input, xc_functionals)
1906 CALL timeset(routinen, handle)
1909 CALL get_qs_env(qs_env, particle_set=particle_set, qs_kind_set=qs_kind_set, natom=natom, &
1910 dft_control=dft_control, input=input, para_env=para_env)
1911 ALLOCATE (int_fxc(natom, 4))
1914 NULLIFY (int_fxc(iatom, i)%array)
1917 nex_atom =
SIZE(xas_atom_env%excited_atoms)
1919 do_sc = xas_tdp_control%do_spin_cons .OR. xas_tdp_control%do_singlet .OR. xas_tdp_control%do_triplet
1920 do_sf = xas_tdp_control%do_spin_flip
1923 IF (qs_env%do_rixs)
THEN
1930 do_gga = needs%drho_spin
1935 num_pe = para_env%num_pe
1936 mepos = para_env%mepos
1942 ibatch = mepos/batch_size
1944 ipe =
modulo(mepos, batch_size)
1946 batch_info%batch_size = batch_size
1947 batch_info%nbatch = nbatch
1948 batch_info%ibatch = ibatch
1949 batch_info%ipe = ipe
1952 CALL batch_info%para_env%from_split(para_env, ibatch)
1956 CALL precompute_so_dso(do_gga, batch_info, xas_atom_env, qs_env)
1959 ex_bo =
get_limit(nex_atom, nbatch, ibatch)
1962 DO iex = ex_bo(1), ex_bo(2)
1964 iatom = xas_atom_env%excited_atoms(iex)
1965 ikind = particle_set(iatom)%atomic_kind%kind_number
1966 exat_neighbors => xas_atom_env%exat_neighbors(iex)%array
1967 ri_dcoeff => xas_atom_env%ri_dcoeff(:, :, iex)
1970 na = xas_atom_env%grid_atom_set(ikind)%grid_atom%ng_sphere
1971 nr = xas_atom_env%grid_atom_set(ikind)%grid_atom%nr
1974 bounds(1:2, 1:3) = 1
1979 rho_cutoff=dft_control%qs_control%eps_rho_rspace, &
1980 drho_cutoff=dft_control%qs_control%eps_rho_rspace)
1987 CALL put_density_on_atomic_grid(rho_set, ri_dcoeff(iatom, :), ikind, &
1988 do_gga, batch_info, xas_atom_env, qs_env)
1993 sr = nb_bo(1); er = nb_bo(2)
1994 DO inb = 1,
SIZE(exat_neighbors)
1996 nb = exat_neighbors(inb)
1997 nbk = particle_set(nb)%atomic_kind%kind_number
1998 CALL put_density_on_other_grid(rho_set, ri_dcoeff(nb, :), nb, nbk, iatom, &
1999 ikind, sr, er, do_gga, xas_atom_env, qs_env)
2004 CALL batch_info%para_env%sum(rho_set%rhoa)
2005 CALL batch_info%para_env%sum(rho_set%rhob)
2008 CALL batch_info%para_env%sum(rho_set%drhoa(dir)%array)
2009 CALL batch_info%para_env%sum(rho_set%drhob(dir)%array)
2014 IF (do_gga)
CALL compute_norm_drho(rho_set, ikind, xas_atom_env)
2017 CALL xc_functionals_eval(xc_functionals, lsd=.true., rho_set=rho_set, deriv_set=deriv_set, &
2022 CALL integrate_sc_fxc(int_fxc, iatom, ikind, deriv_set, xas_atom_env, qs_env)
2027 CALL integrate_sf_fxc(int_fxc, iatom, ikind, rho_set, deriv_set, xas_atom_env, qs_env)
2031 IF (do_gga .AND. do_sc)
THEN
2032 CALL integrate_gga_fxc(int_fxc, iatom, ikind, batch_info, rho_set, deriv_set, &
2033 xas_atom_env, qs_env)
2044 CALL para_env%sync()
2046 CALL timestop(handle)
2062 SUBROUTINE integrate_gga_fxc(int_fxc, iatom, ikind, batch_info, rho_set, deriv_set, &
2063 xas_atom_env, qs_env)
2066 INTEGER,
INTENT(IN) :: iatom, ikind
2073 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_gga_fxc'
2075 INTEGER :: bo(2), dir, handle, i, ia, ir, jpgf, &
2076 jset, jso, l, maxso, na, nr, nset, &
2077 nsgf, nsoi, nsotot, startj, ub
2078 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2079 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: rexp
2080 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: int_sgf, res, so, work
2081 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dso
2082 REAL(
dp),
DIMENSION(:, :),
POINTER :: dgr1, dgr2, ga, gr, ri_sphi_so, weight, &
2084 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dga1, dga2
2091 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2093 NULLIFY (grid_atom, ri_basis, qs_kind_set, ga, gr, dgr1, dgr2, lmax, lmin, npgf)
2094 NULLIFY (weight, ri_sphi_so, dga1, dga2, para_env, harmonics, zet)
2106 CALL timeset(routinen, handle)
2110 IF (xas_atom_env%nspins == 2) ub = 3
2113 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
2114 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
2115 na = grid_atom%ng_sphere
2117 weight => grid_atom%weight
2120 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, para_env=para_env)
2121 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
2123 CALL get_gto_basis_set(gto_basis_set=ri_basis, lmax=lmax, lmin=lmin, nsgf=nsgf, &
2124 maxso=maxso, npgf=npgf, nset=nset, zet=zet)
2128 ga => xas_atom_env%ga(ikind)%array
2129 gr => xas_atom_env%gr(ikind)%array
2130 dgr1 => xas_atom_env%dgr1(ikind)%array
2131 dgr2 => xas_atom_env%dgr2(ikind)%array
2132 dga1 => xas_atom_env%dga1(ikind)%array
2133 dga2 => xas_atom_env%dga2(ikind)%array
2144 ALLOCATE (so(na, nr))
2145 ALLOCATE (dso(na, nr, 3))
2150 ALLOCATE (int_so(ub))
2152 ALLOCATE (vxc(i)%array(na, nr))
2153 ALLOCATE (vxg(i)%array(na, nr, 3))
2154 ALLOCATE (int_so(i)%array(nsotot, nsotot))
2155 vxc(i)%array = 0.0_dp; vxg(i)%array = 0.0_dp; int_so(i)%array = 0.0_dp
2159 DO jpgf = 1, npgf(jset)
2160 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
2161 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
2167 rexp(1:nr) = exp(-zet(jpgf, jset)*grid_atom%rad2(1:nr))
2175 so(ia, ir) = grid_atom%rad(ir)**l*rexp(ir)*harmonics%slm(ia, jso)
2178 dso(ia, ir, :) = 0.0_dp
2180 dso(ia, ir, dir) = dso(ia, ir, dir) &
2181 + grid_atom%rad(ir)**(l - 1)*rexp(ir)*harmonics%dslm_dxyz(dir, ia, jso) &
2182 - 2.0_dp*zet(jpgf, jset)*grid_atom%rad(ir)**(l + 1)*rexp(ir) &
2183 *harmonics%a(dir, ia)*harmonics%slm(ia, jso)
2190 CALL get_vxc_vxg(vxc, vxg, so, dso, na, nr, rho_set, deriv_set, weight)
2194 nsoi = batch_info%nso_proc(ikind)
2195 bo = batch_info%so_bo(:, ikind)
2196 ALLOCATE (res(nsoi, nsoi), work(na, nsoi))
2197 res = 0.0_dp; work = 0.0_dp
2202 CALL dgemm(
'N',
'N', na, nsoi, nr, 1.0_dp, vxc(i)%array(:, :), na, &
2203 gr(:, 1:nsoi), nr, 0.0_dp, work, na)
2204 CALL dgemm(
'T',
'N', nsoi, nsoi, na, 1.0_dp, work, na, &
2205 ga(:, 1:nsoi), na, 0.0_dp, res, nsoi)
2206 int_so(i)%array(bo(1):bo(2), startj + jso) =
get_diag(res)
2211 CALL dgemm(
'N',
'N', na, nsoi, nr, 1.0_dp, vxg(i)%array(:, :, dir), na, &
2212 dgr1(:, 1:nsoi), nr, 0.0_dp, work, na)
2213 CALL dgemm(
'T',
'N', nsoi, nsoi, na, 1.0_dp, work, na, &
2214 dga1(:, 1:nsoi, dir), na, 0.0_dp, res, nsoi)
2215 CALL daxpy(nsoi, 1.0_dp,
get_diag(res), 1, int_so(i)%array(bo(1):bo(2), startj + jso), 1)
2217 CALL dgemm(
'N',
'N', na, nsoi, nr, 1.0_dp, vxg(i)%array(:, :, dir), na, &
2218 dgr2(:, 1:nsoi), nr, 0.0_dp, work, na)
2219 CALL dgemm(
'T',
'N', nsoi, nsoi, na, 1.0_dp, work, na, &
2220 dga2(:, 1:nsoi, dir), na, 0.0_dp, res, nsoi)
2221 CALL daxpy(nsoi, 1.0_dp,
get_diag(res), 1, int_so(i)%array(bo(1):bo(2), startj + jso), 1)
2226 DEALLOCATE (res, work)
2233 ri_sphi_so => xas_atom_env%ri_sphi_so(ikind)%array
2234 ALLOCATE (int_sgf(nsgf, nsgf))
2236 CALL batch_info%para_env%sum(int_so(i)%array)
2237 CALL contract_so2sgf(int_sgf, int_so(i)%array, ri_basis, ri_sphi_so)
2238 CALL daxpy(nsgf*nsgf, 1.0_dp, int_sgf, 1, int_fxc(iatom, i)%array, 1)
2243 DEALLOCATE (vxc(i)%array)
2244 DEALLOCATE (vxg(i)%array)
2245 DEALLOCATE (int_so(i)%array)
2247 DEALLOCATE (vxc, vxg, int_so)
2249 CALL timestop(handle)
2251 END SUBROUTINE integrate_gga_fxc
2270 SUBROUTINE get_vxc_vxg(vxc, vxg, so, dso, na, nr, rho_set, deriv_set, weight)
2274 REAL(
dp),
DIMENSION(:, :) :: so
2275 REAL(
dp),
DIMENSION(:, :, :) :: dso
2276 INTEGER,
INTENT(IN) :: na, nr
2279 REAL(
dp),
DIMENSION(:, :),
POINTER :: weight
2281 CHARACTER(len=*),
PARAMETER :: routinen =
'get_vxc_vxg'
2283 INTEGER :: dir, handle, i, ia, ir, ub
2284 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dot_proda, dot_prodb, tmp
2285 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: d1e, d2e, norm_drhoa, norm_drhob
2288 NULLIFY (norm_drhoa, norm_drhob, d2e, d1e, deriv)
2290 CALL timeset(routinen, handle)
2299 norm_drhoa => rho_set%norm_drhoa
2300 norm_drhob => rho_set%norm_drhob
2304 vxc(i)%array = 0.0_dp
2305 vxg(i)%array = 0.0_dp
2308 ALLOCATE (tmp(na, nr), dot_proda(na, nr), dot_prodb(na, nr))
2309 dot_proda = 0.0_dp; dot_prodb = 0.0_dp
2325 dot_proda(ia, ir) = dot_proda(ia, ir) + rho_set%drhoa(dir)%array(ia, ir, 1)*dso(ia, ir, dir)
2326 dot_prodb(ia, ir) = dot_prodb(ia, ir) + rho_set%drhob(dir)%array(ia, ir, 1)*dso(ia, ir, dir)
2336 IF (
ASSOCIATED(deriv))
THEN
2341 vxc(1)%array(ia, ir) = d2e(ia, ir, 1)*dot_proda(ia, ir)
2350 IF (
ASSOCIATED(deriv))
THEN
2355 vxc(1)%array(ia, ir) = vxc(1)%array(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2365 vxc(1)%array(ia, ir) = vxc(1)%array(ia, ir)*weight(ia, ir)
2372 IF (
ASSOCIATED(deriv))
THEN
2377 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2385 IF (
ASSOCIATED(deriv))
THEN
2390 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2398 IF (
ASSOCIATED(deriv))
THEN
2403 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2411 IF (
ASSOCIATED(deriv))
THEN
2416 tmp(ia, ir) = tmp(ia, ir) - d1e(ia, ir, 1)*dot_proda(ia, ir) &
2417 /max(norm_drhoa(ia, ir, 1), rho_set%drho_cutoff)**2
2428 vxg(1)%array(ia, ir, dir) = tmp(ia, ir)*rho_set%drhoa(dir)%array(ia, ir, 1)
2436 IF (
ASSOCIATED(deriv))
THEN
2441 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2449 IF (
ASSOCIATED(deriv))
THEN
2454 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2462 IF (
ASSOCIATED(deriv))
THEN
2467 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2478 vxg(1)%array(ia, ir, dir) = vxg(1)%array(ia, ir, dir) + tmp(ia, ir)*rho_set%drhob(dir)%array(ia, ir, 1)
2486 IF (
ASSOCIATED(deriv))
THEN
2492 vxg(1)%array(ia, ir, dir) = vxg(1)%array(ia, ir, dir) + d1e(ia, ir, 1)*dso(ia, ir, dir)
2504 vxg(1)%array(ia, ir, dir) = vxg(1)%array(ia, ir, dir)*weight(ia, ir)
2514 IF (
ASSOCIATED(deriv))
THEN
2519 vxc(2)%array(ia, ir) = d2e(ia, ir, 1)*dot_prodb(ia, ir)
2527 IF (
ASSOCIATED(deriv))
THEN
2532 vxc(2)%array(ia, ir) = vxc(2)%array(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2542 vxc(2)%array(ia, ir) = vxc(2)%array(ia, ir)*weight(ia, ir)
2549 IF (
ASSOCIATED(deriv))
THEN
2554 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2562 IF (
ASSOCIATED(deriv))
THEN
2567 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2575 IF (
ASSOCIATED(deriv))
THEN
2580 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2591 vxg(2)%array(ia, ir, dir) = tmp(ia, ir)*rho_set%drhoa(dir)%array(ia, ir, 1)
2599 IF (
ASSOCIATED(deriv))
THEN
2604 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2612 IF (
ASSOCIATED(deriv))
THEN
2617 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2625 IF (
ASSOCIATED(deriv))
THEN
2630 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2641 vxg(2)%array(ia, ir, dir) = vxg(2)%array(ia, ir, dir) + tmp(ia, ir)*rho_set%drhob(dir)%array(ia, ir, 1)
2649 IF (
ASSOCIATED(deriv))
THEN
2655 vxg(2)%array(ia, ir, dir) = vxg(2)%array(ia, ir, dir) + d1e(ia, ir, 1)*dso(ia, ir, dir)
2667 vxg(2)%array(ia, ir, dir) = vxg(2)%array(ia, ir, dir)*weight(ia, ir)
2678 IF (
ASSOCIATED(deriv))
THEN
2683 vxc(3)%array(ia, ir) = d2e(ia, ir, 1)*dot_prodb(ia, ir)
2691 IF (
ASSOCIATED(deriv))
THEN
2696 vxc(3)%array(ia, ir) = vxc(3)%array(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2706 vxc(3)%array(ia, ir) = vxc(3)%array(ia, ir)*weight(ia, ir)
2713 IF (
ASSOCIATED(deriv))
THEN
2718 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2726 IF (
ASSOCIATED(deriv))
THEN
2731 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2739 IF (
ASSOCIATED(deriv))
THEN
2744 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2752 IF (
ASSOCIATED(deriv))
THEN
2757 tmp(ia, ir) = tmp(ia, ir) - d1e(ia, ir, 1)*dot_prodb(ia, ir) &
2758 /max(norm_drhob(ia, ir, 1), rho_set%drho_cutoff)**2
2769 vxg(3)%array(ia, ir, dir) = tmp(ia, ir)*rho_set%drhob(dir)%array(ia, ir, 1)
2777 IF (
ASSOCIATED(deriv))
THEN
2782 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2790 IF (
ASSOCIATED(deriv))
THEN
2795 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2803 IF (
ASSOCIATED(deriv))
THEN
2808 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2819 vxg(3)%array(ia, ir, dir) = vxg(3)%array(ia, ir, dir) + &
2820 tmp(ia, ir)*rho_set%drhoa(dir)%array(ia, ir, 1)
2828 IF (
ASSOCIATED(deriv))
THEN
2834 vxg(3)%array(ia, ir, dir) = vxg(3)%array(ia, ir, dir) + d1e(ia, ir, 1)*dso(ia, ir, dir)
2846 vxg(3)%array(ia, ir, dir) = vxg(3)%array(ia, ir, dir)*weight(ia, ir)
2856 CALL timestop(handle)
2858 END SUBROUTINE get_vxc_vxg
2869 SUBROUTINE integrate_sc_fxc(int_fxc, iatom, ikind, deriv_set, xas_atom_env, qs_env)
2872 INTEGER,
INTENT(IN) :: iatom, ikind
2877 INTEGER :: i, maxso, na, nr, nset, nsotot, nspins, &
2879 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fxc, int_so
2880 REAL(
dp),
DIMENSION(:, :),
POINTER :: ri_sphi_so
2885 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2888 NULLIFY (grid_atom, ri_basis, ri_sphi_so, qs_kind_set, dft_control)
2891 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
2892 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
2893 na = grid_atom%ng_sphere
2895 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
2898 ri_sphi_so => xas_atom_env%ri_sphi_so(ikind)%array
2899 nspins = dft_control%nspins
2907 IF (
ASSOCIATED(derivs(i)%deriv))
THEN
2913 ALLOCATE (fxc(na, nr))
2914 ALLOCATE (int_so(nsotot, nsotot))
2918 DO i = 1, nspins + 1
2920 IF (
ASSOCIATED(derivs(i)%deriv))
THEN
2921 fxc(:, :) = d2e(i)%array(:, :, 1)*grid_atom%weight(:, :)
2922 CALL integrate_so_prod(int_so, fxc, ikind, xas_atom_env, qs_env)
2926 ALLOCATE (int_fxc(iatom, i)%array(ri_nsgf, ri_nsgf))
2927 int_fxc(iatom, i)%array = 0.0_dp
2928 CALL contract_so2sgf(int_fxc(iatom, i)%array, int_so, ri_basis, ri_sphi_so)
2931 END SUBROUTINE integrate_sc_fxc
2944 SUBROUTINE integrate_sf_fxc(int_fxc, iatom, ikind, rho_set, deriv_set, xas_atom_env, qs_env)
2947 INTEGER,
INTENT(IN) :: iatom, ikind
2953 INTEGER :: ia, ir, maxso, na, nr, nset, nsotot, &
2955 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fxc, int_so
2956 REAL(
dp),
DIMENSION(:, :),
POINTER :: ri_sphi_so
2957 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rhoa, rhob
2962 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2965 NULLIFY (grid_atom, deriv, ri_basis, ri_sphi_so, qs_kind_set, rhoa, rhob, dft_control)
2968 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
2969 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
2970 na = grid_atom%ng_sphere
2972 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
2975 ri_sphi_so => xas_atom_env%ri_sphi_so(ikind)%array
2976 rhoa => rho_set%rhoa
2977 rhob => rho_set%rhob
2981 IF (
ASSOCIATED(deriv))
THEN
2985 IF (
ASSOCIATED(deriv))
THEN
2992 IF (
ASSOCIATED(deriv))
THEN
2996 IF (
ASSOCIATED(deriv))
THEN
3000 IF (
ASSOCIATED(deriv))
THEN
3005 ALLOCATE (fxc(na, nr))
3014 IF (abs(rhoa(ia, ir, 1) - rhob(ia, ir, 1)) > dft_control%qs_control%eps_rho_rspace)
THEN
3015 fxc(ia, ir) = grid_atom%weight(ia, ir)/(rhoa(ia, ir, 1) - rhob(ia, ir, 1)) &
3016 *(d1e(1)%array(ia, ir, 1) - d1e(2)%array(ia, ir, 1))
3018 fxc(ia, ir) = 0.5_dp*grid_atom%weight(ia, ir)* &
3019 (d2e(1)%array(ia, ir, 1) + d2e(3)%array(ia, ir, 1) - 2._dp*d2e(2)%array(ia, ir, 1))
3027 ALLOCATE (int_so(nsotot, nsotot))
3029 CALL integrate_so_prod(int_so, fxc, ikind, xas_atom_env, qs_env)
3032 ALLOCATE (int_fxc(iatom, 4)%array(ri_nsgf, ri_nsgf))
3033 int_fxc(iatom, 4)%array = 0.0_dp
3034 CALL contract_so2sgf(int_fxc(iatom, 4)%array, int_so, ri_basis, ri_sphi_so)
3036 END SUBROUTINE integrate_sf_fxc
3045 SUBROUTINE contract_so2sgf(int_sgf, int_so, basis, sphi_so)
3047 REAL(
dp),
DIMENSION(:, :) :: int_sgf, int_so
3049 REAL(
dp),
DIMENSION(:, :) :: sphi_so
3051 INTEGER :: iset, jset, maxso, nset, nsoi, nsoj, &
3052 sgfi, sgfj, starti, startj
3053 INTEGER,
DIMENSION(:),
POINTER :: lmax, npgf, nsgf_set
3054 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
3056 NULLIFY (nsgf_set, npgf, lmax, first_sgf)
3058 CALL get_gto_basis_set(basis, nset=nset, maxso=maxso, nsgf_set=nsgf_set, first_sgf=first_sgf, &
3059 npgf=npgf, lmax=lmax)
3062 starti = (iset - 1)*maxso + 1
3063 nsoi = npgf(iset)*
nsoset(lmax(iset))
3064 sgfi = first_sgf(1, iset)
3067 startj = (jset - 1)*maxso + 1
3068 nsoj = npgf(jset)*
nsoset(lmax(jset))
3069 sgfj = first_sgf(1, jset)
3071 CALL ab_contract(int_sgf(sgfi:sgfi + nsgf_set(iset) - 1, sgfj:sgfj + nsgf_set(jset) - 1), &
3072 int_so(starti:starti + nsoi - 1, startj:startj + nsoj - 1), &
3073 sphi_so(:, sgfi:), sphi_so(:, sgfj:), nsoi, nsoj, &
3074 nsgf_set(iset), nsgf_set(jset))
3078 END SUBROUTINE contract_so2sgf
3092 SUBROUTINE integrate_so_prod(intso, fxc, ikind, xas_atom_env, qs_env)
3094 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: intso
3095 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: fxc
3096 INTEGER,
INTENT(IN) :: ikind
3100 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_so_prod'
3102 INTEGER :: handle, ia, ic, icg, ipgf1, ipgf2, iset1, iset2, iso, iso1, iso2, l, ld, lmax12, &
3103 lmin12, m1, m2, max_iso_not0, max_iso_not0_local, max_s_harm, maxl, maxso, n1, n2, na, &
3104 ngau1, ngau2, nngau1, nr, nset, size1
3105 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list
3106 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list
3107 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
3108 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
3109 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: gfxcg, gg, matso
3110 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
3111 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
3115 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3117 CALL timeset(routinen, handle)
3119 NULLIFY (grid_atom, harmonics, ri_basis, qs_kind_set, lmax, lmin, npgf, zet, my_cg)
3122 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
3123 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
3124 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
3125 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
3127 CALL get_gto_basis_set(ri_basis, lmax=lmax, lmin=lmin, maxso=maxso, maxl=maxl, npgf=npgf, &
3130 na = grid_atom%ng_sphere
3132 my_cg => harmonics%my_CG
3133 max_iso_not0 = harmonics%max_iso_not0
3134 max_s_harm = harmonics%max_s_harm
3135 cpassert(2*maxl <=
indso(1, max_iso_not0))
3137 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl))
3138 ALLOCATE (gfxcg(na, 0:2*maxl))
3140 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm))
3150 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
3151 max_s_harm, lmax(iset1) + lmax(iset2), cg_list, cg_n_list, &
3153 cpassert(max_iso_not0_local <= max_iso_not0)
3156 DO ipgf1 = 1, npgf(iset1)
3157 ngau1 = n1*(ipgf1 - 1) + m1
3159 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
3161 g1(:) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
3162 DO ipgf2 = 1, npgf(iset2)
3163 ngau2 = n2*(ipgf2 - 1) + m2
3165 g2(:) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
3166 lmin12 = lmin(iset1) + lmin(iset2)
3167 lmax12 = lmax(iset1) + lmax(iset2)
3171 IF (lmin12 == 0)
THEN
3172 gg(:, lmin12) = g1(:)*g2(:)
3174 gg(:, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(:)*g2(:)
3177 DO l = lmin12 + 1, lmax12
3178 gg(:, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
3182 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, fxc(1:na, 1:nr), na, gg(:, 0:lmax12), &
3183 nr, 0.0_dp, gfxcg(1:na, 0:lmax12), na)
3187 DO iso = 1, max_iso_not0_local
3188 DO icg = 1, cg_n_list(iso)
3189 iso1 = cg_list(1, icg, iso)
3190 iso2 = cg_list(2, icg, iso)
3194 matso(iso1, iso2) = matso(iso1, iso2) + gfxcg(ia, l)* &
3195 my_cg(iso1, iso2, iso)*harmonics%slm(ia, iso)
3201 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
3202 iso1 =
nsoset(lmin(iset1) - 1) + 1
3204 CALL daxpy(size1, 1.0_dp, matso(iso1:, ic), 1, intso(nngau1 + 1:, iso2), 1)
3214 CALL timestop(handle)
3216 END SUBROUTINE integrate_so_prod
3227 SUBROUTINE integrate_so_dxdy_prod(intso, V, ikind, qs_env, soc_atom_env)
3229 REAL(
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: intso
3230 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: v
3231 INTEGER,
INTENT(IN) :: ikind
3235 INTEGER :: i, ipgf, iset, iso, j, jpgf, jset, jso, &
3236 k, l, maxso, na, nr, nset, starti, &
3238 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
3239 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fga, fgr, r1, r2, work
3240 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: a1, a2
3241 REAL(
dp),
DIMENSION(:, :),
POINTER :: slm, zet
3242 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dslm_dxyz
3246 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3248 NULLIFY (grid_atom, harmonics, basis, qs_kind_set, dslm_dxyz, slm, lmin, lmax, npgf, zet)
3250 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
3251 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=
"ORB")
3252 IF (
PRESENT(soc_atom_env))
THEN
3253 grid_atom => soc_atom_env%grid_atom_set(ikind)%grid_atom
3254 harmonics => soc_atom_env%harmonics_atom_set(ikind)%harmonics_atom
3256 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=
"ORB", harmonics=harmonics, &
3257 grid_atom=grid_atom)
3260 na = grid_atom%ng_sphere
3263 slm => harmonics%slm
3264 dslm_dxyz => harmonics%dslm_dxyz
3268 maxso=maxso, npgf=npgf, nset=nset, zet=zet)
3274 ALLOCATE (a1(na, nset*maxso, 3), a2(na, nset*maxso, 3))
3275 ALLOCATE (r1(nr, nset*maxso), r2(nr, nset*maxso))
3276 a1 = 0.0_dp; a2 = 0.0_dp
3277 r1 = 0.0_dp; r2 = 0.0_dp
3280 DO ipgf = 1, npgf(iset)
3281 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
3282 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
3289 r1(1:nr, starti + iso) = grid_atom%rad(1:nr)**(l - 1)*exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
3292 r2(1:nr, starti + iso) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1) &
3293 *exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
3297 a1(1:na, starti + iso, i) = dslm_dxyz(i, 1:na, iso)
3300 a2(1:na, starti + iso, i) = harmonics%a(i, 1:na)*slm(1:na, iso)
3309 ALLOCATE (fga(na, 1))
3310 ALLOCATE (fgr(nr, 1))
3311 ALLOCATE (work(na, 1))
3312 fga = 0.0_dp; fgr = 0.0_dp; work = 0.0_dp
3316 DO ipgf = 1, npgf(iset)
3317 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
3318 DO jpgf = 1, npgf(jset)
3319 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
3323 k = mod(i + 1, 3) + 1
3325 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
3326 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
3331 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r1(1:nr, startj + jso)
3332 fga(1:na, 1) = a1(1:na, starti + iso, j)*a1(1:na, startj + jso, k)
3334 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3335 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 0.0_dp, &
3336 intso(starti + iso:, startj + jso, i), 1)
3339 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r2(1:nr, startj + jso)
3340 fga(1:na, 1) = a1(1:na, starti + iso, j)*a2(1:na, startj + jso, k)
3342 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3343 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
3344 intso(starti + iso:, startj + jso, i), 1)
3347 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r1(1:nr, startj + jso)
3348 fga(1:na, 1) = a2(1:na, starti + iso, j)*a1(1:na, startj + jso, k)
3350 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3351 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
3352 intso(starti + iso:, startj + jso, i), 1)
3355 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r2(1:nr, startj + jso)
3356 fga(1:na, 1) = a2(1:na, starti + iso, j)*a2(1:na, startj + jso, k)
3358 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3359 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
3360 intso(starti + iso:, startj + jso, i), 1)
3372 intso(:, :, i) = intso(:, :, i) - transpose(intso(:, :, i))
3375 END SUBROUTINE integrate_so_dxdy_prod
3389 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_soc
3394 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_soc_atoms'
3396 INTEGER :: handle, i, iat, ikind, ir, jat, maxso, &
3397 na, nkind, nr, nset, nsgf
3398 LOGICAL :: all_potential_present
3400 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: vr
3401 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: v
3402 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: intso
3403 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi_so
3404 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: intsgf
3411 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3414 CALL timeset(routinen, handle)
3416 NULLIFY (int_soc, basis, qs_kind_set, sphi_so, matrix_s, grid)
3417 NULLIFY (particle_set)
3420 CALL get_qs_env(qs_env, nkind=nkind, qs_kind_set=qs_kind_set, matrix_s=matrix_s, &
3421 particle_set=particle_set)
3424 CALL get_qs_kind_set(qs_kind_set, all_potential_present=all_potential_present)
3427 ALLOCATE (int_soc(nkind))
3429 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=
"ORB", zeff=zeff)
3430 IF (
PRESENT(soc_atom_env))
THEN
3431 grid => soc_atom_env%grid_atom_set(ikind)%grid_atom
3433 CALL get_qs_kind(qs_kind_set(ikind), grid_atom=grid)
3436 ALLOCATE (intso(nset*maxso, nset*maxso, 3))
3446 ALLOCATE (v(na, nr))
3449 CALL daxpy(na, vr(ir)/(4.0_dp*
c_light_au**2 - 2.0_dp*vr(ir)), grid%weight(:, ir), 1, &
3455 IF (
PRESENT(xas_atom_env))
THEN
3456 CALL integrate_so_dxdy_prod(intso, v, ikind, qs_env)
3458 CALL integrate_so_dxdy_prod(intso, v, ikind, qs_env, soc_atom_env)
3464 ALLOCATE (int_soc(ikind)%array(nsgf, nsgf, 3))
3465 intsgf => int_soc(ikind)%array
3466 IF (
PRESENT(xas_atom_env))
THEN
3467 sphi_so => xas_atom_env%orb_sphi_so(ikind)%array
3469 sphi_so => soc_atom_env%orb_sphi_so(ikind)%array
3474 CALL contract_so2sgf(intsgf(:, :, i), intso(:, :, i), basis, sphi_so)
3481 IF ((
PRESENT(xas_atom_env)) .OR. all_potential_present)
THEN
3483 CALL dbcsr_create(matrix_soc(i)%matrix, name=
"SOC MATRIX", template=matrix_s(1)%matrix, &
3484 matrix_type=dbcsr_type_antisymmetric)
3491 IF (.NOT. iat == jat) cycle
3492 ikind = particle_set(iat)%atomic_kind%kind_number
3495 CALL dbcsr_put_block(matrix_soc(i)%matrix, iat, iat, int_soc(ikind)%array(:, :, i))
3502 CALL dbcsr_create(matrix_soc(i)%matrix, name=
"SOC MATRIX", template=matrix_s(1)%matrix, &
3503 matrix_type=dbcsr_type_no_symmetry)
3504 CALL dbcsr_set(matrix_soc(i)%matrix, 0.0_dp)
3505 CALL dbcsr_copy(matrix_soc(i)%matrix, soc_atom_env%soc_pp(i, 1)%matrix)
3515 DEALLOCATE (int_soc(ikind)%array)
3517 DEALLOCATE (int_soc)
3519 CALL timestop(handle)
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Contraction of integrals over primitive Cartesian Gaussians based on the contraction matrix sphi whic...
subroutine, public ab_contract(abint, sab, sphi_a, sphi_b, ncoa, ncob, nsgfa, nsgfb)
contract overlap integrals (a,b) and transfer to spherical Gaussians
Calculate the atomic operator matrices.
subroutine, public calculate_model_potential(modpot, grid, zcore)
Calculate model potential. It is useful to guess atomic orbitals.
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)
...
Handles all functions related to the CELL.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_distribution_release(dist)
...
subroutine, public dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, reuse_arrays)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_replicate_all(matrix)
...
subroutine, public dbcsr_get_stored_coordinates(matrix, row, column, processor)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_finalize(matrix)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_iterator_readonly_start(iterator, matrix, shared, dynamic, dynamic_byrows)
Like dbcsr_iterator_start() but with matrix being INTENT(IN). When invoking this routine,...
subroutine, public dbcsr_put_block(matrix, row, col, block, summation)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
Interface to (sca)lapack for the Cholesky based procedures.
subroutine, public cp_dbcsr_cholesky_decompose(matrix, n, para_env, blacs_env)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
subroutine, public cp_dbcsr_cholesky_invert(matrix, n, para_env, blacs_env, uplo_to_full)
used to replace the cholesky decomposition by the inverse
DBCSR operations in CP2K.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
This is the start of a dbt_api, all publically needed functions are exported here....
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
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.
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
Collection of simple mathematical functions and subroutines.
subroutine, public invmat_symm(a, potrf, uplo)
returns inverse of real symmetric, positive definite matrix
pure real(kind=dp) function, dimension(min(size(a, 1), size(a, 2))), public get_diag(a)
Return the diagonal elements of matrix a as a vector.
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 co
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public nsoset
integer, dimension(:, :), allocatable, public indso
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :), allocatable, public indco
integer, dimension(:), allocatable, public nso
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis)
Get the components of a particle set.
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public c_light_au
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, 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, 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 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)
...
subroutine, public allocate_harmonics_atom(harmonics)
Allocate a spherical harmonics set for the atom grid.
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)
...
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
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 release_neighbor_list_sets(nlists)
releases an array of neighbor_list_sets
Calculation of overlap matrix, its derivatives and forces.
subroutine, public build_overlap_matrix_simple(ks_env, matrix_s, basis_set_list_a, basis_set_list_b, sab_nl)
Calculation of the overlap matrix over Cartesian Gaussian functions.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
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
This module deals with all the integrals done on local atomic grids in xas_tdp. This is mostly used t...
subroutine, public calculate_density_coeffs(xas_atom_env, qs_env)
Compute the coefficients to project the density on a partial RI_XAS basis.
subroutine, public compute_sphi_so(ikind, basis_type, sphi_so, qs_env)
Computes the contraction coefficients to go from spherical orbitals to sgf for a given atomic kind an...
subroutine, public init_xas_atom_env(xas_atom_env, xas_tdp_env, xas_tdp_control, qs_env, ltddfpt)
Initializes a xas_atom_env type given the qs_enxas_atom_env, qs_envv.
subroutine, public integrate_soc_atoms(matrix_soc, xas_atom_env, qs_env, soc_atom_env)
Computes the SOC matrix elements with respect to the ORB basis set for each atomic kind and put them ...
subroutine, public truncate_radial_grid(grid_atom, max_radius)
Reduces the radial extension of an atomic grid such that it only covers a given radius.
subroutine, public init_xas_atom_grid_harmo(xas_atom_env, grid_info, do_xc, qs_env)
Initializes the atomic grids and harmonics for the RI atomic calculations.
subroutine, public integrate_fxc_atoms(int_fxc, xas_atom_env, xas_tdp_control, qs_env)
Integrate the xc kernel as a function of r on the atomic grids for the RI_XAS basis.
3-center integrals machinery for the XAS_TDP method
subroutine, public build_xas_tdp_3c_nl(ac_list, basis_a, basis_c, op_type, qs_env, excited_atoms, x_range, ext_dist2d)
Builds a neighbor lists set taylored for 3-center integral within XAS TDP, such that only excited ato...
subroutine, public build_xas_tdp_ovlp_nl(ab_list, basis_a, basis_b, qs_env, excited_atoms, ext_dist2d)
Builds a neighbor lists set for overlaping 2-center S_ab, where b is restricted on a a given list of ...
subroutine, public fill_pqx_tensor(pq_x, ab_nl, ac_nl, basis_set_list_a, basis_set_list_b, basis_set_list_c, potential_parameter, qs_env, only_bc_same_center, eps_screen)
Fills the given 3 dimensional (pq|X) tensor with integrals.
subroutine, public create_pqx_tensor(pq_x, ab_nl, ac_nl, matrix_dist, blk_size_1, blk_size_2, blk_size_3, only_bc_same_center)
Prepares a tensor to hold 3-center integrals (pq|X), where p,q are distributed according to the given...
Define XAS TDP control type and associated create, release, etc subroutines, as well as XAS TDP envir...
subroutine, public get_proc_batch_sizes(batch_size, nbatch, nex_atom, nprocs)
Uses heuristics to determine a good batching of the processros for fxc integration.
subroutine, public release_batch_info(batch_info)
Releases a batch_info type.
subroutine, public xc_rho_set_atom_update(rho_set, needs, nspins, bo)
...
Module with functions to handle derivative descriptors. derivative description are strings have the f...
integer, parameter, public deriv_norm_drho
integer, parameter, public deriv_norm_drhoa
integer, parameter, public deriv_rhob
integer, parameter, public deriv_rhoa
integer, parameter, public deriv_norm_drhob
represent a group ofunctional derivatives
type(xc_derivative_type) function, pointer, public xc_dset_get_derivative(derivative_set, description, allocate_deriv)
returns the requested xc_derivative
subroutine, public xc_dset_release(derivative_set)
releases a derivative set
subroutine, public xc_dset_create(derivative_set, pw_pool, local_bounds)
creates a derivative set object
Provides types for the management of the xc-functionals and their derivatives.
subroutine, public xc_derivative_get(deriv, split_desc, order, deriv_data, accept_null_data)
returns various information on the given derivative
type(xc_rho_cflags_type) function, public xc_functionals_get_needs(functionals, lsd, calc_potential)
...
subroutine, public xc_functionals_eval(functionals, lsd, rho_set, deriv_set, deriv_order)
...
subroutine, public xc_rho_set_create(rho_set, local_bounds, rho_cutoff, drho_cutoff, tau_cutoff)
allocates and does (minimal) initialization of a rho_set
subroutine, public xc_rho_set_release(rho_set, pw_pool)
releases the given rho_set
Exchange and Correlation functional calculations.
subroutine, public divide_by_norm_drho(deriv_set, rho_set, lsd)
divides derivatives from deriv_set by norm_drho
Type defining parameters related to the simulation cell.
represent a pointer to a 1d array
represent a pointer to a 1d array
represent a pointer to a 2d array
represent a pointer to a 3d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.
a environment type that contains all the info needed for XAS_TDP atomic grid calculations
Type containing control information for TDP XAS calculations.
Type containing informations such as inputs and results for TDP XAS calculations.
A derivative set contains the different derivatives of a xc-functional in form of a linked list.
represent a pointer to a derivative (to have arrays of derivatives)
represent a derivative of a functional
contains a flag for each component of xc_rho_set, so that you can use it to tell which components you...
represent a density, with all the representation and data needed to perform a functional evaluation