93#include "./base/base_uses.f90"
102 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_linres_op'
131 CHARACTER(LEN=*),
PARAMETER :: routinen =
'current_operators'
133 INTEGER :: handle, iao, icenter, idir, ii, iii, &
134 ispin, istate, j, nao, natom, &
135 nbr_center(2), nmo, nsgf, nspins, &
136 nstates(2), output_unit
137 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
138 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
139 REAL(
dp) :: chk(3), ck(3), ckdk(3), dk(3)
140 REAL(
dp),
DIMENSION(:, :),
POINTER :: basisfun_center, vecbuf_c0
148 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: psi0_order
149 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: p_psi0, rxp_psi0
158 POINTER :: sab_all, sab_orb
160 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
163 CALL timeset(routinen, handle)
165 NULLIFY (qs_kind_set, cell, dft_control, linres_control, &
166 logger, particle_set, lr_section, &
167 basisfun_center, centers_set, center_list, p_psi0, &
168 rxp_psi0, vecbuf_c0, psi0_order, &
169 mo_coeff, op_ao, sab_all)
176 extension=
".linresLog")
177 IF (output_unit > 0)
THEN
178 WRITE (output_unit, fmt=
"(T2,A,/)") &
179 "CURRENT| Calculation of the p and (r-d)xp operators applied to psi0"
183 qs_kind_set=qs_kind_set, &
185 dft_control=dft_control, &
186 linres_control=linres_control, &
188 particle_set=particle_set, &
191 dbcsr_dist=dbcsr_dist)
193 nspins = dft_control%nspins
195 CALL get_current_env(current_env=current_env, nao=nao, centers_set=centers_set, &
196 center_list=center_list, basisfun_center=basisfun_center, &
197 nbr_center=nbr_center, p_psi0=p_psi0, rxp_psi0=rxp_psi0, &
198 psi0_order=psi0_order, &
201 ALLOCATE (vecbuf_c0(1, nao))
203 NULLIFY (vecbuf_rmdc0(idir)%array)
204 ALLOCATE (vecbuf_rmdc0(idir)%array(1, nao))
209 natom =
SIZE(particle_set, 1)
210 ALLOCATE (first_sgf(natom))
211 ALLOCATE (last_sgf(natom))
214 first_sgf=first_sgf, &
236 ALLOCATE (row_blk_sizes(natom))
237 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
241 ALLOCATE (op_ao(1)%matrix, op_ao(2)%matrix, op_ao(3)%matrix)
245 dist=dbcsr_dist, matrix_type=dbcsr_type_no_symmetry, &
246 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
252 CALL dbcsr_copy(op_ao(idir)%matrix, op_ao(1)%matrix, &
254 CALL dbcsr_set(op_ao(idir)%matrix, 0.0_dp)
259 mo_coeff => psi0_order(ispin)
264 DO icenter = 1, nbr_center(ispin)
280 rxp_psi0(ispin, idir), ncol=nmo, &
282 DO j = center_list(ispin)%array(1, icenter), center_list(ispin)%array(1, icenter + 1) - 1
283 istate = center_list(ispin)%array(2, j)
286 p_psi0(ispin, idir), 1, istate, istate)
290 CALL cp_fm_to_fm(p_psi0(ispin, 1), rxp_psi0(ispin, 1))
291 CALL cp_fm_to_fm(p_psi0(ispin, 2), rxp_psi0(ispin, 2))
292 CALL cp_fm_to_fm(p_psi0(ispin, 3), rxp_psi0(ispin, 3))
298 IF (output_unit > 0)
THEN
299 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_x =', chk(1)
300 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_y =', chk(2)
301 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_z =', chk(3)
306 ALLOCATE (op_ao(1)%matrix, op_ao(2)%matrix, op_ao(3)%matrix)
310 dist=dbcsr_dist, matrix_type=dbcsr_type_antisymmetric, &
311 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
317 CALL dbcsr_copy(op_ao(idir)%matrix, op_ao(1)%matrix, &
319 CALL dbcsr_set(op_ao(idir)%matrix, 0.0_dp)
329 IF (output_unit > 0)
THEN
330 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_x =', chk(1)
331 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_y =', chk(2)
332 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_z =', chk(3)
337 mo_coeff => psi0_order(ispin)
341 p_psi0(ispin, idir), ncol=nmo, &
349 "PRINT%PROGRAM_RUN_INFO")
376 mo_coeff => psi0_order(ispin)
378 NULLIFY (tmp_fm_struct)
380 ncol_global=nmo, para_env=para_env, &
381 context=mo_coeff%matrix_struct%context)
393 dk(1:3) = centers_set(ispin)%array(1:3, istate)
397 ck(1:3) = basisfun_center(1:3, iao)
398 ckdk =
pbc(dk, ck, cell)
399 vecbuf_rmdc0(idir)%array(1, iao) = vecbuf_c0(1, iao)*ckdk(idir)
402 1, istate, nao, 1, transpose=.true.)
412 fm_work1, ncol=nmo, alpha=-1.0_dp)
418 fm_work1, ncol=nmo, alpha=-1.0_dp)
432 DEALLOCATE (row_blk_sizes)
434 DEALLOCATE (first_sgf, last_sgf)
436 DEALLOCATE (vecbuf_c0)
438 DEALLOCATE (vecbuf_rmdc0(idir)%array)
441 CALL timestop(handle)
455 INTEGER,
INTENT(IN) :: iatom
457 CHARACTER(LEN=*),
PARAMETER :: routinen =
'issc_operators'
459 INTEGER :: handle, idir, ispin, nmo, nspins, &
461 LOGICAL :: do_dso, do_fc, do_pso, do_sd
462 REAL(
dp) :: chk(20), r_i(3)
464 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fc_psi0
465 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dso_psi0, efg_psi0, pso_psi0
468 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_dso, matrix_efg, matrix_fc, &
475 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
478 CALL timeset(routinen, handle)
480 NULLIFY (matrix_fc, matrix_pso, matrix_efg)
481 NULLIFY (efg_psi0, pso_psi0, fc_psi0)
488 extension=
".linresLog")
491 qs_kind_set=qs_kind_set, &
493 dft_control=dft_control, &
494 linres_control=linres_control, &
497 particle_set=particle_set)
499 nspins = dft_control%nspins
502 matrix_efg=matrix_efg, &
503 matrix_pso=matrix_pso, &
504 matrix_fc=matrix_fc, &
505 matrix_dso=matrix_dso, &
516 r_i = particle_set(iatom)%r
525 CALL dbcsr_set(matrix_fc(1)%matrix, 0.0_dp)
530 IF (output_unit > 0)
THEN
531 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| fermi_contact: CheckSum =', chk(1)
538 CALL dbcsr_set(matrix_pso(1)%matrix, 0.0_dp)
539 CALL dbcsr_set(matrix_pso(2)%matrix, 0.0_dp)
540 CALL dbcsr_set(matrix_pso(3)%matrix, 0.0_dp)
547 IF (output_unit > 0)
THEN
548 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_x: CheckSum =', chk(2)
549 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_y: CheckSum =', chk(3)
550 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_z: CheckSum =', chk(4)
557 CALL dbcsr_set(matrix_efg(1)%matrix, 0.0_dp)
558 CALL dbcsr_set(matrix_efg(2)%matrix, 0.0_dp)
559 CALL dbcsr_set(matrix_efg(3)%matrix, 0.0_dp)
560 CALL dbcsr_set(matrix_efg(4)%matrix, 0.0_dp)
561 CALL dbcsr_set(matrix_efg(5)%matrix, 0.0_dp)
562 CALL dbcsr_set(matrix_efg(6)%matrix, 0.0_dp)
572 IF (output_unit > 0)
THEN
573 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3xx-rr)/3: CheckSum =', chk(5)
574 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3yy-rr)/3: CheckSum =', chk(6)
575 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3zz-rr)/3: CheckSum =', chk(7)
576 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg xy: CheckSum =', chk(8)
577 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg xz: CheckSum =', chk(9)
578 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg yz: CheckSum =', chk(10)
583 IF (output_unit > 0)
THEN
584 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| all operator: CheckSum =', sum(chk(1:10))
589 CALL dbcsr_set(matrix_dso(1)%matrix, 0.0_dp)
590 CALL dbcsr_set(matrix_dso(2)%matrix, 0.0_dp)
591 CALL dbcsr_set(matrix_dso(3)%matrix, 0.0_dp)
592 CALL rrc_xyz_ao(matrix_dso, qs_env, (/0.0_dp, 0.0_dp, 0.0_dp/), 1)
598 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
605 efg_psi0(ispin, idir), ncol=nmo, &
614 pso_psi0(ispin, idir), ncol=nmo, &
622 fc_psi0(ispin), ncol=nmo, &
630 dso_psi0(ispin, idir), ncol=nmo, &
638 "PRINT%PROGRAM_RUN_INFO")
640 CALL timestop(handle)
653 LOGICAL :: do_periodic
657 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, polar_env=polar_env)
658 CALL get_polar_env(polar_env=polar_env, do_periodic=do_periodic)
659 IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
660 IF (do_periodic)
THEN
661 CALL polar_tb_operators_berry(qs_env)
663 CALL polar_tb_operators_local(qs_env)
666 IF (do_periodic)
THEN
692 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_berry'
693 COMPLEX(KIND=dp),
PARAMETER ::
one = (1.0_dp, 0.0_dp), &
694 zero = (0.0_dp, 0.0_dp)
696 COMPLEX(DP) :: zdet, zdeta
697 INTEGER :: handle, i, idim, ispin, nao, nmo, &
700 REAL(
dp) :: kvec(3), maxocc
702 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: eigrmat
703 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:, :) :: inv_mat
705 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: op_fm_set, opvec
706 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: inv_work
707 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
716 CALL timeset(routinen, handle)
718 NULLIFY (dberry_psi0, sinmat, cosmat)
721 NULLIFY (cell, dft_control, mos, matrix_s)
724 dft_control=dft_control, &
726 polar_env=polar_env, &
730 nspins = dft_control%nspins
734 dberry_psi0=dberry_psi0)
745 ALLOCATE (opvec(2, dft_control%nspins))
746 ALLOCATE (op_fm_set(2, dft_control%nspins))
747 ALLOCATE (eigrmat(dft_control%nspins))
748 ALLOCATE (inv_mat(3, dft_control%nspins))
749 ALLOCATE (inv_work(2, 3, dft_control%nspins))
752 DO ispin = 1, dft_control%nspins
753 NULLIFY (tmp_fm_struct, mo_coeff)
754 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
756 ncol_global=nmo, para_env=para_env, context=mo_coeff%matrix_struct%context)
757 DO i = 1,
SIZE(op_fm_set, 1)
758 CALL cp_fm_create(opvec(i, ispin), mo_coeff%matrix_struct)
761 CALL cp_cfm_create(eigrmat(ispin), op_fm_set(1, ispin)%matrix_struct)
764 CALL cp_cfm_create(inv_mat(i, ispin), op_fm_set(1, ispin)%matrix_struct)
765 CALL cp_fm_create(inv_work(2, i, ispin), op_fm_set(2, ispin)%matrix_struct)
766 CALL cp_fm_create(inv_work(1, i, ispin), op_fm_set(1, ispin)%matrix_struct)
770 NULLIFY (cosmat, sinmat)
771 ALLOCATE (cosmat, sinmat)
772 CALL dbcsr_copy(cosmat, matrix_s(1)%matrix,
'COS MOM')
773 CALL dbcsr_copy(sinmat, matrix_s(1)%matrix,
'SIN MOM')
776 kvec(:) =
twopi*cell%h_inv(i, :)
781 DO ispin = 1, dft_control%nspins
782 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff=mo_coeff, nmo=nmo)
785 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff, opvec(1, ispin), 0.0_dp, &
788 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff, opvec(2, ispin), 0.0_dp, &
795 DO ispin = 1, dft_control%nspins
798 eigrmat(ispin)%local_data(:, idim) = &
799 cmplx(op_fm_set(1, ispin)%local_data(:, idim), &
800 -op_fm_set(2, ispin)%local_data(:, idim),
dp)
803 CALL cp_cfm_solve(eigrmat(ispin), inv_mat(i, ispin), zdeta)
807 DO ispin = 1, dft_control%nspins
809 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo, maxocc=maxocc)
811 inv_work(1, i, ispin)%local_data(:, z) = real(inv_mat(i, ispin)%local_data(:, z),
dp)
812 inv_work(2, i, ispin)%local_data(:, z) = aimag(inv_mat(i, ispin)%local_data(:, z))
814 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, -1.0_dp, opvec(1, ispin), inv_work(2, i, ispin), &
815 0.0_dp, dberry_psi0(i, ispin))
816 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, 1.0_dp, opvec(2, ispin), inv_work(1, i, ispin), &
817 1.0_dp, dberry_psi0(i, ispin))
822 DO ispin = 1, dft_control%nspins
840 CALL timestop(handle)
858 SUBROUTINE polar_tb_operators_berry(qs_env)
862 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_tb_operators_berry'
865 INTEGER :: handle, i, icol, idir, irow, ispin, nmo, &
867 LOGICAL :: do_raman, found
869 REAL(
dp),
DIMENSION(3) :: kvec, ria, rib
870 REAL(
dp),
DIMENSION(3, 3) :: hmat
871 REAL(
dp),
DIMENSION(:, :),
POINTER :: d_block, s_block
873 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
876 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
882 CALL timeset(routinen, handle)
884 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, &
885 cell=cell, particle_set=particle_set, &
886 polar_env=polar_env, mos=mos, matrix_s=matrix_s)
888 nspins = dft_control%nspins
892 dberry_psi0=dberry_psi0)
898 ALLOCATE (dipmat(i)%matrix)
899 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
903 hmat = cell%hmat(:, :)/
twopi
907 NULLIFY (s_block, d_block)
909 ria = particle_set(irow)%r
910 rib = particle_set(icol)%r
912 kvec(:) =
twopi*cell%h_inv(idir, :)
913 dd = sum(kvec(:)*ria(:))
914 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)
915 fdir = aimag(log(zdeta))
916 dd = sum(kvec(:)*rib(:))
917 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)
918 fdir = fdir + aimag(log(zdeta))
920 row=irow, col=icol, block=d_block, found=found)
922 d_block = d_block + 0.5_dp*fdir*s_block
928 DO ispin = 1, dft_control%nspins
929 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
932 dberry_psi0(i, ispin), ncol=nmo)
943 CALL timestop(handle)
944 END SUBROUTINE polar_tb_operators_berry
962 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_local'
964 INTEGER :: handle, i, ispin, nmo, nspins
966 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
968 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
973 CALL timeset(routinen, handle)
976 dft_control=dft_control, &
977 polar_env=polar_env, &
981 nspins = dft_control%nspins
985 dberry_psi0=dberry_psi0)
992 ALLOCATE (dipmat(i)%matrix)
993 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
999 DO ispin = 1, dft_control%nspins
1000 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
1003 dberry_psi0(i, ispin), ncol=nmo)
1014 CALL timestop(handle)
1032 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_local_wannier'
1034 INTEGER :: alpha, handle, i, icenter, ispin, &
1035 map_atom, map_molecule, &
1036 max_nbr_center, nao, natom, nmo, &
1038 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: mapping_atom_molecule
1039 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: mapping_wannier_atom
1040 REAL(
dp) :: f_spin, smallest_r, tmp_r
1041 REAL(
dp),
DIMENSION(3) :: distance, r_shifted
1042 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: apt_el, apt_nuc
1043 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: apt_center, apt_subset
1046 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
1047 TYPE(
cp_fm_type),
POINTER :: mo_coeff, overlap1_mo, tmp_fm, &
1048 tmp_fm_like_mos, tmp_fm_momo
1052 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1054 CALL timeset(routinen, handle)
1056 NULLIFY (qs_kind_set, particle_set, molecule_set, cell)
1059 qs_kind_set=qs_kind_set, &
1060 particle_set=particle_set, &
1061 molecule_set=molecule_set, &
1062 polar_env=polar_env, &
1065 CALL get_polar_env(polar_env=polar_env, dberry_psi0=dberry_psi0)
1067 nsubset =
SIZE(molecule_set)
1068 natom =
SIZE(particle_set)
1069 apt_el => dcdr_env%apt_el_dcdr
1070 apt_nuc => dcdr_env%apt_nuc_dcdr
1071 apt_subset => dcdr_env%apt_el_dcdr_per_subset
1072 apt_center => dcdr_env%apt_el_dcdr_per_center
1075 IF (dcdr_env%nspins == 1)
THEN
1076 max_nbr_center = dcdr_env%nbr_center(1)
1078 max_nbr_center = max(dcdr_env%nbr_center(1), dcdr_env%nbr_center(2))
1080 ALLOCATE (mapping_wannier_atom(max_nbr_center, dcdr_env%nspins))
1081 ALLOCATE (mapping_atom_molecule(natom))
1082 centers_set => dcdr_env%centers_set
1083 DO ispin = 1, dcdr_env%nspins
1084 DO icenter = 1, dcdr_env%nbr_center(ispin)
1088 r_shifted=r_shifted)
1090 smallest_r = huge(0._dp)
1092 distance =
pbc(r_shifted, particle_set(i)%r(1:3), cell)
1093 tmp_r = sum(distance**2)
1094 IF (tmp_r < smallest_r)
THEN
1095 mapping_wannier_atom(icenter, ispin) = i
1103 IF (dcdr_env%lambda == 1 .AND. dcdr_env%beta == 1)
THEN
1104 DO icenter = 1, dcdr_env%nbr_center(ispin)
1105 map_atom = mapping_wannier_atom(icenter, ispin)
1106 map_molecule = mapping_atom_molecule(map_atom)
1112 f_spin = 2._dp/dcdr_env%nspins
1114 DO ispin = 1, dcdr_env%nspins
1117 ALLOCATE (tmp_fm_like_mos)
1118 ALLOCATE (overlap1_mo)
1119 CALL cp_fm_create(tmp_fm_like_mos, dcdr_env%likemos_fm_struct(ispin)%struct)
1120 CALL cp_fm_create(overlap1_mo, dcdr_env%momo_fm_struct(ispin)%struct)
1121 nmo = dcdr_env%nmo(ispin)
1122 mo_coeff => dcdr_env%mo_coeff(ispin)
1128 1.0_dp, mo_coeff, tmp_fm_like_mos, &
1129 0.0_dp, overlap1_mo)
1135 -0.5_dp, mo_coeff, overlap1_mo, &
1136 -1.0_dp, dcdr_env%dCR_prime(ispin))
1141 ALLOCATE (tmp_fm_momo)
1142 CALL cp_fm_create(tmp_fm, dcdr_env%likemos_fm_struct(ispin)%struct)
1143 CALL cp_fm_create(tmp_fm_momo, dcdr_env%momo_fm_struct(ispin)%struct)
1147 DO icenter = 1, dcdr_env%nbr_center(ispin)
1148 CALL dbcsr_set(dcdr_env%moments(alpha)%matrix, 0.0_dp)
1150 ref_point=centers_set(ispin)%array(1:3, icenter))
1152 mo_coeff=mo_coeff, work=tmp_fm, nmo=nmo, &
1154 res=dberry_psi0(alpha, ispin))
1162 DEALLOCATE (overlap1_mo)
1164 DEALLOCATE (tmp_fm_like_mos)
1165 DEALLOCATE (tmp_fm_momo)
1170 CALL timestop(handle)
1184 SUBROUTINE polar_tb_operators_local(qs_env)
1188 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_tb_operators_local'
1190 INTEGER :: handle, i, icol, irow, ispin, nmo, nspins
1191 LOGICAL :: do_raman, found
1193 REAL(
dp),
DIMENSION(3) :: ria, rib
1194 REAL(
dp),
DIMENSION(:, :),
POINTER :: d_block, s_block
1196 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
1199 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
1205 CALL timeset(routinen, handle)
1207 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, &
1208 cell=cell, particle_set=particle_set, &
1209 polar_env=polar_env, mos=mos, matrix_s=matrix_s)
1211 nspins = dft_control%nspins
1214 do_raman=do_raman, &
1215 dberry_psi0=dberry_psi0)
1219 ALLOCATE (dipmat(3))
1221 ALLOCATE (dipmat(i)%matrix)
1222 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
1227 NULLIFY (s_block, d_block)
1229 ria = particle_set(irow)%r
1230 ria =
pbc(ria, cell)
1231 rib = particle_set(icol)%r
1232 rib =
pbc(rib, cell)
1235 row=irow, col=icol, block=d_block, found=found)
1237 fdir = 0.5_dp*(ria(i) + rib(i))
1238 d_block = s_block*fdir
1244 DO ispin = 1, dft_control%nspins
1245 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
1248 dberry_psi0(i, ispin), ncol=nmo)
1259 CALL timestop(handle)
1261 END SUBROUTINE polar_tb_operators_local
1277 IF ((b .EQ. a + 1 .OR. b .EQ. a - 2) .AND. (c .EQ. b + 1 .OR. c .EQ. b - 2))
THEN
1279 ELSEIF ((b .EQ. a - 1 .OR. b .EQ. a + 2) .AND. (c .EQ. b - 1 .OR. c .EQ. b + 2))
THEN
1293 INTEGER :: ii, iii, i
1301 ELSEIF (iii == 0)
THEN
1303 ELSEIF (ii == iii)
THEN
1305 i =
coset(l(1), l(2), l(3)) - 1
1310 i =
coset(l(1), l(2), l(3)) - 1
1321 INTEGER,
INTENT(IN) :: i1
1322 INTEGER,
INTENT(OUT) :: i2, i3
1327 ELSEIF (i1 == 2)
THEN
1330 ELSEIF (i1 == 3)
THEN
1345 INTEGER,
INTENT(IN) :: i1, i2
1346 INTEGER,
INTENT(OUT) :: i3
1348 IF ((i1 + i2) == 3)
THEN
1350 ELSEIF ((i1 + i2) == 4)
THEN
1352 ELSEIF ((i1 + i2) == 5)
THEN
1370 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(in) :: ra, rc
1372 INTEGER,
INTENT(IN) :: ixyz
1374 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_scale_by_pbc_AC'
1376 INTEGER :: handle, icol_global, icol_local, &
1377 irow_global, irow_local, m, mypcol, &
1378 myprow, n, ncol_local, nrow_local
1379 REAL(kind=
dp) :: dist(3), rra(3), rrc(3)
1380 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a
1382 CALL timeset(routinen, handle)
1384 myprow = matrix%matrix_struct%context%mepos(1)
1385 mypcol = matrix%matrix_struct%context%mepos(2)
1387 nrow_local = matrix%matrix_struct%nrow_locals(myprow)
1388 ncol_local = matrix%matrix_struct%ncol_locals(mypcol)
1393 a => matrix%local_data
1394 DO icol_local = 1, ncol_local
1395 icol_global = matrix%matrix_struct%col_indices(icol_local)
1396 IF (icol_global .GT. n) cycle
1397 rrc = rc(:, icol_global)
1398 DO irow_local = 1, nrow_local
1399 irow_global = matrix%matrix_struct%row_indices(irow_local)
1400 IF (irow_global .GT. m) cycle
1401 rra = ra(:, irow_global)
1402 dist =
pbc(rrc, rra, cell)
1403 a(irow_local, icol_local) = a(irow_local, icol_local)*dist(ixyz)
1407 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_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
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)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
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_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_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,...
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
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)
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, 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, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, 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)
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, basis_type, total_zeff_corr, npgf_seg)
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)
...
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)
Calculation of the linear momentum matrix <mu|∂|nu> over Cartesian Gaussian functions.
subroutine, public rrc_xyz_ao(op, qs_env, rc, order, minimum_image, soft)
Calculation of the components of the dipole operator in the length form by taking the relative positi...
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.