92#include "./base/base_uses.f90"
101 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_linres_op'
130 CHARACTER(LEN=*),
PARAMETER :: routinen =
'current_operators'
132 INTEGER :: handle, iao, icenter, idir, ii, iii, &
133 ispin, istate, j, nao, natom, &
134 nbr_center(2), nmo, nsgf, nspins, &
135 nstates(2), output_unit
136 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
137 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
138 REAL(
dp) :: chk(3), ck(3), ckdk(3), dk(3)
139 REAL(
dp),
DIMENSION(:, :),
POINTER :: basisfun_center, vecbuf_c0
147 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: psi0_order
148 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: p_psi0, rxp_psi0
157 POINTER :: sab_all, sab_orb
159 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
162 CALL timeset(routinen, handle)
164 NULLIFY (qs_kind_set, cell, dft_control, linres_control, &
165 logger, particle_set, lr_section, &
166 basisfun_center, centers_set, center_list, p_psi0, &
167 rxp_psi0, vecbuf_c0, psi0_order, &
168 mo_coeff, op_ao, sab_all)
175 extension=
".linresLog")
176 IF (output_unit > 0)
THEN
177 WRITE (output_unit, fmt=
"(T2,A,/)") &
178 "CURRENT| Calculation of the p and (r-d)xp operators applied to psi0"
182 qs_kind_set=qs_kind_set, &
184 dft_control=dft_control, &
185 linres_control=linres_control, &
187 particle_set=particle_set, &
190 dbcsr_dist=dbcsr_dist)
192 nspins = dft_control%nspins
194 CALL get_current_env(current_env=current_env, nao=nao, centers_set=centers_set, &
195 center_list=center_list, basisfun_center=basisfun_center, &
196 nbr_center=nbr_center, p_psi0=p_psi0, rxp_psi0=rxp_psi0, &
197 psi0_order=psi0_order, &
200 ALLOCATE (vecbuf_c0(1, nao))
202 NULLIFY (vecbuf_rmdc0(idir)%array)
203 ALLOCATE (vecbuf_rmdc0(idir)%array(1, nao))
208 natom =
SIZE(particle_set, 1)
209 ALLOCATE (first_sgf(natom))
210 ALLOCATE (last_sgf(natom))
213 first_sgf=first_sgf, &
235 ALLOCATE (row_blk_sizes(natom))
236 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
240 ALLOCATE (op_ao(1)%matrix, op_ao(2)%matrix, op_ao(3)%matrix)
244 dist=dbcsr_dist, matrix_type=dbcsr_type_no_symmetry, &
245 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
251 CALL dbcsr_copy(op_ao(idir)%matrix, op_ao(1)%matrix, &
253 CALL dbcsr_set(op_ao(idir)%matrix, 0.0_dp)
258 mo_coeff => psi0_order(ispin)
263 DO icenter = 1, nbr_center(ispin)
279 rxp_psi0(ispin, idir), ncol=nmo, &
281 DO j = center_list(ispin)%array(1, icenter), center_list(ispin)%array(1, icenter + 1) - 1
282 istate = center_list(ispin)%array(2, j)
285 p_psi0(ispin, idir), 1, istate, istate)
289 CALL cp_fm_to_fm(p_psi0(ispin, 1), rxp_psi0(ispin, 1))
290 CALL cp_fm_to_fm(p_psi0(ispin, 2), rxp_psi0(ispin, 2))
291 CALL cp_fm_to_fm(p_psi0(ispin, 3), rxp_psi0(ispin, 3))
297 IF (output_unit > 0)
THEN
298 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_x =', chk(1)
299 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_y =', chk(2)
300 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_z =', chk(3)
305 ALLOCATE (op_ao(1)%matrix, op_ao(2)%matrix, op_ao(3)%matrix)
309 dist=dbcsr_dist, matrix_type=dbcsr_type_antisymmetric, &
310 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
316 CALL dbcsr_copy(op_ao(idir)%matrix, op_ao(1)%matrix, &
318 CALL dbcsr_set(op_ao(idir)%matrix, 0.0_dp)
327 IF (output_unit > 0)
THEN
328 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_x =', chk(1)
329 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_y =', chk(2)
330 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_z =', chk(3)
335 mo_coeff => psi0_order(ispin)
339 p_psi0(ispin, idir), ncol=nmo, &
347 "PRINT%PROGRAM_RUN_INFO")
374 mo_coeff => psi0_order(ispin)
376 NULLIFY (tmp_fm_struct)
378 ncol_global=nmo, para_env=para_env, &
379 context=mo_coeff%matrix_struct%context)
391 dk(1:3) = centers_set(ispin)%array(1:3, istate)
395 ck(1:3) = basisfun_center(1:3, iao)
396 ckdk =
pbc(dk, ck, cell)
397 vecbuf_rmdc0(idir)%array(1, iao) = vecbuf_c0(1, iao)*ckdk(idir)
400 1, istate, nao, 1, transpose=.true.)
410 fm_work1, ncol=nmo, alpha=-1.0_dp)
416 fm_work1, ncol=nmo, alpha=-1.0_dp)
430 DEALLOCATE (row_blk_sizes)
432 DEALLOCATE (first_sgf, last_sgf)
434 DEALLOCATE (vecbuf_c0)
436 DEALLOCATE (vecbuf_rmdc0(idir)%array)
439 CALL timestop(handle)
453 INTEGER,
INTENT(IN) :: iatom
455 CHARACTER(LEN=*),
PARAMETER :: routinen =
'issc_operators'
457 INTEGER :: handle, idir, ispin, nmo, nspins, &
459 LOGICAL :: do_dso, do_fc, do_pso, do_sd
460 REAL(
dp) :: chk(20), r_i(3)
462 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fc_psi0
463 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dso_psi0, efg_psi0, pso_psi0
466 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_dso, matrix_efg, matrix_fc, &
473 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
476 CALL timeset(routinen, handle)
478 NULLIFY (matrix_fc, matrix_pso, matrix_efg)
479 NULLIFY (efg_psi0, pso_psi0, fc_psi0)
486 extension=
".linresLog")
489 qs_kind_set=qs_kind_set, &
491 dft_control=dft_control, &
492 linres_control=linres_control, &
495 particle_set=particle_set)
497 nspins = dft_control%nspins
500 matrix_efg=matrix_efg, &
501 matrix_pso=matrix_pso, &
502 matrix_fc=matrix_fc, &
503 matrix_dso=matrix_dso, &
514 r_i = particle_set(iatom)%r
523 CALL dbcsr_set(matrix_fc(1)%matrix, 0.0_dp)
528 IF (output_unit > 0)
THEN
529 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| fermi_contact: CheckSum =', chk(1)
536 CALL dbcsr_set(matrix_pso(1)%matrix, 0.0_dp)
537 CALL dbcsr_set(matrix_pso(2)%matrix, 0.0_dp)
538 CALL dbcsr_set(matrix_pso(3)%matrix, 0.0_dp)
545 IF (output_unit > 0)
THEN
546 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_x: CheckSum =', chk(2)
547 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_y: CheckSum =', chk(3)
548 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_z: CheckSum =', chk(4)
555 CALL dbcsr_set(matrix_efg(1)%matrix, 0.0_dp)
556 CALL dbcsr_set(matrix_efg(2)%matrix, 0.0_dp)
557 CALL dbcsr_set(matrix_efg(3)%matrix, 0.0_dp)
558 CALL dbcsr_set(matrix_efg(4)%matrix, 0.0_dp)
559 CALL dbcsr_set(matrix_efg(5)%matrix, 0.0_dp)
560 CALL dbcsr_set(matrix_efg(6)%matrix, 0.0_dp)
570 IF (output_unit > 0)
THEN
571 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3xx-rr)/3: CheckSum =', chk(5)
572 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3yy-rr)/3: CheckSum =', chk(6)
573 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3zz-rr)/3: CheckSum =', chk(7)
574 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg xy: CheckSum =', chk(8)
575 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg xz: CheckSum =', chk(9)
576 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg yz: CheckSum =', chk(10)
581 IF (output_unit > 0)
THEN
582 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| all operator: CheckSum =', sum(chk(1:10))
587 CALL dbcsr_set(matrix_dso(1)%matrix, 0.0_dp)
588 CALL dbcsr_set(matrix_dso(2)%matrix, 0.0_dp)
589 CALL dbcsr_set(matrix_dso(3)%matrix, 0.0_dp)
591 ref_point=[0.0_dp, 0.0_dp, 0.0_dp], all_images=.true.)
597 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
604 efg_psi0(ispin, idir), ncol=nmo, &
613 pso_psi0(ispin, idir), ncol=nmo, &
621 fc_psi0(ispin), ncol=nmo, &
629 dso_psi0(ispin, idir), ncol=nmo, &
637 "PRINT%PROGRAM_RUN_INFO")
639 CALL timestop(handle)
652 LOGICAL :: do_periodic
656 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, polar_env=polar_env)
657 CALL get_polar_env(polar_env=polar_env, do_periodic=do_periodic)
658 IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
659 IF (do_periodic)
THEN
660 CALL polar_tb_operators_berry(qs_env)
662 CALL polar_tb_operators_local(qs_env)
665 IF (do_periodic)
THEN
691 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_berry'
692 COMPLEX(KIND=dp),
PARAMETER ::
one = (1.0_dp, 0.0_dp), &
693 zero = (0.0_dp, 0.0_dp)
695 COMPLEX(DP) :: zdet, zdeta
696 INTEGER :: handle, i, idim, ispin, nao, nmo, &
699 REAL(
dp) :: kvec(3), maxocc
701 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: eigrmat
702 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:, :) :: inv_mat
704 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: op_fm_set, opvec
705 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: inv_work
706 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
715 CALL timeset(routinen, handle)
717 NULLIFY (dberry_psi0, sinmat, cosmat)
720 NULLIFY (cell, dft_control, mos, matrix_s)
723 dft_control=dft_control, &
725 polar_env=polar_env, &
729 nspins = dft_control%nspins
733 dberry_psi0=dberry_psi0)
744 ALLOCATE (opvec(2, dft_control%nspins))
745 ALLOCATE (op_fm_set(2, dft_control%nspins))
746 ALLOCATE (eigrmat(dft_control%nspins))
747 ALLOCATE (inv_mat(3, dft_control%nspins))
748 ALLOCATE (inv_work(2, 3, dft_control%nspins))
751 DO ispin = 1, dft_control%nspins
752 NULLIFY (tmp_fm_struct, mo_coeff)
753 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
755 ncol_global=nmo, para_env=para_env, context=mo_coeff%matrix_struct%context)
756 DO i = 1,
SIZE(op_fm_set, 1)
757 CALL cp_fm_create(opvec(i, ispin), mo_coeff%matrix_struct)
760 CALL cp_cfm_create(eigrmat(ispin), op_fm_set(1, ispin)%matrix_struct)
763 CALL cp_cfm_create(inv_mat(i, ispin), op_fm_set(1, ispin)%matrix_struct)
764 CALL cp_fm_create(inv_work(2, i, ispin), op_fm_set(2, ispin)%matrix_struct)
765 CALL cp_fm_create(inv_work(1, i, ispin), op_fm_set(1, ispin)%matrix_struct)
769 NULLIFY (cosmat, sinmat)
770 ALLOCATE (cosmat, sinmat)
771 CALL dbcsr_copy(cosmat, matrix_s(1)%matrix,
'COS MOM')
772 CALL dbcsr_copy(sinmat, matrix_s(1)%matrix,
'SIN MOM')
775 kvec(:) =
twopi*cell%h_inv(i, :)
778 DO ispin = 1, dft_control%nspins
779 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff=mo_coeff, nmo=nmo)
782 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff, opvec(1, ispin), 0.0_dp, &
785 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff, opvec(2, ispin), 0.0_dp, &
792 DO ispin = 1, dft_control%nspins
795 eigrmat(ispin)%local_data(:, idim) = &
796 cmplx(op_fm_set(1, ispin)%local_data(:, idim), &
797 -op_fm_set(2, ispin)%local_data(:, idim),
dp)
800 CALL cp_cfm_solve(eigrmat(ispin), inv_mat(i, ispin), zdeta)
804 DO ispin = 1, dft_control%nspins
806 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo, maxocc=maxocc)
808 inv_work(1, i, ispin)%local_data(:, z) = real(inv_mat(i, ispin)%local_data(:, z),
dp)
809 inv_work(2, i, ispin)%local_data(:, z) = aimag(inv_mat(i, ispin)%local_data(:, z))
811 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, -1.0_dp, opvec(1, ispin), inv_work(2, i, ispin), &
812 0.0_dp, dberry_psi0(i, ispin))
813 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, 1.0_dp, opvec(2, ispin), inv_work(1, i, ispin), &
814 1.0_dp, dberry_psi0(i, ispin))
819 DO ispin = 1, dft_control%nspins
837 CALL timestop(handle)
855 SUBROUTINE polar_tb_operators_berry(qs_env)
859 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_tb_operators_berry'
862 INTEGER :: handle, i, icol, idir, irow, ispin, nmo, &
864 LOGICAL :: do_raman, found
866 REAL(
dp),
DIMENSION(3) :: kvec, ria, rib
867 REAL(
dp),
DIMENSION(3, 3) :: hmat
868 REAL(
dp),
DIMENSION(:, :),
POINTER :: d_block, s_block
870 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
873 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
879 CALL timeset(routinen, handle)
881 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, &
882 cell=cell, particle_set=particle_set, &
883 polar_env=polar_env, mos=mos, matrix_s=matrix_s)
885 nspins = dft_control%nspins
889 dberry_psi0=dberry_psi0)
895 ALLOCATE (dipmat(i)%matrix)
896 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
900 hmat = cell%hmat(:, :)/
twopi
904 NULLIFY (s_block, d_block)
906 ria = particle_set(irow)%r
907 rib = particle_set(icol)%r
909 kvec(:) =
twopi*cell%h_inv(idir, :)
910 dd = sum(kvec(:)*ria(:))
911 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)
912 fdir = aimag(log(zdeta))
913 dd = sum(kvec(:)*rib(:))
914 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)
915 fdir = fdir + aimag(log(zdeta))
917 row=irow, col=icol, block=d_block, found=found)
919 d_block = d_block + 0.5_dp*fdir*s_block
925 DO ispin = 1, dft_control%nspins
926 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
929 dberry_psi0(i, ispin), ncol=nmo)
940 CALL timestop(handle)
941 END SUBROUTINE polar_tb_operators_berry
959 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_local'
961 INTEGER :: handle, i, ispin, nmo, nspins
963 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
965 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
970 CALL timeset(routinen, handle)
973 dft_control=dft_control, &
974 polar_env=polar_env, &
978 nspins = dft_control%nspins
982 dberry_psi0=dberry_psi0)
989 ALLOCATE (dipmat(i)%matrix)
990 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
996 DO ispin = 1, dft_control%nspins
997 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
1000 dberry_psi0(i, ispin), ncol=nmo)
1011 CALL timestop(handle)
1029 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_local_wannier'
1031 INTEGER :: alpha, handle, i, icenter, ispin, &
1032 map_atom, map_molecule, &
1033 max_nbr_center, nao, natom, nmo, &
1035 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: mapping_atom_molecule
1036 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: mapping_wannier_atom
1037 REAL(
dp) :: f_spin, smallest_r, tmp_r
1038 REAL(
dp),
DIMENSION(3) :: distance, r_shifted
1039 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: apt_el, apt_nuc
1040 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: apt_center, apt_subset
1043 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
1044 TYPE(
cp_fm_type),
POINTER :: mo_coeff, overlap1_mo, tmp_fm, &
1045 tmp_fm_like_mos, tmp_fm_momo
1049 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1051 CALL timeset(routinen, handle)
1053 NULLIFY (qs_kind_set, particle_set, molecule_set, cell)
1056 qs_kind_set=qs_kind_set, &
1057 particle_set=particle_set, &
1058 molecule_set=molecule_set, &
1059 polar_env=polar_env, &
1062 CALL get_polar_env(polar_env=polar_env, dberry_psi0=dberry_psi0)
1064 nsubset =
SIZE(molecule_set)
1065 natom =
SIZE(particle_set)
1066 apt_el => dcdr_env%apt_el_dcdr
1067 apt_nuc => dcdr_env%apt_nuc_dcdr
1068 apt_subset => dcdr_env%apt_el_dcdr_per_subset
1069 apt_center => dcdr_env%apt_el_dcdr_per_center
1072 IF (dcdr_env%nspins == 1)
THEN
1073 max_nbr_center = dcdr_env%nbr_center(1)
1075 max_nbr_center = max(dcdr_env%nbr_center(1), dcdr_env%nbr_center(2))
1077 ALLOCATE (mapping_wannier_atom(max_nbr_center, dcdr_env%nspins))
1078 ALLOCATE (mapping_atom_molecule(natom))
1079 centers_set => dcdr_env%centers_set
1080 DO ispin = 1, dcdr_env%nspins
1081 DO icenter = 1, dcdr_env%nbr_center(ispin)
1085 r_shifted=r_shifted)
1087 smallest_r = huge(0._dp)
1089 distance =
pbc(r_shifted, particle_set(i)%r(1:3), cell)
1090 tmp_r = sum(distance**2)
1091 IF (tmp_r < smallest_r)
THEN
1092 mapping_wannier_atom(icenter, ispin) = i
1100 IF (dcdr_env%lambda == 1 .AND. dcdr_env%beta == 1)
THEN
1101 DO icenter = 1, dcdr_env%nbr_center(ispin)
1102 map_atom = mapping_wannier_atom(icenter, ispin)
1103 map_molecule = mapping_atom_molecule(map_atom)
1109 f_spin = 2._dp/dcdr_env%nspins
1111 DO ispin = 1, dcdr_env%nspins
1114 ALLOCATE (tmp_fm_like_mos)
1115 ALLOCATE (overlap1_mo)
1116 CALL cp_fm_create(tmp_fm_like_mos, dcdr_env%likemos_fm_struct(ispin)%struct)
1117 CALL cp_fm_create(overlap1_mo, dcdr_env%momo_fm_struct(ispin)%struct)
1118 nmo = dcdr_env%nmo(ispin)
1119 mo_coeff => dcdr_env%mo_coeff(ispin)
1125 1.0_dp, mo_coeff, tmp_fm_like_mos, &
1126 0.0_dp, overlap1_mo)
1132 -0.5_dp, mo_coeff, overlap1_mo, &
1133 -1.0_dp, dcdr_env%dCR_prime(ispin))
1138 ALLOCATE (tmp_fm_momo)
1139 CALL cp_fm_create(tmp_fm, dcdr_env%likemos_fm_struct(ispin)%struct)
1140 CALL cp_fm_create(tmp_fm_momo, dcdr_env%momo_fm_struct(ispin)%struct)
1144 DO icenter = 1, dcdr_env%nbr_center(ispin)
1145 CALL dbcsr_set(dcdr_env%moments(alpha)%matrix, 0.0_dp)
1147 ref_point=centers_set(ispin)%array(1:3, icenter))
1149 mo_coeff=mo_coeff, work=tmp_fm, nmo=nmo, &
1151 res=dberry_psi0(alpha, ispin))
1159 DEALLOCATE (overlap1_mo)
1161 DEALLOCATE (tmp_fm_like_mos)
1162 DEALLOCATE (tmp_fm_momo)
1167 CALL timestop(handle)
1181 SUBROUTINE polar_tb_operators_local(qs_env)
1185 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_tb_operators_local'
1187 INTEGER :: handle, i, icol, irow, ispin, nmo, nspins
1188 LOGICAL :: do_raman, found
1190 REAL(
dp),
DIMENSION(3) :: ria, rib
1191 REAL(
dp),
DIMENSION(:, :),
POINTER :: d_block, s_block
1193 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
1196 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
1202 CALL timeset(routinen, handle)
1204 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, &
1205 cell=cell, particle_set=particle_set, &
1206 polar_env=polar_env, mos=mos, matrix_s=matrix_s)
1208 nspins = dft_control%nspins
1211 do_raman=do_raman, &
1212 dberry_psi0=dberry_psi0)
1216 ALLOCATE (dipmat(3))
1218 ALLOCATE (dipmat(i)%matrix)
1219 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
1224 NULLIFY (s_block, d_block)
1226 ria = particle_set(irow)%r
1227 ria =
pbc(ria, cell)
1228 rib = particle_set(icol)%r
1229 rib =
pbc(rib, cell)
1232 row=irow, col=icol, block=d_block, found=found)
1234 fdir = 0.5_dp*(ria(i) + rib(i))
1235 d_block = s_block*fdir
1241 DO ispin = 1, dft_control%nspins
1242 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
1245 dberry_psi0(i, ispin), ncol=nmo)
1256 CALL timestop(handle)
1258 END SUBROUTINE polar_tb_operators_local
1274 IF ((b == a + 1 .OR. b == a - 2) .AND. (c == b + 1 .OR. c == b - 2))
THEN
1276 ELSE IF ((b == a - 1 .OR. b == a + 2) .AND. (c == b - 1 .OR. c == b + 2))
THEN
1290 INTEGER :: ii, iii, i
1298 ELSE IF (iii == 0)
THEN
1300 ELSE IF (ii == iii)
THEN
1302 i =
coset(l(1), l(2), l(3)) - 1
1307 i =
coset(l(1), l(2), l(3)) - 1
1318 INTEGER,
INTENT(IN) :: i1
1319 INTEGER,
INTENT(OUT) :: i2, i3
1324 ELSE IF (i1 == 2)
THEN
1327 ELSE IF (i1 == 3)
THEN
1342 INTEGER,
INTENT(IN) :: i1, i2
1343 INTEGER,
INTENT(OUT) :: i3
1345 IF ((i1 + i2) == 3)
THEN
1347 ELSE IF ((i1 + i2) == 4)
THEN
1349 ELSE IF ((i1 + i2) == 5)
THEN
1367 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(in) :: ra, rc
1369 INTEGER,
INTENT(IN) :: ixyz
1371 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_scale_by_pbc_AC'
1373 INTEGER :: handle, icol_global, icol_local, &
1374 irow_global, irow_local, m, mypcol, &
1375 myprow, n, ncol_local, nrow_local
1376 REAL(kind=
dp) :: dist(3), rra(3), rrc(3)
1377 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a
1379 CALL timeset(routinen, handle)
1381 myprow = matrix%matrix_struct%context%mepos(1)
1382 mypcol = matrix%matrix_struct%context%mepos(2)
1384 nrow_local = matrix%matrix_struct%nrow_locals(myprow)
1385 ncol_local = matrix%matrix_struct%ncol_locals(mypcol)
1390 a => matrix%local_data
1391 DO icol_local = 1, ncol_local
1392 icol_global = matrix%matrix_struct%col_indices(icol_local)
1393 IF (icol_global > n) cycle
1394 rrc = rc(:, icol_global)
1395 DO irow_local = 1, nrow_local
1396 irow_global = matrix%matrix_struct%row_indices(irow_local)
1397 IF (irow_global > m) cycle
1398 rra = ra(:, irow_global)
1399 dist =
pbc(rrc, rra, cell)
1400 a(irow_local, icol_local) = a(irow_local, icol_local)*dist(ixyz)
1404 CALL timestop(handle)
Handles all functions related to the CELL.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_solve(matrix_a, general_a, determinant)
Solve the system of linear equations A*b=A_general using LU decomposition. Pay attention that both ma...
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
real(kind=dp) function, public dbcsr_checksum(matrix, pos)
Calculates the checksum of a DBCSR matrix.
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
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_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
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
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
various routines to log and control the output. The idea is that decisions about where to log should ...
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...
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)
...
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,...
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public one
real(kind=dp), parameter, public twopi
real(kind=dp), parameter, public zero
Interface to the message passing library MPI.
Define the data structure for the molecule information.
subroutine, public molecule_of_atom(molecule_set, atom_to_mol)
finds for each atom the molecule it belongs to
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:, :, :), allocatable, public coset
basic linear algebra operations for full matrixes
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.
Calculate the derivatives of the MO coefficients wrt nuclear coordinates.
subroutine, public multiply_localization(ao_matrix, mo_coeff, work, nmo, icenter, res)
Multiply (ao_matrix @ mo_coeff) and store the column icenter in res.
subroutine, public shift_wannier_into_cell(r, cell, r_shifted)
...
Distribution of the electric field gradient integral matrix.
subroutine, public build_efg_matrix(qs_env, matrix_efg, rc)
Calculation of the electric field gradient matrix over Cartesian Gaussian functions.
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_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.
Calculate the operators p rxp and D needed in the optimization of the different contribution of the f...
subroutine, public polar_operators_berry(qs_env)
Calculate the Berry phase operator in the AO basis and then the derivative of the Berry phase operato...
integer function, public ind_m2(ii, iii)
...
subroutine, public polar_operators_local_wannier(qs_env, dcdr_env)
Calculate the dipole operator referenced at the Wannier centers in the MO basis.
subroutine, public current_operators(current_env, qs_env)
Calculate the first order hamiltonian applied to the ao and then apply them to the ground state orbit...
subroutine, public set_vecp(i1, i2, i3)
...
real(dp) function, public fac_vecp(a, b, c)
...
subroutine, public polar_operators(qs_env)
Calculate the dipole operator in the AO basis and its derivative wrt to MOs.
subroutine, public polar_operators_local(qs_env)
Calculate the Berry phase operator in the AO basis and then the derivative of the Berry phase operato...
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)
...
subroutine, public issc_operators(issc_env, qs_env, iatom)
...
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)
...
subroutine, public get_issc_env(issc_env, issc_on_atom_list, issc_gapw_radius, issc_loc, do_fc, do_sd, do_pso, do_dso, issc, interpolate_issc, psi1_efg, psi1_pso, psi1_dso, psi1_fc, efg_psi0, pso_psi0, dso_psi0, fc_psi0, matrix_efg, matrix_pso, matrix_dso, matrix_fc)
...
subroutine, public get_polar_env(polar_env, do_raman, do_periodic, dberry_psi0, polar, psi1_dberry, run_stopped)
...
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)
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_moment_matrix(qs_env, moments, nmoments, ref_point, ref_points, basis_type, all_images, minimum_image, neighbor_image, first_component)
...
subroutine, public build_berry_moment_matrix(qs_env, cosmat, sinmat, kvec, sab_orb_external, basis_type)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public build_ang_mom_matrix(qs_env, matrix, rc)
Calculation of the angular momentum matrix over Cartesian Gaussian functions.
subroutine, public build_lin_mom_matrix(qs_env, matrix, minimum_image)
Calculation of the linear momentum matrix <mu|∂|nu> over Cartesian Gaussian functions.
Distribution of the spin orbit integral matrix.
subroutine, public build_pso_matrix(qs_env, matrix_so, rc)
Calculation of the paramagnetic spin orbit matrix over Cartesian Gaussian functions.
Type defining parameters related to the simulation cell.
represent a pointer to a 2d array
represent a pointer to a 2d array
Represent a complex full matrix.
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
Provides all information about a quickstep kind.
General settings for linear response calculations.