19 gto_basis_set_p_type,&
34 USE dbcsr_api,
ONLY: &
35 dbcsr_copy, dbcsr_create, dbcsr_distribution_get, dbcsr_distribution_new, &
36 dbcsr_distribution_release, dbcsr_distribution_type, dbcsr_filter, dbcsr_finalize, &
37 dbcsr_get_block_p, dbcsr_get_stored_coordinates, dbcsr_iterator_blocks_left, &
38 dbcsr_iterator_next_block, dbcsr_iterator_start, dbcsr_iterator_stop, dbcsr_iterator_type, &
39 dbcsr_p_type, dbcsr_put_block, dbcsr_release, dbcsr_replicate_all, dbcsr_set, dbcsr_type, &
40 dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, dbcsr_type_symmetric
41 USE dbt_api,
ONLY: dbt_destroy,&
43 dbt_iterator_blocks_left,&
44 dbt_iterator_next_block,&
109 xas_tdp_control_type,&
132 #include "./base/base_uses.f90"
138 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xas_tdp_atom'
160 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
161 TYPE(xas_tdp_env_type),
POINTER :: xas_tdp_env
162 TYPE(xas_tdp_control_type),
POINTER :: xas_tdp_control
163 TYPE(qs_environment_type),
POINTER :: qs_env
164 LOGICAL,
OPTIONAL :: ltddfpt
166 CHARACTER(len=*),
PARAMETER :: routinen =
'init_xas_atom_env'
168 INTEGER :: handle, ikind, natom, nex_atoms, &
169 nex_kinds, nkind, nspins
171 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
172 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
174 NULLIFY (qs_kind_set, particle_set)
176 CALL timeset(routinen, handle)
179 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, natom=natom, particle_set=particle_set)
181 nkind =
SIZE(qs_kind_set)
182 nex_kinds = xas_tdp_env%nex_kinds
183 nex_atoms = xas_tdp_env%nex_atoms
184 do_xc = xas_tdp_control%do_xc
185 IF (
PRESENT(ltddfpt) .AND. ltddfpt) do_xc = .false.
186 nspins = 1;
IF (xas_tdp_control%do_uks .OR. xas_tdp_control%do_roks) nspins = 2
188 xas_atom_env%nspins = nspins
189 xas_atom_env%ri_radius = xas_tdp_control%ri_radius
190 ALLOCATE (xas_atom_env%grid_atom_set(nkind))
191 ALLOCATE (xas_atom_env%harmonics_atom_set(nkind))
192 ALLOCATE (xas_atom_env%ri_sphi_so(nkind))
193 ALLOCATE (xas_atom_env%orb_sphi_so(nkind))
195 ALLOCATE (xas_atom_env%gr(nkind))
196 ALLOCATE (xas_atom_env%ga(nkind))
197 ALLOCATE (xas_atom_env%dgr1(nkind))
198 ALLOCATE (xas_atom_env%dgr2(nkind))
199 ALLOCATE (xas_atom_env%dga1(nkind))
200 ALLOCATE (xas_atom_env%dga2(nkind))
203 xas_atom_env%excited_atoms => xas_tdp_env%ex_atom_indices
204 xas_atom_env%excited_kinds => xas_tdp_env%ex_kind_indices
211 NULLIFY (xas_atom_env%orb_sphi_so(ikind)%array, xas_atom_env%ri_sphi_so(ikind)%array)
212 CALL compute_sphi_so(ikind,
"ORB", xas_atom_env%orb_sphi_so(ikind)%array, qs_env)
213 IF (any(xas_atom_env%excited_kinds == ikind))
THEN
214 CALL compute_sphi_so(ikind,
"RI_XAS", xas_atom_env%ri_sphi_so(ikind)%array, qs_env)
219 IF (do_xc .AND. (.NOT. xas_tdp_control%xps_only))
THEN
223 CALL timestop(handle)
238 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
239 CHARACTER(len=default_string_length), &
240 DIMENSION(:, :),
POINTER :: grid_info
241 LOGICAL,
INTENT(IN) :: do_xc
242 TYPE(qs_environment_type),
POINTER :: qs_env
244 CHARACTER(LEN=default_string_length) :: kind_name
245 INTEGER :: igrid, ikind, il, iso, iso1, iso2, l1, l1l2, l2, la, lc1, lc2, lcleb, ll, llmax, &
246 lp, m1, m2, max_s_harm, max_s_set, maxl, maxlgto, maxs, mm, mp, na, nr, quadrature, stat
247 REAL(
dp) :: kind_radius
248 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rga
249 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
250 TYPE(dft_control_type),
POINTER :: dft_control
251 TYPE(grid_atom_type),
POINTER :: grid_atom
252 TYPE(gto_basis_set_type),
POINTER :: tmp_basis
253 TYPE(harmonics_atom_type),
POINTER :: harmonics
254 TYPE(qs_control_type),
POINTER :: qs_control
255 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
257 NULLIFY (my_cg, qs_kind_set, tmp_basis, grid_atom, harmonics, qs_control, dft_control)
260 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
262 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto, basis_type=
"RI_XAS")
266 qs_control => dft_control%qs_control
270 max_s_harm =
nsoset(llmax)
271 max_s_set =
nsoset(maxlgto)
276 CALL reallocate(my_cg, 1, max_s_set, 1, max_s_set, 1, max_s_harm)
278 ALLOCATE (rga(lcleb, 2))
287 CALL clebsch_gordon(l1, m1, l2, m2, rga)
288 IF (l1 + l2 > llmax)
THEN
295 IF (m1*m2 < 0 .OR. (m1*m2 == 0 .AND. (m1 < 0 .OR. m2 < 0)))
THEN
302 DO lp = mod(l1 + l2, 2), l1l2, 2
304 IF (abs(mp) <= lp)
THEN
306 iso =
nsoset(lp - 1) + lp + 1 + mp
308 iso =
nsoset(lp - 1) + lp + 1 - abs(mp)
310 my_cg(iso1, iso2, iso) = rga(il, 1)
312 IF (mp /= mm .AND. abs(mm) <= lp)
THEN
314 iso =
nsoset(lp - 1) + lp + 1 + mm
316 iso =
nsoset(lp - 1) + lp + 1 - abs(mm)
318 my_cg(iso1, iso2, iso) = rga(il, 2)
330 quadrature = qs_control%gapw_control%quadrature
332 DO ikind = 1,
SIZE(xas_atom_env%grid_atom_set)
335 NULLIFY (xas_atom_env%grid_atom_set(ikind)%grid_atom)
336 NULLIFY (xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom)
340 NULLIFY (grid_atom, harmonics)
341 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
342 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
345 CALL get_qs_kind(qs_kind_set(ikind), ngrid_rad=nr, ngrid_ang=na, name=kind_name)
348 IF (any(grid_info == kind_name))
THEN
349 DO igrid = 1,
SIZE(grid_info, 1)
350 IF (grid_info(igrid, 1) == kind_name)
THEN
353 READ (grid_info(igrid, 2), *, iostat=stat) na
354 IF (stat .NE. 0) cpabort(
"The 'na' value for the GRID keyword must be an integer")
355 READ (grid_info(igrid, 3), *, iostat=stat) nr
356 IF (stat .NE. 0) cpabort(
"The 'nr' value for the GRID keyword must be an integer")
360 ELSE IF (do_xc .AND. any(xas_atom_env%excited_kinds == ikind))
THEN
362 cpwarn(
"The default (and possibly small) GAPW grid is being used for one excited KIND")
368 grid_atom%ng_sphere = na
372 IF (any(xas_atom_env%excited_kinds == ikind) .AND. do_xc)
THEN
373 CALL get_qs_kind(qs_kind_set(ikind), basis_set=tmp_basis, basis_type=
"RI_XAS")
375 CALL get_qs_kind(qs_kind_set(ikind), basis_set=tmp_basis, basis_type=
"ORB")
377 CALL get_gto_basis_set(gto_basis_set=tmp_basis, maxl=maxl, kind_radius=kind_radius)
384 my_cg, na, llmax, maxs, max_s_harm, ll, grid_atom%wa, &
385 grid_atom%azi, grid_atom%pol)
386 CALL get_maxl_cg(harmonics, tmp_basis, llmax, max_s_harm)
404 TYPE(grid_atom_type),
POINTER :: grid_atom
405 REAL(
dp),
INTENT(IN) :: max_radius
407 INTEGER :: first_ir, ir, llmax_p1, na, new_nr, nr
410 na = grid_atom%ng_sphere
411 llmax_p1 =
SIZE(grid_atom%rad2l, 2) - 1
415 IF (grid_atom%rad(ir) < max_radius)
THEN
420 new_nr = nr - first_ir + 1
423 grid_atom%nr = new_nr
425 grid_atom%rad(1:new_nr) = grid_atom%rad(first_ir:nr)
426 grid_atom%rad2(1:new_nr) = grid_atom%rad2(first_ir:nr)
427 grid_atom%wr(1:new_nr) = grid_atom%wr(first_ir:nr)
428 grid_atom%weight(:, 1:new_nr) = grid_atom%weight(:, first_ir:nr)
429 grid_atom%rad2l(1:new_nr, :) = grid_atom%rad2l(first_ir:nr, :)
430 grid_atom%oorad2l(1:new_nr, :) = grid_atom%oorad2l(first_ir:nr, :)
432 CALL reallocate(grid_atom%rad, 1, new_nr)
433 CALL reallocate(grid_atom%rad2, 1, new_nr)
434 CALL reallocate(grid_atom%wr, 1, new_nr)
435 CALL reallocate(grid_atom%weight, 1, na, 1, new_nr)
436 CALL reallocate(grid_atom%rad2l, 1, new_nr, 0, llmax_p1)
437 CALL reallocate(grid_atom%oorad2l, 1, new_nr, 0, llmax_p1)
451 INTEGER,
INTENT(IN) :: ikind
452 CHARACTER(len=*),
INTENT(IN) :: basis_type
453 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi_so
454 TYPE(qs_environment_type),
POINTER :: qs_env
456 INTEGER :: ico, ipgf, iset, iso, l, lx, ly, lz, &
457 maxso, nset, sgfi, start_c, start_s
458 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
459 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
461 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi
462 TYPE(gto_basis_set_type),
POINTER :: basis
463 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
465 NULLIFY (basis, lmax, lmin, npgf, nsgf_set, qs_kind_set, first_sgf, sphi)
467 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
468 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=basis_type)
469 CALL get_gto_basis_set(basis, lmax=lmax, nset=nset, npgf=npgf, maxso=maxso, lmin=lmin, &
470 nsgf_set=nsgf_set, sphi=sphi, first_sgf=first_sgf)
472 ALLOCATE (sphi_so(maxso, sum(nsgf_set)))
476 sgfi = first_sgf(1, iset)
477 DO ipgf = 1, npgf(iset)
478 start_s = (ipgf - 1)*
nsoset(lmax(iset))
479 start_c = (ipgf - 1)*
ncoset(lmax(iset))
480 DO l = lmin(iset), lmax(iset)
489 sphi_so(start_s +
nsoset(l - 1) + iso, sgfi:sgfi + nsgf_set(iset) - 1) = &
490 sphi_so(start_s +
nsoset(l - 1) + iso, sgfi:sgfi + nsgf_set(iset) - 1) + &
491 factor*sphi(start_c +
ncoset(l - 1) + ico, sgfi:sgfi + nsgf_set(iset) - 1)
512 SUBROUTINE find_neighbors(base_atoms, mat_s, radius, qs_env, all_neighbors, neighbor_set)
514 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: base_atoms
515 TYPE(dbcsr_type),
INTENT(IN) :: mat_s
517 TYPE(qs_environment_type),
POINTER :: qs_env
518 INTEGER,
DIMENSION(:),
OPTIONAL,
POINTER :: all_neighbors
519 TYPE(cp_1d_i_p_type),
DIMENSION(:),
OPTIONAL, &
520 POINTER :: neighbor_set
522 INTEGER :: blk, i, iat, ibase, iblk, jblk, mepos, &
524 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: blk_to_base, inb, who_is_there
525 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: n_neighbors
526 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_base_atom
527 REAL(
dp) :: dist2, rad2, ri(3), rij(3), rj(3)
528 TYPE(cell_type),
POINTER :: cell
529 TYPE(cp_1d_i_p_type),
DIMENSION(:),
POINTER :: my_neighbor_set
530 TYPE(dbcsr_iterator_type) :: iter
531 TYPE(mp_para_env_type),
POINTER :: para_env
532 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
534 NULLIFY (particle_set, para_env, my_neighbor_set, cell)
537 CALL get_qs_env(qs_env, para_env=para_env, natom=natom, particle_set=particle_set, cell=cell)
538 mepos = para_env%mepos
539 nbase =
SIZE(base_atoms)
541 ALLOCATE (my_neighbor_set(nbase))
544 ALLOCATE (blk_to_base(natom), is_base_atom(natom))
545 blk_to_base = 0; is_base_atom = .false.
547 blk_to_base(base_atoms(ibase)) = ibase
548 is_base_atom(base_atoms(ibase)) = .true.
552 ALLOCATE (n_neighbors(nbase, 0:para_env%num_pe - 1))
555 CALL dbcsr_iterator_start(iter, mat_s)
556 DO WHILE (dbcsr_iterator_blocks_left(iter))
558 CALL dbcsr_iterator_next_block(iter, row=iblk, column=jblk, blk=blk)
561 IF (iblk == jblk) cycle
564 ri =
pbc(particle_set(iblk)%r, cell)
565 rj =
pbc(particle_set(jblk)%r, cell)
566 rij =
pbc(ri, rj, cell)
568 IF (dist2 > rad2) cycle
570 IF (is_base_atom(iblk))
THEN
571 ibase = blk_to_base(iblk)
572 n_neighbors(ibase, mepos) = n_neighbors(ibase, mepos) + 1
574 IF (is_base_atom(jblk))
THEN
575 ibase = blk_to_base(jblk)
576 n_neighbors(ibase, mepos) = n_neighbors(ibase, mepos) + 1
580 CALL dbcsr_iterator_stop(iter)
581 CALL para_env%sum(n_neighbors)
585 ALLOCATE (my_neighbor_set(ibase)%array(sum(n_neighbors(ibase, :))))
586 my_neighbor_set(ibase)%array = 0
590 CALL dbcsr_iterator_start(iter, mat_s)
591 ALLOCATE (inb(nbase))
593 DO WHILE (dbcsr_iterator_blocks_left(iter))
595 CALL dbcsr_iterator_next_block(iter, row=iblk, column=jblk, blk=blk)
596 IF (iblk == jblk) cycle
599 ri =
pbc(particle_set(iblk)%r, cell)
600 rj =
pbc(particle_set(jblk)%r, cell)
601 rij =
pbc(ri, rj, cell)
603 IF (dist2 > rad2) cycle
605 IF (is_base_atom(iblk))
THEN
606 ibase = blk_to_base(iblk)
607 my_neighbor_set(ibase)%array(sum(n_neighbors(ibase, 0:mepos - 1)) + inb(ibase)) = jblk
608 inb(ibase) = inb(ibase) + 1
610 IF (is_base_atom(jblk))
THEN
611 ibase = blk_to_base(jblk)
612 my_neighbor_set(ibase)%array(sum(n_neighbors(ibase, 0:mepos - 1)) + inb(ibase)) = iblk
613 inb(ibase) = inb(ibase) + 1
617 CALL dbcsr_iterator_stop(iter)
621 CALL para_env%sum(my_neighbor_set(ibase)%array)
625 IF (
PRESENT(all_neighbors))
THEN
626 ALLOCATE (who_is_there(natom))
630 who_is_there(base_atoms(ibase)) = 1
631 DO nb = 1,
SIZE(my_neighbor_set(ibase)%array)
632 who_is_there(my_neighbor_set(ibase)%array(nb)) = 1
636 ALLOCATE (all_neighbors(natom))
639 IF (who_is_there(iat) == 1)
THEN
641 all_neighbors(i) = iat
644 CALL reallocate(all_neighbors, 1, i)
648 IF (
PRESENT(neighbor_set))
THEN
649 neighbor_set => my_neighbor_set
652 DEALLOCATE (my_neighbor_set(ibase)%array)
654 DEALLOCATE (my_neighbor_set)
657 END SUBROUTINE find_neighbors
671 SUBROUTINE get_exat_ri_sinv(ri_sinv, whole_s, neighbors, idx_to_nb, basis_set_ri, qs_env)
673 TYPE(dbcsr_type) :: ri_sinv, whole_s
674 INTEGER,
DIMENSION(:),
INTENT(IN) :: neighbors, idx_to_nb
675 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_ri
676 TYPE(qs_environment_type),
POINTER :: qs_env
678 CHARACTER(len=*),
PARAMETER :: routinen =
'get_exat_ri_sinv'
680 INTEGER :: blk, dest, group_handle, handle, iat, &
681 ikind, inb, ir, is, jat, jnb, natom, &
682 nnb, npcols, nprows, source, tag
683 INTEGER,
DIMENSION(:),
POINTER :: col_dist, nsgf, row_dist
684 INTEGER,
DIMENSION(:, :),
POINTER :: pgrid
685 LOGICAL :: found_risinv, found_whole
686 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_neighbor
687 REAL(
dp) :: ri(3), rij(3), rj(3)
688 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: radius
689 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_risinv, block_whole
690 TYPE(cell_type),
POINTER :: cell
691 TYPE(cp_2d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: recv_buff, send_buff
692 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
693 TYPE(dbcsr_distribution_type) :: sinv_dist
694 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
695 TYPE(dbcsr_iterator_type) :: iter
696 TYPE(mp_comm_type) :: group
697 TYPE(mp_para_env_type),
POINTER :: para_env
698 TYPE(mp_request_type),
ALLOCATABLE,
DIMENSION(:) :: recv_req, send_req
699 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
701 NULLIFY (pgrid, dbcsr_dist, row_dist, col_dist, nsgf, particle_set, block_whole, block_risinv)
702 NULLIFY (cell, para_env, blacs_env)
704 CALL timeset(routinen, handle)
706 CALL get_qs_env(qs_env, dbcsr_dist=dbcsr_dist, particle_set=particle_set, natom=natom, &
707 para_env=para_env, blacs_env=blacs_env, cell=cell)
708 nnb =
SIZE(neighbors)
709 ALLOCATE (nsgf(nnb), is_neighbor(natom), radius(nnb))
710 is_neighbor = .false.
713 ikind = particle_set(iat)%atomic_kind%kind_number
714 CALL get_gto_basis_set(basis_set_ri(ikind)%gto_basis_set, nsgf=nsgf(inb), kind_radius=radius(inb))
715 is_neighbor(iat) = .true.
719 CALL dbcsr_distribution_get(dbcsr_dist, group=group_handle, pgrid=pgrid, nprows=nprows, npcols=npcols)
720 CALL group%set_handle(group_handle)
722 ALLOCATE (row_dist(nnb), col_dist(nnb))
724 row_dist(inb) =
modulo(nprows - inb, nprows)
725 col_dist(inb) =
modulo(npcols - inb, npcols)
728 CALL dbcsr_distribution_new(sinv_dist, group=group_handle, pgrid=pgrid, row_dist=row_dist, &
731 CALL dbcsr_create(matrix=ri_sinv, name=
"RI_SINV", matrix_type=dbcsr_type_symmetric, &
732 dist=sinv_dist, row_blk_size=nsgf, col_blk_size=nsgf)
735 ri =
pbc(particle_set(neighbors(inb))%r, cell)
739 rj =
pbc(particle_set(neighbors(jnb))%r, cell)
740 rij =
pbc(ri, rj, cell)
741 IF (sum(rij**2) > (radius(inb) + radius(jnb))**2) cycle
743 CALL dbcsr_get_stored_coordinates(ri_sinv, inb, jnb, blk)
744 IF (para_env%mepos == blk)
THEN
745 ALLOCATE (block_risinv(nsgf(inb), nsgf(jnb)))
746 block_risinv = 0.0_dp
747 CALL dbcsr_put_block(ri_sinv, inb, jnb, block_risinv)
748 DEALLOCATE (block_risinv)
752 CALL dbcsr_finalize(ri_sinv)
754 CALL dbcsr_distribution_release(sinv_dist)
755 DEALLOCATE (row_dist, col_dist)
759 ALLOCATE (send_buff(nnb**2), recv_buff(nnb**2))
760 ALLOCATE (send_req(nnb**2), recv_req(nnb**2))
764 CALL dbcsr_iterator_start(iter, whole_s)
765 DO WHILE (dbcsr_iterator_blocks_left(iter))
767 CALL dbcsr_iterator_next_block(iter, row=iat, column=jat, blk=blk)
768 CALL dbcsr_get_block_p(whole_s, iat, jat, block_whole, found_whole)
771 IF (.NOT. found_whole) cycle
772 IF (.NOT. is_neighbor(iat)) cycle
773 IF (.NOT. is_neighbor(jat)) cycle
779 CALL dbcsr_get_block_p(ri_sinv, inb, jnb, block_risinv, found_risinv)
780 IF (found_risinv)
THEN
781 CALL dcopy(nsgf(inb)*nsgf(jnb), block_whole, 1, block_risinv, 1)
785 CALL dbcsr_get_stored_coordinates(ri_sinv, inb, jnb, dest)
787 send_buff(is)%array => block_whole
788 tag = natom*inb + jnb
789 CALL group%isend(msgin=send_buff(is)%array, dest=dest, request=send_req(is), tag=tag)
794 CALL dbcsr_iterator_stop(iter)
797 CALL dbcsr_iterator_start(iter, ri_sinv)
798 DO WHILE (dbcsr_iterator_blocks_left(iter))
800 CALL dbcsr_iterator_next_block(iter, row=inb, column=jnb, blk=blk)
801 CALL dbcsr_get_block_p(ri_sinv, inb, jnb, block_risinv, found_risinv)
803 IF (.NOT. found_risinv) cycle
809 CALL dbcsr_get_stored_coordinates(whole_s, iat, jat, source)
810 IF (para_env%mepos == source) cycle
812 tag = natom*inb + jnb
814 recv_buff(ir)%array => block_risinv
815 CALL group%irecv(msgout=recv_buff(ir)%array, source=source, request=recv_req(ir), &
819 CALL dbcsr_iterator_stop(iter)
822 CALL mp_waitall(send_req(1:is))
823 CALL mp_waitall(recv_req(1:ir))
829 CALL dbcsr_get_block_p(ri_sinv, 1, 1, block_risinv, found_risinv)
830 IF (found_risinv)
THEN
837 CALL dbcsr_filter(ri_sinv, 1.e-10_dp)
839 CALL dbcsr_replicate_all(ri_sinv)
844 CALL timestop(handle)
846 END SUBROUTINE get_exat_ri_sinv
861 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
862 TYPE(qs_environment_type),
POINTER :: qs_env
864 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_density_coeffs'
866 INTEGER :: exat, handle, i, iat, iatom, iex, inb, &
867 ind(3), ispin, jatom, jnb, katom, &
868 natom, nex, nkind, nnb, nspins, &
870 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: blk_size_orb, blk_size_ri, idx_to_nb, &
872 INTEGER,
DIMENSION(:),
POINTER :: all_ri_atoms
873 LOGICAL :: pmat_found, pmat_foundt, sinv_found, &
874 sinv_foundt, tensor_found, unique
875 REAL(
dp) :: factor, prefac
876 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: work2
877 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: work1
878 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: t_block
879 REAL(
dp),
DIMENSION(:, :),
POINTER :: pmat_block, pmat_blockt, sinv_block, &
881 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
882 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
883 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: overlap, rho_ao
884 TYPE(dbcsr_type) :: ri_sinv
885 TYPE(dbcsr_type),
POINTER :: ri_mats
886 TYPE(dbt_iterator_type) :: iter
887 TYPE(dbt_type) :: pqx
888 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_orb, basis_set_ri
889 TYPE(libint_potential_type) :: pot
890 TYPE(mp_para_env_type),
POINTER :: para_env
891 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
892 POINTER :: ab_list, ac_list, sab_ri
893 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
894 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
895 TYPE(qs_rho_type),
POINTER :: rho
897 NULLIFY (qs_kind_set, basis_set_ri, basis_set_orb, ac_list, rho, rho_ao, sab_ri, ri_mats)
898 NULLIFY (particle_set, para_env, all_ri_atoms, overlap, pmat_blockt)
899 NULLIFY (blacs_env, pmat_block, ab_list, dbcsr_dist, sinv_block, sinv_blockt)
909 CALL timeset(routinen, handle)
911 CALL get_qs_env(qs_env, nkind=nkind, qs_kind_set=qs_kind_set, rho=rho, &
912 natom=natom, particle_set=particle_set, dbcsr_dist=dbcsr_dist, &
913 para_env=para_env, blacs_env=blacs_env)
914 nspins = xas_atom_env%nspins
915 nex =
SIZE(xas_atom_env%excited_atoms)
919 ALLOCATE (basis_set_ri(nkind))
920 ALLOCATE (basis_set_orb(nkind))
927 ri_mats => overlap(1)%matrix
931 CALL find_neighbors(xas_atom_env%excited_atoms, ri_mats, xas_atom_env%ri_radius, &
932 qs_env, all_neighbors=all_ri_atoms, neighbor_set=xas_atom_env%exat_neighbors)
935 factor = 0.5_dp;
IF (nspins == 2) factor = 1.0_dp
940 ALLOCATE (blk_size_ri(natom))
941 CALL get_particle_set(particle_set, qs_kind_set, nsgf=blk_size_ri, basis=basis_set_ri)
942 ALLOCATE (xas_atom_env%ri_dcoeff(natom, nspins, nex))
946 NULLIFY (xas_atom_env%ri_dcoeff(iat, ispin, iex)%array)
947 IF ((.NOT. any(xas_atom_env%exat_neighbors(iex)%array == iat)) &
948 .AND. (.NOT. xas_atom_env%excited_atoms(iex) == iat)) cycle
949 ALLOCATE (xas_atom_env%ri_dcoeff(iat, ispin, iex)%array(blk_size_ri(iat)))
950 xas_atom_env%ri_dcoeff(iat, ispin, iex)%array = 0.0_dp
956 IF (output_unit > 0)
THEN
957 WRITE (output_unit, fmt=
"(/,T7,A,/,T7,A)") &
958 "Excited atom, natoms in RI_REGION:", &
959 "---------------------------------"
965 ALLOCATE (blk_size_orb(natom))
966 CALL get_particle_set(particle_set, qs_kind_set, nsgf=blk_size_orb, basis=basis_set_orb)
971 exat = xas_atom_env%excited_atoms(iex)
972 nnb = 1 +
SIZE(xas_atom_env%exat_neighbors(iex)%array)
973 ALLOCATE (neighbors(nnb))
975 neighbors(2:nnb) = xas_atom_env%exat_neighbors(iex)%array(:)
976 CALL sort_unique(neighbors, unique)
979 ALLOCATE (idx_to_nb(natom))
982 idx_to_nb(neighbors(inb)) = inb
985 IF (output_unit > 0)
THEN
986 WRITE (output_unit, fmt=
"(T7,I12,I21)") &
994 qs_env, excited_atoms=neighbors)
999 CALL create_pqx_tensor(pqx, ab_list, ac_list, dbcsr_dist, blk_size_orb, blk_size_orb, &
1001 CALL fill_pqx_tensor(pqx, ab_list, ac_list, basis_set_orb, basis_set_orb, basis_set_ri, &
1006 CALL get_exat_ri_sinv(ri_sinv, ri_mats, neighbors, idx_to_nb, basis_set_ri, qs_env)
1016 CALL dbt_iterator_start(iter, pqx)
1017 DO WHILE (dbt_iterator_blocks_left(iter))
1018 CALL dbt_iterator_next_block(iter, ind)
1019 CALL dbt_get_block(pqx, ind, t_block, tensor_found)
1024 inb = idx_to_nb(katom)
1028 IF (iatom == jatom) prefac = 1.0_dp
1030 DO ispin = 1, nspins
1033 CALL dbcsr_get_block_p(rho_ao(ispin)%matrix, iatom, jatom, pmat_block, pmat_found)
1034 CALL dbcsr_get_block_p(rho_ao(ispin)%matrix, jatom, iatom, pmat_blockt, pmat_foundt)
1035 IF ((.NOT. pmat_found) .AND. (.NOT. pmat_foundt)) cycle
1037 ALLOCATE (work1(blk_size_ri(katom), 1))
1041 IF (pmat_found)
THEN
1042 DO i = 1, blk_size_ri(katom)
1043 work1(i, 1) = prefac*sum(pmat_block(:, :)*t_block(:, :, i))
1046 DO i = 1, blk_size_ri(katom)
1047 work1(i, 1) = prefac*sum(transpose(pmat_blockt(:, :))*t_block(:, :, i))
1054 ri_at = neighbors(jnb)
1057 CALL dbcsr_get_block_p(ri_sinv, inb, jnb, sinv_block, sinv_found)
1058 CALL dbcsr_get_block_p(ri_sinv, jnb, inb, sinv_blockt, sinv_foundt)
1059 IF ((.NOT. sinv_found) .AND. (.NOT. sinv_foundt)) cycle
1062 ALLOCATE (work2(
SIZE(xas_atom_env%ri_dcoeff(ri_at, ispin, iex)%array)))
1065 IF (sinv_found)
THEN
1066 DO i = 1, blk_size_ri(katom)
1067 work2(:) = work2(:) + factor*work1(i, 1)*sinv_block(i, :)
1070 DO i = 1, blk_size_ri(katom)
1071 work2(:) = work2(:) + factor*work1(i, 1)*sinv_blockt(:, i)
1074 DO i = 1,
SIZE(work2)
1076 xas_atom_env%ri_dcoeff(ri_at, ispin, iex)%array(i) = &
1077 xas_atom_env%ri_dcoeff(ri_at, ispin, iex)%array(i) + work2(i)
1086 DEALLOCATE (t_block)
1088 CALL dbt_iterator_stop(iter)
1092 CALL dbcsr_release(ri_sinv)
1093 CALL dbt_destroy(pqx)
1096 DEALLOCATE (neighbors, idx_to_nb)
1102 DO ispin = 1, nspins
1104 IF ((.NOT. any(xas_atom_env%exat_neighbors(iex)%array == iat)) &
1105 .AND. (.NOT. xas_atom_env%excited_atoms(iex) == iat)) cycle
1106 CALL para_env%sum(xas_atom_env%ri_dcoeff(iat, ispin, iex)%array)
1113 DEALLOCATE (basis_set_ri, basis_set_orb, all_ri_atoms)
1115 CALL timestop(handle)
1131 SUBROUTINE put_density_on_atomic_grid(rho_set, ri_dcoeff, atom_kind, do_gga, batch_info, &
1132 xas_atom_env, qs_env)
1134 TYPE(xc_rho_set_type),
INTENT(INOUT) :: rho_set
1135 TYPE(cp_1d_r_p_type),
DIMENSION(:) :: ri_dcoeff
1136 INTEGER,
INTENT(IN) :: atom_kind
1137 LOGICAL,
INTENT(IN) :: do_gga
1138 TYPE(batch_info_type) :: batch_info
1139 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
1140 TYPE(qs_environment_type),
POINTER :: qs_env
1142 CHARACTER(len=*),
PARAMETER :: routinen =
'put_density_on_atomic_grid'
1144 INTEGER :: dir, handle, ipgf, iset, iso, iso_proc, &
1145 ispin, maxso, n, na, nr, nset, nsgfi, &
1146 nsoi, nspins, sgfi, starti
1147 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
1148 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
1149 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: so
1150 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dso
1151 REAL(
dp),
DIMENSION(:, :),
POINTER :: dgr1, dgr2, ga, gr, ri_sphi_so, zet
1152 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dga1, dga2, rhoa, rhob
1153 TYPE(cp_1d_r_p_type),
DIMENSION(:),
POINTER :: ri_dcoeff_so
1154 TYPE(grid_atom_type),
POINTER :: grid_atom
1155 TYPE(gto_basis_set_type),
POINTER :: ri_basis
1156 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1158 NULLIFY (grid_atom, ri_basis, qs_kind_set, lmax, npgf, zet, nsgf_set, ri_sphi_so)
1159 NULLIFY (lmin, first_sgf, rhoa, rhob, ga, gr, dgr1, dgr2, dga1, dga2, ri_dcoeff_so)
1161 CALL timeset(routinen, handle)
1169 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
1170 CALL get_qs_kind(qs_kind_set(atom_kind), basis_set=ri_basis, basis_type=
"RI_XAS")
1171 CALL get_gto_basis_set(ri_basis, lmax=lmax, npgf=npgf, zet=zet, nset=nset, nsgf_set=nsgf_set, &
1172 first_sgf=first_sgf, lmin=lmin, maxso=maxso)
1175 grid_atom => xas_atom_env%grid_atom_set(atom_kind)%grid_atom
1176 na = grid_atom%ng_sphere
1179 nspins = xas_atom_env%nspins
1180 ri_sphi_so => xas_atom_env%ri_sphi_so(atom_kind)%array
1183 rhoa => rho_set%rhoa
1184 rhob => rho_set%rhob
1185 rhoa = 0.0_dp; rhob = 0.0_dp;
1188 rho_set%drhoa(dir)%array = 0.0_dp
1189 rho_set%drhob(dir)%array = 0.0_dp
1194 ga => xas_atom_env%ga(atom_kind)%array
1195 gr => xas_atom_env%gr(atom_kind)%array
1197 dga1 => xas_atom_env%dga1(atom_kind)%array
1198 dga2 => xas_atom_env%dga2(atom_kind)%array
1199 dgr1 => xas_atom_env%dgr1(atom_kind)%array
1200 dgr2 => xas_atom_env%dgr2(atom_kind)%array
1202 dga1 => xas_atom_env%dga1(atom_kind)%array
1203 dga2 => xas_atom_env%dga2(atom_kind)%array
1204 dgr1 => xas_atom_env%dgr1(atom_kind)%array
1205 dgr2 => xas_atom_env%dgr2(atom_kind)%array
1209 ALLOCATE (ri_dcoeff_so(nspins))
1210 DO ispin = 1, nspins
1211 ALLOCATE (ri_dcoeff_so(ispin)%array(nset*maxso))
1212 ri_dcoeff_so(ispin)%array = 0.0_dp
1216 sgfi = first_sgf(1, iset)
1217 nsoi = npgf(iset)*
nsoset(lmax(iset))
1218 nsgfi = nsgf_set(iset)
1220 CALL dgemv(
'N', nsoi, nsgfi, 1.0_dp, ri_sphi_so(1:nsoi, sgfi:sgfi + nsgfi - 1), nsoi, &
1221 ri_dcoeff(ispin)%array(sgfi:sgfi + nsgfi - 1), 1, 0.0_dp, &
1222 ri_dcoeff_so(ispin)%array((iset - 1)*maxso + 1:(iset - 1)*maxso + nsoi), 1)
1228 ALLOCATE (so(na, nr))
1229 IF (do_gga)
ALLOCATE (dso(na, nr, 3))
1232 DO iso_proc = 1, batch_info%nso_proc(atom_kind)
1233 iset = batch_info%so_proc_info(atom_kind)%array(1, iso_proc)
1234 ipgf = batch_info%so_proc_info(atom_kind)%array(2, iso_proc)
1235 iso = batch_info%so_proc_info(atom_kind)%array(3, iso_proc)
1238 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
1241 CALL dgemm(
'N',
'T', na, nr, 1, 1.0_dp, ga(:, iso_proc:iso_proc), na, &
1242 gr(:, iso_proc:iso_proc), nr, 0.0_dp, so(:, :), na)
1248 CALL dgemm(
'N',
'T', na, nr, 1, 1.0_dp, dga1(:, iso_proc:iso_proc, dir), na, &
1249 dgr1(:, iso_proc:iso_proc), nr, 0.0_dp, dso(:, :, dir), na)
1250 CALL dgemm(
'N',
'T', na, nr, 1, 1.0_dp, dga2(:, iso_proc:iso_proc, dir), na, &
1251 dgr2(:, iso_proc:iso_proc), nr, 1.0_dp, dso(:, :, dir), na)
1256 CALL daxpy(n, ri_dcoeff_so(1)%array(starti + iso), so, 1, rhoa(:, :, 1), 1)
1258 IF (nspins == 2)
THEN
1259 CALL daxpy(n, ri_dcoeff_so(2)%array(starti + iso), so, 1, rhob(:, :, 1), 1)
1266 CALL daxpy(n, ri_dcoeff_so(1)%array(starti + iso), dso(:, :, dir), &
1267 1, rho_set%drhoa(dir)%array(:, :, 1), 1)
1269 IF (nspins == 2)
THEN
1270 CALL daxpy(n, ri_dcoeff_so(2)%array(starti + iso), dso(:, :, dir), &
1271 1, rho_set%drhob(dir)%array(:, :, 1), 1)
1279 IF (nspins == 1)
THEN
1280 CALL dcopy(n, rhoa(:, :, 1), 1, rhob(:, :, 1), 1)
1284 CALL dcopy(n, rho_set%drhoa(dir)%array(:, :, 1), 1, rho_set%drhob(dir)%array(:, :, 1), 1)
1292 DO ispin = 1, nspins
1293 DEALLOCATE (ri_dcoeff_so(ispin)%array)
1295 DEALLOCATE (ri_dcoeff_so)
1297 CALL timestop(handle)
1299 END SUBROUTINE put_density_on_atomic_grid
1318 SUBROUTINE put_density_on_other_grid(rho_set, ri_dcoeff, source_iat, source_ikind, target_iat, &
1319 target_ikind, sr, er, do_gga, xas_atom_env, qs_env)
1321 TYPE(xc_rho_set_type),
INTENT(INOUT) :: rho_set
1322 TYPE(cp_1d_r_p_type),
DIMENSION(:) :: ri_dcoeff
1323 INTEGER,
INTENT(IN) :: source_iat, source_ikind, target_iat, &
1324 target_ikind, sr, er
1325 LOGICAL,
INTENT(IN) :: do_gga
1326 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
1327 TYPE(qs_environment_type),
POINTER :: qs_env
1329 CHARACTER(len=*),
PARAMETER :: routinen =
'put_density_on_other_grid'
1331 INTEGER :: dir, handle, ia, ico, ipgf, ir, iset, &
1332 isgf, lx, ly, lz, n, na, nr, nset, &
1334 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
1335 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
1337 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sgf
1338 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: co, dsgf, pos
1339 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: dco
1340 REAL(
dp),
DIMENSION(3) :: rs, rst, rt
1341 REAL(
dp),
DIMENSION(:, :),
POINTER :: ri_sphi, zet
1342 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rhoa, rhob
1343 TYPE(cell_type),
POINTER :: cell
1344 TYPE(grid_atom_type),
POINTER :: grid_atom
1345 TYPE(gto_basis_set_type),
POINTER :: ri_basis
1346 TYPE(harmonics_atom_type),
POINTER :: harmonics
1347 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1348 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1350 NULLIFY (qs_kind_set, ri_basis, lmax, npgf, nsgf_set, lmin, zet, first_sgf, grid_atom)
1351 NULLIFY (harmonics, rhoa, rhob, particle_set, cell, ri_sphi)
1358 CALL timeset(routinen, handle)
1361 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, particle_set=particle_set, cell=cell)
1363 CALL get_qs_kind(qs_kind_set(source_ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
1364 CALL get_gto_basis_set(ri_basis, lmax=lmax, npgf=npgf, zet=zet, nset=nset, nsgf_set=nsgf_set, &
1365 first_sgf=first_sgf, lmin=lmin, sphi=ri_sphi)
1368 grid_atom => xas_atom_env%grid_atom_set(target_ikind)%grid_atom
1369 harmonics => xas_atom_env%harmonics_atom_set(target_ikind)%harmonics_atom
1370 na = grid_atom%ng_sphere
1373 nspins = xas_atom_env%nspins
1376 rhoa => rho_set%rhoa
1377 rhob => rho_set%rhob
1380 rs =
pbc(particle_set(source_iat)%r, cell)
1381 rt =
pbc(particle_set(target_iat)%r, cell)
1382 rst =
pbc(rs, rt, cell)
1385 ALLOCATE (pos(na, sr:er, 4))
1391 pos(ia, ir, 1:3) = harmonics%a(:, ia)*grid_atom%rad(ir) + rst
1392 pos(ia, ir, 4) = pos(ia, ir, 1)**2 + pos(ia, ir, 2)**2 + pos(ia, ir, 3)**2
1401 ALLOCATE (co(na, sr:er, npgf(iset)*
ncoset(lmax(iset))))
1402 IF (do_gga)
ALLOCATE (dco(na, sr:er, 3, npgf(iset)*
ncoset(lmax(iset))))
1411 co(ia, ir, :) = 0.0_dp
1413 dco(ia, ir, :, :) = 0.0_dp
1419 DO ipgf = 1, npgf(iset)
1420 start = (ipgf - 1)*
ncoset(lmax(iset))
1423 DO ico =
ncoset(lmin(iset) - 1) + 1,
ncoset(lmax(iset))
1432 rmom = exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1433 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1434 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1435 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1436 co(ia, ir, start + ico) = rmom
1453 rmom = -2.0_dp*pos(ia, ir, 1)*zet(ipgf, iset)*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1454 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1455 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1456 dco(ia, ir, 1, start + ico) = rmom
1468 rmom = (lx*pos(ia, ir, 1)**(lx - 1) - 2.0_dp*pos(ia, ir, 1)**(lx + 1)* &
1469 zet(ipgf, iset))*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1471 rmom = (1.0_dp - 2.0_dp*pos(ia, ir, 1)**2*zet(ipgf, iset))* &
1472 exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1474 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1475 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1476 dco(ia, ir, 1, start + ico) = rmom
1491 rmom = -2.0_dp*pos(ia, ir, 2)*zet(ipgf, iset)*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1492 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1493 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1494 dco(ia, ir, 2, start + ico) = rmom
1506 rmom = (ly*pos(ia, ir, 2)**(ly - 1) - 2.0_dp*pos(ia, ir, 2)**(ly + 1)*zet(ipgf, iset)) &
1507 *exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1509 rmom = (1.0_dp - 2.0_dp*pos(ia, ir, 2)**2*zet(ipgf, iset)) &
1510 *exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1512 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1513 IF (lz /= 0) rmom = rmom*pos(ia, ir, 3)**lz
1514 dco(ia, ir, 2, start + ico) = rmom
1529 rmom = -2.0_dp*pos(ia, ir, 3)*zet(ipgf, iset)*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1530 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1531 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1532 dco(ia, ir, 3, start + ico) = rmom
1544 rmom = (lz*pos(ia, ir, 3)**(lz - 1) - 2.0_dp*pos(ia, ir, 3)**(lz + 1)* &
1545 zet(ipgf, iset))*exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1547 rmom = (1.0_dp - 2.0_dp*pos(ia, ir, 3)**2*zet(ipgf, iset))* &
1548 exp(-zet(ipgf, iset)*pos(ia, ir, 4))
1550 IF (lx /= 0) rmom = rmom*pos(ia, ir, 1)**lx
1551 IF (ly /= 0) rmom = rmom*pos(ia, ir, 2)**ly
1552 dco(ia, ir, 3, start + ico) = rmom
1570 ALLOCATE (sgf(na, sr:er))
1571 IF (do_gga)
ALLOCATE (dsgf(na, sr:er, 3))
1572 sgfi = first_sgf(1, iset) - 1
1574 DO isgf = 1, nsgf_set(iset)
1576 IF (do_gga) dsgf = 0.0_dp
1578 DO ipgf = 1, npgf(iset)
1579 start = (ipgf - 1)*
ncoset(lmax(iset))
1580 DO ico =
ncoset(lmin(iset) - 1) + 1,
ncoset(lmax(iset))
1581 CALL daxpy(n, ri_sphi(start + ico, sgfi + isgf), co(:, sr:er, start + ico), 1, sgf(:, sr:er), 1)
1586 CALL daxpy(n, ri_dcoeff(1)%array(sgfi + isgf), sgf(:, sr:er), 1, rhoa(:, sr:er, 1), 1)
1588 IF (nspins == 2)
THEN
1589 CALL daxpy(n, ri_dcoeff(2)%array(sgfi + isgf), sgf(:, sr:er), 1, rhob(:, sr:er, 1), 1)
1595 DO ipgf = 1, npgf(iset)
1596 start = (ipgf - 1)*
ncoset(lmax(iset))
1597 DO ico =
ncoset(lmin(iset) - 1) + 1,
ncoset(lmax(iset))
1599 CALL daxpy(n, ri_sphi(start + ico, sgfi + isgf), dco(:, sr:er, dir, start + ico), &
1600 1, dsgf(:, sr:er, dir), 1)
1606 CALL daxpy(n, ri_dcoeff(1)%array(sgfi + isgf), dsgf(:, sr:er, dir), 1, &
1607 rho_set%drhoa(dir)%array(:, sr:er, 1), 1)
1609 IF (nspins == 2)
THEN
1610 CALL daxpy(n, ri_dcoeff(2)%array(sgfi + isgf), dsgf(:, sr:er, dir), 1, &
1611 rho_set%drhob(dir)%array(:, sr:er, 1), 1)
1618 DEALLOCATE (co, sgf)
1619 IF (do_gga)
DEALLOCATE (dco, dsgf)
1623 IF (nspins == 1)
THEN
1624 CALL dcopy(n, rhoa(:, sr:er, 1), 1, rhob(:, sr:er, 1), 1)
1628 CALL dcopy(n, rho_set%drhoa(dir)%array(:, sr:er, 1), 1, rho_set%drhob(dir)%array(:, sr:er, 1), 1)
1633 CALL timestop(handle)
1635 END SUBROUTINE put_density_on_other_grid
1644 SUBROUTINE compute_norm_drho(rho_set, atom_kind, xas_atom_env)
1646 TYPE(xc_rho_set_type),
INTENT(INOUT) :: rho_set
1647 INTEGER,
INTENT(IN) :: atom_kind
1648 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
1650 INTEGER :: dir, ia, ir, n, na, nr, nspins
1652 na = xas_atom_env%grid_atom_set(atom_kind)%grid_atom%ng_sphere
1653 nr = xas_atom_env%grid_atom_set(atom_kind)%grid_atom%nr
1655 nspins = xas_atom_env%nspins
1657 rho_set%norm_drhoa = 0.0_dp
1658 rho_set%norm_drhob = 0.0_dp
1659 rho_set%norm_drho = 0.0_dp
1664 rho_set%norm_drhoa(ia, ir, 1) = rho_set%norm_drhoa(ia, ir, 1) &
1665 + rho_set%drhoa(dir)%array(ia, ir, 1)**2
1669 rho_set%norm_drhoa = sqrt(rho_set%norm_drhoa)
1671 IF (nspins == 1)
THEN
1673 CALL dcopy(n, rho_set%norm_drhoa(:, :, 1), 1, rho_set%norm_drhob(:, :, 1), 1)
1678 rho_set%norm_drhob(ia, ir, 1) = rho_set%norm_drhob(ia, ir, 1) &
1679 + rho_set%drhob(dir)%array(ia, ir, 1)**2
1683 rho_set%norm_drhob = sqrt(rho_set%norm_drhob)
1689 rho_set%norm_drho(ia, ir, 1) = rho_set%norm_drho(ia, ir, 1) + &
1690 (rho_set%drhoa(dir)%array(ia, ir, 1) + &
1691 rho_set%drhob(dir)%array(ia, ir, 1))**2
1695 rho_set%norm_drho = sqrt(rho_set%norm_drho)
1697 END SUBROUTINE compute_norm_drho
1708 SUBROUTINE precompute_so_dso(do_gga, batch_info, xas_atom_env, qs_env)
1710 LOGICAL,
INTENT(IN) :: do_gga
1711 TYPE(batch_info_type) :: batch_info
1712 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
1713 TYPE(qs_environment_type),
POINTER :: qs_env
1715 CHARACTER(len=*),
PARAMETER :: routinen =
'precompute_so_dso'
1717 INTEGER :: bo(2), dir, handle, ikind, ipgf, iset, &
1718 iso, iso_proc, l, maxso, n, na, nkind, &
1719 nr, nset, nso_proc, nsotot, starti
1720 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, nsgf_set
1721 INTEGER,
DIMENSION(:, :),
POINTER :: so_proc_info
1722 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: rexp
1723 REAL(
dp),
DIMENSION(:, :),
POINTER :: dgr1, dgr2, ga, gr, slm, zet
1724 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dga1, dga2, dslm_dxyz
1725 TYPE(grid_atom_type),
POINTER :: grid_atom
1726 TYPE(gto_basis_set_type),
POINTER :: ri_basis
1727 TYPE(harmonics_atom_type),
POINTER :: harmonics
1728 TYPE(mp_para_env_type),
POINTER :: para_env
1729 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1731 NULLIFY (qs_kind_set, harmonics, grid_atom, slm, dslm_dxyz, ri_basis, lmax, lmin, npgf)
1732 NULLIFY (nsgf_set, zet, para_env, so_proc_info)
1734 CALL timeset(routinen, handle)
1736 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, para_env=para_env)
1737 nkind =
SIZE(qs_kind_set)
1739 ALLOCATE (batch_info%so_proc_info(nkind))
1740 ALLOCATE (batch_info%nso_proc(nkind))
1741 ALLOCATE (batch_info%so_bo(2, nkind))
1745 NULLIFY (xas_atom_env%ga(ikind)%array)
1746 NULLIFY (xas_atom_env%gr(ikind)%array)
1747 NULLIFY (xas_atom_env%dga1(ikind)%array)
1748 NULLIFY (xas_atom_env%dga2(ikind)%array)
1749 NULLIFY (xas_atom_env%dgr1(ikind)%array)
1750 NULLIFY (xas_atom_env%dgr2(ikind)%array)
1752 NULLIFY (batch_info%so_proc_info(ikind)%array)
1754 IF (.NOT. any(xas_atom_env%excited_kinds == ikind)) cycle
1757 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
1758 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
1760 na = grid_atom%ng_sphere
1764 slm => harmonics%slm
1765 dslm_dxyz => harmonics%dslm_dxyz
1768 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
1770 nsgf_set=nsgf_set, lmin=lmin, maxso=maxso)
1774 bo =
get_limit(nsotot, batch_info%batch_size, batch_info%ipe)
1775 nso_proc = bo(2) - bo(1) + 1
1776 batch_info%so_bo(:, ikind) = bo
1777 batch_info%nso_proc(ikind) = nso_proc
1780 ALLOCATE (batch_info%so_proc_info(ikind)%array(3, nso_proc))
1781 so_proc_info => batch_info%so_proc_info(ikind)%array
1784 DO ipgf = 1, npgf(iset)
1785 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
1786 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
1789 IF (starti + iso < bo(1) .OR. starti + iso > bo(2)) cycle
1790 iso_proc = starti + iso - bo(1) + 1
1791 so_proc_info(1, iso_proc) = iset
1792 so_proc_info(2, iso_proc) = ipgf
1793 so_proc_info(3, iso_proc) = iso
1800 ALLOCATE (xas_atom_env%ga(ikind)%array(na, nso_proc))
1801 ALLOCATE (xas_atom_env%gr(ikind)%array(nr, nso_proc))
1802 xas_atom_env%ga(ikind)%array = 0.0_dp; xas_atom_env%gr(ikind)%array = 0.0_dp
1804 ALLOCATE (xas_atom_env%dga1(ikind)%array(na, nso_proc, 3))
1805 ALLOCATE (xas_atom_env%dgr1(ikind)%array(nr, nso_proc))
1806 ALLOCATE (xas_atom_env%dga2(ikind)%array(na, nso_proc, 3))
1807 ALLOCATE (xas_atom_env%dgr2(ikind)%array(nr, nso_proc))
1808 xas_atom_env%dga1(ikind)%array = 0.0_dp; xas_atom_env%dgr1(ikind)%array = 0.0_dp
1809 xas_atom_env%dga2(ikind)%array = 0.0_dp; xas_atom_env%dgr2(ikind)%array = 0.0_dp
1812 ga => xas_atom_env%ga(ikind)%array
1813 gr => xas_atom_env%gr(ikind)%array
1814 dga1 => xas_atom_env%dga1(ikind)%array
1815 dga2 => xas_atom_env%dga2(ikind)%array
1816 dgr1 => xas_atom_env%dgr1(ikind)%array
1817 dgr2 => xas_atom_env%dgr2(ikind)%array
1821 DO iso_proc = 1, nso_proc
1822 iset = so_proc_info(1, iso_proc)
1823 ipgf = so_proc_info(2, iso_proc)
1824 iso = so_proc_info(3, iso_proc)
1832 rexp(1:nr) = exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
1833 gr(1:nr, iso_proc) = grid_atom%rad(1:nr)**l*rexp(1:nr)
1836 ga(1:na, iso_proc) = slm(1:na, iso)
1845 dgr1(1:nr, iso_proc) = grid_atom%rad(1:nr)**(l - 1)*rexp(1:nr)
1846 dgr2(1:nr, iso_proc) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1)*rexp(1:nr)
1850 dga1(1:na, iso_proc, dir) = dslm_dxyz(dir, 1:na, iso)
1851 dga2(1:na, iso_proc, dir) = harmonics%a(dir, 1:na)*slm(1:na, iso)
1860 CALL timestop(handle)
1862 END SUBROUTINE precompute_so_dso
1876 TYPE(cp_2d_r_p_type),
DIMENSION(:, :),
POINTER :: int_fxc
1877 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
1878 TYPE(xas_tdp_control_type),
POINTER :: xas_tdp_control
1879 TYPE(qs_environment_type),
POINTER :: qs_env
1881 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_fxc_atoms'
1883 INTEGER :: batch_size, dir, er, ex_bo(2), handle, i, iatom, ibatch, iex, ikind, inb, ipe, &
1884 mepos, na, natom, nb, nb_bo(2), nbatch, nbk, nex_atom, nr, num_pe, sr
1885 INTEGER,
DIMENSION(2, 3) :: bounds
1886 INTEGER,
DIMENSION(:),
POINTER :: exat_neighbors
1887 LOGICAL :: do_gga, do_sc, do_sf
1888 TYPE(batch_info_type) :: batch_info
1889 TYPE(cp_1d_r_p_type),
DIMENSION(:, :),
POINTER :: ri_dcoeff
1890 TYPE(dft_control_type),
POINTER :: dft_control
1891 TYPE(mp_para_env_type),
POINTER :: para_env
1892 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1893 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1894 TYPE(section_vals_type),
POINTER :: input, xc_functionals
1895 TYPE(xc_derivative_set_type) :: deriv_set
1896 TYPE(xc_rho_cflags_type) :: needs
1897 TYPE(xc_rho_set_type) :: rho_set
1899 NULLIFY (particle_set, qs_kind_set, dft_control, para_env, exat_neighbors)
1900 NULLIFY (input, xc_functionals)
1902 CALL timeset(routinen, handle)
1905 CALL get_qs_env(qs_env, particle_set=particle_set, qs_kind_set=qs_kind_set, natom=natom, &
1906 dft_control=dft_control, input=input, para_env=para_env)
1907 ALLOCATE (int_fxc(natom, 4))
1910 NULLIFY (int_fxc(iatom, i)%array)
1913 nex_atom =
SIZE(xas_atom_env%excited_atoms)
1915 do_sc = xas_tdp_control%do_spin_cons .OR. xas_tdp_control%do_singlet .OR. xas_tdp_control%do_triplet
1916 do_sf = xas_tdp_control%do_spin_flip
1922 do_gga = needs%drho_spin
1927 num_pe = para_env%num_pe
1928 mepos = para_env%mepos
1934 ibatch = mepos/batch_size
1936 ipe =
modulo(mepos, batch_size)
1938 batch_info%batch_size = batch_size
1939 batch_info%nbatch = nbatch
1940 batch_info%ibatch = ibatch
1941 batch_info%ipe = ipe
1944 CALL batch_info%para_env%from_split(para_env, ibatch)
1948 CALL precompute_so_dso(do_gga, batch_info, xas_atom_env, qs_env)
1951 ex_bo =
get_limit(nex_atom, nbatch, ibatch)
1954 DO iex = ex_bo(1), ex_bo(2)
1956 iatom = xas_atom_env%excited_atoms(iex)
1957 ikind = particle_set(iatom)%atomic_kind%kind_number
1958 exat_neighbors => xas_atom_env%exat_neighbors(iex)%array
1959 ri_dcoeff => xas_atom_env%ri_dcoeff(:, :, iex)
1962 na = xas_atom_env%grid_atom_set(ikind)%grid_atom%ng_sphere
1963 nr = xas_atom_env%grid_atom_set(ikind)%grid_atom%nr
1966 bounds(1:2, 1:3) = 1
1971 rho_cutoff=dft_control%qs_control%eps_rho_rspace, &
1972 drho_cutoff=dft_control%qs_control%eps_rho_rspace)
1979 CALL put_density_on_atomic_grid(rho_set, ri_dcoeff(iatom, :), ikind, &
1980 do_gga, batch_info, xas_atom_env, qs_env)
1985 sr = nb_bo(1); er = nb_bo(2)
1986 DO inb = 1,
SIZE(exat_neighbors)
1988 nb = exat_neighbors(inb)
1989 nbk = particle_set(nb)%atomic_kind%kind_number
1990 CALL put_density_on_other_grid(rho_set, ri_dcoeff(nb, :), nb, nbk, iatom, &
1991 ikind, sr, er, do_gga, xas_atom_env, qs_env)
1996 CALL batch_info%para_env%sum(rho_set%rhoa)
1997 CALL batch_info%para_env%sum(rho_set%rhob)
2000 CALL batch_info%para_env%sum(rho_set%drhoa(dir)%array)
2001 CALL batch_info%para_env%sum(rho_set%drhob(dir)%array)
2006 IF (do_gga)
CALL compute_norm_drho(rho_set, ikind, xas_atom_env)
2009 CALL xc_functionals_eval(xc_functionals, lsd=.true., rho_set=rho_set, deriv_set=deriv_set, &
2014 CALL integrate_sc_fxc(int_fxc, iatom, ikind, deriv_set, xas_atom_env, qs_env)
2019 CALL integrate_sf_fxc(int_fxc, iatom, ikind, rho_set, deriv_set, xas_atom_env, qs_env)
2023 IF (do_gga .AND. do_sc)
THEN
2024 CALL integrate_gga_fxc(int_fxc, iatom, ikind, batch_info, rho_set, deriv_set, &
2025 xas_atom_env, qs_env)
2036 CALL para_env%sync()
2038 CALL timestop(handle)
2054 SUBROUTINE integrate_gga_fxc(int_fxc, iatom, ikind, batch_info, rho_set, deriv_set, &
2055 xas_atom_env, qs_env)
2057 TYPE(cp_2d_r_p_type),
DIMENSION(:, :),
POINTER :: int_fxc
2058 INTEGER,
INTENT(IN) :: iatom, ikind
2059 TYPE(batch_info_type) :: batch_info
2060 TYPE(xc_rho_set_type),
INTENT(IN) :: rho_set
2061 TYPE(xc_derivative_set_type),
INTENT(INOUT) :: deriv_set
2062 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
2063 TYPE(qs_environment_type),
POINTER :: qs_env
2065 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_gga_fxc'
2067 INTEGER :: bo(2), dir, handle, i, ia, ir, jpgf, &
2068 jset, jso, l, maxso, na, nr, nset, &
2069 nsgf, nsoi, nsotot, startj, ub
2070 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2071 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: rexp
2072 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: int_sgf, res, so, work
2073 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dso
2074 REAL(
dp),
DIMENSION(:, :),
POINTER :: dgr1, dgr2, ga, gr, ri_sphi_so, weight, &
2076 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dga1, dga2
2077 TYPE(cp_2d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: int_so, vxc
2078 TYPE(cp_3d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: vxg
2079 TYPE(grid_atom_type),
POINTER :: grid_atom
2080 TYPE(gto_basis_set_type),
POINTER :: ri_basis
2081 TYPE(harmonics_atom_type),
POINTER :: harmonics
2082 TYPE(mp_para_env_type),
POINTER :: para_env
2083 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2085 NULLIFY (grid_atom, ri_basis, qs_kind_set, ga, gr, dgr1, dgr2, lmax, lmin, npgf)
2086 NULLIFY (weight, ri_sphi_so, dga1, dga2, para_env, harmonics, zet)
2098 CALL timeset(routinen, handle)
2102 IF (xas_atom_env%nspins == 2) ub = 3
2105 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
2106 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
2107 na = grid_atom%ng_sphere
2109 weight => grid_atom%weight
2112 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, para_env=para_env)
2113 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
2115 CALL get_gto_basis_set(gto_basis_set=ri_basis, lmax=lmax, lmin=lmin, nsgf=nsgf, &
2116 maxso=maxso, npgf=npgf, nset=nset, zet=zet)
2120 ga => xas_atom_env%ga(ikind)%array
2121 gr => xas_atom_env%gr(ikind)%array
2122 dgr1 => xas_atom_env%dgr1(ikind)%array
2123 dgr2 => xas_atom_env%dgr2(ikind)%array
2124 dga1 => xas_atom_env%dga1(ikind)%array
2125 dga2 => xas_atom_env%dga2(ikind)%array
2136 ALLOCATE (so(na, nr))
2137 ALLOCATE (dso(na, nr, 3))
2142 ALLOCATE (int_so(ub))
2144 ALLOCATE (vxc(i)%array(na, nr))
2145 ALLOCATE (vxg(i)%array(na, nr, 3))
2146 ALLOCATE (int_so(i)%array(nsotot, nsotot))
2147 vxc(i)%array = 0.0_dp; vxg(i)%array = 0.0_dp; int_so(i)%array = 0.0_dp
2151 DO jpgf = 1, npgf(jset)
2152 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
2153 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
2159 rexp(1:nr) = exp(-zet(jpgf, jset)*grid_atom%rad2(1:nr))
2167 so(ia, ir) = grid_atom%rad(ir)**l*rexp(ir)*harmonics%slm(ia, jso)
2170 dso(ia, ir, :) = 0.0_dp
2172 dso(ia, ir, dir) = dso(ia, ir, dir) &
2173 + grid_atom%rad(ir)**(l - 1)*rexp(ir)*harmonics%dslm_dxyz(dir, ia, jso) &
2174 - 2.0_dp*zet(jpgf, jset)*grid_atom%rad(ir)**(l + 1)*rexp(ir) &
2175 *harmonics%a(dir, ia)*harmonics%slm(ia, jso)
2182 CALL get_vxc_vxg(vxc, vxg, so, dso, na, nr, rho_set, deriv_set, weight)
2186 nsoi = batch_info%nso_proc(ikind)
2187 bo = batch_info%so_bo(:, ikind)
2188 ALLOCATE (res(nsoi, nsoi), work(na, nsoi))
2189 res = 0.0_dp; work = 0.0_dp
2194 CALL dgemm(
'N',
'N', na, nsoi, nr, 1.0_dp, vxc(i)%array(:, :), na, &
2195 gr(:, 1:nsoi), nr, 0.0_dp, work, na)
2196 CALL dgemm(
'T',
'N', nsoi, nsoi, na, 1.0_dp, work, na, &
2197 ga(:, 1:nsoi), na, 0.0_dp, res, nsoi)
2198 int_so(i)%array(bo(1):bo(2), startj + jso) =
get_diag(res)
2203 CALL dgemm(
'N',
'N', na, nsoi, nr, 1.0_dp, vxg(i)%array(:, :, dir), na, &
2204 dgr1(:, 1:nsoi), nr, 0.0_dp, work, na)
2205 CALL dgemm(
'T',
'N', nsoi, nsoi, na, 1.0_dp, work, na, &
2206 dga1(:, 1:nsoi, dir), na, 0.0_dp, res, nsoi)
2207 CALL daxpy(nsoi, 1.0_dp,
get_diag(res), 1, int_so(i)%array(bo(1):bo(2), startj + jso), 1)
2209 CALL dgemm(
'N',
'N', na, nsoi, nr, 1.0_dp, vxg(i)%array(:, :, dir), na, &
2210 dgr2(:, 1:nsoi), nr, 0.0_dp, work, na)
2211 CALL dgemm(
'T',
'N', nsoi, nsoi, na, 1.0_dp, work, na, &
2212 dga2(:, 1:nsoi, dir), na, 0.0_dp, res, nsoi)
2213 CALL daxpy(nsoi, 1.0_dp,
get_diag(res), 1, int_so(i)%array(bo(1):bo(2), startj + jso), 1)
2218 DEALLOCATE (res, work)
2225 ri_sphi_so => xas_atom_env%ri_sphi_so(ikind)%array
2226 ALLOCATE (int_sgf(nsgf, nsgf))
2228 CALL batch_info%para_env%sum(int_so(i)%array)
2229 CALL contract_so2sgf(int_sgf, int_so(i)%array, ri_basis, ri_sphi_so)
2230 CALL daxpy(nsgf*nsgf, 1.0_dp, int_sgf, 1, int_fxc(iatom, i)%array, 1)
2235 DEALLOCATE (vxc(i)%array)
2236 DEALLOCATE (vxg(i)%array)
2237 DEALLOCATE (int_so(i)%array)
2239 DEALLOCATE (vxc, vxg, int_so)
2241 CALL timestop(handle)
2243 END SUBROUTINE integrate_gga_fxc
2262 SUBROUTINE get_vxc_vxg(vxc, vxg, so, dso, na, nr, rho_set, deriv_set, weight)
2264 TYPE(cp_2d_r_p_type),
DIMENSION(:) :: vxc
2265 TYPE(cp_3d_r_p_type),
DIMENSION(:) :: vxg
2266 REAL(
dp),
DIMENSION(:, :) :: so
2267 REAL(
dp),
DIMENSION(:, :, :) :: dso
2268 INTEGER,
INTENT(IN) :: na, nr
2269 TYPE(xc_rho_set_type),
INTENT(IN) :: rho_set
2270 TYPE(xc_derivative_set_type),
INTENT(IN) :: deriv_set
2271 REAL(
dp),
DIMENSION(:, :),
POINTER :: weight
2273 CHARACTER(len=*),
PARAMETER :: routinen =
'get_vxc_vxg'
2275 INTEGER :: dir, handle, i, ia, ir, ub
2276 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dot_proda, dot_prodb, tmp
2277 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: d1e, d2e, norm_drhoa, norm_drhob
2278 TYPE(xc_derivative_type),
POINTER :: deriv
2280 NULLIFY (norm_drhoa, norm_drhob, d2e, d1e, deriv)
2282 CALL timeset(routinen, handle)
2291 norm_drhoa => rho_set%norm_drhoa
2292 norm_drhob => rho_set%norm_drhob
2296 vxc(i)%array = 0.0_dp
2297 vxg(i)%array = 0.0_dp
2300 ALLOCATE (tmp(na, nr), dot_proda(na, nr), dot_prodb(na, nr))
2301 dot_proda = 0.0_dp; dot_prodb = 0.0_dp
2317 dot_proda(ia, ir) = dot_proda(ia, ir) + rho_set%drhoa(dir)%array(ia, ir, 1)*dso(ia, ir, dir)
2318 dot_prodb(ia, ir) = dot_prodb(ia, ir) + rho_set%drhob(dir)%array(ia, ir, 1)*dso(ia, ir, dir)
2328 IF (
ASSOCIATED(deriv))
THEN
2333 vxc(1)%array(ia, ir) = d2e(ia, ir, 1)*dot_proda(ia, ir)
2342 IF (
ASSOCIATED(deriv))
THEN
2347 vxc(1)%array(ia, ir) = vxc(1)%array(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2357 vxc(1)%array(ia, ir) = vxc(1)%array(ia, ir)*weight(ia, ir)
2364 IF (
ASSOCIATED(deriv))
THEN
2369 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2377 IF (
ASSOCIATED(deriv))
THEN
2382 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2390 IF (
ASSOCIATED(deriv))
THEN
2395 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2403 IF (
ASSOCIATED(deriv))
THEN
2408 tmp(ia, ir) = tmp(ia, ir) - d1e(ia, ir, 1)*dot_proda(ia, ir) &
2409 /max(norm_drhoa(ia, ir, 1), rho_set%drho_cutoff)**2
2420 vxg(1)%array(ia, ir, dir) = tmp(ia, ir)*rho_set%drhoa(dir)%array(ia, ir, 1)
2428 IF (
ASSOCIATED(deriv))
THEN
2433 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2441 IF (
ASSOCIATED(deriv))
THEN
2446 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2454 IF (
ASSOCIATED(deriv))
THEN
2459 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2470 vxg(1)%array(ia, ir, dir) = vxg(1)%array(ia, ir, dir) + tmp(ia, ir)*rho_set%drhob(dir)%array(ia, ir, 1)
2478 IF (
ASSOCIATED(deriv))
THEN
2484 vxg(1)%array(ia, ir, dir) = vxg(1)%array(ia, ir, dir) + d1e(ia, ir, 1)*dso(ia, ir, dir)
2496 vxg(1)%array(ia, ir, dir) = vxg(1)%array(ia, ir, dir)*weight(ia, ir)
2506 IF (
ASSOCIATED(deriv))
THEN
2511 vxc(2)%array(ia, ir) = d2e(ia, ir, 1)*dot_prodb(ia, ir)
2519 IF (
ASSOCIATED(deriv))
THEN
2524 vxc(2)%array(ia, ir) = vxc(2)%array(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2534 vxc(2)%array(ia, ir) = vxc(2)%array(ia, ir)*weight(ia, ir)
2541 IF (
ASSOCIATED(deriv))
THEN
2546 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2554 IF (
ASSOCIATED(deriv))
THEN
2559 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2567 IF (
ASSOCIATED(deriv))
THEN
2572 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2583 vxg(2)%array(ia, ir, dir) = tmp(ia, ir)*rho_set%drhoa(dir)%array(ia, ir, 1)
2591 IF (
ASSOCIATED(deriv))
THEN
2596 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2604 IF (
ASSOCIATED(deriv))
THEN
2609 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2617 IF (
ASSOCIATED(deriv))
THEN
2622 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2633 vxg(2)%array(ia, ir, dir) = vxg(2)%array(ia, ir, dir) + tmp(ia, ir)*rho_set%drhob(dir)%array(ia, ir, 1)
2641 IF (
ASSOCIATED(deriv))
THEN
2647 vxg(2)%array(ia, ir, dir) = vxg(2)%array(ia, ir, dir) + d1e(ia, ir, 1)*dso(ia, ir, dir)
2659 vxg(2)%array(ia, ir, dir) = vxg(2)%array(ia, ir, dir)*weight(ia, ir)
2670 IF (
ASSOCIATED(deriv))
THEN
2675 vxc(3)%array(ia, ir) = d2e(ia, ir, 1)*dot_prodb(ia, ir)
2683 IF (
ASSOCIATED(deriv))
THEN
2688 vxc(3)%array(ia, ir) = vxc(3)%array(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2698 vxc(3)%array(ia, ir) = vxc(3)%array(ia, ir)*weight(ia, ir)
2705 IF (
ASSOCIATED(deriv))
THEN
2710 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2718 IF (
ASSOCIATED(deriv))
THEN
2723 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2731 IF (
ASSOCIATED(deriv))
THEN
2736 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2744 IF (
ASSOCIATED(deriv))
THEN
2749 tmp(ia, ir) = tmp(ia, ir) - d1e(ia, ir, 1)*dot_prodb(ia, ir) &
2750 /max(norm_drhob(ia, ir, 1), rho_set%drho_cutoff)**2
2761 vxg(3)%array(ia, ir, dir) = tmp(ia, ir)*rho_set%drhob(dir)%array(ia, ir, 1)
2769 IF (
ASSOCIATED(deriv))
THEN
2774 tmp(ia, ir) = d2e(ia, ir, 1)*so(ia, ir)
2782 IF (
ASSOCIATED(deriv))
THEN
2787 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_prodb(ia, ir)
2795 IF (
ASSOCIATED(deriv))
THEN
2800 tmp(ia, ir) = tmp(ia, ir) + d2e(ia, ir, 1)*dot_proda(ia, ir)
2811 vxg(3)%array(ia, ir, dir) = vxg(3)%array(ia, ir, dir) + &
2812 tmp(ia, ir)*rho_set%drhoa(dir)%array(ia, ir, 1)
2820 IF (
ASSOCIATED(deriv))
THEN
2826 vxg(3)%array(ia, ir, dir) = vxg(3)%array(ia, ir, dir) + d1e(ia, ir, 1)*dso(ia, ir, dir)
2838 vxg(3)%array(ia, ir, dir) = vxg(3)%array(ia, ir, dir)*weight(ia, ir)
2848 CALL timestop(handle)
2850 END SUBROUTINE get_vxc_vxg
2861 SUBROUTINE integrate_sc_fxc(int_fxc, iatom, ikind, deriv_set, xas_atom_env, qs_env)
2863 TYPE(cp_2d_r_p_type),
DIMENSION(:, :),
POINTER :: int_fxc
2864 INTEGER,
INTENT(IN) :: iatom, ikind
2865 TYPE(xc_derivative_set_type),
INTENT(IN) :: deriv_set
2866 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
2867 TYPE(qs_environment_type),
POINTER :: qs_env
2869 INTEGER :: i, maxso, na, nr, nset, nsotot, nspins, &
2871 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fxc, int_so
2872 REAL(
dp),
DIMENSION(:, :),
POINTER :: ri_sphi_so
2873 TYPE(cp_3d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: d2e
2874 TYPE(dft_control_type),
POINTER :: dft_control
2875 TYPE(grid_atom_type),
POINTER :: grid_atom
2876 TYPE(gto_basis_set_type),
POINTER :: ri_basis
2877 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2878 TYPE(xc_derivative_type),
POINTER :: deriv
2880 NULLIFY (grid_atom, deriv, ri_basis, ri_sphi_so, qs_kind_set, dft_control)
2883 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
2884 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
2885 na = grid_atom%ng_sphere
2887 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
2890 ri_sphi_so => xas_atom_env%ri_sphi_so(ikind)%array
2891 nspins = dft_control%nspins
2903 ALLOCATE (fxc(na, nr))
2904 ALLOCATE (int_so(nsotot, nsotot))
2908 ub = 2;
IF (nspins == 2) ub = 3
2912 fxc(:, :) = d2e(i)%array(:, :, 1)*grid_atom%weight(:, :)
2913 CALL integrate_so_prod(int_so, fxc, ikind, xas_atom_env, qs_env)
2916 ALLOCATE (int_fxc(iatom, i)%array(ri_nsgf, ri_nsgf))
2917 int_fxc(iatom, i)%array = 0.0_dp
2918 CALL contract_so2sgf(int_fxc(iatom, i)%array, int_so, ri_basis, ri_sphi_so)
2922 END SUBROUTINE integrate_sc_fxc
2935 SUBROUTINE integrate_sf_fxc(int_fxc, iatom, ikind, rho_set, deriv_set, xas_atom_env, qs_env)
2937 TYPE(cp_2d_r_p_type),
DIMENSION(:, :),
POINTER :: int_fxc
2938 INTEGER,
INTENT(IN) :: iatom, ikind
2939 TYPE(xc_rho_set_type),
INTENT(IN) :: rho_set
2940 TYPE(xc_derivative_set_type),
INTENT(IN) :: deriv_set
2941 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
2942 TYPE(qs_environment_type),
POINTER :: qs_env
2944 INTEGER :: ia, ir, maxso, na, nr, nset, nsotot, &
2946 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fxc, int_so
2947 REAL(
dp),
DIMENSION(:, :),
POINTER :: ri_sphi_so
2948 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rhoa, rhob
2949 TYPE(cp_3d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: d1e, d2e
2950 TYPE(dft_control_type),
POINTER :: dft_control
2951 TYPE(grid_atom_type),
POINTER :: grid_atom
2952 TYPE(gto_basis_set_type),
POINTER :: ri_basis
2953 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2954 TYPE(xc_derivative_type),
POINTER :: deriv
2956 NULLIFY (grid_atom, deriv, ri_basis, ri_sphi_so, qs_kind_set, rhoa, rhob, dft_control)
2959 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
2960 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
2961 na = grid_atom%ng_sphere
2963 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
2966 ri_sphi_so => xas_atom_env%ri_sphi_so(ikind)%array
2967 rhoa => rho_set%rhoa
2968 rhob => rho_set%rhob
2986 ALLOCATE (fxc(na, nr))
2995 IF (abs(rhoa(ia, ir, 1) - rhob(ia, ir, 1)) > dft_control%qs_control%eps_rho_rspace)
THEN
2996 fxc(ia, ir) = grid_atom%weight(ia, ir)/(rhoa(ia, ir, 1) - rhob(ia, ir, 1)) &
2997 *(d1e(1)%array(ia, ir, 1) - d1e(2)%array(ia, ir, 1))
2999 fxc(ia, ir) = 0.5_dp*grid_atom%weight(ia, ir)* &
3000 (d2e(1)%array(ia, ir, 1) + d2e(3)%array(ia, ir, 1) - 2._dp*d2e(2)%array(ia, ir, 1))
3008 ALLOCATE (int_so(nsotot, nsotot))
3010 CALL integrate_so_prod(int_so, fxc, ikind, xas_atom_env, qs_env)
3013 ALLOCATE (int_fxc(iatom, 4)%array(ri_nsgf, ri_nsgf))
3014 int_fxc(iatom, 4)%array = 0.0_dp
3015 CALL contract_so2sgf(int_fxc(iatom, 4)%array, int_so, ri_basis, ri_sphi_so)
3017 END SUBROUTINE integrate_sf_fxc
3026 SUBROUTINE contract_so2sgf(int_sgf, int_so, basis, sphi_so)
3028 REAL(
dp),
DIMENSION(:, :) :: int_sgf, int_so
3029 TYPE(gto_basis_set_type),
POINTER :: basis
3030 REAL(
dp),
DIMENSION(:, :) :: sphi_so
3032 INTEGER :: iset, jset, maxso, nset, nsoi, nsoj, &
3033 sgfi, sgfj, starti, startj
3034 INTEGER,
DIMENSION(:),
POINTER :: lmax, npgf, nsgf_set
3035 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf
3037 NULLIFY (nsgf_set, npgf, lmax, first_sgf)
3039 CALL get_gto_basis_set(basis, nset=nset, maxso=maxso, nsgf_set=nsgf_set, first_sgf=first_sgf, &
3040 npgf=npgf, lmax=lmax)
3043 starti = (iset - 1)*maxso + 1
3044 nsoi = npgf(iset)*
nsoset(lmax(iset))
3045 sgfi = first_sgf(1, iset)
3048 startj = (jset - 1)*maxso + 1
3049 nsoj = npgf(jset)*
nsoset(lmax(jset))
3050 sgfj = first_sgf(1, jset)
3052 CALL ab_contract(int_sgf(sgfi:sgfi + nsgf_set(iset) - 1, sgfj:sgfj + nsgf_set(jset) - 1), &
3053 int_so(starti:starti + nsoi - 1, startj:startj + nsoj - 1), &
3054 sphi_so(:, sgfi:), sphi_so(:, sgfj:), nsoi, nsoj, &
3055 nsgf_set(iset), nsgf_set(jset))
3059 END SUBROUTINE contract_so2sgf
3073 SUBROUTINE integrate_so_prod(intso, fxc, ikind, xas_atom_env, qs_env)
3075 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: intso
3076 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: fxc
3077 INTEGER,
INTENT(IN) :: ikind
3078 TYPE(xas_atom_env_type),
POINTER :: xas_atom_env
3079 TYPE(qs_environment_type),
POINTER :: qs_env
3081 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_so_prod'
3083 INTEGER :: handle, ia, ic, icg, ipgf1, ipgf2, iset1, iset2, iso, iso1, iso2, l, ld, lmax12, &
3084 lmin12, m1, m2, max_iso_not0, max_iso_not0_local, max_s_harm, maxl, maxso, n1, n2, na, &
3085 ngau1, ngau2, nngau1, nr, nset, size1
3086 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list
3087 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list
3088 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
3089 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
3090 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: gfxcg, gg, matso
3091 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
3092 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
3093 TYPE(grid_atom_type),
POINTER :: grid_atom
3094 TYPE(gto_basis_set_type),
POINTER :: ri_basis
3095 TYPE(harmonics_atom_type),
POINTER :: harmonics
3096 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3098 CALL timeset(routinen, handle)
3100 NULLIFY (grid_atom, harmonics, ri_basis, qs_kind_set, lmax, lmin, npgf, zet, my_cg)
3103 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
3104 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis, basis_type=
"RI_XAS")
3105 grid_atom => xas_atom_env%grid_atom_set(ikind)%grid_atom
3106 harmonics => xas_atom_env%harmonics_atom_set(ikind)%harmonics_atom
3108 CALL get_gto_basis_set(ri_basis, lmax=lmax, lmin=lmin, maxso=maxso, maxl=maxl, npgf=npgf, &
3111 na = grid_atom%ng_sphere
3113 my_cg => harmonics%my_CG
3114 max_iso_not0 = harmonics%max_iso_not0
3115 max_s_harm = harmonics%max_s_harm
3116 cpassert(2*maxl .LE.
indso(1, max_iso_not0))
3118 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl))
3119 ALLOCATE (gfxcg(na, 0:2*maxl))
3121 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm))
3131 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
3132 max_s_harm, lmax(iset1) + lmax(iset2), cg_list, cg_n_list, &
3134 cpassert(max_iso_not0_local .LE. max_iso_not0)
3137 DO ipgf1 = 1, npgf(iset1)
3138 ngau1 = n1*(ipgf1 - 1) + m1
3140 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
3142 g1(:) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
3143 DO ipgf2 = 1, npgf(iset2)
3144 ngau2 = n2*(ipgf2 - 1) + m2
3146 g2(:) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
3147 lmin12 = lmin(iset1) + lmin(iset2)
3148 lmax12 = lmax(iset1) + lmax(iset2)
3152 IF (lmin12 == 0)
THEN
3153 gg(:, lmin12) = g1(:)*g2(:)
3155 gg(:, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(:)*g2(:)
3158 DO l = lmin12 + 1, lmax12
3159 gg(:, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
3163 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, fxc(1:na, 1:nr), na, gg(:, 0:lmax12), &
3164 nr, 0.0_dp, gfxcg(1:na, 0:lmax12), na)
3168 DO iso = 1, max_iso_not0_local
3169 DO icg = 1, cg_n_list(iso)
3170 iso1 = cg_list(1, icg, iso)
3171 iso2 = cg_list(2, icg, iso)
3175 matso(iso1, iso2) = matso(iso1, iso2) + gfxcg(ia, l)* &
3176 my_cg(iso1, iso2, iso)*harmonics%slm(ia, iso)
3182 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
3183 iso1 =
nsoset(lmin(iset1) - 1) + 1
3185 CALL daxpy(size1, 1.0_dp, matso(iso1:, ic), 1, intso(nngau1 + 1:, iso2), 1)
3195 CALL timestop(handle)
3197 END SUBROUTINE integrate_so_prod
3208 SUBROUTINE integrate_so_dxdy_prod(intso, V, ikind, qs_env, soc_atom_env)
3210 REAL(
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: intso
3211 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: v
3212 INTEGER,
INTENT(IN) :: ikind
3213 TYPE(qs_environment_type),
POINTER :: qs_env
3214 TYPE(soc_atom_env_type),
OPTIONAL,
POINTER :: soc_atom_env
3216 INTEGER :: i, ipgf, iset, iso, j, jpgf, jset, jso, &
3217 k, l, maxso, na, nr, nset, starti, &
3219 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
3220 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fga, fgr, r1, r2, work
3221 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: a1, a2
3222 REAL(
dp),
DIMENSION(:, :),
POINTER :: slm, zet
3223 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dslm_dxyz
3224 TYPE(grid_atom_type),
POINTER :: grid_atom
3225 TYPE(gto_basis_set_type),
POINTER :: basis
3226 TYPE(harmonics_atom_type),
POINTER :: harmonics
3227 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3229 NULLIFY (grid_atom, harmonics, basis, qs_kind_set, dslm_dxyz, slm, lmin, lmax, npgf, zet)
3231 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
3232 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=
"ORB")
3233 IF (
PRESENT(soc_atom_env))
THEN
3234 grid_atom => soc_atom_env%grid_atom_set(ikind)%grid_atom
3235 harmonics => soc_atom_env%harmonics_atom_set(ikind)%harmonics_atom
3237 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=
"ORB", harmonics=harmonics, &
3238 grid_atom=grid_atom)
3241 na = grid_atom%ng_sphere
3244 slm => harmonics%slm
3245 dslm_dxyz => harmonics%dslm_dxyz
3249 maxso=maxso, npgf=npgf, nset=nset, zet=zet)
3255 ALLOCATE (a1(na, nset*maxso, 3), a2(na, nset*maxso, 3))
3256 ALLOCATE (r1(nr, nset*maxso), r2(nr, nset*maxso))
3257 a1 = 0.0_dp; a2 = 0.0_dp
3258 r1 = 0.0_dp; r2 = 0.0_dp
3261 DO ipgf = 1, npgf(iset)
3262 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
3263 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
3270 r1(1:nr, starti + iso) = grid_atom%rad(1:nr)**(l - 1)*exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
3273 r2(1:nr, starti + iso) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1) &
3274 *exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
3278 a1(1:na, starti + iso, i) = dslm_dxyz(i, 1:na, iso)
3281 a2(1:na, starti + iso, i) = harmonics%a(i, 1:na)*slm(1:na, iso)
3290 ALLOCATE (fga(na, 1))
3291 ALLOCATE (fgr(nr, 1))
3292 ALLOCATE (work(na, 1))
3293 fga = 0.0_dp; fgr = 0.0_dp; work = 0.0_dp
3297 DO ipgf = 1, npgf(iset)
3298 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
3299 DO jpgf = 1, npgf(jset)
3300 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
3304 k = mod(i + 1, 3) + 1
3306 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
3307 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
3312 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r1(1:nr, startj + jso)
3313 fga(1:na, 1) = a1(1:na, starti + iso, j)*a1(1:na, startj + jso, k)
3315 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3316 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 0.0_dp, &
3317 intso(starti + iso:, startj + jso, i), 1)
3320 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r2(1:nr, startj + jso)
3321 fga(1:na, 1) = a1(1:na, starti + iso, j)*a2(1:na, startj + jso, k)
3323 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3324 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
3325 intso(starti + iso:, startj + jso, i), 1)
3328 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r1(1:nr, startj + jso)
3329 fga(1:na, 1) = a2(1:na, starti + iso, j)*a1(1:na, startj + jso, k)
3331 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3332 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
3333 intso(starti + iso:, startj + jso, i), 1)
3336 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r2(1:nr, startj + jso)
3337 fga(1:na, 1) = a2(1:na, starti + iso, j)*a2(1:na, startj + jso, k)
3339 CALL dgemm(
'N',
'N', na, 1, nr, 1.0_dp, v, na, fgr, nr, 0.0_dp, work, na)
3340 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
3341 intso(starti + iso:, startj + jso, i), 1)
3353 intso(:, :, i) = intso(:, :, i) - transpose(intso(:, :, i))
3356 END SUBROUTINE integrate_so_dxdy_prod
3370 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_soc
3371 TYPE(xas_atom_env_type),
OPTIONAL,
POINTER :: xas_atom_env
3372 TYPE(qs_environment_type),
POINTER :: qs_env
3373 TYPE(soc_atom_env_type),
OPTIONAL,
POINTER :: soc_atom_env
3375 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_soc_atoms'
3377 INTEGER :: blk, handle, i, iat, ikind, ir, jat, &
3378 maxso, na, nkind, nr, nset, nsgf
3379 LOGICAL :: all_potential_present
3381 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: vr
3382 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: v
3383 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: intso
3384 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi_so
3385 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: intsgf
3386 TYPE(cp_3d_r_p_type),
DIMENSION(:),
POINTER :: int_soc
3387 TYPE(dbcsr_iterator_type) :: iter
3388 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s
3389 TYPE(grid_atom_type),
POINTER :: grid
3390 TYPE(gto_basis_set_type),
POINTER :: basis
3391 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
3392 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3395 CALL timeset(routinen, handle)
3397 NULLIFY (int_soc, basis, qs_kind_set, sphi_so, matrix_s, grid)
3398 NULLIFY (particle_set)
3401 CALL get_qs_env(qs_env, nkind=nkind, qs_kind_set=qs_kind_set, matrix_s=matrix_s, &
3402 particle_set=particle_set)
3405 CALL get_qs_kind_set(qs_kind_set, all_potential_present=all_potential_present)
3408 ALLOCATE (int_soc(nkind))
3410 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis, basis_type=
"ORB", zeff=zeff)
3411 IF (
PRESENT(soc_atom_env))
THEN
3412 grid => soc_atom_env%grid_atom_set(ikind)%grid_atom
3414 CALL get_qs_kind(qs_kind_set(ikind), grid_atom=grid)
3417 ALLOCATE (intso(nset*maxso, nset*maxso, 3))
3427 ALLOCATE (v(na, nr))
3430 CALL daxpy(na, vr(ir)/(4.0_dp*
c_light_au**2 - 2.0_dp*vr(ir)), grid%weight(:, ir), 1, &
3436 IF (
PRESENT(xas_atom_env))
THEN
3437 CALL integrate_so_dxdy_prod(intso, v, ikind, qs_env)
3439 CALL integrate_so_dxdy_prod(intso, v, ikind, qs_env, soc_atom_env)
3445 ALLOCATE (int_soc(ikind)%array(nsgf, nsgf, 3))
3446 intsgf => int_soc(ikind)%array
3447 IF (
PRESENT(xas_atom_env))
THEN
3448 sphi_so => xas_atom_env%orb_sphi_so(ikind)%array
3450 sphi_so => soc_atom_env%orb_sphi_so(ikind)%array
3455 CALL contract_so2sgf(intsgf(:, :, i), intso(:, :, i), basis, sphi_so)
3462 IF ((
PRESENT(xas_atom_env)) .OR. all_potential_present)
THEN
3464 CALL dbcsr_create(matrix_soc(i)%matrix, name=
"SOC MATRIX", template=matrix_s(1)%matrix, &
3465 matrix_type=dbcsr_type_antisymmetric)
3468 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
3469 DO WHILE (dbcsr_iterator_blocks_left(iter))
3471 CALL dbcsr_iterator_next_block(iter, row=iat, column=jat, blk=blk)
3472 IF (.NOT. iat == jat) cycle
3473 ikind = particle_set(iat)%atomic_kind%kind_number
3476 CALL dbcsr_put_block(matrix_soc(i)%matrix, iat, iat, int_soc(ikind)%array(:, :, i))
3480 CALL dbcsr_iterator_stop(iter)
3483 CALL dbcsr_create(matrix_soc(i)%matrix, name=
"SOC MATRIX", template=matrix_s(1)%matrix, &
3484 matrix_type=dbcsr_type_no_symmetry)
3485 CALL dbcsr_set(matrix_soc(i)%matrix, 0.0_dp)
3486 CALL dbcsr_copy(matrix_soc(i)%matrix, soc_atom_env%soc_pp(i, 1)%matrix)
3491 CALL dbcsr_finalize(matrix_soc(i)%matrix)
3496 DEALLOCATE (int_soc(ikind)%array)
3498 DEALLOCATE (int_soc)
3500 CALL timestop(handle)
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
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)
...
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...
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, upper_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, cholesky_triangle)
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 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_nonbond, sab_almo, sab_kp, sab_kp_nosym, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
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, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, 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_r3d_rs_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, floating, name, element_symbol, pao_basis_size, 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)
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 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...
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.
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