30 dbcsr_type_antisymmetric,&
75#include "./base/base_uses.f90"
81 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rt_propagation_velocity_gauge'
95 LOGICAL,
INTENT(IN),
OPTIONAL :: subtract_nl_term
97 CHARACTER(len=*),
PARAMETER :: routinen =
'velocity_gauge_ks_matrix'
99 INTEGER :: handle, idir, image, nder, nimages
100 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
101 LOGICAL :: calculate_forces, my_subtract_nl_term, &
102 ppnl_present, use_virial
103 REAL(kind=
dp) :: eps_ppnl, factor
104 REAL(kind=
dp),
DIMENSION(3) :: vec_pot
107 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: momentum, nl_term
108 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_h, matrix_h_im, matrix_nl, &
113 POINTER :: sab_orb, sap_ppnl
116 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
122 CALL timeset(routinen, handle)
126 my_subtract_nl_term = .false.
127 IF (
PRESENT(subtract_nl_term)) my_subtract_nl_term = subtract_nl_term
129 NULLIFY (dft_control, matrix_s, sab_orb, matrix_h, cell, input, matrix_h_im, kpoints, cell_to_index, &
130 sap_ppnl, particle_set, qs_kind_set, atomic_kind_set, virial, force, matrix_p, rho, matrix_nl)
134 dft_control=dft_control, &
137 matrix_s_kp=matrix_s, &
138 matrix_h_kp=matrix_h, &
141 matrix_h_im_kp=matrix_h_im)
143 nimages = dft_control%nimages
144 ppnl_present =
ASSOCIATED(sap_ppnl)
146 IF (nimages > 1)
THEN
147 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
151 IF (my_subtract_nl_term)
THEN
152 IF (ppnl_present)
THEN
154 qs_kind_set=qs_kind_set, &
155 particle_set=particle_set, &
156 atomic_kind_set=atomic_kind_set, &
162 calculate_forces = .false.
165 eps_ppnl = dft_control%qs_control%eps_ppnl
168 DO image = 1, nimages
169 ALLOCATE (matrix_nl(1, image)%matrix)
170 CALL dbcsr_create(matrix_nl(1, image)%matrix, template=matrix_s(1, 1)%matrix)
175 CALL build_core_ppnl(matrix_nl, matrix_p, force, virial, calculate_forces, use_virial, nder, &
176 qs_kind_set, atomic_kind_set, particle_set, sab_orb, sap_ppnl, eps_ppnl, &
177 nimages, cell_to_index,
"ORB")
179 DO image = 1, nimages
180 CALL dbcsr_add(matrix_h(1, image)%matrix, matrix_nl(1, image)%matrix,
one, -
one)
188 vec_pot = dft_control%rtp_control%vec_pot
195 CALL dbcsr_create(momentum(idir)%matrix, template=matrix_s(1, 1)%matrix, &
196 matrix_type=dbcsr_type_antisymmetric)
203 DO image = 1, nimages
208 DO image = 1, nimages
210 CALL dbcsr_add(matrix_h_im(1, image)%matrix, momentum(idir)%matrix,
one, -vec_pot(idir))
219 factor = factor + vec_pot(idir)**2
222 DO image = 1, nimages
223 CALL dbcsr_add(matrix_h(1, image)%matrix, matrix_s(1, image)%matrix,
one, 0.5_dp*factor)
227 IF (ppnl_present)
THEN
228 IF (dft_control%rtp_control%nl_gauge_transform)
THEN
233 CALL dbcsr_create(nl_term(1)%matrix, template=matrix_s(1, 1)%matrix, &
234 matrix_type=dbcsr_type_symmetric, name=
"nl gauge term real part")
239 CALL dbcsr_create(nl_term(2)%matrix, template=matrix_s(1, 1)%matrix, &
240 matrix_type=dbcsr_type_antisymmetric, name=
"nl gauge term imaginary part")
244 CALL velocity_gauge_nl_term(qs_env, nl_term, vec_pot)
246 DO image = 1, nimages
248 CALL dbcsr_add(matrix_h_im(1, image)%matrix, nl_term(2)%matrix,
one,
one)
254 CALL timestop(handle)
268 REAL(kind=
dp) :: field(3)
270 CALL make_field(dft_control, field, qs_env%sim_step, qs_env%sim_time)
271 dft_control%rtp_control%field = field
272 dft_control%rtp_control%vec_pot = dft_control%rtp_control%vec_pot - field*qs_env%rtp%dt
274 dft_control%efield_fields(1)%efield%vec_pot_initial = dft_control%rtp_control%vec_pot
284 SUBROUTINE velocity_gauge_nl_term(qs_env, nl_term, vec_pot)
288 REAL(kind=
dp),
DIMENSION(3),
INTENT(in) :: vec_pot
290 CHARACTER(len=*),
PARAMETER :: routiunen =
"velocity_gauge_nl_term"
292 COMPLEX(KIND=dp),
ALLOCATABLE :: zblock(:, :)
293 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER :: achint, bcint
294 INTEGER :: handle, iac, iatom, ibc, icol, ikind, &
295 irow, jatom, jkind, kac, kbc, kkind, &
296 maxl, maxlgto, maxlppnl, na, natom, &
298 INTEGER,
DIMENSION(3) :: cell_b
301 REAL(kind=
dp),
DIMENSION(3) :: rab
302 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: imag_block, real_block
308 DIMENSION(:) :: basis_set
311 POINTER :: sab_orb, sap_ppnl
313 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
324 CALL timeset(routiunen, handle)
326 NULLIFY (sap_ppnl, sab_orb)
331 IF (
ASSOCIATED(sap_ppnl))
THEN
332 NULLIFY (qs_kind_set, particle_set, cell, dft_control)
334 dft_control=dft_control, &
335 qs_kind_set=qs_kind_set, &
336 particle_set=particle_set, &
338 atomic_kind_set=atomic_kind_set)
340 nkind =
SIZE(atomic_kind_set)
341 natom =
SIZE(particle_set)
342 eps_ppnl = dft_control%qs_control%eps_ppnl
348 maxl = max(maxlppnl, maxlgto)
353 ALLOCATE (sap_int(nkind*nkind))
356 ALLOCATE (basis_set(nkind))
358 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
359 IF (
ASSOCIATED(orb_basis_set))
THEN
360 basis_set(ikind)%gto_basis_set => orb_basis_set
362 NULLIFY (basis_set(ikind)%gto_basis_set)
367 CALL build_sap_exp_ints(sap_int, sap_ppnl, qs_kind_set, particle_set, &
368 cell, kvec=vec_pot, basis_set=basis_set, nkind=nkind, &
392 NULLIFY (real_block, imag_block)
393 NULLIFY (achint, bcint)
397 DO slot = 1, sab_orb(1)%nl_size
398 ikind = sab_orb(1)%nlist_task(slot)%ikind
399 jkind = sab_orb(1)%nlist_task(slot)%jkind
400 iatom = sab_orb(1)%nlist_task(slot)%iatom
401 jatom = sab_orb(1)%nlist_task(slot)%jatom
402 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell
403 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
405 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
406 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
408 IF (iatom <= jatom)
THEN
419 IF (
ASSOCIATED(real_block) .AND.
ASSOCIATED(imag_block))
THEN
422 iac = ikind + nkind*(kkind - 1)
423 ibc = jkind + nkind*(kkind - 1)
424 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist)) cycle
425 IF (.NOT.
ASSOCIATED(sap_int(ibc)%alist)) cycle
426 CALL get_alist(sap_int(iac), alist_ac, iatom)
427 CALL get_alist(sap_int(ibc), alist_bc, jatom)
428 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
429 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
430 DO kac = 1, alist_ac%nclist
431 DO kbc = 1, alist_bc%nclist
432 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
433 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
435 IF (alist_ac%clist(kac)%maxac*alist_bc%clist(kbc)%maxach < eps_ppnl) cycle
438 IF (iatom <= jatom)
THEN
439 achint => alist_ac%clist(kac)%achint
440 bcint => alist_bc%clist(kbc)%acint
442 achint => alist_bc%clist(kbc)%achint
443 bcint => alist_ac%clist(kac)%acint
449 ALLOCATE (zblock(na, nb))
454 zblock(:, :) = matmul(conjg(achint(1:na, 1:np, 1)), transpose(bcint(1:nb, 1:np, 1)))
455 real_block(1:na, 1:nb) = real_block(1:na, 1:nb) + real(zblock, kind=
dp)
456 imag_block(1:na, 1:nb) = imag_block(1:na, 1:nb) + aimag(zblock)
481 DEALLOCATE (basis_set)
484 CALL timestop(handle)
486 END SUBROUTINE velocity_gauge_nl_term
503 POINTER :: matrix_cre, matrix_cim
504 REAL(kind=
dp),
DIMENSION(3),
INTENT(in) :: vec_pot
506 CHARACTER(len=*),
PARAMETER :: routiunen =
"velocity_gauge_nl_commutator"
508 COMPLEX(KIND=dp),
ALLOCATABLE :: zblock(:, :)
509 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER :: achint, bcint
510 INTEGER :: handle, iac, iatom, ibc, icol, idir, &
511 ikind, irow, jatom, jkind, kac, kbc, &
512 kkind, m, maxl, maxlgto, maxlppnl, na, &
513 natom, nb, nkind, np, slot
514 INTEGER,
DIMENSION(3) :: cell_b
517 REAL(kind=
dp),
DIMENSION(3) :: rab
518 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: imag_block, real_block
524 DIMENSION(:) :: basis_set
527 POINTER :: sab_orb, sap_ppnl
529 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
540 CALL timeset(routiunen, handle)
542 NULLIFY (sap_ppnl, sab_orb)
547 IF (
ASSOCIATED(sap_ppnl))
THEN
548 NULLIFY (qs_kind_set, particle_set, cell, dft_control)
550 dft_control=dft_control, &
551 qs_kind_set=qs_kind_set, &
552 particle_set=particle_set, &
554 atomic_kind_set=atomic_kind_set)
556 nkind =
SIZE(atomic_kind_set)
557 natom =
SIZE(particle_set)
558 eps_ppnl = dft_control%qs_control%eps_ppnl
565 maxl = max(maxlppnl, maxlgto)
570 ALLOCATE (sap_int(nkind*nkind))
573 ALLOCATE (basis_set(nkind))
575 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
576 IF (
ASSOCIATED(orb_basis_set))
THEN
577 basis_set(ikind)%gto_basis_set => orb_basis_set
579 NULLIFY (basis_set(ikind)%gto_basis_set)
584 CALL build_sap_exp_ints(sap_int, sap_ppnl, qs_kind_set, particle_set, &
585 cell, kvec=vec_pot, basis_set=basis_set, nkind=nkind, &
586 derivative=.false.,
moment=.true.)
609 NULLIFY (real_block, imag_block)
610 NULLIFY (achint, bcint)
614 DO slot = 1, sab_orb(1)%nl_size
615 ikind = sab_orb(1)%nlist_task(slot)%ikind
616 jkind = sab_orb(1)%nlist_task(slot)%jkind
617 iatom = sab_orb(1)%nlist_task(slot)%iatom
618 jatom = sab_orb(1)%nlist_task(slot)%jatom
619 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell
620 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
622 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
623 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
625 IF (iatom <= jatom)
THEN
635 iac = ikind + nkind*(kkind - 1)
636 ibc = jkind + nkind*(kkind - 1)
637 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist)) cycle
638 IF (.NOT.
ASSOCIATED(sap_int(ibc)%alist)) cycle
639 CALL get_alist(sap_int(iac), alist_ac, iatom)
640 CALL get_alist(sap_int(ibc), alist_bc, jatom)
641 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
642 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
643 DO kac = 1, alist_ac%nclist
644 DO kbc = 1, alist_bc%nclist
645 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
646 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
648 IF (alist_ac%clist(kac)%maxac*alist_bc%clist(kbc)%maxach < eps_ppnl) cycle
651 IF (iatom <= jatom)
THEN
652 achint => alist_ac%clist(kac)%achint
653 bcint => alist_bc%clist(kbc)%acint
655 achint => alist_bc%clist(kbc)%achint
656 bcint => alist_ac%clist(kac)%acint
662 ALLOCATE (zblock(na, nb))
670 IF (.NOT. (
ASSOCIATED(real_block) .AND.
ASSOCIATED(imag_block))) cycle
672 zblock(:, :) = matmul(conjg(achint(1:na, 1:np, 1)), transpose(bcint(1:nb, 1:np, m))) - &
673 matmul(conjg(achint(1:na, 1:np, m)), transpose(bcint(1:nb, 1:np, 1)))
674 real_block(1:na, 1:nb) = real_block(1:na, 1:nb) + real(zblock, kind=
dp)
675 imag_block(1:na, 1:nb) = imag_block(1:na, 1:nb) + aimag(zblock)
700 DEALLOCATE (basis_set)
703 CALL timestop(handle)
727 SUBROUTINE build_sap_exp_ints(sap_int, sap_ppnl, qs_kind_set, particle_set, cell, &
728 kvec, basis_set, nkind, derivative, moment)
730 INTENT(INOUT),
POINTER :: sap_int
732 INTENT(IN),
POINTER :: sap_ppnl
734 POINTER :: qs_kind_set
736 POINTER :: particle_set
737 TYPE(
cell_type),
INTENT(IN),
POINTER :: cell
738 REAL(kind=
dp),
DIMENSION(3),
INTENT(in) :: kvec
740 INTENT(IN) :: basis_set
741 INTEGER,
INTENT(IN) :: nkind
742 LOGICAL,
INTENT(IN) :: derivative
743 LOGICAL,
INTENT(IN),
OPTIONAL ::
moment
745 CHARACTER(len=*),
PARAMETER :: routiunen =
"build_sap_exp_ints"
747 COMPLEX(KIND=dp),
ALLOCATABLE :: ai_work_dz(:, :, :), ai_work_z(:, :), &
748 work_dz(:, :, :), work_z(:, :)
749 INTEGER :: handle, i, iac, iatom, idir, ikind, ilist, iset, jneighbor, katom, kkind, l, &
750 lc_max, lc_min, ldints, lppnl, maxco, maxlppnl, maxppnl, maxsgf, na, nb, ncoa, ncoc, &
751 nlist, nneighbor, np, nppnl, nprjc, nseta, nsgfa, nsl, prjc, sgfa, slot
752 INTEGER,
DIMENSION(3) :: cell_c
753 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nprj_ppnl, &
755 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
756 LOGICAL :: dogth, my_moment
757 REAL(kind=
dp) :: dac, ppnl_radius
758 REAL(kind=
dp),
DIMENSION(1) :: rprjc, zetc
759 REAL(kind=
dp),
DIMENSION(3) :: ra, rac, raf, rc, rcf
760 REAL(kind=
dp),
DIMENSION(:),
POINTER :: alpha_ppnl, set_radius_a
761 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cprj, rpgfa, sphi_a, vprj_ppnl, zeta
768 CALL timeset(routiunen, handle)
773 cpassert(.NOT. (derivative .AND. my_moment))
775 IF (derivative .OR. my_moment) nsl = 4
784 ldints = max(maxco,
ncoset(maxlppnl), maxsgf, maxppnl)
787 NULLIFY (gpotential, spotential)
788 ALLOCATE (gpotential(nkind), spotential(nkind))
790 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential, sgp_potential=sgp_potential)
791 NULLIFY (gpotential(ikind)%gth_potential)
792 NULLIFY (spotential(ikind)%sgp_potential)
793 IF (
ASSOCIATED(gth_potential))
THEN
794 gpotential(ikind)%gth_potential => gth_potential
795 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
796 spotential(ikind)%sgp_potential => sgp_potential
802 DO slot = 1, sap_ppnl(1)%nl_size
804 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
805 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
806 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
807 katom = sap_ppnl(1)%nlist_task(slot)%jatom
808 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
809 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
810 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
812 iac = ikind + nkind*(kkind - 1)
813 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
814 IF (.NOT.
ASSOCIATED(gpotential(kkind)%gth_potential) .AND. &
815 .NOT.
ASSOCIATED(spotential(kkind)%sgp_potential)) cycle
816 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist))
THEN
817 sap_int(iac)%a_kind = ikind
818 sap_int(iac)%p_kind = kkind
819 sap_int(iac)%nalist = nlist
820 ALLOCATE (sap_int(iac)%alist(nlist))
822 NULLIFY (sap_int(iac)%alist(i)%clist)
823 sap_int(iac)%alist(i)%aatom = 0
824 sap_int(iac)%alist(i)%nclist = 0
827 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist(ilist)%clist))
THEN
828 sap_int(iac)%alist(ilist)%aatom = iatom
829 sap_int(iac)%alist(ilist)%nclist = nneighbor
830 ALLOCATE (sap_int(iac)%alist(ilist)%clist(nneighbor))
832 clist => sap_int(iac)%alist(ilist)%clist(i)
834 NULLIFY (clist%acint)
835 NULLIFY (clist%achint)
836 NULLIFY (clist%sgf_list)
853 ALLOCATE (work_z(ldints, ldints), ai_work_z(maxco, maxco))
854 IF (derivative .OR. my_moment)
THEN
855 ALLOCATE (work_dz(ldints, ldints, 3), ai_work_dz(maxco, maxco, 3))
861 NULLIFY (first_sgfa, la_max, la_min, npgfa, nsgf_seta, rpgfa, set_radius_a, sphi_a, zeta)
862 NULLIFY (alpha_ppnl, cprj, nprj_ppnl, vprj_ppnl)
866 DO slot = 1, sap_ppnl(1)%nl_size
867 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
868 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
869 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
870 katom = sap_ppnl(1)%nlist_task(slot)%jatom
871 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
872 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
873 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
874 jneighbor = sap_ppnl(1)%nlist_task(slot)%inode
875 cell_c(:) = sap_ppnl(1)%nlist_task(slot)%cell(:)
876 rac(1:3) = sap_ppnl(1)%nlist_task(slot)%r(1:3)
879 iac = ikind + nkind*(kkind - 1)
880 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
882 first_sgfa => basis_set(ikind)%gto_basis_set%first_sgf
883 la_max => basis_set(ikind)%gto_basis_set%lmax
884 la_min => basis_set(ikind)%gto_basis_set%lmin
885 npgfa => basis_set(ikind)%gto_basis_set%npgf
886 nseta = basis_set(ikind)%gto_basis_set%nset
887 nsgfa = basis_set(ikind)%gto_basis_set%nsgf
888 nsgf_seta => basis_set(ikind)%gto_basis_set%nsgf_set
889 rpgfa => basis_set(ikind)%gto_basis_set%pgf_radius
890 set_radius_a => basis_set(ikind)%gto_basis_set%set_radius
891 sphi_a => basis_set(ikind)%gto_basis_set%sphi
892 zeta => basis_set(ikind)%gto_basis_set%zet
894 IF (
ASSOCIATED(gpotential(kkind)%gth_potential))
THEN
897 alpha_ppnl => gpotential(kkind)%gth_potential%alpha_ppnl
898 cprj => gpotential(kkind)%gth_potential%cprj
899 lppnl = gpotential(kkind)%gth_potential%lppnl
900 nppnl = gpotential(kkind)%gth_potential%nppnl
901 nprj_ppnl => gpotential(kkind)%gth_potential%nprj_ppnl
902 ppnl_radius = gpotential(kkind)%gth_potential%ppnl_radius
903 vprj_ppnl => gpotential(kkind)%gth_potential%vprj_ppnl
908 clist => sap_int(iac)%alist(ilist)%clist(jneighbor)
914 ALLOCATE (clist%acint(nsgfa, nppnl, nsl), clist%achint(nsgfa, nppnl, nsl))
916 clist%achint = 0.0_dp
920 ra(:) =
pbc(particle_set(iatom)%r(:), cell)
928 ncoa = npgfa(iset)*
ncoset(la_max(iset))
929 sgfa = first_sgfa(1, iset)
933 IF (derivative .OR. my_moment) work_dz = 0.0_dp
935 nprjc = nprj_ppnl(l)*
nco(l)
936 IF (nprjc == 0) cycle
937 rprjc(1) = ppnl_radius
938 IF (set_radius_a(iset) + rprjc(1) < dac) cycle
939 lc_max = l + 2*(nprj_ppnl(l) - 1)
941 zetc(1) = alpha_ppnl(l)
945 CALL expikr(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
946 lc_max, 1, zetc, rprjc, lc_min, raf, rcf, kvec, ai_work_z, dexpab=ai_work_dz)
947 ELSE IF (my_moment)
THEN
949 CALL expikr(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
950 lc_max, 1, zetc, rprjc, lc_min, raf, rcf, kvec, ai_work_z, momentab=ai_work_dz)
952 CALL expikr(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
953 lc_max, 1, zetc, rprjc, lc_min, raf, rcf, kvec, ai_work_z)
959 work_z(1:na, prjc:prjc + nb - 1) = &
960 matmul(ai_work_z(1:na, 1:np), cprj(1:np, prjc:prjc + nb - 1))
962 IF (derivative .OR. my_moment)
THEN
964 work_dz(1:na, prjc:prjc + nb - 1, idir) = &
965 matmul(ai_work_dz(1:na, 1:np, idir), cprj(1:np, prjc:prjc + nb - 1))
976 clist%acint(sgfa:sgfa + na - 1, 1:nb, 1) = &
977 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work_z(1:np, 1:nb))
978 IF (derivative .OR. my_moment)
THEN
980 clist%acint(sgfa:sgfa + na - 1, 1:nb, 1 + idir) = &
981 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work_dz(1:np, 1:nb, idir))
987 clist%achint(sgfa:sgfa + na - 1, 1:nb, idir) = &
988 matmul(clist%acint(sgfa:sgfa + na - 1, 1:nb, idir), vprj_ppnl(1:nb, 1:nb))
994 clist%maxac = maxval(max(abs(real(clist%acint(:, :, 1), kind=
dp)), abs(aimag(clist%acint(:, :, 1)))))
995 clist%maxach = maxval(max(abs(real(clist%achint(:, :, 1), kind=
dp)), abs(aimag(clist%achint(:, :, 1)))))
998 DEALLOCATE (work_z, ai_work_z)
999 IF (derivative .OR. my_moment)
DEALLOCATE (work_dz, ai_work_dz)
1003 DEALLOCATE (gpotential, spotential)
1005 CALL timestop(handle)
1007 END SUBROUTINE build_sap_exp_ints
1020 CHARACTER(len=*),
PARAMETER :: routiunen =
"velocity_gauge_nl_force"
1022 COMPLEX(KIND=dp),
ALLOCATABLE :: zblock(:, :), zblock_b(:, :)
1023 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER :: achint, acint, bchint, bcint
1024 INTEGER :: handle, i, iac, iatom, ibc, icol, idir, ikind, irow, jatom, jkind, kac, katom, &
1025 kbc, kkind, maxl, maxlgto, maxlppnl, na, natom, nb, nkind, np, slot
1026 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of
1027 INTEGER,
DIMENSION(3) :: cell_b
1028 LOGICAL :: found_imag, found_real
1029 REAL(
dp) :: eps_ppnl, f0, sign_imag
1030 REAL(kind=
dp),
DIMENSION(3) :: fa, fb, rab, vec_pot
1032 POINTER :: sab_orb, sap_ppnl
1035 DIMENSION(:) :: basis_set
1037 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao, rho_ao_im
1041 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: matrix_p_imag, matrix_p_real
1042 REAL(kind=
dp),
DIMENSION(3, SIZE(particle_set)) :: force_thread
1044 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1048 CALL timeset(routiunen, handle)
1055 IF (
ASSOCIATED(sap_ppnl))
THEN
1056 NULLIFY (qs_kind_set, cell, dft_control, force, sab_orb, atomic_kind_set, &
1063 dft_control=dft_control, &
1064 qs_kind_set=qs_kind_set, &
1066 atomic_kind_set=atomic_kind_set, &
1069 nkind =
SIZE(atomic_kind_set)
1070 natom =
SIZE(particle_set)
1071 eps_ppnl = dft_control%qs_control%eps_ppnl
1077 maxl = max(maxlppnl, maxlgto)
1081 ALLOCATE (sap_int(nkind*nkind))
1084 ALLOCATE (basis_set(nkind))
1086 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1087 IF (
ASSOCIATED(orb_basis_set))
THEN
1088 basis_set(ikind)%gto_basis_set => orb_basis_set
1090 NULLIFY (basis_set(ikind)%gto_basis_set)
1095 vec_pot = dft_control%rtp_control%vec_pot
1097 force_thread = 0.0_dp
1099 CALL qs_rho_get(rho_struct=rho, rho_ao=rho_ao, rho_ao_im=rho_ao_im)
1101 IF (
SIZE(rho_ao) == 2)
THEN
1102 CALL dbcsr_add(rho_ao(1)%matrix, rho_ao(2)%matrix, &
1103 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
1104 CALL dbcsr_add(rho_ao_im(1)%matrix, rho_ao_im(2)%matrix, &
1105 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
1109 CALL build_sap_exp_ints(sap_int, sap_ppnl, qs_kind_set, particle_set, &
1110 cell, kvec=vec_pot, basis_set=basis_set, nkind=nkind, derivative=.true.)
1126 NULLIFY (acint, bcint, achint, bchint)
1130 DO slot = 1, sab_orb(1)%nl_size
1131 ikind = sab_orb(1)%nlist_task(slot)%ikind
1132 jkind = sab_orb(1)%nlist_task(slot)%jkind
1133 iatom = sab_orb(1)%nlist_task(slot)%iatom
1134 jatom = sab_orb(1)%nlist_task(slot)%jatom
1135 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell
1136 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
1138 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
1139 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
1142 IF (iatom == jatom)
THEN
1151 IF (iatom <= jatom)
THEN
1160 NULLIFY (matrix_p_real, matrix_p_imag)
1162 CALL dbcsr_get_block_p(rho_ao_im(1)%matrix, irow, icol, matrix_p_imag, found_imag)
1164 IF (found_real .OR. found_imag)
THEN
1167 iac = ikind + nkind*(kkind - 1)
1168 ibc = jkind + nkind*(kkind - 1)
1169 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist)) cycle
1170 IF (.NOT.
ASSOCIATED(sap_int(ibc)%alist)) cycle
1171 CALL get_alist(sap_int(iac), alist_ac, iatom)
1172 CALL get_alist(sap_int(ibc), alist_bc, jatom)
1173 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
1174 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
1175 DO kac = 1, alist_ac%nclist
1176 DO kbc = 1, alist_bc%nclist
1177 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
1178 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
1180 IF (alist_ac%clist(kac)%maxac*alist_bc%clist(kbc)%maxach < eps_ppnl) cycle
1182 acint => alist_ac%clist(kac)%acint
1183 bcint => alist_bc%clist(kbc)%acint
1184 achint => alist_ac%clist(kac)%achint
1185 bchint => alist_bc%clist(kbc)%achint
1191 katom = alist_ac%clist(kac)%catom
1192 ALLOCATE (zblock(merge(na, nb, iatom <= jatom), merge(nb, na, iatom <= jatom)))
1193 ALLOCATE (zblock_b(
SIZE(zblock, 1),
SIZE(zblock, 2)))
1195 IF (iatom <= jatom)
THEN
1196 zblock(:, :) = matmul(acint(1:na, 1:np, 1 + idir), &
1197 conjg(transpose(bchint(1:nb, 1:np, 1))))
1198 zblock_b(:, :) = matmul(achint(1:na, 1:np, 1), &
1199 conjg(transpose(bcint(1:nb, 1:np, 1 + idir))))
1201 zblock(:, :) = matmul(bchint(1:nb, 1:np, 1), &
1202 conjg(transpose(acint(1:na, 1:np, 1 + idir))))
1203 zblock_b(:, :) = matmul(bcint(1:nb, 1:np, 1 + idir), &
1204 conjg(transpose(achint(1:na, 1:np, 1))))
1208 IF (found_real)
THEN
1209 fa(idir) = sum(matrix_p_real(1:
SIZE(zblock, 1), 1:
SIZE(zblock, 2))*real(zblock, kind=
dp))
1210 fb(idir) = sum(matrix_p_real(1:
SIZE(zblock_b, 1), 1:
SIZE(zblock_b, 2))*real(zblock_b, kind=
dp))
1212 IF (found_imag)
THEN
1213 fa(idir) = fa(idir) - sign_imag*sum(matrix_p_imag(1:
SIZE(zblock, 1), 1:
SIZE(zblock, 2))*aimag(zblock))
1214 fb(idir) = fb(idir) - sign_imag*sum(matrix_p_imag(1:
SIZE(zblock_b, 1), 1:
SIZE(zblock_b, 2))*aimag(zblock_b))
1216 force_thread(idir, iatom) = force_thread(idir, iatom) + f0*fa(idir)
1217 force_thread(idir, katom) = force_thread(idir, katom) - f0*fa(idir)
1218 force_thread(idir, jatom) = force_thread(idir, jatom) + f0*fb(idir)
1219 force_thread(idir, katom) = force_thread(idir, katom) - f0*fb(idir)
1221 DEALLOCATE (zblock, zblock_b)
1237 i = atom_of_kind(iatom)
1238 ikind = kind_of(iatom)
1239 force(ikind)%gth_ppnl(:, i) = force(ikind)%gth_ppnl(:, i) + force_thread(:, iatom)
1244 IF (
SIZE(rho_ao) == 2)
THEN
1245 CALL dbcsr_add(rho_ao(1)%matrix, rho_ao(2)%matrix, &
1246 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
1247 CALL dbcsr_add(rho_ao_im(1)%matrix, rho_ao_im(2)%matrix, &
1248 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
1252 DEALLOCATE (basis_set, atom_of_kind, kind_of)
1256 CALL timestop(handle)
Calculation of the moment integrals over Cartesian Gaussian-type functions.
subroutine, public moment(la_max, npgfa, zeta, rpgfa, la_min, lb_max, npgfb, zetb, rpgfb, lc_max, rac, rbc, mab, overlap)
...
subroutine, public expikr(la_max_set, npgfa, zeta, rpgfa, la_min_set, lb_max, npgfb, zetb, rpgfb, lb_min, rac, rbc, kvec, expab, dexpab, dexpba, momentab)
Evaluate primitive exp(i k.r) integrals through the complex overlap recurrence.
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public mattiat2022
Handles all functions related to the CELL.
Calculation of the non-local pseudopotential contribution to the core Hamiltonian <a|V(non-local)|b> ...
subroutine, public build_core_ppnl(matrix_h, matrix_p, force, virial, calculate_forces, use_virial, nder, qs_kind_set, atomic_kind_set, particle_set, sab_orb, sap_ppnl, eps_ppnl, nimages, cell_to_index, basis_type, deltar, matrix_l, atcore)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
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.
all routins needed for a nonperiodic electric field
subroutine, public make_field(dft_control, field, sim_step, sim_time)
computes the amplitude of the efield within a given envelop
Definition of the atomic potential types.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, lattice_fft)
Retrieve information from a kpoint environment.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public one
real(kind=dp), parameter, public zero
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public ncoset
Define the data structure for the particle information.
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.
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
Define the neighbor list data types and the corresponding functionality.
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...
Routines to perform the RTP in the velocity gauge.
subroutine, public velocity_gauge_nl_force(qs_env, particle_set)
Calculate the force associated to non-local pseudo potential in the velocity gauge.
subroutine, public velocity_gauge_nl_commutator(qs_env, matrix_cre, matrix_cim, vec_pot)
Calculate the commutator [Vnl~, r_d] (d=x,y,z) of the gauge-transformed nonlocal pseudopotential with...
subroutine, public velocity_gauge_ks_matrix(qs_env, subtract_nl_term)
...
subroutine, public update_vector_potential(qs_env, dft_control)
Update the vector potential in the case where a time-dependant electric field is apply.
General overlap type integrals containers.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Contains information about kpoints.
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.