46 USE dbcsr_api,
ONLY: &
47 dbcsr_checksum, dbcsr_convert_offsets_to_sizes, dbcsr_copy, dbcsr_create, &
48 dbcsr_deallocate_matrix, dbcsr_distribution_type, dbcsr_get_block_p, &
49 dbcsr_iterator_blocks_left, dbcsr_iterator_next_block, dbcsr_iterator_start, &
50 dbcsr_iterator_stop, dbcsr_iterator_type, dbcsr_p_type, dbcsr_set, dbcsr_type, &
51 dbcsr_type_antisymmetric, dbcsr_type_no_symmetry
83 #include "./base/base_uses.f90"
91 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_linres_op'
117 TYPE(current_env_type) :: current_env
118 TYPE(qs_environment_type),
POINTER :: qs_env
120 CHARACTER(LEN=*),
PARAMETER :: routinen =
'current_operators'
122 INTEGER :: handle, iao, icenter, idir, ii, iii, &
123 ispin, istate, j, nao, natom, &
124 nbr_center(2), nmo, nsgf, nspins, &
125 nstates(2), output_unit
126 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
127 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
128 REAL(
dp) :: chk(3), ck(3), ckdk(3), dk(3)
129 REAL(
dp),
DIMENSION(:, :),
POINTER :: basisfun_center, vecbuf_c0
130 TYPE(cell_type),
POINTER :: cell
131 TYPE(cp_2d_i_p_type),
DIMENSION(:),
POINTER :: center_list
132 TYPE(cp_2d_r_p_type),
DIMENSION(3) :: vecbuf_rmdc0
133 TYPE(cp_2d_r_p_type),
DIMENSION(:),
POINTER :: centers_set
134 TYPE(cp_fm_struct_type),
POINTER :: tmp_fm_struct
135 TYPE(cp_fm_type) :: fm_work1
136 TYPE(cp_fm_type),
DIMENSION(3) :: fm_rmd_mos
137 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: psi0_order
138 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: p_psi0, rxp_psi0
139 TYPE(cp_fm_type),
POINTER :: mo_coeff
140 TYPE(cp_logger_type),
POINTER :: logger
141 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
142 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: op_ao
143 TYPE(dft_control_type),
POINTER :: dft_control
144 TYPE(linres_control_type),
POINTER :: linres_control
145 TYPE(mp_para_env_type),
POINTER :: para_env
146 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
147 POINTER :: sab_all, sab_orb
148 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
149 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
150 TYPE(section_vals_type),
POINTER :: lr_section
152 CALL timeset(routinen, handle)
154 NULLIFY (qs_kind_set, cell, dft_control, linres_control, &
155 logger, particle_set, lr_section, &
156 basisfun_center, centers_set, center_list, p_psi0, &
157 rxp_psi0, vecbuf_c0, psi0_order, &
158 mo_coeff, op_ao, sab_all)
165 extension=
".linresLog")
166 IF (output_unit > 0)
THEN
167 WRITE (output_unit, fmt=
"(T2,A,/)") &
168 "CURRENT| Calculation of the p and (r-d)xp operators applied to psi0"
172 qs_kind_set=qs_kind_set, &
174 dft_control=dft_control, &
175 linres_control=linres_control, &
177 particle_set=particle_set, &
180 dbcsr_dist=dbcsr_dist)
182 nspins = dft_control%nspins
184 CALL get_current_env(current_env=current_env, nao=nao, centers_set=centers_set, &
185 center_list=center_list, basisfun_center=basisfun_center, &
186 nbr_center=nbr_center, p_psi0=p_psi0, rxp_psi0=rxp_psi0, &
187 psi0_order=psi0_order, &
190 ALLOCATE (vecbuf_c0(1, nao))
192 NULLIFY (vecbuf_rmdc0(idir)%array)
193 ALLOCATE (vecbuf_rmdc0(idir)%array(1, nao))
198 natom =
SIZE(particle_set, 1)
199 ALLOCATE (first_sgf(natom))
200 ALLOCATE (last_sgf(natom))
203 first_sgf=first_sgf, &
225 ALLOCATE (row_blk_sizes(natom))
226 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
230 ALLOCATE (op_ao(1)%matrix, op_ao(2)%matrix, op_ao(3)%matrix)
232 CALL dbcsr_create(matrix=op_ao(1)%matrix, &
234 dist=dbcsr_dist, matrix_type=dbcsr_type_no_symmetry, &
235 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
236 nze=0, mutable_work=.true.)
238 CALL dbcsr_set(op_ao(1)%matrix, 0.0_dp)
241 CALL dbcsr_copy(op_ao(idir)%matrix, op_ao(1)%matrix, &
242 "op_ao"//
"-"//trim(adjustl(cp_to_string(idir))))
243 CALL dbcsr_set(op_ao(idir)%matrix, 0.0_dp)
248 mo_coeff => psi0_order(ispin)
253 DO icenter = 1, nbr_center(ispin)
254 CALL dbcsr_set(op_ao(1)%matrix, 0.0_dp)
255 CALL dbcsr_set(op_ao(2)%matrix, 0.0_dp)
256 CALL dbcsr_set(op_ao(3)%matrix, 0.0_dp)
263 chk(1) = chk(1) + dbcsr_checksum(op_ao(1)%matrix)
264 chk(2) = chk(2) + dbcsr_checksum(op_ao(2)%matrix)
265 chk(3) = chk(3) + dbcsr_checksum(op_ao(3)%matrix)
269 rxp_psi0(ispin, idir), ncol=nmo, &
271 DO j = center_list(ispin)%array(1, icenter), center_list(ispin)%array(1, icenter + 1) - 1
272 istate = center_list(ispin)%array(2, j)
274 CALL cp_fm_to_fm(rxp_psi0(ispin, idir), &
275 p_psi0(ispin, idir), 1, istate, istate)
279 CALL cp_fm_to_fm(p_psi0(ispin, 1), rxp_psi0(ispin, 1))
280 CALL cp_fm_to_fm(p_psi0(ispin, 2), rxp_psi0(ispin, 2))
281 CALL cp_fm_to_fm(p_psi0(ispin, 3), rxp_psi0(ispin, 3))
287 IF (output_unit > 0)
THEN
288 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_x =', chk(1)
289 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_y =', chk(2)
290 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum L_z =', chk(3)
295 ALLOCATE (op_ao(1)%matrix, op_ao(2)%matrix, op_ao(3)%matrix)
297 CALL dbcsr_create(matrix=op_ao(1)%matrix, &
299 dist=dbcsr_dist, matrix_type=dbcsr_type_antisymmetric, &
300 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
301 nze=0, mutable_work=.true.)
303 CALL dbcsr_set(op_ao(1)%matrix, 0.0_dp)
306 CALL dbcsr_copy(op_ao(idir)%matrix, op_ao(1)%matrix, &
307 "op_ao"//
"-"//trim(adjustl(cp_to_string(idir))))
308 CALL dbcsr_set(op_ao(idir)%matrix, 0.0_dp)
315 chk(1) = dbcsr_checksum(op_ao(1)%matrix)
316 chk(2) = dbcsr_checksum(op_ao(2)%matrix)
317 chk(3) = dbcsr_checksum(op_ao(3)%matrix)
318 IF (output_unit > 0)
THEN
319 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_x =', chk(1)
320 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_y =', chk(2)
321 WRITE (output_unit,
'(T2,A,E23.16)')
'CURRENT| current_operators: CheckSum P_z =', chk(3)
326 mo_coeff => psi0_order(ispin)
330 p_psi0(ispin, idir), ncol=nmo, &
338 "PRINT%PROGRAM_RUN_INFO")
365 mo_coeff => psi0_order(ispin)
367 NULLIFY (tmp_fm_struct)
369 ncol_global=nmo, para_env=para_env, &
370 context=mo_coeff%matrix_struct%context)
382 dk(1:3) = centers_set(ispin)%array(1:3, istate)
386 ck(1:3) = basisfun_center(1:3, iao)
387 ckdk =
pbc(dk, ck, cell)
388 vecbuf_rmdc0(idir)%array(1, iao) = vecbuf_c0(1, iao)*ckdk(idir)
391 1, istate, nao, 1, transpose=.true.)
401 fm_work1, ncol=nmo, alpha=-1.0_dp)
407 fm_work1, ncol=nmo, alpha=-1.0_dp)
414 CALL cp_fm_release(fm_rmd_mos(idir))
416 CALL cp_fm_release(fm_work1)
421 DEALLOCATE (row_blk_sizes)
423 DEALLOCATE (first_sgf, last_sgf)
425 DEALLOCATE (vecbuf_c0)
427 DEALLOCATE (vecbuf_rmdc0(idir)%array)
430 CALL timestop(handle)
442 TYPE(issc_env_type) :: issc_env
443 TYPE(qs_environment_type),
POINTER :: qs_env
444 INTEGER,
INTENT(IN) :: iatom
446 CHARACTER(LEN=*),
PARAMETER :: routinen =
'issc_operators'
448 INTEGER :: handle, idir, ispin, nmo, nspins, &
450 LOGICAL :: do_dso, do_fc, do_pso, do_sd
451 REAL(
dp) :: chk(20), r_i(3)
452 TYPE(cell_type),
POINTER :: cell
453 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: fc_psi0
454 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: dso_psi0, efg_psi0, pso_psi0
455 TYPE(cp_fm_type),
POINTER :: mo_coeff
456 TYPE(cp_logger_type),
POINTER :: logger
457 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_dso, matrix_efg, matrix_fc, &
459 TYPE(dft_control_type),
POINTER :: dft_control
460 TYPE(linres_control_type),
POINTER :: linres_control
461 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
462 TYPE(mp_para_env_type),
POINTER :: para_env
463 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
464 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
465 TYPE(section_vals_type),
POINTER :: lr_section
467 CALL timeset(routinen, handle)
469 NULLIFY (matrix_fc, matrix_pso, matrix_efg)
470 NULLIFY (efg_psi0, pso_psi0, fc_psi0)
477 extension=
".linresLog")
480 qs_kind_set=qs_kind_set, &
482 dft_control=dft_control, &
483 linres_control=linres_control, &
486 particle_set=particle_set)
488 nspins = dft_control%nspins
491 matrix_efg=matrix_efg, &
492 matrix_pso=matrix_pso, &
493 matrix_fc=matrix_fc, &
494 matrix_dso=matrix_dso, &
505 r_i = particle_set(iatom)%r
514 CALL dbcsr_set(matrix_fc(1)%matrix, 0.0_dp)
517 chk(1) = dbcsr_checksum(matrix_fc(1)%matrix)
519 IF (output_unit > 0)
THEN
520 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| fermi_contact: CheckSum =', chk(1)
527 CALL dbcsr_set(matrix_pso(1)%matrix, 0.0_dp)
528 CALL dbcsr_set(matrix_pso(2)%matrix, 0.0_dp)
529 CALL dbcsr_set(matrix_pso(3)%matrix, 0.0_dp)
532 chk(2) = dbcsr_checksum(matrix_pso(1)%matrix)
533 chk(3) = dbcsr_checksum(matrix_pso(2)%matrix)
534 chk(4) = dbcsr_checksum(matrix_pso(3)%matrix)
536 IF (output_unit > 0)
THEN
537 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_x: CheckSum =', chk(2)
538 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_y: CheckSum =', chk(3)
539 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| pso_z: CheckSum =', chk(4)
546 CALL dbcsr_set(matrix_efg(1)%matrix, 0.0_dp)
547 CALL dbcsr_set(matrix_efg(2)%matrix, 0.0_dp)
548 CALL dbcsr_set(matrix_efg(3)%matrix, 0.0_dp)
549 CALL dbcsr_set(matrix_efg(4)%matrix, 0.0_dp)
550 CALL dbcsr_set(matrix_efg(5)%matrix, 0.0_dp)
551 CALL dbcsr_set(matrix_efg(6)%matrix, 0.0_dp)
554 chk(5) = dbcsr_checksum(matrix_efg(1)%matrix)
555 chk(6) = dbcsr_checksum(matrix_efg(2)%matrix)
556 chk(7) = dbcsr_checksum(matrix_efg(3)%matrix)
557 chk(8) = dbcsr_checksum(matrix_efg(4)%matrix)
558 chk(9) = dbcsr_checksum(matrix_efg(5)%matrix)
559 chk(10) = dbcsr_checksum(matrix_efg(6)%matrix)
561 IF (output_unit > 0)
THEN
562 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3xx-rr)/3: CheckSum =', chk(5)
563 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3yy-rr)/3: CheckSum =', chk(6)
564 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg (3zz-rr)/3: CheckSum =', chk(7)
565 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg xy: CheckSum =', chk(8)
566 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg xz: CheckSum =', chk(9)
567 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| efg yz: CheckSum =', chk(10)
572 IF (output_unit > 0)
THEN
573 WRITE (output_unit,
'(T2,A,E23.16)')
'ISSC| all operator: CheckSum =', sum(chk(1:10))
578 CALL dbcsr_set(matrix_dso(1)%matrix, 0.0_dp)
579 CALL dbcsr_set(matrix_dso(2)%matrix, 0.0_dp)
580 CALL dbcsr_set(matrix_dso(3)%matrix, 0.0_dp)
581 CALL rrc_xyz_ao(matrix_dso, qs_env, (/0.0_dp, 0.0_dp, 0.0_dp/), 1)
587 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
594 efg_psi0(ispin, idir), ncol=nmo, &
603 pso_psi0(ispin, idir), ncol=nmo, &
611 fc_psi0(ispin), ncol=nmo, &
619 dso_psi0(ispin, idir), ncol=nmo, &
627 "PRINT%PROGRAM_RUN_INFO")
629 CALL timestop(handle)
640 TYPE(qs_environment_type),
POINTER :: qs_env
642 LOGICAL :: do_periodic
643 TYPE(dft_control_type),
POINTER :: dft_control
644 TYPE(polar_env_type),
POINTER :: polar_env
646 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, polar_env=polar_env)
647 CALL get_polar_env(polar_env=polar_env, do_periodic=do_periodic)
648 IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
649 IF (do_periodic)
THEN
650 CALL polar_tb_operators_berry(qs_env)
652 CALL polar_tb_operators_local(qs_env)
655 IF (do_periodic)
THEN
656 CALL polar_operators_berry(qs_env)
658 CALL polar_operators_local(qs_env)
677 SUBROUTINE polar_operators_berry(qs_env)
679 TYPE(qs_environment_type),
POINTER :: qs_env
681 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_berry'
682 COMPLEX(KIND=dp),
PARAMETER :: one = (1.0_dp, 0.0_dp), &
683 zero = (0.0_dp, 0.0_dp)
685 COMPLEX(DP) :: zdet, zdeta
686 INTEGER :: handle, i, idim, ispin, nao, nmo, &
689 REAL(
dp) :: kvec(3), maxocc
690 TYPE(cell_type),
POINTER :: cell
691 TYPE(cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: eigrmat
692 TYPE(cp_cfm_type),
ALLOCATABLE,
DIMENSION(:, :) :: inv_mat
693 TYPE(cp_fm_struct_type),
POINTER :: tmp_fm_struct
694 TYPE(cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: op_fm_set, opvec
695 TYPE(cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: inv_work
696 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
697 TYPE(cp_fm_type),
POINTER :: mo_coeff
698 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s
699 TYPE(dbcsr_type),
POINTER :: cosmat, sinmat
700 TYPE(dft_control_type),
POINTER :: dft_control
701 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
702 TYPE(mp_para_env_type),
POINTER :: para_env
703 TYPE(polar_env_type),
POINTER :: polar_env
705 CALL timeset(routinen, handle)
707 NULLIFY (dberry_psi0, sinmat, cosmat)
710 NULLIFY (cell, dft_control, mos, matrix_s)
713 dft_control=dft_control, &
715 polar_env=polar_env, &
719 nspins = dft_control%nspins
723 dberry_psi0=dberry_psi0)
734 ALLOCATE (opvec(2, dft_control%nspins))
735 ALLOCATE (op_fm_set(2, dft_control%nspins))
736 ALLOCATE (eigrmat(dft_control%nspins))
737 ALLOCATE (inv_mat(3, dft_control%nspins))
738 ALLOCATE (inv_work(2, 3, dft_control%nspins))
741 DO ispin = 1, dft_control%nspins
742 NULLIFY (tmp_fm_struct, mo_coeff)
743 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
745 ncol_global=nmo, para_env=para_env, context=mo_coeff%matrix_struct%context)
746 DO i = 1,
SIZE(op_fm_set, 1)
747 CALL cp_fm_create(opvec(i, ispin), mo_coeff%matrix_struct)
750 CALL cp_cfm_create(eigrmat(ispin), op_fm_set(1, ispin)%matrix_struct)
753 CALL cp_cfm_create(inv_mat(i, ispin), op_fm_set(1, ispin)%matrix_struct)
754 CALL cp_fm_create(inv_work(2, i, ispin), op_fm_set(2, ispin)%matrix_struct)
755 CALL cp_fm_create(inv_work(1, i, ispin), op_fm_set(1, ispin)%matrix_struct)
759 NULLIFY (cosmat, sinmat)
760 ALLOCATE (cosmat, sinmat)
761 CALL dbcsr_copy(cosmat, matrix_s(1)%matrix,
'COS MOM')
762 CALL dbcsr_copy(sinmat, matrix_s(1)%matrix,
'SIN MOM')
765 kvec(:) =
twopi*cell%h_inv(i, :)
766 CALL dbcsr_set(cosmat, 0.0_dp)
767 CALL dbcsr_set(sinmat, 0.0_dp)
770 DO ispin = 1, dft_control%nspins
771 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff=mo_coeff, nmo=nmo)
774 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff, opvec(1, ispin), 0.0_dp, &
777 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff, opvec(2, ispin), 0.0_dp, &
784 DO ispin = 1, dft_control%nspins
787 eigrmat(ispin)%local_data(:, idim) = &
788 cmplx(op_fm_set(1, ispin)%local_data(:, idim), &
789 -op_fm_set(2, ispin)%local_data(:, idim),
dp)
792 CALL cp_cfm_solve(eigrmat(ispin), inv_mat(i, ispin), zdeta)
796 DO ispin = 1, dft_control%nspins
798 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo, maxocc=maxocc)
800 inv_work(1, i, ispin)%local_data(:, z) = real(inv_mat(i, ispin)%local_data(:, z),
dp)
801 inv_work(2, i, ispin)%local_data(:, z) = aimag(inv_mat(i, ispin)%local_data(:, z))
803 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, -1.0_dp, opvec(1, ispin), inv_work(2, i, ispin), &
804 0.0_dp, dberry_psi0(i, ispin))
805 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, 1.0_dp, opvec(2, ispin), inv_work(1, i, ispin), &
806 1.0_dp, dberry_psi0(i, ispin))
811 DO ispin = 1, dft_control%nspins
820 CALL cp_fm_release(inv_work)
821 CALL cp_fm_release(opvec)
822 CALL cp_fm_release(op_fm_set)
824 CALL dbcsr_deallocate_matrix(cosmat)
825 CALL dbcsr_deallocate_matrix(sinmat)
829 CALL timestop(handle)
831 END SUBROUTINE polar_operators_berry
847 SUBROUTINE polar_tb_operators_berry(qs_env)
849 TYPE(qs_environment_type),
POINTER :: qs_env
851 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_tb_operators_berry'
854 INTEGER :: blk, handle, i, icol, idir, irow, ispin, &
856 LOGICAL :: do_raman, found
858 REAL(
dp),
DIMENSION(3) :: kvec, ria, rib
859 REAL(
dp),
DIMENSION(3, 3) :: hmat
860 REAL(
dp),
DIMENSION(:, :),
POINTER :: d_block, s_block
861 TYPE(cell_type),
POINTER :: cell
862 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
863 TYPE(cp_fm_type),
POINTER :: mo_coeff
864 TYPE(dbcsr_iterator_type) :: iter
865 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
866 TYPE(dft_control_type),
POINTER :: dft_control
867 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
868 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
869 TYPE(polar_env_type),
POINTER :: polar_env
871 CALL timeset(routinen, handle)
873 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, &
874 cell=cell, particle_set=particle_set, &
875 polar_env=polar_env, mos=mos, matrix_s=matrix_s)
877 nspins = dft_control%nspins
881 dberry_psi0=dberry_psi0)
887 ALLOCATE (dipmat(i)%matrix)
888 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
889 CALL dbcsr_set(dipmat(i)%matrix, 0.0_dp)
892 hmat = cell%hmat(:, :)/
twopi
894 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
895 DO WHILE (dbcsr_iterator_blocks_left(iter))
896 NULLIFY (s_block, d_block)
897 CALL dbcsr_iterator_next_block(iter, irow, icol, s_block, blk)
898 ria = particle_set(irow)%r
899 rib = particle_set(icol)%r
901 kvec(:) =
twopi*cell%h_inv(idir, :)
902 dd = sum(kvec(:)*ria(:))
903 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)
904 fdir = aimag(log(zdeta))
905 dd = sum(kvec(:)*rib(:))
906 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)
907 fdir = fdir + aimag(log(zdeta))
908 CALL dbcsr_get_block_p(matrix=dipmat(idir)%matrix, &
909 row=irow, col=icol, block=d_block, found=found)
911 d_block = d_block + 0.5_dp*fdir*s_block
914 CALL dbcsr_iterator_stop(iter)
917 DO ispin = 1, dft_control%nspins
918 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
921 dberry_psi0(i, ispin), ncol=nmo)
926 CALL dbcsr_deallocate_matrix(dipmat(i)%matrix)
932 CALL timestop(handle)
933 END SUBROUTINE polar_tb_operators_berry
947 SUBROUTINE polar_operators_local(qs_env)
949 TYPE(qs_environment_type),
POINTER :: qs_env
951 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_operators_local'
953 INTEGER :: handle, i, ispin, nmo, nspins
955 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
956 TYPE(cp_fm_type),
POINTER :: mo_coeff
957 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
958 TYPE(dft_control_type),
POINTER :: dft_control
959 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
960 TYPE(polar_env_type),
POINTER :: polar_env
962 CALL timeset(routinen, handle)
965 dft_control=dft_control, &
966 polar_env=polar_env, &
970 nspins = dft_control%nspins
974 dberry_psi0=dberry_psi0)
981 ALLOCATE (dipmat(i)%matrix)
982 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
983 CALL dbcsr_set(dipmat(i)%matrix, 0.0_dp)
988 DO ispin = 1, dft_control%nspins
989 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
992 dberry_psi0(i, ispin), ncol=nmo)
997 CALL dbcsr_deallocate_matrix(dipmat(i)%matrix)
1003 CALL timestop(handle)
1005 END SUBROUTINE polar_operators_local
1018 SUBROUTINE polar_tb_operators_local(qs_env)
1020 TYPE(qs_environment_type),
POINTER :: qs_env
1022 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_tb_operators_local'
1024 INTEGER :: blk, handle, i, icol, irow, ispin, nmo, &
1026 LOGICAL :: do_raman, found
1028 REAL(
dp),
DIMENSION(3) :: ria, rib
1029 REAL(
dp),
DIMENSION(:, :),
POINTER :: d_block, s_block
1030 TYPE(cell_type),
POINTER :: cell
1031 TYPE(cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0
1032 TYPE(cp_fm_type),
POINTER :: mo_coeff
1033 TYPE(dbcsr_iterator_type) :: iter
1034 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
1035 TYPE(dft_control_type),
POINTER :: dft_control
1036 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
1037 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1038 TYPE(polar_env_type),
POINTER :: polar_env
1040 CALL timeset(routinen, handle)
1042 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, &
1043 cell=cell, particle_set=particle_set, &
1044 polar_env=polar_env, mos=mos, matrix_s=matrix_s)
1046 nspins = dft_control%nspins
1049 do_raman=do_raman, &
1050 dberry_psi0=dberry_psi0)
1054 ALLOCATE (dipmat(3))
1056 ALLOCATE (dipmat(i)%matrix)
1057 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'dipole')
1060 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
1061 DO WHILE (dbcsr_iterator_blocks_left(iter))
1062 NULLIFY (s_block, d_block)
1063 CALL dbcsr_iterator_next_block(iter, irow, icol, s_block, blk)
1064 ria = particle_set(irow)%r
1065 ria =
pbc(ria, cell)
1066 rib = particle_set(icol)%r
1067 rib =
pbc(rib, cell)
1069 CALL dbcsr_get_block_p(matrix=dipmat(i)%matrix, &
1070 row=irow, col=icol, block=d_block, found=found)
1072 fdir = 0.5_dp*(ria(i) + rib(i))
1073 d_block = s_block*fdir
1076 CALL dbcsr_iterator_stop(iter)
1079 DO ispin = 1, dft_control%nspins
1080 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
1083 dberry_psi0(i, ispin), ncol=nmo)
1088 CALL dbcsr_deallocate_matrix(dipmat(i)%matrix)
1094 CALL timestop(handle)
1096 END SUBROUTINE polar_tb_operators_local
1112 IF ((b .EQ. a + 1 .OR. b .EQ. a - 2) .AND. (c .EQ. b + 1 .OR. c .EQ. b - 2))
THEN
1114 ELSEIF ((b .EQ. a - 1 .OR. b .EQ. a + 2) .AND. (c .EQ. b - 1 .OR. c .EQ. b + 2))
THEN
1128 INTEGER :: ii, iii, i
1136 ELSEIF (iii == 0)
THEN
1138 ELSEIF (ii == iii)
THEN
1140 i =
coset(l(1), l(2), l(3)) - 1
1145 i =
coset(l(1), l(2), l(3)) - 1
1156 INTEGER,
INTENT(IN) :: i1
1157 INTEGER,
INTENT(OUT) :: i2, i3
1162 ELSEIF (i1 == 2)
THEN
1165 ELSEIF (i1 == 3)
THEN
1180 INTEGER,
INTENT(IN) :: i1, i2
1181 INTEGER,
INTENT(OUT) :: i3
1183 IF ((i1 + i2) == 3)
THEN
1185 ELSEIF ((i1 + i2) == 4)
THEN
1187 ELSEIF ((i1 + i2) == 5)
THEN
1204 TYPE(cp_fm_type),
INTENT(IN) :: matrix
1205 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(in) :: ra, rc
1206 TYPE(cell_type),
POINTER :: cell
1207 INTEGER,
INTENT(IN) :: ixyz
1209 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_scale_by_pbc_AC'
1211 INTEGER :: handle, icol_global, icol_local, irow_global, irow_local, m, mypcol, myprow, n, &
1212 ncol_block, ncol_global, ncol_local, npcol, nprow, nrow_block, nrow_global, nrow_local
1213 REAL(kind=
dp) :: dist(3), rra(3), rrc(3)
1214 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a
1216 CALL timeset(routinen, handle)
1218 myprow = matrix%matrix_struct%context%mepos(1)
1219 mypcol = matrix%matrix_struct%context%mepos(2)
1220 nprow = matrix%matrix_struct%context%num_pe(1)
1221 npcol = matrix%matrix_struct%context%num_pe(2)
1223 nrow_block = matrix%matrix_struct%nrow_block
1224 ncol_block = matrix%matrix_struct%ncol_block
1225 nrow_global = matrix%matrix_struct%nrow_global
1226 ncol_global = matrix%matrix_struct%ncol_global
1227 nrow_local = matrix%matrix_struct%nrow_locals(myprow)
1228 ncol_local = matrix%matrix_struct%ncol_locals(mypcol)
1233 a => matrix%local_data
1234 DO icol_local = 1, ncol_local
1235 icol_global =
cp_fm_indxl2g(icol_local, ncol_block, mypcol, &
1236 matrix%matrix_struct%first_p_pos(2), npcol)
1237 IF (icol_global .GT. n) cycle
1238 rrc = rc(:, icol_global)
1239 DO irow_local = 1, nrow_local
1240 irow_global =
cp_fm_indxl2g(irow_local, nrow_block, myprow, &
1241 matrix%matrix_struct%first_p_pos(1), nprow)
1242 IF (irow_global .GT. m) cycle
1243 rra = ra(:, irow_global)
1244 dist =
pbc(rrc, rra, cell)
1245 a(irow_local, icol_local) = a(irow_local, icol_local)*dist(ixyz)
1249 CALL timestop(handle)
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
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...
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
integer function, public cp_fm_indxl2g(INDXLOC, NB, IPROC, ISRCPROC, NPROCS)
wrapper to scalapack function INDXL2G that computes the global index of a distributed matrix entry po...
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 twopi
Interface to the message passing library MPI.
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.
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_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, 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, 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)
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...
integer function, public ind_m2(ii, iii)
...
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 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_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)
...
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)
...
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.