133#include "./base/base_uses.f90"
142 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_linres_current'
146 REAL(dp),
POINTER,
DIMENSION(:, :) :: r => null()
149 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, -1.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, &
150 0.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, -1.0_dp, 0.0_dp, 0.0_dp, &
151 0.0_dp, -1.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp], [3, 3, 3])
184 INTEGER,
INTENT(IN) :: ib
186 CHARACTER(LEN=*),
PARAMETER :: routinen =
'current_build_current'
188 CHARACTER(LEN=default_path_length) :: ext, filename, my_pos
189 INTEGER :: handle, idir, iib, iiib, ispin, istate, &
190 j, jstate, nao, natom, nmo, nspins, &
191 nstates(2), output_unit, unit_nr
192 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
193 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
194 LOGICAL :: append_cube, gapw, mpi_io
195 REAL(
dp) :: dk(3), jrho_tot_g(3, 3), &
196 jrho_tot_r(3, 3), maxocc, scale_fac
197 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ddk
198 REAL(
dp),
EXTERNAL :: ddot
201 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: p_psi1, psi1
202 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: psi0_order
203 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: psi1_d, psi1_p, psi1_rxp
207 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: density_matrix0, density_matrix_a, &
208 density_matrix_ii, density_matrix_iii
221 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
227 CALL timeset(routinen, handle)
229 NULLIFY (logger, current_section, density_matrix0, density_matrix_a, &
230 density_matrix_ii, density_matrix_iii, cell, dft_control, mos, &
231 particle_set, pw_env, auxbas_rs_desc, auxbas_pw_pool, &
232 para_env, center_list, mo_coeff, jrho1_r, jrho1_g, &
233 psi1_p, psi1_d, psi1_rxp, sab_all, qs_kind_set)
240 center_list=center_list, &
244 psi0_order=psi0_order, &
251 dft_control=dft_control, &
258 particle_set=particle_set, &
259 qs_kind_set=qs_kind_set, &
260 dbcsr_dist=dbcsr_dist)
264 gapw = dft_control%qs_control%gapw
265 nspins = dft_control%nspins
266 natom =
SIZE(particle_set, 1)
269 ALLOCATE (psi1(nspins), p_psi1(nspins))
271 CALL cp_fm_create(psi1(ispin), psi0_order(ispin)%matrix_struct)
272 CALL cp_fm_create(p_psi1(ispin), psi0_order(ispin)%matrix_struct)
284 ALLOCATE (first_sgf(natom))
285 ALLOCATE (last_sgf(natom))
287 first_sgf=first_sgf, &
289 ALLOCATE (row_blk_sizes(natom))
290 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
291 DEALLOCATE (first_sgf)
292 DEALLOCATE (last_sgf)
298 ALLOCATE (density_matrix0(ispin)%matrix)
299 CALL dbcsr_create(matrix=density_matrix0(ispin)%matrix, &
300 name=
"density_matrix0", &
301 dist=dbcsr_dist, matrix_type=dbcsr_type_no_symmetry, &
302 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
307 ALLOCATE (density_matrix_a(ispin)%matrix)
308 CALL dbcsr_copy(density_matrix_a(ispin)%matrix, density_matrix0(ispin)%matrix, &
309 name=
"density_matrix_a")
312 ALLOCATE (density_matrix_ii(ispin)%matrix)
313 CALL dbcsr_copy(density_matrix_ii(ispin)%matrix, density_matrix0(ispin)%matrix, &
314 name=
"density_matrix_ii")
317 ALLOCATE (density_matrix_iii(ispin)%matrix)
318 CALL dbcsr_copy(density_matrix_iii(ispin)%matrix, density_matrix0(ispin)%matrix, &
319 name=
"density_matrix_iii")
322 DEALLOCATE (row_blk_sizes)
335 mo_coeff => psi0_order(ispin)
338 CALL get_mo_set(mo_set=mos(ispin), maxocc=maxocc)
342 CALL dbcsr_set(density_matrix0(ispin)%matrix, 0.0_dp)
344 matrix_v=mo_coeff, matrix_g=mo_coeff, &
345 ncol=nmo, alpha=maxocc)
348 ALLOCATE (ddk(3, nmo))
353 associate(psi_a_ib => psi1(ispin), psi_buf => p_psi1(ispin))
359 DO istate = 1, current_env%nbr_center(ispin)
360 dk(1:3) = current_env%centers_set(ispin)%array(1:3, istate)
364 DO j = center_list(ispin)%array(1, istate), center_list(ispin)%array(1, istate + 1) - 1
365 jstate = center_list(ispin)%array(2, j)
366 CALL cp_fm_to_fm(psi1_p(ispin, iib), psi_a_ib, 1, jstate, jstate)
367 CALL cp_fm_to_fm(psi1_p(ispin, iiib), psi_buf, 1, jstate, jstate)
368 ddk(:, jstate) = dk(1:3)
381 IF (current_env%full)
THEN
390 CALL dbcsr_set(density_matrix_a(ispin)%matrix, 0.0_dp)
392 matrix_v=mo_coeff, matrix_g=psi_a_ib, &
393 ncol=nmo, alpha=maxocc)
397 CALL dbcsr_set(density_matrix_iii(ispin)%matrix, 0.0_dp)
399 matrix_v=mo_coeff, matrix_g=psi1_p(ispin, iiib), &
400 ncol=nmo, alpha=maxocc)
403 CALL dbcsr_set(density_matrix_ii(ispin)%matrix, 0.0_dp)
405 matrix_v=mo_coeff, matrix_g=psi1_p(ispin, iib), &
406 ncol=nmo, alpha=maxocc)
413 CALL qs_rho_get(current_env%jrho1_set(idir)%rho, rho_r=jrho1_r)
414 CALL qs_rho_get(current_env%jrho1_set(idir)%rho, rho_g=jrho1_g)
415 associate(jrho_rspace => jrho1_r(ispin), jrho_gspace => jrho1_g(ispin))
419 density_matrix_a(ispin)%matrix, &
420 density_matrix_ii(ispin)%matrix, &
421 density_matrix_iii(ispin)%matrix, &
422 ib, idir, jrho_rspace, jrho_gspace, qs_env, &
425 scale_fac = cell%deth/
twopi
426 CALL pw_scale(jrho_rspace, scale_fac)
427 CALL pw_scale(jrho_gspace, scale_fac)
433 IF (output_unit > 0)
THEN
434 WRITE (output_unit,
'(T2,2(A,E24.16))')
'Integrated j_'&
435 &//achar(idir + 119)//achar(ib + 119)//
'(r): G-space=', &
436 jrho_tot_g(idir, ib),
' R-space=', jrho_tot_r(idir, ib)
452 CALL calculate_jrho_atom_coeff(qs_env, current_env, &
456 density_matrix_iii, &
463 CALL calculate_jrho_atom_rad(qs_env, current_env, idir)
466 CALL calculate_jrho_atom(current_env, qs_env, ib, idir)
471 IF (btest(cp_print_key_should_output(logger%iter_info, current_section,&
472 &
"PRINT%CURRENT_CUBES"), cp_p_file))
THEN
473 append_cube = section_get_lval(current_section,
"PRINT%CURRENT_CUBES%APPEND")
475 IF (append_cube)
THEN
479 CALL pw_env_get(pw_env, auxbas_rs_desc=auxbas_rs_desc, &
480 auxbas_pw_pool=auxbas_pw_pool)
482 CALL auxbas_pw_pool%create_pw(wf_r)
486 CALL qs_rho_get(current_env%jrho1_set(idir)%rho, rho_r=jrho1_r)
488 CALL pw_axpy(jrho1_r(ispin), wf_r, 1.0_dp)
495 cpabort(
"GAPW needs to be finalized")
499 WRITE (ext,
'(a2,I1,a2,I1,a5)')
"iB", ib,
"_d", idir,
".cube"
500 WRITE (ext,
'(a2,a1,a2,a1,a5)')
"iB", achar(ib + 119),
"_d", achar(idir + 119),
".cube"
501 unit_nr = cp_print_key_unit_nr(logger, current_section,
"PRINT%CURRENT_CUBES", &
502 extension=trim(ext), middle_name=trim(filename), &
503 log_filename=.false., file_position=my_pos, &
506 CALL cp_pw_to_cube(wf_r, unit_nr,
"RESPONSE CURRENT DENSITY ", &
507 particles=particles, &
508 stride=section_get_ivals(current_section,
"PRINT%CURRENT_CUBES%STRIDE"), &
510 CALL cp_print_key_finished_output(unit_nr, logger, current_section,&
511 &
"PRINT%CURRENT_CUBES", mpi_io=mpi_io)
514 CALL auxbas_pw_pool%give_back_pw(wf_r)
518 IF (output_unit > 0)
THEN
519 WRITE (output_unit,
'(T2,A,E24.16)')
'CheckSum R-integrated j=', &
520 sqrt(ddot(9, jrho_tot_r(1, 1), 1, jrho_tot_r(1, 1), 1))
525 CALL cp_fm_release(psi1)
526 CALL cp_fm_release(p_psi1)
528 CALL dbcsr_deallocate_matrix_set(density_matrix0)
529 CALL dbcsr_deallocate_matrix_set(density_matrix_a)
530 CALL dbcsr_deallocate_matrix_set(density_matrix_ii)
531 CALL dbcsr_deallocate_matrix_set(density_matrix_iii)
534 CALL timestop(handle)
578 current_rs, current_gs, qs_env, current_env, soft_valid, retain_rsgrid)
580 TYPE(dbcsr_type),
POINTER :: mat_d0, mat_jp, mat_jp_rii, mat_jp_riii
581 INTEGER,
INTENT(IN) :: ib, idir
582 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: current_rs
583 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: current_gs
584 TYPE(qs_environment_type),
POINTER :: qs_env
585 TYPE(current_env_type) :: current_env
586 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid, retain_rsgrid
588 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_jrho_resp'
589 INTEGER,
PARAMETER :: max_tasks = 2000
591 CHARACTER(LEN=default_string_length) :: basis_type
592 INTEGER :: adbmdab_func, bcol, brow, cindex, curr_tasks, handle, i, iatom, iatom_old, idir2, &
593 igrid_level, iib, iiib, ikind, ikind_old, ipgf, iset, iset_old, itask, ithread, jatom, &
594 jatom_old, jkind, jkind_old, jpgf, jset, jset_old, maxco, maxpgf, maxset, maxsgf, &
595 maxsgf_set, na1, na2, natom, nb1, nb2, ncoa, ncob, nimages, nkind, nseta, nsetb, ntasks, &
597 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
599 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
600 LOGICAL :: atom_pair_changed, den_found, &
601 den_found_a, distributed_rs_grids, &
602 do_igaim, my_retain_rsgrid, my_soft
603 REAL(dp),
DIMENSION(:, :, :),
POINTER :: my_current, my_gauge, my_rho
604 REAL(kind=dp) :: eps_rho_rspace, f, kind_radius_a, &
605 kind_radius_b, lxo2, lyo2, lzo2, &
606 prefactor, radius, scale, scale2, zetp
607 REAL(kind=dp),
DIMENSION(3) :: ra, rab, rb, rp
608 REAL(kind=dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
609 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: jp_block_a, jp_block_b, jp_block_c, jp_block_d, &
610 jpab_a, jpab_b, jpab_c, jpab_d, rpgfa, rpgfb, sphi_a, sphi_b, work, zeta, zetb
611 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: jpabt_a, jpabt_b, jpabt_c, jpabt_d, workt
612 TYPE(atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
613 TYPE(cell_type),
POINTER :: cell
614 TYPE(cube_info_type),
DIMENSION(:),
POINTER :: cube_info
615 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: deltajp_a, deltajp_b, deltajp_c, &
617 TYPE(dbcsr_type),
POINTER :: mat_a, mat_b, mat_c, mat_d
618 TYPE(dft_control_type),
POINTER :: dft_control
619 TYPE(gridlevel_info_type),
POINTER :: gridlevel_info
620 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_list
621 TYPE(gto_basis_set_type),
POINTER :: basis_set_a, basis_set_b, orb_basis_set
622 TYPE(mp_para_env_type),
POINTER :: para_env
623 TYPE(neighbor_list_iterator_p_type), &
624 DIMENSION(:),
POINTER :: nl_iterator
625 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
627 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
628 TYPE(pw_env_type),
POINTER :: pw_env
629 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
630 TYPE(qs_kind_type),
POINTER :: qs_kind
631 TYPE(realspace_grid_desc_p_type),
DIMENSION(:), &
633 TYPE(realspace_grid_type),
DIMENSION(:),
POINTER :: rs_current, rs_rho
634 TYPE(realspace_grid_type),
DIMENSION(:, :), &
636 TYPE(task_type),
DIMENSION(:),
POINTER :: tasks
638 NULLIFY (qs_kind, cell, dft_control, orb_basis_set, rs_rho, &
639 qs_kind_set, sab_orb, particle_set, rs_current, pw_env, &
640 rs_descs, para_env, set_radius_a, set_radius_b, la_max, la_min, &
641 lb_max, lb_min, npgfa, npgfb, nsgfa, nsgfb, rpgfa, rpgfb, &
642 sphi_a, sphi_b, zeta, zetb, first_sgfa, first_sgfb, tasks, &
643 workt, mat_a, mat_b, mat_c, mat_d, rs_gauge)
644 NULLIFY (deltajp_a, deltajp_b, deltajp_c, deltajp_d)
645 NULLIFY (jp_block_a, jp_block_b, jp_block_c, jp_block_d)
646 NULLIFY (jpabt_a, jpabt_b, jpabt_c, jpabt_d)
647 NULLIFY (atom_pair_send, atom_pair_recv)
649 CALL timeset(routinen, handle)
654 do_igaim = current_env%gauge == current_gauge_atom
659 IF (do_igaim) mat_d => mat_d0
661 my_retain_rsgrid = .false.
662 IF (
PRESENT(retain_rsgrid)) my_retain_rsgrid = retain_rsgrid
664 CALL get_qs_env(qs_env=qs_env, &
665 qs_kind_set=qs_kind_set, &
667 dft_control=dft_control, &
668 particle_set=particle_set, &
673 IF (do_igaim)
CALL get_current_env(current_env=current_env, rs_gauge=rs_gauge)
676 CALL set_vecp(ib, iib, iiib)
682 CALL set_vecp_rev(idir, ib, idir2)
683 scale2 = fac_vecp(idir, ib, idir2)
687 gridlevel_info => pw_env%gridlevel_info
688 cube_info => pw_env%cube_info
691 cpassert(
ASSOCIATED(sab_orb))
693 cpassert(
ASSOCIATED(pw_env))
694 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
696 distributed_rs_grids = .false.
697 DO igrid_level = 1, gridlevel_info%ngrid_levels
698 IF (.NOT. all(rs_descs(igrid_level)%rs_desc%perd == 1))
THEN
699 distributed_rs_grids = .true.
702 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
706 CALL get_qs_kind_set(qs_kind_set=qs_kind_set, &
709 maxsgf_set=maxsgf_set)
711 lxo2 = sqrt(sum(cell%hmat(:, 1)**2))/2.0_dp
712 lyo2 = sqrt(sum(cell%hmat(:, 2)**2))/2.0_dp
713 lzo2 = sqrt(sum(cell%hmat(:, 3)**2))/2.0_dp
716 IF (
PRESENT(soft_valid)) my_soft = soft_valid
718 basis_type =
"ORB_SOFT"
723 nkind =
SIZE(qs_kind_set)
725 CALL reallocate(jpabt_a, 1, maxco, 1, maxco, 0, nthread - 1)
726 CALL reallocate(jpabt_b, 1, maxco, 1, maxco, 0, nthread - 1)
727 CALL reallocate(jpabt_c, 1, maxco, 1, maxco, 0, nthread - 1)
728 CALL reallocate(jpabt_d, 1, maxco, 1, maxco, 0, nthread - 1)
729 CALL reallocate(workt, 1, maxco, 1, maxsgf_set, 0, nthread - 1)
730 CALL reallocate_tasks(tasks, max_tasks)
733 curr_tasks =
SIZE(tasks)
736 natom =
SIZE(particle_set)
741 nimages = dft_control%nimages
742 cpassert(nimages == 1)
746 qs_kind => qs_kind_set(ikind)
748 CALL get_qs_kind(qs_kind=qs_kind, basis_set=orb_basis_set)
750 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
752 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, npgf=npgfa, nset=nseta)
753 maxset = max(nseta, maxset)
754 maxpgf = max(maxval(npgfa), maxpgf)
761 ALLOCATE (deltajp_a(1), deltajp_b(1), deltajp_c(1), deltajp_d(1))
762 IF (distributed_rs_grids)
THEN
763 ALLOCATE (deltajp_a(1)%matrix, deltajp_b(1)%matrix, deltajp_c(1)%matrix)
765 ALLOCATE (deltajp_d(1)%matrix)
768 CALL dbcsr_create(deltajp_a(1)%matrix, template=mat_a, name=
'deltajp_a')
769 CALL dbcsr_create(deltajp_b(1)%matrix, template=mat_a, name=
'deltajp_b')
770 CALL dbcsr_create(deltajp_c(1)%matrix, template=mat_a, name=
'deltajp_c')
771 IF (do_igaim)
CALL dbcsr_create(deltajp_d(1)%matrix, template=mat_a, name=
'deltajp_d')
773 deltajp_a(1)%matrix => mat_a
774 deltajp_b(1)%matrix => mat_b
775 deltajp_c(1)%matrix => mat_c
776 IF (do_igaim) deltajp_d(1)%matrix => mat_d
779 ALLOCATE (basis_set_list(nkind))
781 qs_kind => qs_kind_set(ikind)
782 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set_a, basis_type=basis_type)
783 IF (
ASSOCIATED(basis_set_a))
THEN
784 basis_set_list(ikind)%gto_basis_set => basis_set_a
786 NULLIFY (basis_set_list(ikind)%gto_basis_set)
789 CALL neighbor_list_iterator_create(nl_iterator, sab_orb)
790 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
791 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, iatom=iatom, jatom=jatom, r=rab)
792 basis_set_a => basis_set_list(ikind)%gto_basis_set
793 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
794 basis_set_b => basis_set_list(jkind)%gto_basis_set
795 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
796 ra(:) = pbc(particle_set(iatom)%r, cell)
798 first_sgfa => basis_set_a%first_sgf
799 la_max => basis_set_a%lmax
800 la_min => basis_set_a%lmin
801 npgfa => basis_set_a%npgf
802 nseta = basis_set_a%nset
803 nsgfa => basis_set_a%nsgf_set
804 rpgfa => basis_set_a%pgf_radius
805 set_radius_a => basis_set_a%set_radius
806 kind_radius_a = basis_set_a%kind_radius
807 sphi_a => basis_set_a%sphi
808 zeta => basis_set_a%zet
810 first_sgfb => basis_set_b%first_sgf
811 lb_max => basis_set_b%lmax
812 lb_min => basis_set_b%lmin
813 npgfb => basis_set_b%npgf
814 nsetb = basis_set_b%nset
815 nsgfb => basis_set_b%nsgf_set
816 rpgfb => basis_set_b%pgf_radius
817 set_radius_b => basis_set_b%set_radius
818 kind_radius_b = basis_set_b%kind_radius
819 sphi_b => basis_set_b%sphi
820 zetb => basis_set_b%zet
822 IF (abs(rab(1)) > lxo2 .OR. abs(rab(2)) > lyo2 .OR. abs(rab(3)) > lzo2)
THEN
829 CALL dbcsr_get_block_p(matrix=mat_a, row=brow, col=bcol, &
830 block=jp_block_a, found=den_found_a)
831 CALL dbcsr_get_block_p(matrix=mat_b, row=brow, col=bcol, &
832 block=jp_block_b, found=den_found)
833 CALL dbcsr_get_block_p(matrix=mat_c, row=brow, col=bcol, &
834 block=jp_block_c, found=den_found)
835 IF (do_igaim)
CALL dbcsr_get_block_p(matrix=mat_d, row=brow, col=bcol, &
836 block=jp_block_d, found=den_found)
838 IF (.NOT.
ASSOCIATED(jp_block_a)) cycle
840 IF (distributed_rs_grids)
THEN
841 CALL dbcsr_put_block(deltajp_a(1)%matrix, brow, bcol, jp_block_a)
842 CALL dbcsr_put_block(deltajp_b(1)%matrix, brow, bcol, jp_block_b)
843 CALL dbcsr_put_block(deltajp_c(1)%matrix, brow, bcol, jp_block_c)
845 CALL dbcsr_put_block(deltajp_d(1)%matrix, brow, bcol, jp_block_d)
849 CALL task_list_inner_loop(tasks, ntasks, curr_tasks, rs_descs, &
850 dft_control, cube_info, gridlevel_info, cindex, &
851 iatom, jatom, rpgfa, rpgfb, zeta, zetb, kind_radius_b, &
852 set_radius_a, set_radius_b, ra, rab, &
853 la_max, la_min, lb_max, lb_min, npgfa, npgfb, nseta, nsetb)
856 CALL neighbor_list_iterator_release(nl_iterator)
858 DEALLOCATE (basis_set_list)
860 IF (distributed_rs_grids)
THEN
861 CALL dbcsr_finalize(deltajp_a(1)%matrix)
862 CALL dbcsr_finalize(deltajp_b(1)%matrix)
863 CALL dbcsr_finalize(deltajp_c(1)%matrix)
864 IF (do_igaim)
CALL dbcsr_finalize(deltajp_d(1)%matrix)
869 CALL distribute_tasks(rs_descs=rs_descs, ntasks=ntasks, natoms=natom, tasks=tasks, &
870 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
871 symmetric=.false., reorder_rs_grid_ranks=.true., &
872 skip_load_balance_distributed=.false., balance_replicated=.false.)
874 ALLOCATE (rs_current(gridlevel_info%ngrid_levels))
876 DO igrid_level = 1, gridlevel_info%ngrid_levels
879 IF (rs_descs(igrid_level)%rs_desc%distributed .AND. .NOT. my_retain_rsgrid)
THEN
880 CALL rs_grid_release(rs_rho(igrid_level))
881 CALL rs_grid_create(rs_rho(igrid_level), rs_descs(igrid_level)%rs_desc)
883 CALL rs_grid_zero(rs_rho(igrid_level))
884 CALL rs_grid_create(rs_current(igrid_level), rs_descs(igrid_level)%rs_desc)
885 CALL rs_grid_zero(rs_current(igrid_level))
890 IF (.NOT. current_env%gauge_init .AND. do_igaim)
THEN
891 CALL current_set_gauge(current_env, qs_env)
892 current_env%gauge_init = .true.
897 DO igrid_level = 1, gridlevel_info%ngrid_levels
898 my_rho => rs_rho(igrid_level)%r
899 my_current => rs_current(igrid_level)%r
900 IF (lbound(my_rho, 3) /= lbound(my_current, 3) .OR. &
901 lbound(my_rho, 2) /= lbound(my_current, 2) .OR. &
902 lbound(my_rho, 1) /= lbound(my_current, 1) .OR. &
903 ubound(my_rho, 3) /= ubound(my_current, 3) .OR. &
904 ubound(my_rho, 2) /= ubound(my_current, 2) .OR. &
905 ubound(my_rho, 1) /= ubound(my_current, 1))
THEN
906 WRITE (*, *)
'LBOUND(my_rho,3),LBOUND(my_current,3)', lbound(my_rho, 3), lbound(my_current, 3)
907 WRITE (*, *)
'LBOUND(my_rho,2),LBOUND(my_current,2)', lbound(my_rho, 2), lbound(my_current, 2)
908 WRITE (*, *)
'LBOUND(my_rho,1),LBOUND(my_current,1)', lbound(my_rho, 1), lbound(my_current, 1)
909 WRITE (*, *)
'UBOUND(my_rho,3),UBOUND(my_current,3)', ubound(my_rho, 3), ubound(my_current, 3)
910 WRITE (*, *)
'UBOUND(my_rho,2),UBOUND(my_current,2)', ubound(my_rho, 2), ubound(my_current, 2)
911 WRITE (*, *)
'UBOUND(my_rho,1),UBOUND(my_current,1)', ubound(my_rho, 1), ubound(my_current, 1)
915 my_gauge => rs_gauge(1, igrid_level)%r
916 IF (lbound(my_rho, 3) /= lbound(my_gauge, 3) .OR. &
917 lbound(my_rho, 2) /= lbound(my_gauge, 2) .OR. &
918 lbound(my_rho, 1) /= lbound(my_gauge, 1) .OR. &
919 ubound(my_rho, 3) /= ubound(my_gauge, 3) .OR. &
920 ubound(my_rho, 2) /= ubound(my_gauge, 2) .OR. &
921 ubound(my_rho, 1) /= ubound(my_gauge, 1))
THEN
922 WRITE (*, *)
'LBOUND(my_rho,3),LBOUND(my_gauge,3)', lbound(my_rho, 3), lbound(my_gauge, 3)
923 WRITE (*, *)
'LBOUND(my_rho,2),LBOUND(my_gauge,2)', lbound(my_rho, 2), lbound(my_gauge, 2)
924 WRITE (*, *)
'LBOUND(my_rho,1),LBOUND(my_gauge,1)', lbound(my_rho, 1), lbound(my_gauge, 1)
925 WRITE (*, *)
'UBOUND(my_rho,3),UbOUND(my_gauge,3)', ubound(my_rho, 3), ubound(my_gauge, 3)
926 WRITE (*, *)
'UBOUND(my_rho,2),UBOUND(my_gauge,2)', ubound(my_rho, 2), ubound(my_gauge, 2)
927 WRITE (*, *)
'UBOUND(my_rho,1),UBOUND(my_gauge,1)', ubound(my_rho, 1), ubound(my_gauge, 1)
935 IF (distributed_rs_grids)
THEN
936 CALL rs_distribute_matrix(rs_descs=rs_descs, pmats=deltajp_a, &
937 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
938 nimages=nimages, scatter=.true.)
939 CALL rs_distribute_matrix(rs_descs=rs_descs, pmats=deltajp_b, &
940 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
941 nimages=nimages, scatter=.true.)
942 CALL rs_distribute_matrix(rs_descs=rs_descs, pmats=deltajp_c, &
943 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
944 nimages=nimages, scatter=.true.)
945 IF (do_igaim)
CALL rs_distribute_matrix(rs_descs=rs_descs, pmats=deltajp_d, &
946 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
947 nimages=nimages, scatter=.true.)
951 jpab_a => jpabt_a(:, :, ithread)
952 jpab_b => jpabt_b(:, :, ithread)
953 jpab_c => jpabt_c(:, :, ithread)
954 IF (do_igaim) jpab_d => jpabt_d(:, :, ithread)
955 work => workt(:, :, ithread)
957 iatom_old = -1; jatom_old = -1; iset_old = -1; jset_old = -1
958 ikind_old = -1; jkind_old = -1
960 loop_tasks:
DO itask = 1, ntasks
961 igrid_level = tasks(itask)%grid_level
962 cindex = tasks(itask)%image
963 iatom = tasks(itask)%iatom
964 jatom = tasks(itask)%jatom
965 iset = tasks(itask)%iset
966 jset = tasks(itask)%jset
967 ipgf = tasks(itask)%ipgf
968 jpgf = tasks(itask)%jpgf
971 cpassert(tasks(itask)%dist_type /= 2)
973 IF (iatom /= iatom_old .OR. jatom /= jatom_old)
THEN
975 ikind = particle_set(iatom)%atomic_kind%kind_number
976 jkind = particle_set(jatom)%atomic_kind%kind_number
978 IF (iatom /= iatom_old) ra(:) = pbc(particle_set(iatom)%r, cell)
983 IF (ikind /= ikind_old)
THEN
984 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
985 basis_type=basis_type)
987 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
988 first_sgf=first_sgfa, &
995 set_radius=set_radius_a, &
1000 IF (jkind /= jkind_old)
THEN
1002 CALL get_qs_kind(qs_kind_set(jkind), &
1003 basis_set=orb_basis_set, basis_type=basis_type)
1005 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
1006 first_sgf=first_sgfb, &
1007 kind_radius=kind_radius_b, &
1014 set_radius=set_radius_b, &
1020 CALL dbcsr_get_block_p(matrix=deltajp_a(1)%matrix, row=brow, col=bcol, &
1021 block=jp_block_a, found=den_found)
1022 CALL dbcsr_get_block_p(matrix=deltajp_b(1)%matrix, row=brow, col=bcol, &
1023 block=jp_block_b, found=den_found)
1024 CALL dbcsr_get_block_p(matrix=deltajp_c(1)%matrix, row=brow, col=bcol, &
1025 block=jp_block_c, found=den_found)
1026 IF (do_igaim)
CALL dbcsr_get_block_p(matrix=deltajp_d(1)%matrix, row=brow, col=bcol, &
1027 block=jp_block_d, found=den_found)
1029 IF (.NOT.
ASSOCIATED(jp_block_a))
THEN
1030 cpabort(
"p_block not associated in deltap")
1038 atom_pair_changed = .true.
1042 atom_pair_changed = .false.
1046 IF (atom_pair_changed .OR. iset_old /= iset .OR. jset_old /= jset)
THEN
1048 ncoa = npgfa(iset)*
ncoset(la_max(iset))
1049 sgfa = first_sgfa(1, iset)
1050 ncob = npgfb(jset)*
ncoset(lb_max(jset))
1051 sgfb = first_sgfb(1, jset)
1054 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
1055 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
1056 jp_block_a(sgfa, sgfb),
SIZE(jp_block_a, 1), &
1057 0.0_dp, work(1, 1), maxco)
1058 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
1059 1.0_dp, work(1, 1), maxco, &
1060 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
1061 0.0_dp, jpab_a(1, 1), maxco)
1063 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
1064 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
1065 jp_block_b(sgfa, sgfb),
SIZE(jp_block_b, 1), &
1066 0.0_dp, work(1, 1), maxco)
1067 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
1068 1.0_dp, work(1, 1), maxco, &
1069 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
1070 0.0_dp, jpab_b(1, 1), maxco)
1072 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
1073 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
1074 jp_block_c(sgfa, sgfb),
SIZE(jp_block_c, 1), &
1075 0.0_dp, work(1, 1), maxco)
1076 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
1077 1.0_dp, work(1, 1), maxco, &
1078 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
1079 0.0_dp, jpab_c(1, 1), maxco)
1082 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
1083 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
1084 jp_block_d(sgfa, sgfb),
SIZE(jp_block_d, 1), &
1085 0.0_dp, work(1, 1), maxco)
1086 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
1087 1.0_dp, work(1, 1), maxco, &
1088 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
1089 0.0_dp, jpab_d(1, 1), maxco)
1099 adbmdab_func = grid_func_adbmdab_x
1101 adbmdab_func = grid_func_adbmdab_y
1103 adbmdab_func = grid_func_adbmdab_z
1105 cpabort(
"invalid idir")
1108 rab(:) = tasks(itask)%rab
1109 rb(:) = ra(:) + rab(:)
1110 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
1111 f = zetb(jpgf, jset)/zetp
1112 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
1113 rp(:) = ra(:) + f*rab(:)
1115 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
1116 na2 = ipgf*
ncoset(la_max(iset))
1117 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
1118 nb2 = jpgf*
ncoset(lb_max(jset))
1127 radius = exp_radius_very_extended(la_min=la_min(iset), la_max=la_max(iset), &
1128 lb_min=lb_min(jset), lb_max=lb_max(jset), &
1129 ra=ra, rb=rb, rp=rp, zetp=zetp, eps=eps_rho_rspace, &
1130 prefactor=prefactor, cutoff=1.0_dp)
1132 CALL collocate_pgf_product(la_max(iset), zeta(ipgf, iset), &
1133 la_min(iset), lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
1134 ra, rab, scale, jpab_a, na1 - 1, nb1 - 1, &
1135 rs_current(igrid_level), &
1136 radius=radius, ga_gb_function=adbmdab_func)
1140 IF (scale2 /= 0.0_dp)
THEN
1141 CALL collocate_pgf_product(la_max(iset), zeta(ipgf, iset), &
1142 la_min(iset), lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
1143 ra, rab, scale2, jpab_d, na1 - 1, nb1 - 1, &
1144 rs_rho(igrid_level), &
1145 radius=radius, ga_gb_function=grid_func_ab)
1151 current_env%rs_buf(igrid_level)%r(:, :, :) = 0.0_dp
1152 CALL collocate_pgf_product(la_max(iset), zeta(ipgf, iset), &
1153 la_min(iset), lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
1154 ra, rab, scale, jpab_b, na1 - 1, nb1 - 1, &
1156 ga_gb_function=adbmdab_func, &
1157 rsgrid=current_env%rs_buf(igrid_level))
1158 CALL collocate_gauge_ortho(rsgrid=current_env%rs_buf(igrid_level), &
1159 rsbuf=rs_current(igrid_level), &
1160 rsgauge=rs_gauge(iiib, igrid_level), &
1161 cube_info=cube_info(igrid_level), radius=radius, &
1162 zeta=zeta(ipgf, iset), zetb=zetb(jpgf, jset), &
1163 ra=ra, rab=rab, ir=iiib)
1169 current_env%rs_buf(igrid_level)%r(:, :, :) = 0.0_dp
1170 CALL collocate_pgf_product(la_max(iset), zeta(ipgf, iset), &
1171 la_min(iset), lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
1172 ra, rab, scale, jpab_c, na1 - 1, nb1 - 1, &
1174 ga_gb_function=adbmdab_func, &
1175 rsgrid=current_env%rs_buf(igrid_level))
1176 CALL collocate_gauge_ortho(rsgrid=current_env%rs_buf(igrid_level), &
1177 rsbuf=rs_current(igrid_level), &
1178 rsgauge=rs_gauge(iib, igrid_level), &
1179 cube_info=cube_info(igrid_level), radius=radius, &
1180 zeta=zeta(ipgf, iset), zetb=zetb(jpgf, jset), &
1181 ra=ra, rab=rab, ir=iib)
1187 CALL collocate_pgf_product(la_max(iset), zeta(ipgf, iset), &
1188 la_min(iset), lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
1189 ra, rab, scale, jpab_b, na1 - 1, nb1 - 1, &
1190 rs_current(igrid_level), &
1192 ga_gb_function=encode_ardbmdarb_func(idir=idir, ir=iiib))
1197 CALL collocate_pgf_product(la_max(iset), zeta(ipgf, iset), &
1198 la_min(iset), lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
1199 ra, rab, scale, jpab_c, na1 - 1, nb1 - 1, &
1200 rs_current(igrid_level), &
1202 ga_gb_function=encode_ardbmdarb_func(idir=idir, ir=iib))
1209 DO igrid_level = 1, gridlevel_info%ngrid_levels
1210 CALL rs_grid_mult_and_add(rs_current(igrid_level), rs_rho(igrid_level), &
1211 rs_gauge(idir2, igrid_level), 1.0_dp)
1216 IF (distributed_rs_grids)
THEN
1217 CALL dbcsr_deallocate_matrix(deltajp_a(1)%matrix)
1218 CALL dbcsr_deallocate_matrix(deltajp_b(1)%matrix)
1219 CALL dbcsr_deallocate_matrix(deltajp_c(1)%matrix)
1220 IF (do_igaim)
CALL dbcsr_deallocate_matrix(deltajp_d(1)%matrix)
1222 DEALLOCATE (deltajp_a, deltajp_b, deltajp_c, deltajp_d)
1224 DEALLOCATE (jpabt_a, jpabt_b, jpabt_c, jpabt_d, workt, tasks)
1226 IF (
ASSOCIATED(atom_pair_send))
DEALLOCATE (atom_pair_send)
1227 IF (
ASSOCIATED(atom_pair_recv))
DEALLOCATE (atom_pair_recv)
1229 CALL density_rs2pw(pw_env, rs_current, current_rs, current_gs)
1230 DO i = 1,
SIZE(rs_current)
1231 CALL rs_grid_release(rs_current(i))
1234 DO i = 1,
SIZE(rs_rho)
1235 IF (rs_descs(i)%rs_desc%distributed .AND. .NOT. my_retain_rsgrid)
THEN
1236 CALL rs_grid_release(rs_rho(i))
1241 DEALLOCATE (rs_current)
1243 CALL timestop(handle)
1253 FUNCTION encode_ardbmdarb_func(idir, ir)
RESULT(func)
1254 INTEGER,
INTENT(IN) :: idir, ir
1257 cpassert(1 <= idir .AND. idir <= 3 .AND. 1 <= ir .AND. ir <= 3)
1258 SELECT CASE (10*idir + ir)
1260 func = grid_func_ardbmdarb_xx
1262 func = grid_func_ardbmdarb_xy
1264 func = grid_func_ardbmdarb_xz
1266 func = grid_func_ardbmdarb_yx
1268 func = grid_func_ardbmdarb_yy
1270 func = grid_func_ardbmdarb_yz
1272 func = grid_func_ardbmdarb_zx
1274 func = grid_func_ardbmdarb_zy
1276 func = grid_func_ardbmdarb_zz
1278 cpabort(
"invalid idir or iiiB")
1280 END FUNCTION encode_ardbmdarb_func
1295 SUBROUTINE collocate_gauge_ortho(rsgrid, rsbuf, rsgauge, cube_info, radius, ra, rab, zeta, zetb, ir)
1296 TYPE(realspace_grid_type) :: rsgrid, rsbuf, rsgauge
1297 TYPE(cube_info_type),
INTENT(IN) :: cube_info
1298 REAL(kind=dp),
INTENT(IN) :: radius
1299 REAL(kind=dp),
DIMENSION(3),
INTENT(IN) :: ra, rab
1300 REAL(kind=dp),
INTENT(IN) :: zeta, zetb
1301 INTEGER,
INTENT(IN) :: ir
1303 INTEGER :: cmax, i, ig, igmax, igmin, j, j2, jg, &
1304 jg2, jgmin, k, k2, kg, kg2, kgmin, &
1305 length, offset, sci, start
1306 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: map
1307 INTEGER,
DIMENSION(3) :: cubecenter, lb_cube, ng, ub_cube
1308 INTEGER,
DIMENSION(:),
POINTER :: sphere_bounds
1309 REAL(kind=dp) :: f, point(3, 4), res(4), x, y, y2, z, z2, &
1311 REAL(kind=dp),
DIMENSION(3) :: dr, rap, rb, rbp, roffset, rp
1312 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: gauge, grid, grid_buf
1314 cpassert(rsgrid%desc%orthorhombic)
1315 NULLIFY (sphere_bounds)
1317 grid => rsgrid%r(:, :, :)
1318 grid_buf => rsbuf%r(:, :, :)
1319 gauge => rsgauge%r(:, :, :)
1325 rbp(:) = rap(:) - rab(:)
1326 rp(:) = ra(:) + rap(:)
1327 rb(:) = ra(:) + rab(:)
1330 ng(:) = rsgrid%desc%npts(:)
1331 dr(1) = rsgrid%desc%dh(1, 1)
1332 dr(2) = rsgrid%desc%dh(2, 2)
1333 dr(3) = rsgrid%desc%dh(3, 3)
1336 CALL return_cube(cube_info, radius, lb_cube, ub_cube, sphere_bounds)
1337 cmax = maxval(ub_cube)
1346 ALLOCATE (map(-cmax:cmax, 3))
1348 CALL compute_cube_center(cubecenter, rsgrid%desc, zeta, zetb, ra, rab)
1349 roffset(:) = rp(:) - real(cubecenter(:), dp)*dr(:)
1353 IF (rsgrid%desc%perd(i) == 1)
THEN
1356 offset =
modulo(cubecenter(i) + start, ng(i)) + 1 - start
1357 length = min(ub_cube(i), ng(i) - offset) - start
1358 DO ig = start, start + length
1359 map(ig, i) = ig + offset
1361 IF (start + length >= ub_cube(i))
EXIT
1362 start = start + length + 1
1366 offset =
modulo(cubecenter(i) + lb_cube(i) + rsgrid%desc%lb(i) - rsgrid%lb_local(i), ng(i)) + 1 - lb_cube(i)
1368 IF (ub_cube(i) + offset > ubound(grid, i) .OR. lb_cube(i) + offset < lbound(grid, i))
THEN
1369 cpabort(
"Cube bound out of grid bounds")
1371 DO ig = lb_cube(i), ub_cube(i)
1372 map(ig, i) = ig + offset
1379 kgmin = sphere_bounds(sci)
1385 jgmin = sphere_bounds(sci)
1387 z = (real(kg, dp) + real(cubecenter(3), dp))*dr(3)
1388 z2 = (real(kg2, dp) + real(cubecenter(3), dp))*dr(3)
1393 igmin = sphere_bounds(sci)
1396 y = (real(jg, dp) + real(cubecenter(2), dp))*dr(2)
1397 y2 = (real(jg2, dp) + real(cubecenter(2), dp))*dr(2)
1398 DO ig = igmin, igmax
1400 x = (real(ig, dp) + real(cubecenter(1), dp))*dr(1)
1401 point(1, 1) = x; point(2, 1) = y; point(3, 1) = z
1402 point(1, 2) = x; point(2, 2) = y2; point(3, 2) = z
1403 point(1, 3) = x; point(2, 3) = y; point(3, 3) = z2
1404 point(1, 4) = x; point(2, 4) = y2; point(3, 4) = z2
1406 res(1) = (point(ir, 1) - rb(ir)) - gauge(i, j, k)
1407 res(2) = (point(ir, 2) - rb(ir)) - gauge(i, j2, k)
1408 res(3) = (point(ir, 3) - rb(ir)) - gauge(i, j, k2)
1409 res(4) = (point(ir, 4) - rb(ir)) - gauge(i, j2, k2)
1411 grid_buf(i, j, k) = grid_buf(i, j, k) + grid(i, j, k)*res(1)
1412 grid_buf(i, j2, k) = grid_buf(i, j2, k) + grid(i, j2, k)*res(2)
1413 grid_buf(i, j, k2) = grid_buf(i, j, k2) + grid(i, j, k2)*res(3)
1414 grid_buf(i, j2, k2) = grid_buf(i, j2, k2) + grid(i, j2, k2)*res(4)
1418 END SUBROUTINE collocate_gauge_ortho
1425 SUBROUTINE current_set_gauge(current_env, qs_env)
1427 TYPE(current_env_type) :: current_env
1428 TYPE(qs_environment_type),
POINTER :: qs_env
1430 CHARACTER(LEN=*),
PARAMETER :: routinen =
'current_set_gauge'
1434 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :) :: box_data
1435 INTEGER :: handle, igrid_level, nbox(3), gauge
1436 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: box_ptr
1437 TYPE(realspace_grid_desc_p_type),
DIMENSION(:), &
1439 TYPE(pw_env_type),
POINTER :: pw_env
1440 TYPE(realspace_grid_type),
DIMENSION(:, :),
POINTER :: rs_gauge
1442 TYPE(box_type),
DIMENSION(:, :, :),
POINTER :: box
1443 LOGICAL :: use_old_gauge_atom
1445 NULLIFY (rs_gauge, box)
1447 CALL timeset(routinen, handle)
1449 CALL get_current_env(current_env=current_env, &
1450 use_old_gauge_atom=use_old_gauge_atom, &
1451 rs_gauge=rs_gauge, &
1454 IF (gauge == current_gauge_atom)
THEN
1455 CALL get_qs_env(qs_env=qs_env, &
1457 CALL pw_env_get(pw_env=pw_env, &
1461 IF (use_old_gauge_atom)
THEN
1462 CALL box_atoms(qs_env)
1464 CALL box_atoms_new(current_env, qs_env, box)
1468 DO igrid_level = pw_env%gridlevel_info%ngrid_levels, 1, -1
1471 CALL rs_grid_create(rs_gauge(idir, igrid_level), rs_descs(igrid_level)%rs_desc)
1474 IF (use_old_gauge_atom)
THEN
1475 CALL collocate_gauge(current_env, qs_env, &
1476 rs_gauge(1, igrid_level), &
1477 rs_gauge(2, igrid_level), &
1478 rs_gauge(3, igrid_level))
1480 CALL collocate_gauge_new(current_env, qs_env, &
1481 rs_gauge(1, igrid_level), &
1482 rs_gauge(2, igrid_level), &
1483 rs_gauge(3, igrid_level), &
1489 ALLOCATE (current_env%rs_buf(pw_env%gridlevel_info%ngrid_levels))
1490 DO igrid_level = 1, pw_env%gridlevel_info%ngrid_levels
1491 CALL rs_grid_create(current_env%rs_buf(igrid_level), rs_descs(igrid_level)%rs_desc)
1494 DEALLOCATE (box_ptr, box_data)
1495 CALL deallocate_box(box)
1498 CALL timestop(handle)
1506 SUBROUTINE box_atoms(qs_env)
1507 TYPE(qs_environment_type),
POINTER :: qs_env
1509 REAL(kind=dp),
PARAMETER :: box_size_guess = 5.0_dp
1511 INTEGER :: i, iatom, ibox, ii, jbox, kbox, natms
1512 REAL(dp) :: offset(3)
1513 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :) :: ratom
1514 TYPE(cell_type),
POINTER :: cell
1515 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1516 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1518 CALL get_qs_env(qs_env=qs_env, &
1519 qs_kind_set=qs_kind_set, &
1521 particle_set=particle_set)
1523 natms =
SIZE(particle_set, 1)
1524 ALLOCATE (ratom(3, natms))
1527 nbox(1) = ceiling(cell%hmat(1, 1)/box_size_guess)
1528 nbox(2) = ceiling(cell%hmat(2, 2)/box_size_guess)
1529 nbox(3) = ceiling(cell%hmat(3, 3)/box_size_guess)
1531 dbox(1) = cell%hmat(1, 1)/real(nbox(1), dp)
1532 dbox(2) = cell%hmat(2, 2)/real(nbox(2), dp)
1533 dbox(3) = cell%hmat(3, 3)/real(nbox(3), dp)
1535 ALLOCATE (box_ptr(0:nbox(1), 0:nbox(2) - 1, 0:nbox(3) - 1), box_data(3, natms))
1536 box_data(:, :) = huge(0.0_dp)
1537 box_ptr(:, :, :) = huge(0)
1539 offset(1) = cell%hmat(1, 1)*0.5_dp
1540 offset(2) = cell%hmat(2, 2)*0.5_dp
1541 offset(3) = cell%hmat(3, 3)*0.5_dp
1543 ratom(:, iatom) = pbc(particle_set(iatom)%r(:), cell) + offset(:)
1547 DO kbox = 0, nbox(3) - 1
1548 DO jbox = 0, nbox(2) - 1
1549 box_ptr(0, jbox, kbox) = i
1550 DO ibox = 0, nbox(1) - 1
1553 IF (int(ratom(1, iatom)/dbox(1)) == ibox .AND. &
1554 int(ratom(2, iatom)/dbox(2)) == jbox .AND. &
1555 int(ratom(3, iatom)/dbox(3)) == kbox)
THEN
1556 box_data(:, i) = ratom(:, iatom) - offset(:)
1561 box_ptr(ibox + 1, jbox, kbox) = box_ptr(ibox, jbox, kbox) + ii
1567 DO kbox = 0, nbox(3) - 1
1568 DO jbox = 0, nbox(2) - 1
1569 DO ibox = 0, nbox(1) - 1
1570 WRITE (*, *)
'box=', ibox, jbox, kbox
1571 WRITE (*, *)
'nbr atom=', box_ptr(ibox + 1, jbox, kbox) - box_ptr(ibox, jbox, kbox)
1572 DO iatom = box_ptr(ibox, jbox, kbox), box_ptr(ibox + 1, jbox, kbox) - 1
1573 WRITE (*, *)
'iatom=', iatom
1574 WRITE (*,
'(A,3E14.6)')
'coor=', box_data(:, iatom)
1581 END SUBROUTINE box_atoms
1591 SUBROUTINE collocate_gauge(current_env, qs_env, rs_grid_x, rs_grid_y, rs_grid_z)
1593 TYPE(current_env_type) :: current_env
1594 TYPE(qs_environment_type),
POINTER :: qs_env
1595 TYPE(realspace_grid_type),
INTENT(IN) :: rs_grid_x, rs_grid_y, rs_grid_z
1597 INTEGER :: i, iatom, ibeg, ibox, iend,
imax,
imin, &
1598 j, jatom, jbox, jmax, jmin, k, kbox, &
1599 kmax, kmin, lb(3), lb_local(3), natms, &
1601 REAL(kind=dp) :: ab, buf_tmp, dist, dr(3), &
1602 gauge_atom_radius, offset(3), pa, pb, &
1603 point(3), pra(3), r(3), res(3), summe, &
1605 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:) :: buf, nrm_atms_pnt
1606 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: atms_pnt, ratom
1607 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: grid_x, grid_y, grid_z
1608 TYPE(cell_type),
POINTER :: cell
1609 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1610 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1614 CALL get_current_env(current_env=current_env, &
1615 gauge_atom_radius=gauge_atom_radius)
1617 CALL get_qs_env(qs_env=qs_env, &
1618 qs_kind_set=qs_kind_set, &
1620 particle_set=particle_set)
1622 natms =
SIZE(particle_set, 1)
1623 dr(1) = rs_grid_x%desc%dh(1, 1)
1624 dr(2) = rs_grid_x%desc%dh(2, 2)
1625 dr(3) = rs_grid_x%desc%dh(3, 3)
1626 lb(:) = rs_grid_x%desc%lb(:)
1627 lb_local(:) = rs_grid_x%lb_local(:)
1628 grid_x => rs_grid_x%r(:, :, :)
1629 grid_y => rs_grid_y%r(:, :, :)
1630 grid_z => rs_grid_z%r(:, :, :)
1631 ng(:) = ubound(grid_x)
1632 offset(1) = cell%hmat(1, 1)*0.5_dp
1633 offset(2) = cell%hmat(2, 2)*0.5_dp
1634 offset(3) = cell%hmat(3, 3)*0.5_dp
1635 ALLOCATE (buf(natms), ratom(3, natms), atms_pnt(3, natms), nrm_atms_pnt(natms))
1642 point(3) = real(k - 1 + lb_local(3) - lb(3), dp)*dr(3)
1643 point(2) = real(j - 1 + lb_local(2) - lb(2), dp)*dr(2)
1644 point(1) = real(i - 1 + lb_local(1) - lb(1), dp)*dr(1)
1645 point = pbc(point, cell)
1649 kmin = int((point(3) + offset(3) - gauge_atom_radius)/dbox(3))
1650 kmax = int((point(3) + offset(3) + gauge_atom_radius)/dbox(3))
1651 IF (kmax - kmin + 1 > nbox(3))
THEN
1655 DO kbox = kmin, kmax
1656 jmin = int((point(2) + offset(2) - gauge_atom_radius)/dbox(2))
1657 jmax = int((point(2) + offset(2) + gauge_atom_radius)/dbox(2))
1658 IF (jmax - jmin + 1 > nbox(2))
THEN
1662 DO jbox = jmin, jmax
1663 imin = int((point(1) + offset(1) - gauge_atom_radius)/dbox(1))
1664 imax = int((point(1) + offset(1) + gauge_atom_radius)/dbox(1))
1665 IF (
imax -
imin + 1 > nbox(1))
THEN
1671 iend = box_ptr(
modulo(ibox, nbox(1)) + 1,
modulo(jbox, nbox(2)),
modulo(kbox, nbox(3))) - 1
1672 DO iatom = ibeg, iend
1673 r(:) = pbc(box_data(:, iatom) - point(:), cell) + point(:)
1674 dist = (r(1) - point(1))**2 + (r(2) - point(2))**2 + (r(3) - point(3))**2
1675 IF (dist < gauge_atom_radius**2)
THEN
1676 natms_local = natms_local + 1
1677 ratom(:, natms_local) = r(:)
1683 atms_pnt(1, natms_local) = x
1684 atms_pnt(2, natms_local) = y
1685 atms_pnt(3, natms_local) = z
1686 nrm_atms_pnt(natms_local) = sqrt(x*x + y*y + z*z)
1693 IF (natms_local > 0)
THEN
1696 DO iatom = 1, natms_local
1698 pra(1) = atms_pnt(1, iatom)
1699 pra(2) = atms_pnt(2, iatom)
1700 pra(3) = atms_pnt(3, iatom)
1701 pa = nrm_atms_pnt(iatom)
1702 DO jatom = 1, natms_local
1703 IF (iatom == jatom) cycle
1704 pb = nrm_atms_pnt(jatom)
1705 x = pra(1) - atms_pnt(1, jatom)
1706 y = pra(2) - atms_pnt(2, jatom)
1707 z = pra(3) - atms_pnt(3, jatom)
1708 ab = sqrt(x*x + y*y + z*z)
1711 tmp = 0.5_dp*(3.0_dp - tmp*tmp)*tmp
1712 tmp = 0.5_dp*(3.0_dp - tmp*tmp)*tmp
1713 tmp = 0.5_dp*(3.0_dp - tmp*tmp)*tmp
1714 buf_tmp = buf_tmp*0.5_dp*(1.0_dp - tmp)
1716 buf(iatom) = buf_tmp
1722 DO iatom = 1, natms_local
1723 res(1) = res(1) + ratom(1, iatom)*buf(iatom)
1724 res(2) = res(2) + ratom(2, iatom)*buf(iatom)
1725 res(3) = res(3) + ratom(3, iatom)*buf(iatom)
1726 summe = summe + buf(iatom)
1728 res(1) = res(1)/summe
1729 res(2) = res(2)/summe
1730 res(3) = res(3)/summe
1731 grid_x(i, j, k) = point(1) - res(1)
1732 grid_y(i, j, k) = point(2) - res(2)
1733 grid_z(i, j, k) = point(3) - res(3)
1735 grid_x(i, j, k) = 0.0_dp
1736 grid_y(i, j, k) = 0.0_dp
1737 grid_z(i, j, k) = 0.0_dp
1743 DEALLOCATE (buf, ratom, atms_pnt, nrm_atms_pnt)
1745 END SUBROUTINE collocate_gauge
1753 SUBROUTINE box_atoms_new(current_env, qs_env, box)
1754 TYPE(current_env_type) :: current_env
1755 TYPE(qs_environment_type),
POINTER :: qs_env
1756 TYPE(box_type),
DIMENSION(:, :, :),
POINTER :: box
1758 CHARACTER(LEN=*),
PARAMETER :: routinen =
'box_atoms_new'
1760 INTEGER :: handle, i, iatom, ibeg, ibox, iend, &
1761 ifind, ii,
imax,
imin, j, jatom, jbox, &
1762 jmax, jmin, k, kbox, kmax, kmin, &
1764 REAL(dp) :: gauge_atom_radius, offset(3), scale
1765 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :) :: ratom
1766 REAL(dp),
DIMENSION(:, :),
POINTER :: r_ptr
1767 REAL(kind=dp) :: box_center(3), box_center_wrap(3), &
1768 box_size_guess, r(3)
1769 TYPE(cell_type),
POINTER :: cell
1770 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1771 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1773 CALL timeset(routinen, handle)
1775 CALL get_qs_env(qs_env=qs_env, &
1776 qs_kind_set=qs_kind_set, &
1778 particle_set=particle_set)
1780 CALL get_current_env(current_env=current_env, &
1781 gauge_atom_radius=gauge_atom_radius)
1785 box_size_guess = gauge_atom_radius/scale
1787 natms =
SIZE(particle_set, 1)
1788 ALLOCATE (ratom(3, natms))
1792 nbox(1) = ceiling(cell%hmat(1, 1)/box_size_guess)
1793 nbox(2) = ceiling(cell%hmat(2, 2)/box_size_guess)
1794 nbox(3) = ceiling(cell%hmat(3, 3)/box_size_guess)
1795 dbox(1) = cell%hmat(1, 1)/real(nbox(1), dp)
1796 dbox(2) = cell%hmat(2, 2)/real(nbox(2), dp)
1797 dbox(3) = cell%hmat(3, 3)/real(nbox(3), dp)
1798 ALLOCATE (box_ptr(0:nbox(1), 0:nbox(2) - 1, 0:nbox(3) - 1), box_data(3, natms))
1799 box_data(:, :) = huge(0.0_dp)
1800 box_ptr(:, :, :) = huge(0)
1802 offset(1) = cell%hmat(1, 1)*0.5_dp
1803 offset(2) = cell%hmat(2, 2)*0.5_dp
1804 offset(3) = cell%hmat(3, 3)*0.5_dp
1806 ratom(:, iatom) = pbc(particle_set(iatom)%r(:), cell)
1810 DO kbox = 0, nbox(3) - 1
1811 DO jbox = 0, nbox(2) - 1
1812 box_ptr(0, jbox, kbox) = i
1813 DO ibox = 0, nbox(1) - 1
1816 IF (
modulo(floor(ratom(1, iatom)/dbox(1)), nbox(1)) == ibox .AND. &
1817 modulo(floor(ratom(2, iatom)/dbox(2)), nbox(2)) == jbox .AND. &
1818 modulo(floor(ratom(3, iatom)/dbox(3)), nbox(3)) == kbox)
THEN
1819 box_data(:, i) = ratom(:, iatom)
1824 box_ptr(ibox + 1, jbox, kbox) = box_ptr(ibox, jbox, kbox) + ii
1830 DO kbox = 0, nbox(3) - 1
1831 DO jbox = 0, nbox(2) - 1
1832 DO ibox = 0, nbox(1) - 1
1833 IF (box_ptr(ibox + 1, jbox, kbox) - box_ptr(ibox, jbox, kbox) > 0)
THEN
1834 WRITE (*, *)
'box=', ibox, jbox, kbox
1835 WRITE (*, *)
'nbr atom=', box_ptr(ibox + 1, jbox, kbox) - box_ptr(ibox, jbox, kbox)
1836 DO iatom = box_ptr(ibox, jbox, kbox), box_ptr(ibox + 1, jbox, kbox) - 1
1837 WRITE (*,
'(A,I3,3E14.6)')
'coor=', iatom, box_data(:, iatom)
1846 ALLOCATE (box(0:nbox(1) - 1, 0:nbox(2) - 1, 0:nbox(3) - 1))
1849 DO k = 0, nbox(3) - 1
1850 DO j = 0, nbox(2) - 1
1851 DO i = 0, nbox(1) - 1
1853 box_center(1) = (real(i, dp) + 0.5_dp)*dbox(1)
1854 box_center(2) = (real(j, dp) + 0.5_dp)*dbox(2)
1855 box_center(3) = (real(k, dp) + 0.5_dp)*dbox(3)
1856 box_center_wrap = pbc(box_center, cell)
1860 kmin = floor((box_center(3) - gauge_atom_radius)/dbox(3))
1861 kmax = floor((box_center(3) + gauge_atom_radius)/dbox(3))
1862 IF (kmax - kmin + 1 > nbox(3))
THEN
1866 DO kbox = kmin, kmax
1867 jmin = floor((box_center(2) - gauge_atom_radius)/dbox(2))
1868 jmax = floor((box_center(2) + gauge_atom_radius)/dbox(2))
1869 IF (jmax - jmin + 1 > nbox(2))
THEN
1873 DO jbox = jmin, jmax
1874 imin = floor((box_center(1) - gauge_atom_radius)/dbox(1))
1875 imax = floor((box_center(1) + gauge_atom_radius)/dbox(1))
1876 IF (
imax -
imin + 1 > nbox(1))
THEN
1882 iend = box_ptr(
modulo(ibox, nbox(1)) + 1,
modulo(jbox, nbox(2)),
modulo(kbox, nbox(3))) - 1
1883 DO iatom = ibeg, iend
1884 r = pbc(box_center_wrap(:) - box_data(:, iatom), cell)
1885 IF (abs(r(1)) <= (scale + 0.5_dp)*dbox(1) .AND. &
1886 abs(r(2)) <= (scale + 0.5_dp)*dbox(2) .AND. &
1887 abs(r(3)) <= (scale + 0.5_dp)*dbox(3))
THEN
1888 natms_local = natms_local + 1
1889 ratom(:, natms_local) = box_data(:, iatom)
1897 box(i, j, k)%n = natms_local
1898 NULLIFY (box(i, j, k)%r)
1899 IF (natms_local > 0)
THEN
1900 ALLOCATE (box(i, j, k)%r(3, natms_local))
1901 r_ptr => box(i, j, k)%r
1902 CALL dcopy(3*natms_local, ratom(1, 1), 1, r_ptr(1, 1), 1)
1909 DO k = 0, nbox(3) - 1
1910 DO j = 0, nbox(2) - 1
1911 DO i = 0, nbox(1) - 1
1912 IF (box(i, j, k)%n > 0)
THEN
1914 WRITE (*, *)
'box=', i, j, k
1915 box_center(1) = (real(i, dp) + 0.5_dp)*dbox(1)
1916 box_center(2) = (real(j, dp) + 0.5_dp)*dbox(2)
1917 box_center(3) = (real(k, dp) + 0.5_dp)*dbox(3)
1918 box_center = pbc(box_center, cell)
1919 WRITE (*,
'(A,3E14.6)')
'box_center=', box_center
1920 WRITE (*, *)
'nbr atom=', box(i, j, k)%n
1921 r_ptr => box(i, j, k)%r
1922 DO iatom = 1, box(i, j, k)%n
1923 WRITE (*,
'(A,I3,3E14.6)')
'coor=', iatom, r_ptr(:, iatom)
1924 r(:) = pbc(box_center(:) - r_ptr(:, iatom), cell)
1925 IF (abs(r(1)) > (scale + 0.5_dp)*dbox(1) .OR. &
1926 abs(r(2)) > (scale + 0.5_dp)*dbox(2) .OR. &
1927 abs(r(3)) > (scale + 0.5_dp)*dbox(3))
THEN
1928 WRITE (*, *)
'error too many atoms'
1929 WRITE (*, *)
'dist=', abs(r(:))
1930 WRITE (*, *)
'large_dist=', (scale + 0.5_dp)*dbox
1931 cpabort(
"Some atoms are too far from box center")
1941 DO k = 0, nbox(3) - 1
1942 DO j = 0, nbox(2) - 1
1943 DO i = 0, nbox(1) - 1
1944 box_center(1) = (real(i, dp) + 0.5_dp)*dbox(1)
1945 box_center(2) = (real(j, dp) + 0.5_dp)*dbox(2)
1946 box_center(3) = (real(k, dp) + 0.5_dp)*dbox(3)
1947 box_center = pbc(box_center, cell)
1948 r_ptr => box(i, j, k)%r
1950 r(:) = pbc(box_center(:) - ratom(:, iatom), cell)
1952 DO jatom = 1, box(i, j, k)%n
1953 IF (sum(abs(ratom(:, iatom) - r_ptr(:, jatom))) < 1e-10_dp) ifind = 1
1956 IF (ifind == 0)
THEN
1958 IF (dot_product(r, r) < (gauge_atom_radius*gauge_atom_radius))
THEN
1959 WRITE (*, *)
'error atom too close'
1960 WRITE (*, *)
'iatom', iatom
1961 WRITE (*, *)
'box_center', box_center
1962 WRITE (*, *)
'ratom', ratom(:, iatom)
1963 WRITE (*, *)
'gauge_atom_radius', gauge_atom_radius
1964 cpabort(
"Some atoms are too close within gauge_atom_radius")
1975 CALL timestop(handle)
1977 END SUBROUTINE box_atoms_new
1988 SUBROUTINE collocate_gauge_new(current_env, qs_env, rs_grid_x, rs_grid_y, rs_grid_z, box)
1990 TYPE(current_env_type) :: current_env
1991 TYPE(qs_environment_type),
POINTER :: qs_env
1992 TYPE(realspace_grid_type),
INTENT(IN) :: rs_grid_x, rs_grid_y, rs_grid_z
1993 TYPE(box_type),
DIMENSION(:, :, :),
POINTER :: box
1995 CHARACTER(LEN=*),
PARAMETER :: routinen =
'collocate_gauge_new'
1997 INTEGER :: box_end(3), box_start(3), delta_lb(3), grid_end(3), grid_start(3), handle, i, &
1998 iatom, ib, ibox, j, jatom, jb, jbox, k, kb, kbox, lb(3), lb_local(3), natms, &
1999 natms_local0, natms_local1, ng(3)
2000 INTEGER(KIND=int_8) :: box_lower(3), box_upper(3), &
2001 grid_lower(3), grid_upper(3), npts(3)
2002 REAL(dp),
DIMENSION(:, :),
POINTER :: r_ptr
2003 REAL(kind=dp) :: ab, box_center(3), buf_tmp, dist, dr(3), &
2004 gauge_atom_radius, offset(3), pa, pb, &
2005 point(3), pra(3), r(3), res(3), summe, &
2007 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:) :: buf, nrm_atms_pnt
2008 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: atms_pnt, ratom
2009 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: grid_x, grid_y, grid_z
2010 TYPE(cell_type),
POINTER :: cell
2011 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
2012 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2014 CALL timeset(routinen, handle)
2017 CALL get_current_env(current_env=current_env, &
2018 gauge_atom_radius=gauge_atom_radius)
2020 CALL get_qs_env(qs_env=qs_env, &
2021 qs_kind_set=qs_kind_set, &
2023 particle_set=particle_set)
2025 natms =
SIZE(particle_set, 1)
2026 dr(1) = rs_grid_x%desc%dh(1, 1)
2027 dr(2) = rs_grid_x%desc%dh(2, 2)
2028 dr(3) = rs_grid_x%desc%dh(3, 3)
2029 lb(:) = rs_grid_x%desc%lb(:)
2030 lb_local(:) = rs_grid_x%lb_local(:)
2031 grid_x => rs_grid_x%r(:, :, :)
2032 grid_y => rs_grid_y%r(:, :, :)
2033 grid_z => rs_grid_z%r(:, :, :)
2034 ng(:) = ubound(grid_x)
2035 npts(:) = int(rs_grid_x%desc%npts(:), kind=int_8)
2036 delta_lb(:) = lb_local(:) - lb(:)
2037 offset(1) = cell%hmat(1, 1)*0.5_dp
2038 offset(2) = cell%hmat(2, 2)*0.5_dp
2039 offset(3) = cell%hmat(3, 3)*0.5_dp
2040 ALLOCATE (buf(natms), ratom(3, natms), atms_pnt(3, natms), nrm_atms_pnt(natms))
2046 grid_lower = int(delta_lb, kind=int_8)*nbox
2047 grid_upper = (int(ng, kind=int_8) - 1_int_8 + delta_lb)*nbox
2048 box_start = int((grid_lower -
modulo(grid_lower, npts))/npts)
2049 box_end = int((grid_upper -
modulo(grid_upper, npts))/npts)
2052 DO kb = box_start(3), box_end(3)
2053 DO jb = box_start(2), box_end(2)
2054 DO ib = box_start(1), box_end(1)
2055 ibox =
modulo(ib, nbox(1))
2056 jbox =
modulo(jb, nbox(2))
2057 kbox =
modulo(kb, nbox(3))
2062 box_lower = int([ib, jb, kb], kind=int_8)*npts
2063 box_upper = (int([ib, jb, kb], kind=int_8) + 1_int_8)*npts
2064 grid_start = int((box_lower +
modulo(-box_lower, int(nbox, kind=int_8)))/nbox)
2065 grid_end = int((box_upper -
modulo(box_upper, int(nbox, kind=int_8)))/nbox)
2066 grid_start = max(grid_start, delta_lb) - delta_lb + 1
2067 grid_end = min(grid_end, ng - 1 + delta_lb) - delta_lb + 1
2070 grid_lower = (int(grid_start, kind=int_8) - 1_int_8 + delta_lb)*nbox
2071 grid_upper = (int(grid_end, kind=int_8) - 1_int_8 + delta_lb)*nbox
2072 cpassert(all(grid_lower >= box_lower))
2073 cpassert(all(grid_upper <= box_upper))
2076 box_center(1) = (real(ibox, dp) + 0.5_dp)*dbox(1)
2077 box_center(2) = (real(jbox, dp) + 0.5_dp)*dbox(2)
2078 box_center(3) = (real(kbox, dp) + 0.5_dp)*dbox(3)
2081 natms_local0 = box(ibox, jbox, kbox)%n
2082 r_ptr => box(ibox, jbox, kbox)%r
2085 IF (natms_local0 > 0)
THEN
2088 DO k = grid_start(3), grid_end(3)
2089 DO j = grid_start(2), grid_end(2)
2090 DO i = grid_start(1), grid_end(1)
2091 point(1) = real(i - 1 + delta_lb(1), dp)*dr(1)
2092 point(2) = real(j - 1 + delta_lb(2), dp)*dr(2)
2093 point(3) = real(k - 1 + delta_lb(3), dp)*dr(3)
2094 point = pbc(point, cell)
2098 DO iatom = 1, natms_local0
2099 r(:) = pbc(r_ptr(:, iatom) - point(:), cell) + point(:)
2100 dist = (r(1) - point(1))**2 + (r(2) - point(2))**2 + (r(3) - point(3))**2
2101 IF (dist < gauge_atom_radius**2)
THEN
2102 natms_local1 = natms_local1 + 1
2103 ratom(:, natms_local1) = r(:)
2109 atms_pnt(1, natms_local1) = x
2110 atms_pnt(2, natms_local1) = y
2111 atms_pnt(3, natms_local1) = z
2112 nrm_atms_pnt(natms_local1) = sqrt(x*x + y*y + z*z)
2117 IF (natms_local1 > 0)
THEN
2120 DO iatom = 1, natms_local1
2122 pra(1) = atms_pnt(1, iatom)
2123 pra(2) = atms_pnt(2, iatom)
2124 pra(3) = atms_pnt(3, iatom)
2125 pa = nrm_atms_pnt(iatom)
2126 DO jatom = 1, natms_local1
2127 IF (iatom == jatom) cycle
2128 pb = nrm_atms_pnt(jatom)
2129 x = pra(1) - atms_pnt(1, jatom)
2130 y = pra(2) - atms_pnt(2, jatom)
2131 z = pra(3) - atms_pnt(3, jatom)
2132 ab = sqrt(x*x + y*y + z*z)
2135 tmp = 0.5_dp*(3.0_dp - tmp*tmp)*tmp
2136 tmp = 0.5_dp*(3.0_dp - tmp*tmp)*tmp
2137 tmp = 0.5_dp*(3.0_dp - tmp*tmp)*tmp
2138 buf_tmp = buf_tmp*0.5_dp*(1.0_dp - tmp)
2140 buf(iatom) = buf_tmp
2146 DO iatom = 1, natms_local1
2147 res(1) = res(1) + ratom(1, iatom)*buf(iatom)
2148 res(2) = res(2) + ratom(2, iatom)*buf(iatom)
2149 res(3) = res(3) + ratom(3, iatom)*buf(iatom)
2150 summe = summe + buf(iatom)
2152 res(1) = res(1)/summe
2153 res(2) = res(2)/summe
2154 res(3) = res(3)/summe
2155 grid_x(i, j, k) = point(1) - res(1)
2156 grid_y(i, j, k) = point(2) - res(2)
2157 grid_z(i, j, k) = point(3) - res(3)
2159 grid_x(i, j, k) = 0.0_dp
2160 grid_y(i, j, k) = 0.0_dp
2161 grid_z(i, j, k) = 0.0_dp
2170 DO k = grid_start(3), grid_end(3)
2171 DO j = grid_start(2), grid_end(2)
2172 DO i = grid_start(1), grid_end(1)
2173 grid_x(i, j, k) = 0.0_dp
2174 grid_y(i, j, k) = 0.0_dp
2175 grid_z(i, j, k) = 0.0_dp
2186 DEALLOCATE (buf, ratom, atms_pnt, nrm_atms_pnt)
2188 CALL timestop(handle)
2190 END SUBROUTINE collocate_gauge_new
2196 SUBROUTINE deallocate_box(box)
2197 TYPE(box_type),
DIMENSION(:, :, :),
POINTER :: box
2201 IF (
ASSOCIATED(box))
THEN
2202 DO k = lbound(box, 3), ubound(box, 3)
2203 DO j = lbound(box, 2), ubound(box, 2)
2204 DO i = lbound(box, 1), ubound(box, 1)
2205 IF (
ASSOCIATED(box(i, j, k)%r))
THEN
2206 DEALLOCATE (box(i, j, k)%r)
2213 END SUBROUTINE deallocate_box
2214 END SUBROUTINE current_set_gauge
2224 TYPE(current_env_type) :: current_env
2225 TYPE(qs_environment_type),
POINTER :: qs_env
2226 INTEGER,
INTENT(IN) :: ib
2228 IF (current_env%full)
THEN
2229 CALL current_build_chi_many_centers(current_env, qs_env, ib)
2230 ELSE IF (current_env%nbr_center(1) > 1)
THEN
2231 CALL current_build_chi_many_centers(current_env, qs_env, ib)
2233 CALL current_build_chi_one_center(current_env, qs_env, ib)
2244 SUBROUTINE current_build_chi_many_centers(current_env, qs_env, iB)
2246 TYPE(current_env_type) :: current_env
2247 TYPE(qs_environment_type),
POINTER :: qs_env
2248 INTEGER,
INTENT(IN) :: ib
2250 CHARACTER(LEN=*),
PARAMETER :: routinen =
'current_build_chi_many_centers'
2252 CHARACTER(LEN=default_string_length) :: basis_type
2253 INTEGER :: handle, icenter, idir, idir2, ii, iib, iii, iiib, ispin, istate, j, jstate, &
2254 max_states, nao, natom, nbr_center(2), nmo, nspins, nstate_loc, nstates(2), output_unit
2255 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
2256 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
2257 LOGICAL :: chi_pbc, gapw
2258 REAL(dp) :: chi(3), chi_tmp, contrib, contrib2, &
2259 dk(3), int_current(3), &
2260 int_current_tmp, maxocc
2261 TYPE(cell_type),
POINTER :: cell
2262 TYPE(cp_2d_i_p_type),
DIMENSION(:),
POINTER :: center_list
2263 TYPE(cp_2d_r_p_type),
DIMENSION(:),
POINTER :: centers_set
2264 TYPE(cp_fm_struct_type),
POINTER :: tmp_fm_struct
2265 TYPE(cp_fm_type) :: psi0, psi_d, psi_p1, psi_p2, psi_rxp
2266 TYPE(cp_fm_type),
DIMENSION(3) :: p_rxp, r_p1, r_p2
2267 TYPE(cp_fm_type),
DIMENSION(9, 3) :: rr_p1, rr_p2, rr_rxp
2268 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: psi0_order
2269 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: psi1_d, psi1_p, psi1_rxp
2270 TYPE(cp_fm_type),
POINTER :: mo_coeff
2271 TYPE(cp_logger_type),
POINTER :: logger
2272 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
2273 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: op_mom_ao, op_p_ao
2274 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: op_mom_der_ao
2275 TYPE(dft_control_type),
POINTER :: dft_control
2276 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
2277 TYPE(mp_para_env_type),
POINTER :: para_env
2278 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
2279 POINTER :: sab_all, sab_orb
2280 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
2281 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2285 CALL timeset(routinen, handle)
2287 NULLIFY (dft_control, mos, para_env, mo_coeff, op_mom_ao, &
2288 op_mom_der_ao, center_list, centers_set, &
2289 op_p_ao, psi1_p, psi1_rxp, psi1_d, &
2290 cell, particle_set, qs_kind_set)
2292 logger => cp_get_default_logger()
2293 output_unit = cp_logger_get_default_io_unit(logger)
2295 CALL get_qs_env(qs_env=qs_env, &
2296 dft_control=dft_control, &
2298 para_env=para_env, &
2300 dbcsr_dist=dbcsr_dist, &
2301 particle_set=particle_set, &
2302 qs_kind_set=qs_kind_set, &
2306 nspins = dft_control%nspins
2307 gapw = dft_control%qs_control%gapw
2309 IF (gapw) basis_type =
"ORB_SOFT"
2311 CALL get_current_env(current_env=current_env, &
2314 nbr_center=nbr_center, &
2315 center_list=center_list, &
2316 centers_set=centers_set, &
2318 psi1_rxp=psi1_rxp, &
2321 psi0_order=psi0_order)
2325 DO ispin = 1, nspins
2326 DO icenter = 1, nbr_center(ispin)
2327 max_states = max(max_states, center_list(ispin)%array(1, icenter + 1)&
2328 & - center_list(ispin)%array(1, icenter))
2334 CALL dbcsr_allocate_matrix_set(op_mom_ao, 9)
2335 CALL dbcsr_allocate_matrix_set(op_mom_der_ao, 9, 3)
2338 natom =
SIZE(particle_set, 1)
2339 ALLOCATE (first_sgf(natom))
2340 ALLOCATE (last_sgf(natom))
2341 CALL get_particle_set(particle_set, qs_kind_set, &
2342 first_sgf=first_sgf, &
2344 ALLOCATE (row_blk_sizes(natom))
2345 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
2346 DEALLOCATE (first_sgf)
2347 DEALLOCATE (last_sgf)
2350 ALLOCATE (op_mom_ao(1)%matrix)
2351 CALL dbcsr_create(matrix=op_mom_ao(1)%matrix, &
2353 dist=dbcsr_dist, matrix_type=dbcsr_type_no_symmetry, &
2354 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
2355 mutable_work=.true.)
2356 CALL cp_dbcsr_alloc_block_from_nbl(op_mom_ao(1)%matrix, sab_all)
2359 ALLOCATE (op_mom_der_ao(1, idir2)%matrix)
2360 CALL dbcsr_copy(op_mom_der_ao(1, idir2)%matrix, op_mom_ao(1)%matrix, &
2361 "op_mom_der_ao"//
"-"//trim(adjustl(cp_to_string(idir2))))
2364 DO idir = 2,
SIZE(op_mom_ao, 1)
2365 ALLOCATE (op_mom_ao(idir)%matrix)
2366 CALL dbcsr_copy(op_mom_ao(idir)%matrix, op_mom_ao(1)%matrix, &
2367 "op_mom_ao"//
"-"//trim(adjustl(cp_to_string(idir))))
2369 ALLOCATE (op_mom_der_ao(idir, idir2)%matrix)
2370 CALL dbcsr_copy(op_mom_der_ao(idir, idir2)%matrix, op_mom_ao(1)%matrix, &
2371 "op_mom_der_ao"//
"-"//trim(adjustl(cp_to_string(idir*idir2))))
2375 CALL dbcsr_allocate_matrix_set(op_p_ao, 3)
2376 ALLOCATE (op_p_ao(1)%matrix)
2377 CALL dbcsr_create(matrix=op_p_ao(1)%matrix, &
2379 dist=dbcsr_dist, matrix_type=dbcsr_type_antisymmetric, &
2380 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
2381 mutable_work=.true.)
2382 CALL cp_dbcsr_alloc_block_from_nbl(op_p_ao(1)%matrix, sab_orb)
2385 ALLOCATE (op_p_ao(idir)%matrix)
2386 CALL dbcsr_copy(op_p_ao(idir)%matrix, op_p_ao(1)%matrix, &
2387 "op_p_ao"//
"-"//trim(adjustl(cp_to_string(idir))))
2391 DEALLOCATE (row_blk_sizes)
2395 mo_coeff => psi0_order(1)
2396 NULLIFY (tmp_fm_struct)
2397 CALL cp_fm_struct_create(tmp_fm_struct, nrow_global=nao, &
2398 ncol_global=max_states, para_env=para_env, &
2399 context=mo_coeff%matrix_struct%context)
2400 CALL cp_fm_create(psi0, tmp_fm_struct)
2401 CALL cp_fm_create(psi_d, tmp_fm_struct)
2402 CALL cp_fm_create(psi_rxp, tmp_fm_struct)
2403 CALL cp_fm_create(psi_p1, tmp_fm_struct)
2404 CALL cp_fm_create(psi_p2, tmp_fm_struct)
2405 CALL cp_fm_struct_release(tmp_fm_struct)
2407 CALL cp_fm_struct_create(tmp_fm_struct, nrow_global=nao, &
2408 ncol_global=max_states, para_env=para_env, &
2409 context=mo_coeff%matrix_struct%context)
2411 CALL cp_fm_create(p_rxp(idir), tmp_fm_struct, set_zero=.true.)
2412 CALL cp_fm_create(r_p1(idir), tmp_fm_struct, set_zero=.true.)
2413 CALL cp_fm_create(r_p2(idir), tmp_fm_struct, set_zero=.true.)
2415 CALL cp_fm_create(rr_rxp(idir2, idir), tmp_fm_struct, set_zero=.true.)
2416 CALL cp_fm_create(rr_p1(idir2, idir), tmp_fm_struct, set_zero=.true.)
2417 CALL cp_fm_create(rr_p2(idir2, idir), tmp_fm_struct, set_zero=.true.)
2420 CALL cp_fm_struct_release(tmp_fm_struct)
2425 CALL build_lin_mom_matrix(qs_env, op_p_ao)
2429 CALL set_vecp(ib, iib, iiib)
2430 DO ispin = 1, nspins
2433 nmo = nstates(ispin)
2434 mo_coeff => psi0_order(ispin)
2435 CALL get_mo_set(mo_set=mos(ispin), maxocc=maxocc)
2439 int_current = 0.0_dp
2442 DO icenter = 1, nbr_center(ispin)
2445 dk(1:3) = centers_set(ispin)%array(1:3, icenter)
2450 CALL dbcsr_set(op_mom_ao(idir)%matrix, 0.0_dp)
2452 CALL dbcsr_set(op_mom_der_ao(idir, idir2)%matrix, 0.0_dp)
2455 CALL build_local_moments_der_matrix(qs_env, op_mom_der_ao, 2, 2, ref_point=dk, &
2456 moments=op_mom_ao, basis_type=basis_type, &
2457 minimum_image=.false., ordered=.true.)
2460 CALL cp_fm_set_all(psi0, 0.0_dp)
2461 CALL cp_fm_set_all(psi_rxp, 0.0_dp)
2462 CALL cp_fm_set_all(psi_d, 0.0_dp)
2463 CALL cp_fm_set_all(psi_p1, 0.0_dp)
2464 CALL cp_fm_set_all(psi_p2, 0.0_dp)
2465 nstate_loc = center_list(ispin)%array(1, icenter + 1) - center_list(ispin)%array(1, icenter)
2467 DO j = center_list(ispin)%array(1, icenter), center_list(ispin)%array(1, icenter + 1) - 1
2468 istate = center_list(ispin)%array(2, j)
2471 CALL cp_fm_to_fm(mo_coeff, psi0, 1, istate, jstate)
2473 CALL cp_fm_to_fm(psi1_rxp(ispin, ib), psi_rxp, 1, istate, jstate)
2474 IF (current_env%full)
CALL cp_fm_to_fm(psi1_d(ispin, ib), psi_d, 1, istate, jstate)
2477 CALL cp_fm_to_fm(psi1_p(ispin, iib), psi_p1, 1, istate, jstate)
2478 CALL cp_fm_to_fm(psi1_p(ispin, iiib), psi_p2, 1, istate, jstate)
2484 IF (current_env%full)
CALL cp_fm_scale_and_add(1.0_dp, psi_rxp, -1.0_dp, psi_d)
2487 CALL set_vecp(idir, ii, iii)
2488 CALL cp_dbcsr_sm_fm_multiply(op_p_ao(idir)%matrix, psi_rxp, &
2489 p_rxp(idir), ncol=nstate_loc, alpha=1.e0_dp)
2490 IF (iiib == iii .OR. iiib == ii)
THEN
2491 CALL cp_dbcsr_sm_fm_multiply(op_mom_ao(idir)%matrix, psi_p1, &
2492 r_p1(idir), ncol=nstate_loc, alpha=1.e0_dp)
2494 IF (iib == iii .OR. iib == ii)
THEN
2495 CALL cp_dbcsr_sm_fm_multiply(op_mom_ao(idir)%matrix, psi_p2, &
2496 r_p2(idir), ncol=nstate_loc, alpha=1.e0_dp)
2499 IF (idir2 == ii .OR. idir2 == iii)
THEN
2500 CALL cp_dbcsr_sm_fm_multiply(op_mom_der_ao(idir2, idir)%matrix, psi_rxp, &
2501 rr_rxp(idir2, idir), ncol=nstate_loc, alpha=1.e0_dp)
2504 IF (idir2 == ind_m2(ii, iiib) .OR. idir2 == ind_m2(iii, iiib) .OR. idir2 == iiib)
THEN
2505 CALL cp_dbcsr_sm_fm_multiply(op_mom_der_ao(idir2, idir)%matrix, psi_p1, &
2506 rr_p1(idir2, idir), ncol=nstate_loc, alpha=1.e0_dp)
2509 IF (idir2 == ind_m2(ii, iib) .OR. idir2 == ind_m2(iii, iib) .OR. idir2 == iib)
THEN
2510 CALL cp_dbcsr_sm_fm_multiply(op_mom_der_ao(idir2, idir)%matrix, psi_p2, &
2511 rr_p2(idir2, idir), ncol=nstate_loc, alpha=1.e0_dp)
2524 int_current_tmp = 0.0_dp
2527 CALL set_vecp(idir, ii, iii)
2532 CALL cp_fm_trace(psi0, rr_rxp(ii, iii), contrib)
2533 chi_tmp = chi_tmp + 2.0_dp*contrib
2536 CALL cp_fm_trace(psi0, rr_rxp(iii, ii), contrib)
2537 chi_tmp = chi_tmp - 2.0_dp*contrib
2542 CALL cp_fm_trace(psi0, p_rxp(iii), contrib)
2543 IF (.NOT. chi_pbc) chi_tmp = chi_tmp + 2.0_dp*dk(ii)*contrib
2544 int_current_tmp = int_current_tmp + 2.0_dp*contrib
2547 CALL cp_fm_trace(psi0, p_rxp(ii), contrib2)
2548 IF (.NOT. chi_pbc) chi_tmp = chi_tmp - 2.0_dp*dk(iii)*contrib2
2554 idir2 = ind_m2(ii, iib)
2555 CALL cp_fm_trace(psi0, rr_p2(idir2, iii), contrib)
2556 chi_tmp = chi_tmp - 2.0_dp*contrib
2558 IF (iib == iii)
THEN
2559 CALL cp_fm_trace(psi0, r_p2(ii), contrib2)
2560 chi_tmp = chi_tmp - contrib2
2564 idir2 = ind_m2(iii, iib)
2565 CALL cp_fm_trace(psi0, rr_p2(idir2, ii), contrib)
2566 chi_tmp = chi_tmp + 2.0_dp*contrib
2569 CALL cp_fm_trace(psi0, r_p2(iii), contrib2)
2570 chi_tmp = chi_tmp + contrib2
2578 CALL cp_fm_trace(psi0, rr_p2(iib, iii), contrib)
2579 IF (.NOT. chi_pbc) chi_tmp = chi_tmp - 2.0_dp*dk(ii)*contrib
2580 int_current_tmp = int_current_tmp - 2.0_dp*contrib
2583 CALL cp_fm_trace(psi0, rr_p2(iib, ii), contrib2)
2584 IF (.NOT. chi_pbc) chi_tmp = chi_tmp + 2.0_dp*dk(iii)*contrib2
2590 idir2 = ind_m2(ii, iiib)
2591 CALL cp_fm_trace(psi0, rr_p1(idir2, iii), contrib)
2592 chi_tmp = chi_tmp + 2.0_dp*contrib
2594 IF (iiib == iii)
THEN
2595 CALL cp_fm_trace(psi0, r_p1(ii), contrib2)
2596 chi_tmp = chi_tmp + contrib2
2600 idir2 = ind_m2(iii, iiib)
2601 CALL cp_fm_trace(psi0, rr_p1(idir2, ii), contrib)
2602 chi_tmp = chi_tmp - 2.0_dp*contrib
2604 IF (iiib == ii)
THEN
2605 CALL cp_fm_trace(psi0, r_p1(iii), contrib2)
2606 chi_tmp = chi_tmp - contrib2
2613 CALL cp_fm_trace(psi0, rr_p1(iiib, iii), contrib)
2614 IF (.NOT. chi_pbc) chi_tmp = chi_tmp + 2.0_dp*dk(ii)*contrib
2615 int_current_tmp = int_current_tmp + 2.0_dp*contrib
2618 CALL cp_fm_trace(psi0, rr_p1(iiib, ii), contrib2)
2619 IF (.NOT. chi_pbc) chi_tmp = chi_tmp - 2.0_dp*dk(iii)*contrib2
2622 chi(idir) = chi(idir) + maxocc*chi_tmp
2623 int_current(iii) = int_current(iii) + int_current_tmp
2629 current_env%chi_tensor(idir, ib, ispin) = current_env%chi_tensor(idir, ib, ispin) + &
2631 IF (output_unit > 0)
THEN
2642 CALL dbcsr_deallocate_matrix_set(op_mom_ao)
2643 CALL dbcsr_deallocate_matrix_set(op_mom_der_ao)
2644 CALL dbcsr_deallocate_matrix_set(op_p_ao)
2646 CALL cp_fm_release(psi0)
2647 CALL cp_fm_release(psi_rxp)
2648 CALL cp_fm_release(psi_d)
2649 CALL cp_fm_release(psi_p1)
2650 CALL cp_fm_release(psi_p2)
2652 CALL cp_fm_release(p_rxp(idir))
2653 CALL cp_fm_release(r_p1(idir))
2654 CALL cp_fm_release(r_p2(idir))
2656 CALL cp_fm_release(rr_rxp(idir2, idir))
2657 CALL cp_fm_release(rr_p1(idir2, idir))
2658 CALL cp_fm_release(rr_p2(idir2, idir))
2662 CALL timestop(handle)
2664 END SUBROUTINE current_build_chi_many_centers
2672 SUBROUTINE current_build_chi_one_center(current_env, qs_env, iB)
2674 TYPE(current_env_type) :: current_env
2675 TYPE(qs_environment_type),
POINTER :: qs_env
2676 INTEGER,
INTENT(IN) :: ib
2678 CHARACTER(LEN=*),
PARAMETER :: routinen =
'current_build_chi_one_center'
2680 CHARACTER(LEN=default_string_length) :: basis_type
2681 INTEGER :: handle, idir, idir2, iib, iiib, ispin, jdir, jjdir, kdir, max_states, nao, natom, &
2682 nbr_center(2), nmo, nspins, nstates(2), output_unit
2683 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
2684 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
2685 LOGICAL :: chi_pbc, gapw
2686 REAL(dp) :: chi(3), contrib, dk(3), int_current(3), &
2688 TYPE(cell_type),
POINTER :: cell
2689 TYPE(cp_2d_i_p_type),
DIMENSION(:),
POINTER :: center_list
2690 TYPE(cp_2d_r_p_type),
DIMENSION(:),
POINTER :: centers_set
2691 TYPE(cp_fm_type) :: buf
2692 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: psi0_order
2693 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: psi1_p, psi1_rxp
2694 TYPE(cp_fm_type),
POINTER :: mo_coeff
2695 TYPE(cp_logger_type),
POINTER :: logger
2696 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
2697 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: op_mom_ao, op_p_ao
2698 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: op_mom_der_ao
2699 TYPE(dft_control_type),
POINTER :: dft_control
2700 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
2701 TYPE(mp_para_env_type),
POINTER :: para_env
2702 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
2703 POINTER :: sab_all, sab_orb
2704 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
2705 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2709 CALL timeset(routinen, handle)
2711 NULLIFY (dft_control, mos, para_env, mo_coeff, op_mom_ao, &
2712 op_mom_der_ao, center_list, centers_set, &
2713 op_p_ao, psi1_p, psi1_rxp, cell, psi0_order)
2715 logger => cp_get_default_logger()
2716 output_unit = cp_logger_get_default_io_unit(logger)
2718 CALL get_qs_env(qs_env=qs_env, &
2719 dft_control=dft_control, &
2721 para_env=para_env, &
2723 particle_set=particle_set, &
2724 qs_kind_set=qs_kind_set, &
2727 dbcsr_dist=dbcsr_dist)
2729 nspins = dft_control%nspins
2730 gapw = dft_control%qs_control%gapw
2732 IF (gapw) basis_type =
"ORB_SOFT"
2734 CALL get_current_env(current_env=current_env, &
2737 nbr_center=nbr_center, &
2738 center_list=center_list, &
2739 centers_set=centers_set, &
2741 psi1_rxp=psi1_rxp, &
2743 psi0_order=psi0_order)
2745 max_states = maxval(nstates(1:nspins))
2749 CALL dbcsr_allocate_matrix_set(op_mom_ao, 9)
2750 CALL dbcsr_allocate_matrix_set(op_mom_der_ao, 9, 3)
2753 natom =
SIZE(particle_set, 1)
2754 ALLOCATE (first_sgf(natom))
2755 ALLOCATE (last_sgf(natom))
2756 CALL get_particle_set(particle_set, qs_kind_set, &
2757 first_sgf=first_sgf, &
2759 ALLOCATE (row_blk_sizes(natom))
2760 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
2761 DEALLOCATE (first_sgf)
2762 DEALLOCATE (last_sgf)
2765 ALLOCATE (op_mom_ao(1)%matrix)
2766 CALL dbcsr_create(matrix=op_mom_ao(1)%matrix, &
2768 dist=dbcsr_dist, matrix_type=dbcsr_type_no_symmetry, &
2769 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
2770 mutable_work=.true.)
2771 CALL cp_dbcsr_alloc_block_from_nbl(op_mom_ao(1)%matrix, sab_all)
2774 ALLOCATE (op_mom_der_ao(1, idir2)%matrix)
2775 CALL dbcsr_copy(op_mom_der_ao(1, idir2)%matrix, op_mom_ao(1)%matrix, &
2776 "op_mom_der_ao"//
"-"//trim(adjustl(cp_to_string(idir2))))
2779 DO idir = 2,
SIZE(op_mom_ao, 1)
2780 ALLOCATE (op_mom_ao(idir)%matrix)
2781 CALL dbcsr_copy(op_mom_ao(idir)%matrix, op_mom_ao(1)%matrix, &
2782 "op_mom_ao"//
"-"//trim(adjustl(cp_to_string(idir))))
2784 ALLOCATE (op_mom_der_ao(idir, idir2)%matrix)
2785 CALL dbcsr_copy(op_mom_der_ao(idir, idir2)%matrix, op_mom_ao(1)%matrix, &
2786 "op_mom_der_ao"//
"-"//trim(adjustl(cp_to_string(idir*idir2))))
2790 CALL dbcsr_allocate_matrix_set(op_p_ao, 3)
2791 ALLOCATE (op_p_ao(1)%matrix)
2792 CALL dbcsr_create(matrix=op_p_ao(1)%matrix, &
2794 dist=dbcsr_dist, matrix_type=dbcsr_type_antisymmetric, &
2795 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
2796 mutable_work=.true.)
2797 CALL cp_dbcsr_alloc_block_from_nbl(op_p_ao(1)%matrix, sab_orb)
2800 ALLOCATE (op_p_ao(idir)%matrix)
2801 CALL dbcsr_copy(op_p_ao(idir)%matrix, op_p_ao(1)%matrix, &
2802 "op_p_ao"//
"-"//trim(adjustl(cp_to_string(idir))))
2806 DEALLOCATE (row_blk_sizes)
2809 CALL build_lin_mom_matrix(qs_env, op_p_ao)
2813 CALL set_vecp(ib, iib, iiib)
2814 DO ispin = 1, nspins
2816 cpassert(nbr_center(ispin) == 1)
2819 nmo = nstates(ispin)
2820 mo_coeff => psi0_order(ispin)
2821 CALL get_mo_set(mo_set=mos(ispin), maxocc=maxocc)
2824 CALL cp_fm_create(buf, mo_coeff%matrix_struct)
2828 int_current = 0.0_dp
2832 dk(1:3) = centers_set(ispin)%array(1:3, 1)
2837 CALL dbcsr_set(op_mom_ao(idir)%matrix, 0.0_dp)
2839 CALL dbcsr_set(op_mom_der_ao(idir, idir2)%matrix, 0.0_dp)
2842 CALL build_local_moments_der_matrix(qs_env, op_mom_der_ao, 2, 2, ref_point=dk, &
2843 moments=op_mom_ao, basis_type=basis_type, &
2844 minimum_image=.false., ordered=.true.)
2858 IF (.NOT. chi_pbc)
THEN
2859 CALL cp_dbcsr_sm_fm_multiply(op_p_ao(idir)%matrix, mo_coeff, &
2860 buf, ncol=nmo, alpha=1.e0_dp)
2863 IF (
levi_civita(kdir, jdir, idir) == 0.0_dp) cycle
2864 CALL cp_fm_trace(buf, psi1_rxp(ispin, ib), contrib)
2865 chi(kdir) = chi(kdir) -
levi_civita(kdir, jdir, idir)*2.0_dp*dk(jdir)*contrib
2880 CALL cp_dbcsr_sm_fm_multiply(op_mom_der_ao(jdir, idir)%matrix, mo_coeff, &
2881 buf, ncol=nmo, alpha=1.e0_dp)
2883 IF (
levi_civita(kdir, jdir, idir) == 0.0_dp) cycle
2884 CALL cp_fm_trace(buf, psi1_rxp(ispin, ib), contrib)
2885 chi(kdir) = chi(kdir) -
levi_civita(kdir, jdir, idir)*2.0_dp*contrib
2888 IF (.NOT. chi_pbc)
THEN
2889 IF (jdir == iib)
THEN
2892 IF (
levi_civita(kdir, jjdir, idir) == 0.0_dp) cycle
2893 CALL cp_fm_trace(buf, psi1_p(ispin, iiib), contrib)
2894 chi(kdir) = chi(kdir) +
levi_civita(kdir, jjdir, idir)*2.0_dp*dk(jjdir)*contrib
2899 IF (jdir == iiib)
THEN
2902 IF (
levi_civita(kdir, jjdir, idir) == 0.0_dp) cycle
2903 CALL cp_fm_trace(buf, psi1_p(ispin, iib), contrib)
2904 chi(kdir) = chi(kdir) -
levi_civita(kdir, jjdir, idir)*2.0_dp*dk(jjdir)*contrib
2920 CALL cp_dbcsr_sm_fm_multiply(op_mom_der_ao(ind_m2(jdir, iib), idir)%matrix, mo_coeff, &
2921 buf, ncol=nmo, alpha=1.e0_dp)
2923 IF (
levi_civita(kdir, jdir, idir) == 0.0_dp) cycle
2924 CALL cp_fm_trace(buf, psi1_p(ispin, iiib), contrib)
2925 chi(kdir) = chi(kdir) +
levi_civita(kdir, jdir, idir)*2.0_dp*contrib
2928 CALL cp_dbcsr_sm_fm_multiply(op_mom_der_ao(ind_m2(jdir, iiib), idir)%matrix, mo_coeff, &
2929 buf, ncol=nmo, alpha=1.e0_dp)
2931 IF (
levi_civita(kdir, jdir, idir) == 0.0_dp) cycle
2932 CALL cp_fm_trace(buf, psi1_p(ispin, iib), contrib)
2933 chi(kdir) = chi(kdir) -
levi_civita(kdir, jdir, idir)*2.0_dp*contrib
2944 CALL cp_dbcsr_sm_fm_multiply(op_mom_ao(idir)%matrix, mo_coeff, &
2945 buf, ncol=nmo, alpha=1.e0_dp)
2948 IF (
levi_civita(kdir, idir, jdir) == 0.0_dp) cycle
2949 IF (iib == jdir)
THEN
2950 CALL cp_fm_trace(buf, psi1_p(ispin, iiib), contrib)
2951 chi(kdir) = chi(kdir) +
levi_civita(kdir, idir, jdir)*contrib
2958 IF (
levi_civita(kdir, idir, jdir) == 0.0_dp) cycle
2959 IF (iiib == jdir)
THEN
2960 CALL cp_fm_trace(buf, psi1_p(ispin, iib), contrib)
2961 chi(kdir) = chi(kdir) -
levi_civita(kdir, idir, jdir)*contrib
2973 current_env%chi_tensor(idir, ib, ispin) = current_env%chi_tensor(idir, ib, ispin) + &
2975 IF (output_unit > 0)
THEN
2981 CALL cp_fm_release(buf)
2985 CALL dbcsr_deallocate_matrix_set(op_mom_ao)
2986 CALL dbcsr_deallocate_matrix_set(op_mom_der_ao)
2987 CALL dbcsr_deallocate_matrix_set(op_p_ao)
2989 CALL timestop(handle)
2991 END SUBROUTINE current_build_chi_one_center
static int imax(int x, int y)
Returns the larger of two given integers (missing from the C standard).
static int imin(int x, int y)
Returns the smaller of the two integers (missing from the C standard).
static GRID_HOST_DEVICE int ncoset(const int l)
Number of Cartesian orbitals up to given angular momentum quantum.
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.
All kind of helpful little routines.
real(kind=dp) function, public exp_radius_very_extended(la_min, la_max, lb_min, lb_max, pab, o1, o2, ra, rb, rp, zetp, eps, prefactor, cutoff, epsabs)
computes the radius of the Gaussian outside of which it is smaller than eps
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
Handles all functions related to the CELL.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
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_finalize(matrix)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_put_block(matrix, row, col, block, summation)
...
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout, file_access)
...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
...
for a given dr()/dh(r) this will provide the bounds to be used if one wants to go over a sphere-subre...
subroutine, public compute_cube_center(cube_center, rs_desc, zeta, zetb, ra, rab)
unifies the computation of the cube center, so that differences in implementation,...
subroutine, public return_cube(info, radius, lb_cube, ub_cube, sphere_bounds)
...
Fortran API for the grid package, which is written in C.
integer, parameter, public grid_func_adbmdab_z
integer, parameter, public grid_func_adbmdab_y
integer, parameter, public grid_func_ardbmdarb_yx
integer, parameter, public grid_func_ardbmdarb_zz
integer, parameter, public grid_func_ardbmdarb_xy
integer, parameter, public grid_func_ardbmdarb_zx
integer, parameter, public grid_func_ardbmdarb_xx
integer, parameter, public grid_func_ardbmdarb_yz
integer, parameter, public grid_func_ab
integer, parameter, public grid_func_ardbmdarb_yy
integer, parameter, public grid_func_adbmdab_x
subroutine, public collocate_pgf_product(la_max, zeta, la_min, lb_max, zetb, lb_min, ra, rab, scale, pab, o1, o2, rsgrid, ga_gb_function, radius, use_subpatch, subpatch_pattern)
low level collocation of primitive gaussian functions
integer, parameter, public grid_func_ardbmdarb_zy
integer, parameter, public grid_func_ardbmdarb_xz
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
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 ncoset
represent a simple array based list of the given type
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis, ncgf)
Get the components of a particle set.
Define the data structure for the particle information.
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
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, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public 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, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
given the response wavefunctions obtained by the application of the (rxp), p, and ((dk-dl)xp) operato...
subroutine, public calculate_jrho_atom(current_env, qs_env, ib, idir)
...
subroutine, public calculate_jrho_atom_coeff(qs_env, current_env, mat_d0, mat_jp, mat_jp_rii, mat_jp_riii, ib, idir)
Calculate the expansion coefficients for the atomic terms of the current densitiy in GAPW.
subroutine, public calculate_jrho_atom_rad(qs_env, current_env, idir)
...
given the response wavefunctions obtained by the application of the (rxp), p, and ((dk-dl)xp) operato...
subroutine, public current_build_current(current_env, qs_env, ib)
First calculate the density matrixes, for each component of the current they are 3 because of the r d...
real(dp), dimension(3, 3, 3), parameter levi_civita
subroutine, public calculate_jrho_resp(mat_d0, mat_jp, mat_jp_rii, mat_jp_riii, ib, idir, current_rs, current_gs, qs_env, current_env, soft_valid, retain_rsgrid)
Calculation of the idir component of the response current density in the presence of a constant magne...
subroutine, public current_build_chi(current_env, qs_env, ib)
...
Calculate the operators p rxp and D needed in the optimization of the different contribution of the f...
integer function, public ind_m2(ii, iii)
...
subroutine, public set_vecp(i1, i2, i3)
...
real(dp) function, public fac_vecp(a, b, c)
...
subroutine, public fm_scale_by_pbc_ac(matrix, ra, rc, cell, ixyz)
scale a matrix as a_ij = a_ij * pbc(rc(:,j),ra(:,i))(ixyz)
subroutine, public set_vecp_rev(i1, i2, i3)
...
Type definitiona for linear response calculations.
subroutine, public get_current_env(current_env, simple_done, simple_converged, full_done, nao, nstates, gauge, list_cubes, statetrueindex, gauge_name, basisfun_center, nbr_center, center_list, centers_set, psi1_p, psi1_rxp, psi1_d, p_psi0, rxp_psi0, jrho1_atom_set, jrho1_set, chi_tensor, chi_tensor_loc, gauge_atom_radius, rs_gauge, use_old_gauge_atom, chi_pbc, psi0_order)
...
wrapper for the pools of matrixes
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count, cmo_coeff)
Get the components of a MO set data structure.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>.
subroutine, public build_local_moments_der_matrix(qs_env, moments_der, nmoments_der, nmoments, ref_point, moments, basis_type, minimum_image, ordered, lambda, deltar, neighbor_image)
Calculate right-hand sided derivatives of multipole moments, e. g. < a | xy d/dz | b > Optionally sto...
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
subroutine, public build_lin_mom_matrix(qs_env, matrix, minimum_image)
Calculation of the linear momentum matrix <mu|∂|nu> 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...
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
subroutine, public rs_grid_create(rs, desc)
...
subroutine, public rs_grid_mult_and_add(rs1, rs2, rs3, scalar)
rs1(i) = rs1(i) + rs2(i)*rs3(i)
subroutine, public rs_grid_release(rs_grid)
releases the given rs grid (see doc/ReferenceCounting.html)
subroutine, public rs_grid_zero(rs)
Initialize grid to zero.
Transfers densities from PW to RS grids and potentials from PW to RS.
subroutine, public density_rs2pw(pw_env, rs_rho, rho, rho_gspace)
given partial densities on the realspace multigrids, computes the full density on the plane wave grid...
generate the tasks lists used by collocate and integrate routines
subroutine, public rs_distribute_matrix(rs_descs, pmats, atom_pair_send, atom_pair_recv, nimages, scatter, hmats)
redistributes the matrix so that it can be used in realspace operations i.e. according to the task li...
subroutine, public distribute_tasks(rs_descs, ntasks, natoms, tasks, atom_pair_send, atom_pair_recv, symmetric, reorder_rs_grid_ranks, skip_load_balance_distributed, balance_replicated)
Assembles tasks to be performed on local grid.
subroutine, public task_list_inner_loop(tasks, ntasks, curr_tasks, rs_descs, dft_control, cube_info, gridlevel_info, cindex, iatom, jatom, rpgfa, rpgfb, zeta, zetb, kind_radius_b, set_radius_a, set_radius_b, ra, rab, la_max, la_min, lb_max, lb_min, npgfa, npgfb, nseta, nsetb)
...
subroutine, public reallocate_tasks(tasks, new_size)
Grow an array of tasks while preserving the existing entries.
Type defining parameters related to the simulation cell.
represent a pointer to a 2d array
represent a pointer to a 2d array
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment
represent a list of objects
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
container for the pools of matrixes used by qs