46 USE mmpi_negf,
ONLY: create_communicators_negf, &
47 destroy_communicators_negf
48 USE mnegf_interface,
ONLY: negf_interface
49 USE negfmod,
ONLY: smeagolglobal_em_nas => em_nas, &
50 smeagolglobal_em_nau => em_nau, &
51 smeagolglobal_em_nso => em_nso, &
52 smeagolglobal_em_nuo => em_nuo, &
53 smeagolglobal_negfon => negfon
81#include "./base/base_uses.f90"
86 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'smeagol_interface'
101 CHARACTER(LEN=*),
PARAMETER :: routinen =
'run_smeagol_bulktrans'
103 CHARACTER(len=32) :: hst_fmt
104 INTEGER :: funit, handle, img, ispin, lead_label, &
105 log_unit, nimages, nspin
106 INTEGER(kind=int_8) :: ielem
107 INTEGER,
DIMENSION(2) :: max_ij_cell_image
108 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
109 LOGICAL :: do_kpoints, has_unit_metric, not_regtest
110 REAL(kind=
dp) :: h_to_ry
111 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: matrix_siesta_1d, nelectrons
112 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: matrix_siesta_2d
113 TYPE(
dbcsr_p_type),
ALLOCATABLE,
DIMENSION(:) :: matrix_kp_generic
114 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_kp, matrix_s_kp, matrix_w_kp, &
130 CALL get_qs_env(qs_env, dft_control=dft_control)
131 smeagol_control => dft_control%smeagol_control
134 CALL timeset(routinen, handle)
137 h_to_ry = smeagol_control%to_smeagol_energy_units
138 not_regtest = .NOT. smeagol_control%do_regtest
140 lead_label = smeagol_control%lead_label
141 nspin = dft_control%nspins
143 NULLIFY (v_hartree_rspace)
144 CALL get_qs_env(qs_env, energy=energy, para_env=para_env, subsys=subsys, &
145 scf_control=scf_control, &
146 do_kpoints=do_kpoints, kpoints=kpoints, &
147 matrix_ks_kp=matrix_ks_kp, matrix_s_kp=matrix_s_kp, &
148 rho=rho, sab_orb=sab_nl, v_hartree_rspace=v_hartree_rspace)
151 IF (not_regtest)
THEN
153 CALL write_average_hartree_potential(v_hartree_rspace, smeagol_control%project_name)
156 IF (log_unit > 0)
THEN
157 WRITE (log_unit,
'(/,T2,A,T61,ES20.10E2)')
"SMEAGOL| E_FERMI [a.u.] = ", energy%efermi
161 nimages = dft_control%nimages
165 ALLOCATE (cell_to_index(0:0, 0:0, 0:0))
166 cell_to_index(0, 0, 0) = 1
168 cpabort(
"Please enable k-points")
174 max_ij_cell_image(:) = -1
176 IF (smeagol_control%n_cell_images(img) > 0)
THEN
177 max_ij_cell_image(img) = smeagol_control%n_cell_images(img)/2
181 ALLOCATE (matrix_kp_generic(nimages))
184 CALL get_qs_env(qs_env, has_unit_metric=has_unit_metric)
185 IF (.NOT. has_unit_metric)
THEN
186 CALL get_qs_env(qs_env, matrix_w_kp=matrix_w_kp)
187 IF (.NOT.
ASSOCIATED(matrix_w_kp))
THEN
188 NULLIFY (matrix_w_kp)
193 ALLOCATE (matrix_w_kp(ispin, img)%matrix)
194 CALL dbcsr_copy(matrix_w_kp(ispin, img)%matrix, matrix_s_kp(1, 1)%matrix, name=
"W MATRIX")
195 CALL dbcsr_set(matrix_w_kp(ispin, img)%matrix, 0.0_dp)
198 CALL set_ks_env(ks_env, matrix_w_kp=matrix_w_kp)
205 matrix_kp_generic(img)%matrix => matrix_s_kp(1, img)%matrix
209 sab_nl, para_env, max_ij_cell_image, do_merge=.false., gather_root=para_env%source)
213 IF (not_regtest .AND. para_env%mepos == para_env%source)
THEN
216 CALL open_file(
"bulklft.DAT", file_status=
"REPLACE", file_form=
"FORMATTED", file_action=
"WRITE", unit_number=funit)
218 CALL write_bulk_dat_file(funit, siesta_struct, smeagol_control%project_name, nspin, &
219 energy%efermi, scf_control%smear%ELECTRONIC_TEMPERATURE, &
220 h_to_ry, do_kpoints, max_ij_cell_image)
226 CALL open_file(
"bulkrgt.DAT", file_status=
"REPLACE", file_form=
"FORMATTED", file_action=
"WRITE", unit_number=funit)
228 CALL write_bulk_dat_file(funit, siesta_struct, smeagol_control%project_name, nspin, &
229 energy%efermi, scf_control%smear%ELECTRONIC_TEMPERATURE, &
230 h_to_ry, do_kpoints, max_ij_cell_image)
238 IF (para_env%mepos == para_env%source)
THEN
239 ALLOCATE (matrix_siesta_1d(siesta_struct%n_nonzero_elements))
240 ALLOCATE (matrix_siesta_2d(siesta_struct%n_nonzero_elements, nspin))
242 IF (not_regtest)
THEN
243 CALL open_file(trim(smeagol_control%project_name)//
".HST", &
244 file_status=
"REPLACE", file_form=
"FORMATTED", file_action=
"WRITE", unit_number=funit)
247 ALLOCATE (matrix_siesta_1d(1))
248 ALLOCATE (matrix_siesta_2d(1, nspin))
258 matrix_kp_generic(img)%matrix => matrix_ks_kp(ispin, img)%matrix
263 matrix_siesta_2d(:, :) = h_to_ry*matrix_siesta_2d(:, :)
266 WRITE (hst_fmt,
'(A,I0,A)')
"(", nspin,
"ES26.17E3)"
267 DO ielem = 1, siesta_struct%n_nonzero_elements
268 WRITE (funit,
'(ES26.17E3)') matrix_siesta_1d(ielem)
269 WRITE (funit, hst_fmt) matrix_siesta_2d(ielem, :)
278 matrix_kp_generic(img)%matrix => rho_ao_kp(ispin, img)%matrix
283 IF (para_env%mepos == para_env%source)
THEN
284 ALLOCATE (nelectrons(nspin))
289 cpassert(log_unit > 0)
291 WRITE (log_unit,
'(T2,A,T61,F20.10)')
"SMEAGOL| Number of alpha-spin electrons: ", nelectrons(1)
292 WRITE (log_unit,
'(T2,A,T61,F20.10)')
"SMEAGOL| Number of beta-spin electrons: ", nelectrons(2)
294 WRITE (log_unit,
'(T2,A,T61,F20.10)')
"SMEAGOL| Number of electrons: ", nelectrons(1)
296 DEALLOCATE (nelectrons)
298 IF (not_regtest)
THEN
299 CALL open_file(trim(smeagol_control%project_name)//
".DM", &
300 file_status=
"REPLACE", file_form=
"UNFORMATTED", file_action=
"WRITE", unit_number=funit)
302 CALL write_bulk_dm_file(funit, siesta_struct, nspin, matrix_siesta_2d)
308 CALL get_qs_env(qs_env, matrix_w_kp=matrix_w_kp)
309 IF (
ASSOCIATED(matrix_w_kp))
THEN
313 matrix_kp_generic(img)%matrix => matrix_w_kp(ispin, img)%matrix
316 siesta_struct, para_env)
319 IF (not_regtest .AND. para_env%mepos == para_env%source)
THEN
320 CALL open_file(trim(smeagol_control%project_name)//
".EDM", &
321 file_status=
"REPLACE", file_form=
"UNFORMATTED", file_action=
"WRITE", unit_number=funit)
323 CALL write_bulk_dm_file(funit, siesta_struct, nspin, matrix_siesta_2d)
329 DEALLOCATE (matrix_siesta_2d)
330 DEALLOCATE (matrix_siesta_1d)
332 DEALLOCATE (matrix_kp_generic)
333 IF (.NOT. do_kpoints)
DEALLOCATE (cell_to_index)
336 CALL timestop(handle)
353 SUBROUTINE write_bulk_dat_file(funit, siesta_struct, system_label, nspin, EFermi, temperature, &
354 H_to_Ry, do_kpoints, max_ij_cell_image)
355 INTEGER,
INTENT(in) :: funit
357 CHARACTER(len=*),
INTENT(in) :: system_label
358 INTEGER,
INTENT(in) :: nspin
359 REAL(kind=
dp),
INTENT(in) :: efermi, temperature, h_to_ry
360 LOGICAL,
INTENT(in) :: do_kpoints
361 INTEGER,
DIMENSION(2),
INTENT(in) :: max_ij_cell_image
363 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_bulk_dat_file'
365 INTEGER :: handle, icol, irow, nao_supercell, &
367 INTEGER,
DIMENSION(2) :: ncells_siesta
369 CALL timeset(routinen, handle)
372 nao_unitcell = siesta_struct%nrows
373 nao_supercell = siesta_struct%ncols
374 ncells_siesta(1:2) = 2*max_ij_cell_image(1:2) + 1
379 WRITE (funit,
'(1X,A20,3I12,2ES26.17E3,3I12)') &
380 system_label, nao_unitcell, nspin, siesta_struct%n_nonzero_elements, &
381 h_to_ry*efermi, h_to_ry*temperature, ncells_siesta(1:2), nao_supercell
385 DO irow = 1, nao_unitcell
386 WRITE (funit,
'(2I12)') siesta_struct%n_nonzero_cols(irow), siesta_struct%row_offset(irow)
389 DO icol = 1, nao_supercell
390 WRITE (funit,
'(I12)') siesta_struct%indxuo(icol)
394 DO irow = 1, nao_unitcell
395 DO icol = 1, siesta_struct%n_nonzero_cols(irow)
396 WRITE (funit,
'(I12)') siesta_struct%col_index(siesta_struct%row_offset(irow) + icol)
399 WRITE (funit,
'(F21.16,5X,F21.16,5X,F21.16)') siesta_struct%xij(:, siesta_struct%row_offset(irow) + icol)
404 CALL timestop(handle)
405 END SUBROUTINE write_bulk_dat_file
414 SUBROUTINE write_bulk_dm_file(funit, siesta_struct, nspin, matrix_siesta)
415 INTEGER,
INTENT(in) :: funit
417 INTEGER,
INTENT(in) :: nspin
418 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(in) :: matrix_siesta
420 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_bulk_dm_file'
422 INTEGER :: handle, irow, ispin
424 CALL timeset(routinen, handle)
427 WRITE (funit) siesta_struct%nrows, nspin
431 WRITE (funit) siesta_struct%n_nonzero_cols
434 DO irow = 1, siesta_struct%nrows
435 WRITE (funit) siesta_struct%col_index(siesta_struct%row_offset(irow) + 1: &
436 siesta_struct%row_offset(irow) + siesta_struct%n_nonzero_cols(irow))
441 DO irow = 1, siesta_struct%nrows
442 WRITE (funit) matrix_siesta(siesta_struct%row_offset(irow) + 1: &
443 siesta_struct%row_offset(irow) + siesta_struct%n_nonzero_cols(irow), ispin)
447 CALL timestop(handle)
448 END SUBROUTINE write_bulk_dm_file
457 SUBROUTINE write_average_hartree_potential(v_hartree_rspace, project_name)
459 CHARACTER(len=*),
INTENT(in) :: project_name
461 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_average_hartree_potential'
463 INTEGER :: funit, handle, iz, lz, uz
464 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: v_hartree_z_average
465 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
469 CALL timeset(routinen, handle)
471 pw_grid => v_hartree_rspace%pw_grid
472 cr3d => v_hartree_rspace%array
474 ALLOCATE (v_hartree_z_average(pw_grid%bounds(1, 3):pw_grid%bounds(2, 3)))
475 v_hartree_z_average(:) = 0.0_dp
477 lz = pw_grid%bounds_local(1, 3)
478 uz = pw_grid%bounds_local(2, 3)
484 CALL pw_grid%para%group%sum(v_hartree_z_average)
485 v_hartree_z_average(:) = v_hartree_z_average(:)/ &
486 (real(pw_grid%npts(1), kind=
dp)*real(pw_grid%npts(2), kind=
dp))
489 IF (pw_grid%para%group%mepos == pw_grid%para%group%source)
THEN
490 CALL open_file(trim(adjustl(project_name))//
"-VH_AV.dat", &
491 file_status=
"REPLACE", file_form=
"FORMATTED", file_action=
"WRITE", unit_number=funit)
492 WRITE (funit,
'(A,T10,A,T25,A)')
"#",
"z (A)",
"V_H average (eV)"
494 WRITE (funit,
'(F20.10,ES20.10E3)') pw_grid%dh(3, 3)*real(iz - lz, kind=
dp)/
bohr, &
495 v_hartree_z_average(iz)/pw_grid%dvol*
evolt
500 DEALLOCATE (v_hartree_z_average)
501 CALL timestop(handle)
502 END SUBROUTINE write_average_hartree_potential
524 HartreeLeadsLeft, HartreeLeadsRight, HartreeLeadsBottom, &
525 Vbias, zleft, zright, isexplicit_zright, isexplicit_bottom)
528 REAL(kind=
dp),
INTENT(in) :: hartreeleadsleft, hartreeleadsright, &
529 hartreeleadsbottom, vbias, zleft, &
531 LOGICAL,
INTENT(in) :: isexplicit_zright, isexplicit_bottom
533 CHARACTER(LEN=*),
PARAMETER :: routinen =
'smeagol_shift_v_hartree'
535 INTEGER :: handle, iz, l_right, lz, u_left, uz
536 REAL(kind=
dp) :: v_average_left, v_average_right, &
537 v_bias_iz, zright_explicit
538 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: v_hartree_z_average
539 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
541 REAL(kind=
dp),
DIMENSION(3) :: r, r_pbc
544 CALL timeset(routinen, handle)
545 pw_grid => v_hartree_rspace%pw_grid
546 cr3d => v_hartree_rspace%array
548 zright_explicit = zright
549 IF (.NOT. isexplicit_zright)
THEN
550 r_pbc(:) = (/0.0_dp, 0.0_dp, 1.0_dp/)
552 zright_explicit = r(3)
555 ALLOCATE (v_hartree_z_average(pw_grid%bounds(1, 3):pw_grid%bounds(2, 3)))
557 lz = pw_grid%bounds_local(1, 3)
558 uz = pw_grid%bounds_local(2, 3)
560 v_hartree_z_average(:) = 0.0_dp
565 CALL pw_grid%para%group%sum(v_hartree_z_average)
566 v_hartree_z_average(:) = v_hartree_z_average(:)/ &
567 (real(pw_grid%npts(1), kind=
dp)*real(pw_grid%npts(2), kind=
dp))
570 r(1:3) = (/0.0_dp, 0.0_dp, hartreeleadsleft/)
572 u_left = nint(r_pbc(3)*real(pw_grid%npts(3), kind=
dp)) + pw_grid%bounds(1, 3)
573 IF (u_left > pw_grid%bounds(2, 3)) u_left = pw_grid%bounds(2, 3)
576 r(1:3) = (/0.0_dp, 0.0_dp, hartreeleadsright/)
578 l_right = nint(r_pbc(3)*real(pw_grid%npts(3), kind=
dp)) + pw_grid%bounds(1, 3)
579 IF (l_right > pw_grid%bounds(2, 3)) l_right = pw_grid%bounds(2, 3)
581 cpassert(u_left <= l_right)
583 v_average_left = v_hartree_z_average(u_left)
584 v_average_right = v_hartree_z_average(l_right)
587 IF (isexplicit_bottom)
THEN
588 v_hartree_z_average(:) = hartreeleadsbottom*pw_grid%dvol - 0.5_dp*(v_average_left + v_average_right)
591 v_hartree_z_average(:) = 0.0_dp
599 r_pbc(3) = real(iz - pw_grid%bounds(1, 3), kind=
dp)/real(pw_grid%npts(3), kind=
dp)
601 IF (r(3) < zleft)
THEN
602 v_bias_iz = 0.5_dp*vbias
603 ELSE IF (r(3) > zright_explicit)
THEN
604 v_bias_iz = -0.5_dp*vbias
606 v_bias_iz = vbias*(0.5_dp - (r(3) - zleft)/(zright_explicit - zleft))
608 v_hartree_z_average(iz) = v_hartree_z_average(iz) + v_bias_iz*pw_grid%dvol
612 cr3d(:, :, iz) = cr3d(:, :, iz) + v_hartree_z_average(iz)
615 DEALLOCATE (v_hartree_z_average)
616 CALL timestop(handle)
629 LOGICAL,
INTENT(in) :: last
630 INTEGER,
INTENT(in) :: iter
634 CHARACTER(LEN=*),
PARAMETER :: routinen =
'run_smeagol_emtrans'
636 INTEGER :: handle, img, ispin, md_step, natoms, &
638 INTEGER,
DIMENSION(2) :: max_ij_cell_image, n_cell_images
639 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
640 LOGICAL :: do_kpoints, local_ldos, local_trcoeff, &
641 negfon_saved, structure_changed
642 REAL(kind=
dp) :: h_to_ry
643 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: matrix_s_csc_merged
644 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dnew_csc_merged, enew_csc_merged, &
648 TYPE(
dbcsr_p_type),
ALLOCATABLE,
DIMENSION(:) :: matrix_kp_generic
649 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_kp, matrix_s_kp, matrix_w_kp
662 CALL get_qs_env(qs_env, dft_control=dft_control)
664 nspin = dft_control%nspins
665 smeagol_control => dft_control%smeagol_control
666 h_to_ry = smeagol_control%to_smeagol_energy_units
669 CALL timeset(routinen, handle)
671 NULLIFY (kpoints, matrix_s_kp, matrix_ks_kp, matrix_w_kp, para_env, sab_nl, scf_control, subsys)
672#if defined(__SMEAGOL)
676 cpassert(
ASSOCIATED(smeagol_control%aux))
677 CALL get_qs_env(qs_env, para_env=para_env, scf_control=scf_control, &
678 do_kpoints=do_kpoints, kpoints=kpoints, &
679 matrix_ks_kp=matrix_ks_kp, matrix_s_kp=matrix_s_kp, matrix_w_kp=matrix_w_kp, &
680 sab_orb=sab_nl, subsys=subsys)
684 nimages = dft_control%nimages
688 ALLOCATE (cell_to_index(0:0, 0:0, 0:0))
689 cell_to_index(0, 0, 0) = 1
692 max_ij_cell_image(:) = -1
694 IF (smeagol_control%n_cell_images(img) > 0)
THEN
695 max_ij_cell_image(img) = smeagol_control%n_cell_images(img)/2
700 ALLOCATE (matrix_kp_generic(nimages))
702 matrix_kp_generic(img)%matrix => matrix_s_kp(1, img)%matrix
706 cell_to_index, sab_nl, para_env, max_ij_cell_image, do_merge=.true., gather_root=-1)
709 n_cell_images(1:2) = 2*max_ij_cell_image(1:2) + 1
711 ALLOCATE (matrix_s_csc_merged(siesta_struct_merged%n_nonzero_elements))
712 ALLOCATE (matrix_ks_csc_merged(siesta_struct_merged%n_nonzero_elements, nspin))
718 matrix_kp_generic(img)%matrix => matrix_ks_kp(ispin, img)%matrix
722 siesta_struct_merged, para_env)
725 IF (smeagol_control%aux%md_iter_level > 0)
THEN
726 CALL cp_get_iter_nr(logger%iter_info, smeagol_control%aux%md_iter_level, iter_nr=md_step)
727 ELSE IF (smeagol_control%aux%md_iter_level == 0)
THEN
729 md_step = smeagol_control%aux%md_first_step
734 IF (smeagol_control%aux%md_iter_level <= 0) &
737 IF (smeagol_control%aux%md_iter_level <= 0) &
738 smeagol_control%aux%md_iter_level = 0
741 IF (smeagol_control%aux%md_iter_level > 0)
THEN
742 CALL cp_get_iter_nr(logger%iter_info, smeagol_control%aux%md_iter_level, iter_nr=smeagol_control%aux%md_first_step)
745 smeagol_control%aux%md_first_step = 0
748 md_step = smeagol_control%aux%md_first_step
751 CALL reademtr(smeagol_control, natoms, gamma_negf=.false.)
755 matrix_s=matrix_s_kp(1, 1)%matrix, para_env=para_env, iter=iter, &
756 istep=md_step, inicoor=smeagol_control%aux%md_first_step, iv=0, &
757 delta=smeagol_control%aux%delta, nk=kpoints%nkp)
759 CALL create_communicators_negf(parent_comm=para_env%get_handle(), &
760 nprocs_inverse=smeagol_control%aux%nprocs_inverse, &
761 nparallelk=smeagol_control%aux%NParallelK)
763 ALLOCATE (dnew_csc_merged(siesta_struct_merged%n_nonzero_elements, nspin))
764 ALLOCATE (enew_csc_merged(siesta_struct_merged%n_nonzero_elements, nspin))
767 matrix_ks_csc_merged(:, :) = h_to_ry*matrix_ks_csc_merged(:, :)
772 negfon_saved = smeagolglobal_negfon
773 smeagolglobal_negfon = .false.
777 local_trcoeff = smeagol_control%aux%TrCoeff
780 local_trcoeff = .false.
785 smeagolglobal_em_nau = natoms
791 smeagolglobal_em_nuo = siesta_struct_merged%ncols/(n_cell_images(1)*n_cell_images(2))
794 smeagolglobal_em_nas =
SIZE(siesta_struct_merged%xa)
797 smeagolglobal_em_nso = siesta_struct_merged%ncols
804 structure_changed = (iter == 1)
806 CALL negf_interface( &
808 h=matrix_ks_csc_merged, &
809 s=matrix_s_csc_merged, &
810 dm=dnew_csc_merged, &
811 omega=enew_csc_merged, &
813 xij=siesta_struct_merged%xij, &
815 no_s=siesta_struct_merged%ncols, &
817 no_u=siesta_struct_merged%ncols/(n_cell_images(1)*n_cell_images(2)), &
819 no_u_node=siesta_struct_merged%nrows, &
821 xa=siesta_struct_merged%xa, &
825 na_s=
SIZE(siesta_struct_merged%xa), &
827 nspinrealinputmatrix=nspin, &
829 maxnh=int(siesta_struct_merged%n_nonzero_elements), &
831 numh=siesta_struct_merged%n_nonzero_cols, &
833 listhptr=siesta_struct_merged%row_offset, &
835 listh=siesta_struct_merged%col_index, &
839 kpoint=kpoints%xkp, &
841 weight_k=kpoints%wkp, &
843 indxuo=siesta_struct_merged%indxuo, &
845 iaorb=siesta_struct_merged%iaorb, &
849 inicoor=smeagol_control%aux%md_first_step, &
853 iv_step=md_step - smeagol_control%aux%md_first_step, &
855 vb=smeagol_control%aux%VBias*h_to_ry, &
859 last_scf_step=last, &
861 structurechanged=structure_changed, &
863 temp=smeagol_control%aux%temperature*h_to_ry, &
867 slabel=smeagol_control%project_name, &
869 nenergr=smeagol_control%aux%NEnergR, &
870 nenergic=smeagol_control%aux%NEnergIC, &
871 nenergil=smeagol_control%aux%NEnergIL, &
873 npoles=smeagol_control%aux%NPoles, &
875 delta=smeagol_control%aux%deltamin*h_to_ry, &
877 energlb=smeagol_control%aux%EnergLB*h_to_ry, &
879 vinitial=smeagol_control%aux%VBias, &
880 vfinal=smeagol_control%aux%VBias, &
882 spincl=smeagol_control%aux%SpinCL, &
884 nslices=smeagol_control%aux%NSlices, &
886 trcoeff=local_trcoeff, &
887 calciets=smeagol_control%aux%CalcIETS, &
893 tmdskip=smeagol_control%aux%tmdskip, &
895 tmdsampling=smeagol_control%aux%tmdsampling)
902 IF (smeagol_control%aux%bs_add .AND. smeagol_control%aux%bs_method == 1 .AND. smeagol_control%aux%bssc == 0 .AND. &
903 kpoints%nkp > 1 .AND. (.NOT. last))
THEN
905 CALL negf_interface(h=matrix_ks_csc_merged, &
906 s=matrix_s_csc_merged, &
907 dm=dnew_csc_merged, &
908 omega=enew_csc_merged, &
909 xij=siesta_struct_merged%xij, &
910 no_s=siesta_struct_merged%ncols, &
911 no_u=siesta_struct_merged%ncols/(n_cell_images(1)*n_cell_images(2)), &
912 no_u_node=siesta_struct_merged%nrows, &
913 xa=siesta_struct_merged%xa, &
916 na_s=
SIZE(siesta_struct_merged%xa), &
917 nspinrealinputmatrix=nspin, &
918 maxnh=int(siesta_struct_merged%n_nonzero_elements), &
919 numh=siesta_struct_merged%n_nonzero_cols, &
920 listhptr=siesta_struct_merged%row_offset, &
921 listh=siesta_struct_merged%col_index, &
923 kpoint=kpoints%xkp, &
924 weight_k=kpoints%wkp, &
925 indxuo=siesta_struct_merged%indxuo, &
926 iaorb=siesta_struct_merged%iaorb, &
928 inicoor=smeagol_control%aux%md_first_step, &
929 iv_step=md_step - smeagol_control%aux%md_first_step, &
930 vb=smeagol_control%aux%VBias*h_to_ry, &
932 scf_step=merge(2, 1, structure_changed), &
933 last_scf_step=last, &
934 structurechanged=structure_changed, &
935 temp=smeagol_control%aux%temperature*h_to_ry, &
937 slabel=smeagol_control%project_name, &
938 nenergr=smeagol_control%aux%NEnergR, &
939 nenergic=smeagol_control%aux%NEnergIC, &
940 nenergil=smeagol_control%aux%NEnergIL, &
941 npoles=smeagol_control%aux%NPoles, &
942 delta=smeagol_control%aux%deltamin*h_to_ry, &
943 energlb=smeagol_control%aux%EnergLB*h_to_ry, &
945 vinitial=smeagol_control%aux%VBias, &
947 vfinal=smeagol_control%aux%VBias, &
948 spincl=smeagol_control%aux%SpinCL, &
949 nslices=smeagol_control%aux%NSlices, &
950 trcoeff=local_trcoeff, &
951 calciets=smeagol_control%aux%CalcIETS, &
954 tmdskip=smeagol_control%aux%tmdskip, &
955 tmdsampling=smeagol_control%aux%tmdsampling)
960 smeagolglobal_negfon = negfon_saved
963 IF (
PRESENT(rho_ao_kp))
THEN
967 CALL dbcsr_set(rho_ao_kp(ispin, img)%matrix, 0.0_dp)
968 matrix_kp_generic(img)%matrix => rho_ao_kp(ispin, img)%matrix
972 siesta_struct_merged, para_env)
976 IF (smeagol_control%emforces)
THEN
977 enew_csc_merged(:, :) = (1.0_dp/h_to_ry)*enew_csc_merged(:, :)
982 CALL dbcsr_set(matrix_w_kp(ispin, img)%matrix, 0.0_dp)
983 matrix_kp_generic(img)%matrix => matrix_w_kp(ispin, img)%matrix
987 siesta_struct_merged, para_env)
992 CALL destroy_communicators_negf()
995 DEALLOCATE (dnew_csc_merged, enew_csc_merged)
996 DEALLOCATE (matrix_s_csc_merged, matrix_ks_csc_merged)
1000 IF (.NOT. do_kpoints)
DEALLOCATE (cell_to_index)
1002 CALL cp_abort(__location__, &
1003 "CP2K was compiled with no SMEAGOL support.")
1006 mark_used(rho_ao_kp)
1008 mark_used(cell_to_index)
1009 mark_used(do_kpoints)
1010 mark_used(dnew_csc_merged)
1011 mark_used(enew_csc_merged)
1014 mark_used(local_ldos)
1015 mark_used(local_trcoeff)
1016 mark_used(max_ij_cell_image)
1017 mark_used(matrix_kp_generic)
1018 mark_used(matrix_ks_csc_merged)
1019 mark_used(matrix_s_csc_merged)
1022 mark_used(negfon_saved)
1024 mark_used(n_cell_images)
1025 mark_used(siesta_struct_merged)
1026 mark_used(structure_changed)
1030 CALL timestop(handle)
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public bailey2006
integer, save, public ahart2024
Handles all functions related to the CELL.
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_set(matrix, alpha)
...
DBCSR operations in CP2K.
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
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_get_iter_level_by_name(iteration_info, level_name)
Return the index of an iteration level by its name.
subroutine, public cp_get_iter_nr(iteration_info, rlevel, iter_nr, last_iter)
Return the current iteration number at a given level.
sums arrays of real/complex numbers with much reduced round-off as compared to a naive implementation...
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
Interface to the message passing library MPI.
Definition of physical constants:
real(kind=dp), parameter, public evolt
real(kind=dp), parameter, public bohr
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.
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
Utility subroutine for qs energy calculation.
subroutine, public compute_matrix_w(qs_env, calc_forces)
Refactoring of qs_energies_scf. Moves computation of matrix_w into separate subroutine.
Define the neighbor list data types and the corresponding functionality.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
parameters that control an scf iteration
Input control types for NEGF/SMEAGOL transport calculations.
subroutine, public readoptionsnegf_dft(smeagol_control, ucell, torqueflag, torquelin)
subroutine, public reademtr(smeagol_control, natoms, gamma_negf)
subroutine, public emtrans_deallocate_global_arrays()
subroutine, public emtrans_options(smeagol_control, matrix_s, para_env, iter, istep, inicoor, iv, delta, nk)
subroutine, public run_smeagol_emtrans(qs_env, last, iter, rho_ao_kp)
Run NEGF/SMEAGOL transport calculation.
subroutine, public run_smeagol_bulktrans(qs_env)
Save overlap, Kohn-Sham, electron density, and energy-density matrices of semi-infinite electrodes in...
subroutine, public smeagol_shift_v_hartree(v_hartree_rspace, cell, hartreeleadsleft, hartreeleadsright, hartreeleadsbottom, vbias, zleft, zright, isexplicit_zright, isexplicit_bottom)
Align Hatree potential of semi-infinite leads to match bulk-transport calculation and apply external ...
Routines to convert sparse matrices between DBCSR (distributed-blocks compressed sparse rows) and SIE...
subroutine, public siesta_struct_release(siesta_struct)
Release a SIESTA matrix structure.
subroutine, public siesta_struct_create(siesta_struct, matrix_dbcsr_kp, subsys, cell_to_index, sab_nl, para_env, max_ij_cell_image, do_merge, gather_root)
Map non-zero matrix blocks between sparse matrices in DBCSR and SIESTA formats.
subroutine, public convert_distributed_siesta_to_dbcsr(matrix_dbcsr_kp, matrix_siesta, siesta_struct, para_env)
Convert matrix from DBCSR to sparse SIESTA format.
subroutine, public convert_dbcsr_to_distributed_siesta(matrix_siesta, matrix_dbcsr_kp, siesta_struct, para_env)
Convert matrix from DBCSR to sparse SIESTA format.
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.
SMEAGOL-related input parameters.
Sparsity pattern of replicated SIESTA compressed sparse column (CSC) matrices.