30 dbcsr_type_antisymmetric,&
76#include "./base/base_uses.f90"
82 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rt_propagation_velocity_gauge'
96 LOGICAL,
INTENT(IN),
OPTIONAL :: subtract_nl_term
98 CHARACTER(len=*),
PARAMETER :: routinen =
'velocity_gauge_ks_matrix'
100 INTEGER :: handle, idir, image, nder, nimages
101 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
102 LOGICAL :: calculate_forces, my_subtract_nl_term, &
103 ppnl_present, use_virial
104 REAL(kind=
dp) :: eps_ppnl, factor
105 REAL(kind=
dp),
DIMENSION(3) :: vec_pot
108 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: momentum, nl_term
109 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_h, matrix_h_im, matrix_nl, &
114 POINTER :: sab_orb, sap_ppnl
117 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
123 CALL timeset(routinen, handle)
127 my_subtract_nl_term = .false.
128 IF (
PRESENT(subtract_nl_term)) my_subtract_nl_term = subtract_nl_term
130 NULLIFY (dft_control, matrix_s, sab_orb, matrix_h, cell, input, matrix_h_im, kpoints, cell_to_index, &
131 sap_ppnl, particle_set, qs_kind_set, atomic_kind_set, virial, force, matrix_p, rho, matrix_nl)
135 dft_control=dft_control, &
138 matrix_s_kp=matrix_s, &
139 matrix_h_kp=matrix_h, &
142 matrix_h_im_kp=matrix_h_im)
144 nimages = dft_control%nimages
145 ppnl_present =
ASSOCIATED(sap_ppnl)
147 IF (nimages > 1)
THEN
148 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
152 IF (my_subtract_nl_term)
THEN
153 IF (ppnl_present)
THEN
155 qs_kind_set=qs_kind_set, &
156 particle_set=particle_set, &
157 atomic_kind_set=atomic_kind_set, &
163 calculate_forces = .false.
166 eps_ppnl = dft_control%qs_control%eps_ppnl
169 DO image = 1, nimages
170 ALLOCATE (matrix_nl(1, image)%matrix)
171 CALL dbcsr_create(matrix_nl(1, image)%matrix, template=matrix_s(1, 1)%matrix)
176 CALL build_core_ppnl(matrix_nl, matrix_p, force, virial, calculate_forces, use_virial, nder, &
177 qs_kind_set, atomic_kind_set, particle_set, sab_orb, sap_ppnl, eps_ppnl, &
178 nimages, cell_to_index,
"ORB")
180 DO image = 1, nimages
181 CALL dbcsr_add(matrix_h(1, image)%matrix, matrix_nl(1, image)%matrix,
one, -
one)
189 vec_pot = dft_control%rtp_control%vec_pot
196 CALL dbcsr_create(momentum(idir)%matrix, template=matrix_s(1, 1)%matrix, &
197 matrix_type=dbcsr_type_antisymmetric)
204 DO image = 1, nimages
209 DO image = 1, nimages
211 CALL dbcsr_add(matrix_h_im(1, image)%matrix, momentum(idir)%matrix,
one, -vec_pot(idir))
220 factor = factor + vec_pot(idir)**2
223 DO image = 1, nimages
224 CALL dbcsr_add(matrix_h(1, image)%matrix, matrix_s(1, image)%matrix,
one, 0.5*factor)
228 IF (ppnl_present)
THEN
229 IF (dft_control%rtp_control%nl_gauge_transform)
THEN
234 CALL dbcsr_create(nl_term(1)%matrix, template=matrix_s(1, 1)%matrix, &
235 matrix_type=dbcsr_type_symmetric, name=
"nl gauge term real part")
240 CALL dbcsr_create(nl_term(2)%matrix, template=matrix_s(1, 1)%matrix, &
241 matrix_type=dbcsr_type_antisymmetric, name=
"nl gauge term imaginary part")
245 CALL velocity_gauge_nl_term(qs_env, nl_term, vec_pot)
247 DO image = 1, nimages
249 CALL dbcsr_add(matrix_h_im(1, image)%matrix, nl_term(2)%matrix,
one,
one)
255 CALL timestop(handle)
269 REAL(kind=
dp) :: field(3)
271 CALL make_field(dft_control, field, qs_env%sim_step, qs_env%sim_time)
272 dft_control%rtp_control%field = field
273 dft_control%rtp_control%vec_pot = dft_control%rtp_control%vec_pot - field*qs_env%rtp%dt
275 dft_control%efield_fields(1)%efield%vec_pot_initial = dft_control%rtp_control%vec_pot
285 SUBROUTINE velocity_gauge_nl_term(qs_env, nl_term, vec_pot)
289 REAL(kind=
dp),
DIMENSION(3),
INTENT(in) :: vec_pot
291 CHARACTER(len=*),
PARAMETER :: routiunen =
"velocity_gauge_nl_term"
293 INTEGER :: handle, i, iac, iatom, ibc, icol, ikind, &
294 irow, jatom, jkind, kac, kbc, kkind, &
295 maxl, maxlgto, maxlppnl, na, natom, &
297 INTEGER,
DIMENSION(3) :: cell_b
300 REAL(kind=
dp),
DIMENSION(3) :: rab
301 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: imag_block, real_block
302 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: achint_cos, achint_sin, acint_cos, &
303 acint_sin, bchint_cos, bchint_sin, &
305 TYPE(
alist_type),
POINTER :: alist_cos_ac, alist_cos_bc, &
306 alist_sin_ac, alist_sin_bc
311 DIMENSION(:) :: basis_set
314 POINTER :: sab_orb, sap_ppnl
316 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
317 TYPE(
sap_int_type),
DIMENSION(:),
POINTER :: sap_int_cos, sap_int_sin
327 CALL timeset(routiunen, handle)
329 NULLIFY (sap_ppnl, sab_orb)
334 IF (
ASSOCIATED(sap_ppnl))
THEN
335 NULLIFY (qs_kind_set, particle_set, cell, dft_control)
337 dft_control=dft_control, &
338 qs_kind_set=qs_kind_set, &
339 particle_set=particle_set, &
341 atomic_kind_set=atomic_kind_set)
343 nkind =
SIZE(atomic_kind_set)
344 natom =
SIZE(particle_set)
345 eps_ppnl = dft_control%qs_control%eps_ppnl
351 maxl = max(maxlppnl, maxlgto)
355 NULLIFY (sap_int_cos, sap_int_sin)
356 ALLOCATE (sap_int_cos(nkind*nkind), sap_int_sin(nkind*nkind))
357 DO i = 1,
SIZE(sap_int_cos)
358 NULLIFY (sap_int_cos(i)%alist, sap_int_cos(i)%asort, sap_int_cos(i)%aindex)
359 sap_int_cos(i)%nalist = 0
360 NULLIFY (sap_int_sin(i)%alist, sap_int_sin(i)%asort, sap_int_sin(i)%aindex)
361 sap_int_sin(i)%nalist = 0
365 ALLOCATE (basis_set(nkind))
367 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
368 IF (
ASSOCIATED(orb_basis_set))
THEN
369 basis_set(ikind)%gto_basis_set => orb_basis_set
371 NULLIFY (basis_set(ikind)%gto_basis_set)
376 CALL build_sap_exp_ints(sap_int_cos, sap_int_sin, sap_ppnl, qs_kind_set, particle_set, &
377 cell, kvec=vec_pot, basis_set=basis_set, nkind=nkind, &
402 NULLIFY (real_block, imag_block)
403 NULLIFY (acint_cos, bcint_cos, achint_cos, bchint_cos)
404 NULLIFY (acint_sin, bcint_sin, achint_sin, bchint_sin)
408 DO slot = 1, sab_orb(1)%nl_size
409 ikind = sab_orb(1)%nlist_task(slot)%ikind
410 jkind = sab_orb(1)%nlist_task(slot)%jkind
411 iatom = sab_orb(1)%nlist_task(slot)%iatom
412 jatom = sab_orb(1)%nlist_task(slot)%jatom
413 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell
414 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
416 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
417 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
419 IF (iatom <= jatom)
THEN
430 IF (
ASSOCIATED(real_block) .AND.
ASSOCIATED(imag_block))
THEN
433 iac = ikind + nkind*(kkind - 1)
434 ibc = jkind + nkind*(kkind - 1)
435 IF (.NOT.
ASSOCIATED(sap_int_cos(iac)%alist)) cycle
436 IF (.NOT.
ASSOCIATED(sap_int_cos(ibc)%alist)) cycle
437 IF (.NOT.
ASSOCIATED(sap_int_sin(iac)%alist)) cycle
438 IF (.NOT.
ASSOCIATED(sap_int_sin(ibc)%alist)) cycle
439 CALL get_alist(sap_int_cos(iac), alist_cos_ac, iatom)
440 CALL get_alist(sap_int_cos(ibc), alist_cos_bc, jatom)
441 CALL get_alist(sap_int_sin(iac), alist_sin_ac, iatom)
442 CALL get_alist(sap_int_sin(ibc), alist_sin_bc, jatom)
443 IF (.NOT.
ASSOCIATED(alist_cos_ac)) cycle
444 IF (.NOT.
ASSOCIATED(alist_cos_bc)) cycle
445 IF (.NOT.
ASSOCIATED(alist_sin_ac)) cycle
446 IF (.NOT.
ASSOCIATED(alist_sin_bc)) cycle
450 DO kac = 1, alist_cos_ac%nclist
451 DO kbc = 1, alist_cos_bc%nclist
453 IF (alist_cos_ac%clist(kac)%catom /= alist_cos_bc%clist(kbc)%catom) cycle
454 IF (all(cell_b + alist_cos_bc%clist(kbc)%cell - alist_cos_ac%clist(kac)%cell == 0))
THEN
456 IF (alist_cos_ac%clist(kac)%maxac*alist_cos_bc%clist(kbc)%maxach < eps_ppnl &
457 .AND. alist_cos_ac%clist(kac)%maxac*alist_sin_bc%clist(kbc)%maxach < eps_ppnl &
458 .AND. alist_sin_ac%clist(kac)%maxac*alist_cos_bc%clist(kbc)%maxach < eps_ppnl &
459 .AND. alist_sin_ac%clist(kac)%maxac*alist_sin_bc%clist(kbc)%maxach < eps_ppnl) cycle
461 acint_cos => alist_cos_ac%clist(kac)%acint
462 bcint_cos => alist_cos_bc%clist(kbc)%acint
463 achint_cos => alist_cos_ac%clist(kac)%achint
464 bchint_cos => alist_cos_bc%clist(kbc)%achint
465 acint_sin => alist_sin_ac%clist(kac)%acint
466 bcint_sin => alist_sin_bc%clist(kbc)%acint
467 achint_sin => alist_sin_ac%clist(kac)%achint
468 bchint_sin => alist_sin_bc%clist(kbc)%achint
470 na =
SIZE(acint_cos, 1)
471 np =
SIZE(acint_cos, 2)
472 nb =
SIZE(bcint_cos, 1)
476 IF (iatom <= jatom)
THEN
478 real_block(1:na, 1:nb) = real_block(1:na, 1:nb) + &
479 matmul(achint_cos(1:na, 1:np, 1), transpose(bcint_cos(1:nb, 1:np, 1))) + &
480 matmul(achint_sin(1:na, 1:np, 1), transpose(bcint_sin(1:nb, 1:np, 1)))
482 imag_block(1:na, 1:nb) = imag_block(1:na, 1:nb) - &
483 matmul(achint_sin(1:na, 1:np, 1), transpose(bcint_cos(1:nb, 1:np, 1))) + &
484 matmul(achint_cos(1:na, 1:np, 1), transpose(bcint_sin(1:nb, 1:np, 1)))
487 real_block(1:nb, 1:na) = real_block(1:nb, 1:na) + &
488 matmul(bchint_cos(1:nb, 1:np, 1), transpose(acint_cos(1:na, 1:np, 1))) + &
489 matmul(bchint_sin(1:nb, 1:np, 1), transpose(acint_sin(1:na, 1:np, 1)))
491 imag_block(1:nb, 1:na) = imag_block(1:nb, 1:na) - &
492 matmul(bchint_sin(1:nb, 1:np, 1), transpose(acint_cos(1:na, 1:np, 1))) + &
493 matmul(bchint_cos(1:nb, 1:np, 1), transpose(acint_sin(1:na, 1:np, 1)))
520 DEALLOCATE (basis_set)
523 CALL timestop(handle)
525 END SUBROUTINE velocity_gauge_nl_term
542 POINTER :: matrix_cre, matrix_cim
543 REAL(kind=
dp),
DIMENSION(3),
INTENT(in) :: vec_pot
545 CHARACTER(len=*),
PARAMETER :: routiunen =
"velocity_gauge_nl_commutator"
547 INTEGER :: handle, i, iac, iatom, ibc, icol, idir, &
548 ikind, irow, jatom, jkind, kac, kbc, &
549 kkind, m, maxl, maxlgto, maxlppnl, na, &
550 natom, nb, nkind, np, slot
551 INTEGER,
DIMENSION(3) :: cell_b
554 REAL(kind=
dp),
DIMENSION(3) :: rab
555 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: imag_block, real_block
556 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: achint_cos, achint_sin, acint_cos, &
557 acint_sin, bchint_cos, bchint_sin, &
559 TYPE(
alist_type),
POINTER :: alist_cos_ac, alist_cos_bc, &
560 alist_sin_ac, alist_sin_bc
565 DIMENSION(:) :: basis_set
568 POINTER :: sab_orb, sap_ppnl
570 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
571 TYPE(
sap_int_type),
DIMENSION(:),
POINTER :: sap_int_cos, sap_int_sin
581 CALL timeset(routiunen, handle)
583 NULLIFY (sap_ppnl, sab_orb)
588 IF (
ASSOCIATED(sap_ppnl))
THEN
589 NULLIFY (qs_kind_set, particle_set, cell, dft_control)
591 dft_control=dft_control, &
592 qs_kind_set=qs_kind_set, &
593 particle_set=particle_set, &
595 atomic_kind_set=atomic_kind_set)
597 nkind =
SIZE(atomic_kind_set)
598 natom =
SIZE(particle_set)
599 eps_ppnl = dft_control%qs_control%eps_ppnl
607 maxl = max(maxlppnl, maxlgto)
611 NULLIFY (sap_int_cos, sap_int_sin)
612 ALLOCATE (sap_int_cos(nkind*nkind), sap_int_sin(nkind*nkind))
613 DO i = 1,
SIZE(sap_int_cos)
614 NULLIFY (sap_int_cos(i)%alist, sap_int_cos(i)%asort, sap_int_cos(i)%aindex)
615 sap_int_cos(i)%nalist = 0
616 NULLIFY (sap_int_sin(i)%alist, sap_int_sin(i)%asort, sap_int_sin(i)%aindex)
617 sap_int_sin(i)%nalist = 0
621 ALLOCATE (basis_set(nkind))
623 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
624 IF (
ASSOCIATED(orb_basis_set))
THEN
625 basis_set(ikind)%gto_basis_set => orb_basis_set
627 NULLIFY (basis_set(ikind)%gto_basis_set)
632 CALL build_sap_exp_ints(sap_int_cos, sap_int_sin, sap_ppnl, qs_kind_set, particle_set, &
633 cell, kvec=vec_pot, basis_set=basis_set, nkind=nkind, &
634 derivative=.false.,
moment=.true.)
658 NULLIFY (real_block, imag_block)
659 NULLIFY (acint_cos, bcint_cos, achint_cos, bchint_cos)
660 NULLIFY (acint_sin, bcint_sin, achint_sin, bchint_sin)
664 DO slot = 1, sab_orb(1)%nl_size
665 ikind = sab_orb(1)%nlist_task(slot)%ikind
666 jkind = sab_orb(1)%nlist_task(slot)%jkind
667 iatom = sab_orb(1)%nlist_task(slot)%iatom
668 jatom = sab_orb(1)%nlist_task(slot)%jatom
669 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell
670 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
672 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
673 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
675 IF (iatom <= jatom)
THEN
685 iac = ikind + nkind*(kkind - 1)
686 ibc = jkind + nkind*(kkind - 1)
687 IF (.NOT.
ASSOCIATED(sap_int_cos(iac)%alist)) cycle
688 IF (.NOT.
ASSOCIATED(sap_int_cos(ibc)%alist)) cycle
689 IF (.NOT.
ASSOCIATED(sap_int_sin(iac)%alist)) cycle
690 IF (.NOT.
ASSOCIATED(sap_int_sin(ibc)%alist)) cycle
691 CALL get_alist(sap_int_cos(iac), alist_cos_ac, iatom)
692 CALL get_alist(sap_int_cos(ibc), alist_cos_bc, jatom)
693 CALL get_alist(sap_int_sin(iac), alist_sin_ac, iatom)
694 CALL get_alist(sap_int_sin(ibc), alist_sin_bc, jatom)
695 IF (.NOT.
ASSOCIATED(alist_cos_ac)) cycle
696 IF (.NOT.
ASSOCIATED(alist_cos_bc)) cycle
697 IF (.NOT.
ASSOCIATED(alist_sin_ac)) cycle
698 IF (.NOT.
ASSOCIATED(alist_sin_bc)) cycle
702 DO kac = 1, alist_cos_ac%nclist
703 DO kbc = 1, alist_cos_bc%nclist
705 IF (alist_cos_ac%clist(kac)%catom /= alist_cos_bc%clist(kbc)%catom) cycle
706 IF (all(cell_b + alist_cos_bc%clist(kbc)%cell - alist_cos_ac%clist(kac)%cell == 0))
THEN
708 IF (alist_cos_ac%clist(kac)%maxac*alist_cos_bc%clist(kbc)%maxach < eps_ppnl &
709 .AND. alist_cos_ac%clist(kac)%maxac*alist_sin_bc%clist(kbc)%maxach < eps_ppnl &
710 .AND. alist_sin_ac%clist(kac)%maxac*alist_cos_bc%clist(kbc)%maxach < eps_ppnl &
711 .AND. alist_sin_ac%clist(kac)%maxac*alist_sin_bc%clist(kbc)%maxach < eps_ppnl) cycle
713 acint_cos => alist_cos_ac%clist(kac)%acint
714 bcint_cos => alist_cos_bc%clist(kbc)%acint
715 achint_cos => alist_cos_ac%clist(kac)%achint
716 bchint_cos => alist_cos_bc%clist(kbc)%achint
717 acint_sin => alist_sin_ac%clist(kac)%acint
718 bcint_sin => alist_sin_bc%clist(kbc)%acint
719 achint_sin => alist_sin_ac%clist(kac)%achint
720 bchint_sin => alist_sin_bc%clist(kbc)%achint
722 na =
SIZE(acint_cos, 1)
723 np =
SIZE(acint_cos, 2)
724 nb =
SIZE(bcint_cos, 1)
732 IF (.NOT. (
ASSOCIATED(real_block) .AND.
ASSOCIATED(imag_block))) cycle
733 IF (iatom <= jatom)
THEN
735 real_block(1:na, 1:nb) = real_block(1:na, 1:nb) + &
736 matmul(achint_cos(1:na, 1:np, 1), transpose(bcint_cos(1:nb, 1:np, m))) + &
737 matmul(achint_sin(1:na, 1:np, 1), transpose(bcint_sin(1:nb, 1:np, m))) - &
738 matmul(achint_cos(1:na, 1:np, m), transpose(bcint_cos(1:nb, 1:np, 1))) - &
739 matmul(achint_sin(1:na, 1:np, m), transpose(bcint_sin(1:nb, 1:np, 1)))
740 imag_block(1:na, 1:nb) = imag_block(1:na, 1:nb) + &
741 matmul(achint_cos(1:na, 1:np, 1), transpose(bcint_sin(1:nb, 1:np, m))) - &
742 matmul(achint_sin(1:na, 1:np, 1), transpose(bcint_cos(1:nb, 1:np, m))) - &
743 matmul(achint_cos(1:na, 1:np, m), transpose(bcint_sin(1:nb, 1:np, 1))) + &
744 matmul(achint_sin(1:na, 1:np, m), transpose(bcint_cos(1:nb, 1:np, 1)))
747 real_block(1:nb, 1:na) = real_block(1:nb, 1:na) + &
748 matmul(bchint_cos(1:nb, 1:np, 1), transpose(acint_cos(1:na, 1:np, m))) + &
749 matmul(bchint_sin(1:nb, 1:np, 1), transpose(acint_sin(1:na, 1:np, m))) - &
750 matmul(bchint_cos(1:nb, 1:np, m), transpose(acint_cos(1:na, 1:np, 1))) - &
751 matmul(bchint_sin(1:nb, 1:np, m), transpose(acint_sin(1:na, 1:np, 1)))
752 imag_block(1:nb, 1:na) = imag_block(1:nb, 1:na) + &
753 matmul(bchint_cos(1:nb, 1:np, 1), transpose(acint_sin(1:na, 1:np, m))) - &
754 matmul(bchint_sin(1:nb, 1:np, 1), transpose(acint_cos(1:na, 1:np, m))) - &
755 matmul(bchint_cos(1:nb, 1:np, m), transpose(acint_sin(1:na, 1:np, 1))) + &
756 matmul(bchint_sin(1:nb, 1:np, m), transpose(acint_cos(1:na, 1:np, 1)))
782 DEALLOCATE (basis_set)
785 CALL timestop(handle)
810 SUBROUTINE build_sap_exp_ints(sap_int_cos, sap_int_sin, sap_ppnl, qs_kind_set, particle_set, cell, &
811 kvec, basis_set, nkind, derivative, moment)
813 POINTER :: sap_int_cos, sap_int_sin
815 INTENT(IN),
POINTER :: sap_ppnl
817 POINTER :: qs_kind_set
819 POINTER :: particle_set
820 TYPE(
cell_type),
INTENT(IN),
POINTER :: cell
821 REAL(kind=
dp),
DIMENSION(3),
INTENT(in) :: kvec
823 INTENT(IN) :: basis_set
824 INTEGER,
INTENT(IN) :: nkind
825 LOGICAL,
INTENT(IN) :: derivative
826 LOGICAL,
INTENT(IN),
OPTIONAL ::
moment
828 CHARACTER(len=*),
PARAMETER :: routiunen =
"build_sap_exp_ints"
830 INTEGER :: ax, ay, az,
co, cox, coy, coz, handle, i, iac, iatom, idir, ikind, ilist, iob, &
831 ioe, ipgf, iset, jneighbor, katom, kkind, l, la, lc_max, lc_min, ldai, ldax, ldints, &
832 lppnl, maxco, maxl, maxlgto, maxlppnl, maxppnl, maxsgf, na, nb, nco_b, nco_e, ncoa, ncoc, &
833 nlist, nneighbor, np, nppnl, nprjc, nseta, nsgfa, nsl, prjc, sgfa, slot
834 INTEGER,
DIMENSION(3) :: cell_c
835 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nprj_ppnl, &
837 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
838 LOGICAL :: dogth, my_moment
839 REAL(kind=
dp) :: dac, ppnl_radius
840 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ai_work_cos, ai_work_mcos, ai_work_msin, &
841 ai_work_sin, work_cos, work_sin
842 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ai_work_dcos, ai_work_dsin, work_dcos, &
844 REAL(kind=
dp),
DIMENSION(1) :: rprjc, zetc
845 REAL(kind=
dp),
DIMENSION(3) :: ra, rac, raf, rc, rcf
846 REAL(kind=
dp),
DIMENSION(:),
POINTER :: alpha_ppnl, set_radius_a
847 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cprj, rpgfa, sphi_a, vprj_ppnl, zeta
854 CALL timeset(routiunen, handle)
859 cpassert(.NOT. (derivative .AND. my_moment))
861 IF (derivative .OR. my_moment) nsl = 4
871 maxl = max(maxlppnl, maxlgto)
872 ldints = max(maxco,
ncoset(maxlppnl), maxsgf, maxppnl)
878 DO i = 1,
SIZE(basis_set)
879 IF (.NOT.
ASSOCIATED(basis_set(i)%gto_basis_set)) cycle
880 DO iset = 1, basis_set(i)%gto_basis_set%nset
881 ldax = max(ldax, basis_set(i)%gto_basis_set%npgf(iset)* &
882 ncoset(basis_set(i)%gto_basis_set%lmax(iset) + 1))
888 NULLIFY (gpotential, spotential)
889 ALLOCATE (gpotential(nkind), spotential(nkind))
891 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential, sgp_potential=sgp_potential)
892 NULLIFY (gpotential(ikind)%gth_potential)
893 NULLIFY (spotential(ikind)%sgp_potential)
894 IF (
ASSOCIATED(gth_potential))
THEN
895 gpotential(ikind)%gth_potential => gth_potential
896 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
897 spotential(ikind)%sgp_potential => sgp_potential
903 DO slot = 1, sap_ppnl(1)%nl_size
905 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
906 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
907 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
908 katom = sap_ppnl(1)%nlist_task(slot)%jatom
909 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
910 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
911 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
913 iac = ikind + nkind*(kkind - 1)
914 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
915 IF (.NOT.
ASSOCIATED(gpotential(kkind)%gth_potential) .AND. &
916 .NOT.
ASSOCIATED(spotential(kkind)%sgp_potential)) cycle
917 IF (.NOT.
ASSOCIATED(sap_int_cos(iac)%alist))
THEN
918 sap_int_cos(iac)%a_kind = ikind
919 sap_int_cos(iac)%p_kind = kkind
920 sap_int_cos(iac)%nalist = nlist
921 ALLOCATE (sap_int_cos(iac)%alist(nlist))
923 NULLIFY (sap_int_cos(iac)%alist(i)%clist)
924 sap_int_cos(iac)%alist(i)%aatom = 0
925 sap_int_cos(iac)%alist(i)%nclist = 0
928 IF (.NOT.
ASSOCIATED(sap_int_cos(iac)%alist(ilist)%clist))
THEN
929 sap_int_cos(iac)%alist(ilist)%aatom = iatom
930 sap_int_cos(iac)%alist(ilist)%nclist = nneighbor
931 ALLOCATE (sap_int_cos(iac)%alist(ilist)%clist(nneighbor))
933 clist => sap_int_cos(iac)%alist(ilist)%clist(i)
935 NULLIFY (clist%acint)
936 NULLIFY (clist%achint)
937 NULLIFY (clist%sgf_list)
940 IF (.NOT.
ASSOCIATED(sap_int_sin(iac)%alist))
THEN
941 sap_int_sin(iac)%a_kind = ikind
942 sap_int_sin(iac)%p_kind = kkind
943 sap_int_sin(iac)%nalist = nlist
944 ALLOCATE (sap_int_sin(iac)%alist(nlist))
946 NULLIFY (sap_int_sin(iac)%alist(i)%clist)
947 sap_int_sin(iac)%alist(i)%aatom = 0
948 sap_int_sin(iac)%alist(i)%nclist = 0
951 IF (.NOT.
ASSOCIATED(sap_int_sin(iac)%alist(ilist)%clist))
THEN
952 sap_int_sin(iac)%alist(ilist)%aatom = iatom
953 sap_int_sin(iac)%alist(ilist)%nclist = nneighbor
954 ALLOCATE (sap_int_sin(iac)%alist(ilist)%clist(nneighbor))
956 clist => sap_int_sin(iac)%alist(ilist)%clist(i)
958 NULLIFY (clist%acint)
959 NULLIFY (clist%achint)
960 NULLIFY (clist%sgf_list)
980 ALLOCATE (work_cos(ldints, ldints), work_sin(ldints, ldints))
981 ALLOCATE (ai_work_cos(maxco, maxco), ai_work_sin(maxco, maxco))
982 IF (derivative .OR. my_moment)
THEN
983 ALLOCATE (work_dcos(ldints, ldints, 3), work_dsin(ldints, ldints, 3))
984 ALLOCATE (ai_work_dcos(maxco, maxco, 3), ai_work_dsin(maxco, maxco, 3))
987 ALLOCATE (ai_work_mcos(ldax, maxco), ai_work_msin(ldax, maxco))
988 ai_work_mcos = 0.0_dp
989 ai_work_msin = 0.0_dp
995 IF (derivative .OR. my_moment)
THEN
996 ai_work_dcos = 0.0_dp
997 ai_work_dsin = 0.0_dp
1001 NULLIFY (first_sgfa, la_max, la_min, npgfa, nsgf_seta, rpgfa, set_radius_a, sphi_a, zeta)
1002 NULLIFY (alpha_ppnl, cprj, nprj_ppnl, vprj_ppnl)
1003 NULLIFY (clist, clist_sin)
1006 DO slot = 1, sap_ppnl(1)%nl_size
1007 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
1008 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
1009 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
1010 katom = sap_ppnl(1)%nlist_task(slot)%jatom
1011 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
1012 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
1013 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
1014 jneighbor = sap_ppnl(1)%nlist_task(slot)%inode
1015 cell_c(:) = sap_ppnl(1)%nlist_task(slot)%cell(:)
1016 rac(1:3) = sap_ppnl(1)%nlist_task(slot)%r(1:3)
1019 iac = ikind + nkind*(kkind - 1)
1020 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
1022 first_sgfa => basis_set(ikind)%gto_basis_set%first_sgf
1023 la_max => basis_set(ikind)%gto_basis_set%lmax
1024 la_min => basis_set(ikind)%gto_basis_set%lmin
1025 npgfa => basis_set(ikind)%gto_basis_set%npgf
1026 nseta = basis_set(ikind)%gto_basis_set%nset
1027 nsgfa = basis_set(ikind)%gto_basis_set%nsgf
1028 nsgf_seta => basis_set(ikind)%gto_basis_set%nsgf_set
1029 rpgfa => basis_set(ikind)%gto_basis_set%pgf_radius
1030 set_radius_a => basis_set(ikind)%gto_basis_set%set_radius
1031 sphi_a => basis_set(ikind)%gto_basis_set%sphi
1032 zeta => basis_set(ikind)%gto_basis_set%zet
1034 IF (
ASSOCIATED(gpotential(kkind)%gth_potential))
THEN
1037 alpha_ppnl => gpotential(kkind)%gth_potential%alpha_ppnl
1038 cprj => gpotential(kkind)%gth_potential%cprj
1039 lppnl = gpotential(kkind)%gth_potential%lppnl
1040 nppnl = gpotential(kkind)%gth_potential%nppnl
1041 nprj_ppnl => gpotential(kkind)%gth_potential%nprj_ppnl
1042 ppnl_radius = gpotential(kkind)%gth_potential%ppnl_radius
1043 vprj_ppnl => gpotential(kkind)%gth_potential%vprj_ppnl
1048 clist => sap_int_cos(iac)%alist(ilist)%clist(jneighbor)
1049 clist_sin => sap_int_sin(iac)%alist(ilist)%clist(jneighbor)
1054 clist_sin%catom = katom
1055 clist_sin%cell = cell_c
1058 ALLOCATE (clist%acint(nsgfa, nppnl, nsl), clist%achint(nsgfa, nppnl, nsl))
1059 clist%acint = 0.0_dp
1060 clist%achint = 0.0_dp
1063 ALLOCATE (clist_sin%acint(nsgfa, nppnl, nsl), clist_sin%achint(nsgfa, nppnl, nsl))
1064 clist_sin%acint = 0.0_dp
1065 clist_sin%achint = 0.0_dp
1066 clist_sin%nsgf_cnt = 0
1069 ra(:) =
pbc(particle_set(iatom)%r(:), cell)
1077 ncoa = npgfa(iset)*
ncoset(la_max(iset))
1078 sgfa = first_sgfa(1, iset)
1084 nprjc = nprj_ppnl(l)*
nco(l)
1085 IF (nprjc == 0) cycle
1086 rprjc(1) = ppnl_radius
1087 IF (set_radius_a(iset) + rprjc(1) < dac) cycle
1088 lc_max = l + 2*(nprj_ppnl(l) - 1)
1090 zetc(1) = alpha_ppnl(l)
1093 IF (derivative)
THEN
1094 CALL cossin(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
1095 lc_max, 1, zetc, rprjc, lc_min, raf, rcf, kvec, ai_work_cos, ai_work_sin, &
1096 dcosab=ai_work_dcos, dsinab=ai_work_dsin)
1097 ELSE IF (my_moment)
THEN
1102 CALL cossin(la_max(iset) + 1, npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
1103 lc_max, 1, zetc, rprjc, lc_min, raf, rcf, kvec, ai_work_mcos, ai_work_msin)
1104 nco_b =
ncoset(la_max(iset))
1105 nco_e =
ncoset(la_max(iset) + 1)
1106 DO ipgf = 1, npgfa(iset)
1107 iob = (ipgf - 1)*nco_b
1108 ioe = (ipgf - 1)*nco_e
1109 ai_work_cos(iob + 1:iob + nco_b, 1:ncoc) = ai_work_mcos(ioe + 1:ioe + nco_b, 1:ncoc)
1110 ai_work_sin(iob + 1:iob + nco_b, 1:ncoc) = ai_work_msin(ioe + 1:ioe + nco_b, 1:ncoc)
1111 DO la = 0, la_max(iset)
1116 cox =
coset(ax + 1, ay, az)
1117 coy =
coset(ax, ay + 1, az)
1118 coz =
coset(ax, ay, az + 1)
1119 ai_work_dcos(iob +
co, 1:ncoc, 1) = ai_work_mcos(ioe + cox, 1:ncoc) + &
1120 raf(1)*ai_work_mcos(ioe +
co, 1:ncoc)
1121 ai_work_dcos(iob +
co, 1:ncoc, 2) = ai_work_mcos(ioe + coy, 1:ncoc) + &
1122 raf(2)*ai_work_mcos(ioe +
co, 1:ncoc)
1123 ai_work_dcos(iob +
co, 1:ncoc, 3) = ai_work_mcos(ioe + coz, 1:ncoc) + &
1124 raf(3)*ai_work_mcos(ioe +
co, 1:ncoc)
1125 ai_work_dsin(iob +
co, 1:ncoc, 1) = ai_work_msin(ioe + cox, 1:ncoc) + &
1126 raf(1)*ai_work_msin(ioe +
co, 1:ncoc)
1127 ai_work_dsin(iob +
co, 1:ncoc, 2) = ai_work_msin(ioe + coy, 1:ncoc) + &
1128 raf(2)*ai_work_msin(ioe +
co, 1:ncoc)
1129 ai_work_dsin(iob +
co, 1:ncoc, 3) = ai_work_msin(ioe + coz, 1:ncoc) + &
1130 raf(3)*ai_work_msin(ioe +
co, 1:ncoc)
1136 CALL cossin(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
1137 lc_max, 1, zetc, rprjc, lc_min, raf, rcf, kvec, ai_work_cos, ai_work_sin)
1143 work_cos(1:na, prjc:prjc + nb - 1) = &
1144 matmul(ai_work_cos(1:na, 1:np), cprj(1:np, prjc:prjc + nb - 1))
1145 work_sin(1:na, prjc:prjc + nb - 1) = &
1146 matmul(ai_work_sin(1:na, 1:np), cprj(1:np, prjc:prjc + nb - 1))
1148 IF (derivative .OR. my_moment)
THEN
1150 work_dcos(1:na, prjc:prjc + nb - 1, idir) = &
1151 matmul(ai_work_dcos(1:na, 1:np, idir), cprj(1:np, prjc:prjc + nb - 1))
1152 work_dsin(1:na, prjc:prjc + nb - 1, idir) = &
1153 matmul(ai_work_dsin(1:na, 1:np, idir), cprj(1:np, prjc:prjc + nb - 1))
1161 na = nsgf_seta(iset)
1164 clist%acint(sgfa:sgfa + na - 1, 1:nb, 1) = &
1165 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work_cos(1:np, 1:nb))
1166 clist_sin%acint(sgfa:sgfa + na - 1, 1:nb, 1) = &
1167 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work_sin(1:np, 1:nb))
1168 IF (derivative .OR. my_moment)
THEN
1170 clist%acint(sgfa:sgfa + na - 1, 1:nb, 1 + idir) = &
1171 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work_dcos(1:np, 1:nb, idir))
1172 clist_sin%acint(sgfa:sgfa + na - 1, 1:nb, 1 + idir) = &
1173 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work_dsin(1:np, 1:nb, idir))
1178 clist%achint(sgfa:sgfa + na - 1, 1:nb, 1) = &
1179 matmul(clist%acint(sgfa:sgfa + na - 1, 1:nb, 1), vprj_ppnl(1:nb, 1:nb))
1180 clist_sin%achint(sgfa:sgfa + na - 1, 1:nb, 1) = &
1181 matmul(clist_sin%acint(sgfa:sgfa + na - 1, 1:nb, 1), vprj_ppnl(1:nb, 1:nb))
1182 IF (derivative .OR. my_moment)
THEN
1184 clist%achint(sgfa:sgfa + na - 1, 1:nb, 1 + idir) = &
1185 matmul(clist%acint(sgfa:sgfa + na - 1, 1:nb, 1 + idir), vprj_ppnl(1:nb, 1:nb))
1186 clist_sin%achint(sgfa:sgfa + na - 1, 1:nb, 1 + idir) = &
1187 matmul(clist_sin%acint(sgfa:sgfa + na - 1, 1:nb, 1 + idir), vprj_ppnl(1:nb, 1:nb))
1193 clist%maxac = maxval(abs(clist%acint(:, :, 1)))
1194 clist%maxach = maxval(abs(clist%achint(:, :, 1)))
1195 clist_sin%maxac = maxval(abs(clist_sin%acint(:, :, 1)))
1196 clist_sin%maxach = maxval(abs(clist_sin%achint(:, :, 1)))
1199 DEALLOCATE (work_cos, work_sin, ai_work_cos, ai_work_sin)
1200 IF (derivative .OR. my_moment)
DEALLOCATE (work_dcos, work_dsin, ai_work_dcos, ai_work_dsin)
1201 IF (my_moment)
DEALLOCATE (ai_work_mcos, ai_work_msin)
1205 DEALLOCATE (gpotential, spotential)
1207 CALL timestop(handle)
1209 END SUBROUTINE build_sap_exp_ints
1222 CHARACTER(len=*),
PARAMETER :: routiunen =
"velocity_gauge_nl_force"
1224 INTEGER :: handle, i, iac, iatom, ibc, icol, idir, ikind, irow, jatom, jkind, kac, katom, &
1225 kbc, kkind, maxl, maxlgto, maxlppnl, na, natom, nb, nkind, np, slot
1226 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of
1227 INTEGER,
DIMENSION(3) :: cell_b
1228 LOGICAL :: found_imag, found_real
1229 REAL(
dp) :: eps_ppnl, f0, sign_imag
1230 REAL(kind=
dp),
DIMENSION(3) :: fa, fb, rab, vec_pot
1232 POINTER :: sab_orb, sap_ppnl
1235 DIMENSION(:) :: basis_set
1237 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao, rho_ao_im
1240 TYPE(
alist_type),
POINTER :: alist_cos_ac, alist_cos_bc, &
1241 alist_sin_ac, alist_sin_bc
1242 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: achint_cos, achint_sin, acint_cos, &
1243 acint_sin, bchint_cos, bchint_sin, &
1244 bcint_cos, bcint_sin
1245 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: matrix_p_imag, matrix_p_real
1246 REAL(kind=
dp),
DIMENSION(3, SIZE(particle_set)) :: force_thread
1248 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1250 TYPE(
sap_int_type),
DIMENSION(:),
POINTER :: sap_int_cos, sap_int_sin
1252 CALL timeset(routiunen, handle)
1259 IF (
ASSOCIATED(sap_ppnl))
THEN
1260 NULLIFY (qs_kind_set, cell, dft_control, force, sab_orb, atomic_kind_set, &
1261 sap_int_cos, sap_int_sin)
1267 dft_control=dft_control, &
1268 qs_kind_set=qs_kind_set, &
1270 atomic_kind_set=atomic_kind_set, &
1273 nkind =
SIZE(atomic_kind_set)
1274 natom =
SIZE(particle_set)
1275 eps_ppnl = dft_control%qs_control%eps_ppnl
1281 maxl = max(maxlppnl, maxlgto)
1285 ALLOCATE (sap_int_cos(nkind*nkind), sap_int_sin(nkind*nkind))
1286 DO i = 1,
SIZE(sap_int_cos)
1287 NULLIFY (sap_int_cos(i)%alist, sap_int_cos(i)%asort, sap_int_cos(i)%aindex)
1288 sap_int_cos(i)%nalist = 0
1289 NULLIFY (sap_int_sin(i)%alist, sap_int_sin(i)%asort, sap_int_sin(i)%aindex)
1290 sap_int_sin(i)%nalist = 0
1294 ALLOCATE (basis_set(nkind))
1296 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1297 IF (
ASSOCIATED(orb_basis_set))
THEN
1298 basis_set(ikind)%gto_basis_set => orb_basis_set
1300 NULLIFY (basis_set(ikind)%gto_basis_set)
1305 vec_pot = dft_control%rtp_control%vec_pot
1307 force_thread = 0.0_dp
1309 CALL qs_rho_get(rho_struct=rho, rho_ao=rho_ao, rho_ao_im=rho_ao_im)
1311 IF (
SIZE(rho_ao) == 2)
THEN
1312 CALL dbcsr_add(rho_ao(1)%matrix, rho_ao(2)%matrix, &
1313 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
1314 CALL dbcsr_add(rho_ao_im(1)%matrix, rho_ao_im(2)%matrix, &
1315 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
1319 CALL build_sap_exp_ints(sap_int_cos, sap_int_sin, sap_ppnl, qs_kind_set, particle_set, &
1320 cell, kvec=vec_pot, basis_set=basis_set, nkind=nkind, derivative=.true.)
1337 NULLIFY (acint_cos, bcint_cos, achint_cos, bchint_cos)
1338 NULLIFY (acint_sin, bcint_sin, achint_sin, bchint_sin)
1342 DO slot = 1, sab_orb(1)%nl_size
1343 ikind = sab_orb(1)%nlist_task(slot)%ikind
1344 jkind = sab_orb(1)%nlist_task(slot)%jkind
1345 iatom = sab_orb(1)%nlist_task(slot)%iatom
1346 jatom = sab_orb(1)%nlist_task(slot)%jatom
1347 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell
1348 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
1350 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
1351 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
1354 IF (iatom == jatom)
THEN
1363 IF (iatom <= jatom)
THEN
1372 NULLIFY (matrix_p_real, matrix_p_imag)
1374 CALL dbcsr_get_block_p(rho_ao_im(1)%matrix, irow, icol, matrix_p_imag, found_imag)
1376 IF (found_real .OR. found_imag)
THEN
1379 iac = ikind + nkind*(kkind - 1)
1380 ibc = jkind + nkind*(kkind - 1)
1381 IF (.NOT.
ASSOCIATED(sap_int_cos(iac)%alist)) cycle
1382 IF (.NOT.
ASSOCIATED(sap_int_cos(ibc)%alist)) cycle
1383 IF (.NOT.
ASSOCIATED(sap_int_sin(iac)%alist)) cycle
1384 IF (.NOT.
ASSOCIATED(sap_int_sin(ibc)%alist)) cycle
1385 CALL get_alist(sap_int_cos(iac), alist_cos_ac, iatom)
1386 CALL get_alist(sap_int_cos(ibc), alist_cos_bc, jatom)
1387 CALL get_alist(sap_int_sin(iac), alist_sin_ac, iatom)
1388 CALL get_alist(sap_int_sin(ibc), alist_sin_bc, jatom)
1389 IF (.NOT.
ASSOCIATED(alist_cos_ac)) cycle
1390 IF (.NOT.
ASSOCIATED(alist_cos_bc)) cycle
1391 IF (.NOT.
ASSOCIATED(alist_sin_ac)) cycle
1392 IF (.NOT.
ASSOCIATED(alist_sin_bc)) cycle
1396 DO kac = 1, alist_cos_ac%nclist
1397 DO kbc = 1, alist_cos_bc%nclist
1399 IF (alist_cos_ac%clist(kac)%catom /= alist_cos_bc%clist(kbc)%catom) cycle
1400 IF (all(cell_b + alist_cos_bc%clist(kbc)%cell - alist_cos_ac%clist(kac)%cell == 0))
THEN
1402 IF (alist_cos_ac%clist(kac)%maxac*alist_cos_bc%clist(kbc)%maxach < eps_ppnl &
1403 .AND. alist_cos_ac%clist(kac)%maxac*alist_sin_bc%clist(kbc)%maxach < eps_ppnl &
1404 .AND. alist_sin_ac%clist(kac)%maxac*alist_cos_bc%clist(kbc)%maxach < eps_ppnl &
1405 .AND. alist_sin_ac%clist(kac)%maxac*alist_sin_bc%clist(kbc)%maxach < eps_ppnl) cycle
1407 acint_cos => alist_cos_ac%clist(kac)%acint
1408 bcint_cos => alist_cos_bc%clist(kbc)%acint
1409 achint_cos => alist_cos_ac%clist(kac)%achint
1410 bchint_cos => alist_cos_bc%clist(kbc)%achint
1411 acint_sin => alist_sin_ac%clist(kac)%acint
1412 bcint_sin => alist_sin_bc%clist(kbc)%acint
1413 achint_sin => alist_sin_ac%clist(kac)%achint
1414 bchint_sin => alist_sin_bc%clist(kbc)%achint
1416 na =
SIZE(acint_cos, 1)
1417 np =
SIZE(acint_cos, 2)
1418 nb =
SIZE(bcint_cos, 1)
1423 katom = alist_cos_ac%clist(kac)%catom
1425 IF (iatom <= jatom)
THEN
1427 IF (found_real)
THEN
1428 fa(idir) = sum(matrix_p_real(1:na, 1:nb)* &
1429 (+matmul(acint_cos(1:na, 1:np, 1 + idir), transpose(bchint_cos(1:nb, 1:np, 1))) &
1430 + matmul(acint_sin(1:na, 1:np, 1 + idir), transpose(bchint_sin(1:nb, 1:np, 1)))))
1432 IF (found_imag)
THEN
1433 fa(idir) = fa(idir) - sign_imag*sum(matrix_p_imag(1:na, 1:nb)* &
1434 (+matmul(acint_sin(1:na, 1:np, 1 + idir), transpose(bchint_cos(1:nb, 1:np, 1))) &
1435 - matmul(acint_cos(1:na, 1:np, 1 + idir), transpose(bchint_sin(1:nb, 1:np, 1)))))
1438 IF (found_real)
THEN
1439 fb(idir) = sum(matrix_p_real(1:na, 1:nb)* &
1440 (+matmul(achint_cos(1:na, 1:np, 1), transpose(bcint_cos(1:nb, 1:np, 1 + idir))) &
1441 + matmul(achint_sin(1:na, 1:np, 1), transpose(bcint_sin(1:nb, 1:np, 1 + idir)))))
1443 IF (found_imag)
THEN
1444 fb(idir) = fb(idir) - sign_imag*sum(matrix_p_imag(1:na, 1:nb)* &
1445 (-matmul(achint_cos(1:na, 1:np, 1), transpose(bcint_sin(1:nb, 1:np, 1 + idir))) &
1446 + matmul(achint_sin(1:na, 1:np, 1), transpose(bcint_cos(1:nb, 1:np, 1 + idir)))))
1450 IF (found_real)
THEN
1451 fa(idir) = sum(matrix_p_real(1:nb, 1:na)* &
1452 (+matmul(bchint_cos(1:nb, 1:np, 1), transpose(acint_cos(1:na, 1:np, 1 + idir))) &
1453 + matmul(bchint_sin(1:nb, 1:np, 1), transpose(acint_sin(1:na, 1:np, 1 + idir)))))
1455 IF (found_imag)
THEN
1456 fa(idir) = fa(idir) - sign_imag*sum(matrix_p_imag(1:nb, 1:na)* &
1457 (+matmul(bchint_sin(1:nb, 1:np, 1), transpose(acint_cos(1:na, 1:np, 1 + idir))) &
1458 - matmul(bchint_cos(1:nb, 1:np, 1), transpose(acint_sin(1:na, 1:np, 1 + idir)))))
1461 IF (found_real)
THEN
1462 fb(idir) = sum(matrix_p_real(1:nb, 1:na)* &
1463 (+matmul(bcint_cos(1:nb, 1:np, 1 + idir), transpose(achint_cos(1:na, 1:np, 1))) &
1464 + matmul(bcint_sin(1:nb, 1:np, 1 + idir), transpose(achint_sin(1:na, 1:np, 1)))))
1466 IF (found_imag)
THEN
1467 fb(idir) = fb(idir) - sign_imag*sum(matrix_p_imag(1:nb, 1:na)* &
1468 (-matmul(bcint_cos(1:nb, 1:np, 1 + idir), transpose(achint_sin(1:na, 1:np, 1))) &
1469 + matmul(bcint_sin(1:nb, 1:np, 1 + idir), transpose(achint_cos(1:na, 1:np, 1)))))
1472 force_thread(idir, iatom) = force_thread(idir, iatom) + f0*fa(idir)
1473 force_thread(idir, katom) = force_thread(idir, katom) - f0*fa(idir)
1474 force_thread(idir, jatom) = force_thread(idir, jatom) + f0*fb(idir)
1475 force_thread(idir, katom) = force_thread(idir, katom) - f0*fb(idir)
1492 i = atom_of_kind(iatom)
1493 ikind = kind_of(iatom)
1494 force(ikind)%gth_ppnl(:, i) = force(ikind)%gth_ppnl(:, i) + force_thread(:, iatom)
1499 IF (
SIZE(rho_ao) == 2)
THEN
1500 CALL dbcsr_add(rho_ao(1)%matrix, rho_ao(2)%matrix, &
1501 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
1502 CALL dbcsr_add(rho_ao_im(1)%matrix, rho_ao_im(2)%matrix, &
1503 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
1508 DEALLOCATE (basis_set, atom_of_kind, kind_of)
1512 CALL timestop(handle)
Calculation of the moment integrals over Cartesian Gaussian-type functions.
subroutine, public cossin(la_max_set, npgfa, zeta, rpgfa, la_min_set, lb_max, npgfb, zetb, rpgfb, lb_min, rac, rbc, kvec, cosab, sinab, dcosab, dsinab)
...
subroutine, public moment(la_max, npgfa, zeta, rpgfa, la_min, lb_max, npgfb, zetb, rpgfb, lc_max, rac, rbc, mab)
...
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 co
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :, :), allocatable, public coset
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.
subroutine, public release_sap_int(sap_int)
...
subroutine, public sap_sort(sap_int)
...
subroutine, public get_alist(sap_int, alist, atom)
...
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.