147#include "./base/base_uses.f90"
153 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_post_tb'
173 CHARACTER(LEN=*) :: tb_type
174 LOGICAL,
INTENT(IN) :: no_mos
176 CHARACTER(len=*),
PARAMETER :: routinen =
'scf_post_calculation_tb'
178 CHARACTER(LEN=6) :: ana
179 CHARACTER(LEN=default_string_length) :: aname
180 INTEGER :: after, gfn_type, handle, homo, iat, iatom, ikind, img, ispin, iw, nat, natom, &
181 nkind, nlumo_stm, nlumos, nspins, print_level, unit_nr
182 LOGICAL :: do_cube, do_curve, do_dos, do_kpoints, do_pdos, do_projected_dos, explicit, gfn0, &
183 has_homo, omit_headers, print_it, rebuild, vdip
184 REAL(kind=
dp) :: zeff
185 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: mcharge, zcharge
186 REAL(kind=
dp),
DIMENSION(2, 2) :: homo_lumo
187 REAL(kind=
dp),
DIMENSION(:),
POINTER :: echarge, mo_eigenvalues
188 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: charges
191 TYPE(
cp_1d_r_p_type),
DIMENSION(:),
POINTER :: unoccupied_evals_stm
192 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: unoccupied_orbs_stm
195 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, mo_derivs
196 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_p, matrix_s
204 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
210 print_section, sprint_section, &
214 CALL timeset(routinen, handle)
220 CALL get_qs_env(qs_env, dft_control=dft_control)
221 SELECT CASE (trim(tb_type))
224 gfn_type = dft_control%qs_control%xtb_control%gfn_type
225 gfn0 = (gfn_type == 0)
226 vdip = dft_control%qs_control%xtb_control%var_dipole
228 cpabort(
"unknown TB type")
231 cpassert(
ASSOCIATED(qs_env))
232 NULLIFY (rho, para_env, matrix_s, matrix_p)
233 CALL get_qs_env(qs_env, scf_env=scf_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
234 rho=rho, natom=natom, para_env=para_env, &
235 particle_set=particle_set, do_kpoints=do_kpoints, matrix_s_kp=matrix_s)
236 nspins = dft_control%nspins
239 ALLOCATE (charges(natom, nspins), mcharge(natom))
243 ALLOCATE (zcharge(natom))
244 nkind =
SIZE(atomic_kind_set)
247 SELECT CASE (trim(tb_type))
249 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
252 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
255 cpabort(
"unknown TB type")
258 iat = atomic_kind_set(ikind)%atom_list(iatom)
259 mcharge(iat) = zeff - sum(charges(iat, 1:nspins))
271 extension=
".mulliken", log_filename=.false.)
272 IF (unit_nr > 0)
THEN
273 WRITE (unit=unit_nr, fmt=
"(/,/,T2,A)")
"MULLIKEN POPULATION ANALYSIS"
274 IF (nspins == 1)
THEN
275 WRITE (unit=unit_nr, fmt=
"(/,T2,A,T70,A)") &
276 " # Atom Element Kind Atomic population",
" Net charge"
280 SELECT CASE (tb_type)
282 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
285 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
288 cpabort(
"unknown TB type")
290 ana = adjustr(trim(adjustl(aname)))
292 iat = atomic_kind_set(ikind)%atom_list(iatom)
293 WRITE (unit=unit_nr, &
294 fmt=
"(T2,I7,5X,A6,I6,T39,F12.6,T69,F12.6)") &
295 iat, adjustl(ana), ikind, charges(iat, 1), mcharge(iat)
298 WRITE (unit=unit_nr, &
299 fmt=
"(T2,A,T39,F12.6,T69,F12.6,/)") &
300 "# Total charge", sum(charges(:, 1)), sum(mcharge(:))
302 WRITE (unit=unit_nr, fmt=
"(/,T2,A)") &
303 "# Atom Element Kind Atomic population (alpha,beta) Net charge Spin moment"
307 SELECT CASE (tb_type)
309 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
312 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
315 cpabort(
"unknown TB type")
317 ana = adjustr(trim(adjustl(aname)))
319 iat = atomic_kind_set(ikind)%atom_list(iatom)
320 WRITE (unit=unit_nr, &
321 fmt=
"(T2,I6,3X,A6,I6,T29,4(1X,F12.6))") &
322 iat, adjustl(ana), ikind, charges(iat, 1:2), mcharge(iat), &
323 charges(iat, 1) - charges(iat, 2)
326 WRITE (unit=unit_nr, &
327 fmt=
"(T2,A,T29,4(1X,F12.6),/)") &
328 "# Total charge and spin", sum(charges(:, 1)), sum(charges(:, 2)), sum(mcharge(:))
338 SELECT CASE (tb_type)
340 cpwarn(
"Lowdin population analysis not implemented for DFTB method.")
343 log_filename=.false.)
346 IF (print_it) print_level = 2
348 IF (print_it) print_level = 3
350 cpwarn(
"Lowdin charges not implemented for k-point calculations!")
356 cpabort(
"unknown TB type")
364 extension=
".eeq", log_filename=.false.)
365 CALL eeq_print(qs_env, unit_nr, print_level, ext=gfn0)
374 cpwarn(
"Hirshfeld charges not available for TB methods.")
383 cpwarn(
"MAO analysis not available for TB methods.")
392 cpwarn(
"ED analysis not available for TB methods.")
400 extension=
".data", middle_name=
"tb_dipole", log_filename=.false.)
405 cpassert(
ASSOCIATED(echarge))
408 mcharge(1:natom) = echarge(1:natom) - mcharge(1:natom)
410 CALL tb_dipole(qs_env, moments_section, unit_nr, mcharge)
412 CALL tb_dipole(qs_env, moments_section, unit_nr, mcharge)
417 DEALLOCATE (charges, mcharge)
420 IF (.NOT. no_mos)
THEN
424 IF (.NOT. do_kpoints)
THEN
425 SELECT CASE (tb_type)
430 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell, &
431 qs_env=qs_env, calc_energies=.true.)
433 cpabort(
"Unknown TB type")
440 IF (.NOT. no_mos)
THEN
443 IF (explicit .AND. .NOT. qs_env%run_rtp)
CALL wfn_mix_tb(qs_env, dft_section, scf_env)
446 IF (.NOT. no_mos)
THEN
453 IF (do_curve)
CALL calculate_dos_kp(qs_env, dft_section, write_curve_output=.true.)
456 CALL calculate_dos(mos, dft_section, smearing_enabled=dft_control%smear)
457 IF (do_curve)
CALL calculate_dos(mos, dft_section, smearing_enabled=dft_control%smear, &
458 write_curve_output=.true.)
463 IF (do_projected_dos)
THEN
466 write_pdos=do_pdos, write_pdos_curve=do_curve)
468 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv)
469 DO ispin = 1, dft_control%nspins
471 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
472 eigenvalues=mo_eigenvalues)
473 IF (
ASSOCIATED(qs_env%mo_derivs))
THEN
474 mo_coeff_deriv => qs_env%mo_derivs(ispin)%matrix
476 mo_coeff_deriv => null()
479 do_rotation=.true., &
480 co_rotate_dbcsr=mo_coeff_deriv)
483 IF (dft_control%nspins == 2)
THEN
485 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin, &
486 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_curve=do_curve)
489 qs_kind_set, particle_set, qs_env, dft_section, &
490 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_curve=do_curve)
498 SELECT CASE (tb_type)
506 cpabort(
"unknown TB type")
514 cpwarn(
"Energy Windows not implemented for k-points.")
523 cpwarn(
"Energy Windows not implemented for TB methods.")
535 CALL print_e_density(qs_env, zcharge, print_key)
537 cpwarn(
"Electronic density cube file not implemented for TB methods.")
549 CALL print_density_cubes(qs_env, zcharge, print_key, total_density=.true.)
551 cpwarn(
"Total density cube file not implemented for TB methods.")
563 CALL print_density_cubes(qs_env, zcharge, print_key, v_hartree=.true.)
565 cpwarn(
"Hartree potential cube file not implemented for TB methods.")
577 CALL print_density_cubes(qs_env, zcharge, print_key, efield=.true.)
579 cpwarn(
"Efield cube file not implemented for TB methods.")
591 CALL print_elf(qs_env, zcharge, print_key)
593 cpwarn(
"ELF not implemented for TB methods.")
598 IF (.NOT. no_mos)
THEN
606 CALL print_mo_cubes(qs_env, zcharge, print_key)
608 cpwarn(
"Printing of MO cube files not implemented for TB methods.")
614 IF (.NOT. no_mos)
THEN
623 cpwarn(
"STM not implemented for k-point calculations!")
626 cpassert(.NOT. dft_control%restricted)
627 CALL get_qs_env(qs_env, mos=mos, mo_derivs=mo_derivs, &
628 scf_control=scf_control, matrix_ks=ks_rmpv)
629 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
630 DO ispin = 1, dft_control%nspins
631 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=homo)
632 homo_lumo(ispin, 1) = mo_eigenvalues(homo)
635 NULLIFY (unoccupied_orbs_stm, unoccupied_evals_stm)
636 IF (nlumo_stm > 0)
THEN
637 ALLOCATE (unoccupied_orbs_stm(dft_control%nspins))
638 ALLOCATE (unoccupied_evals_stm(dft_control%nspins))
639 CALL make_lumo_tb(qs_env, scf_env, unoccupied_orbs_stm, unoccupied_evals_stm, &
645 CALL th_stm_image(qs_env, print_key, particles, unoccupied_orbs_stm, &
646 unoccupied_evals_stm)
648 IF (nlumo_stm > 0)
THEN
649 DO ispin = 1, dft_control%nspins
650 DEALLOCATE (unoccupied_evals_stm(ispin)%array)
652 DEALLOCATE (unoccupied_evals_stm)
661 CALL get_qs_env(qs_env, matrix_ks_kp=matrix_ks)
668 after = min(max(after, 1), 16)
669 DO ispin = 1, dft_control%nspins
670 DO img = 1,
SIZE(matrix_p, 2)
672 para_env, output_unit=iw, omit_headers=omit_headers)
680 "AO_MATRICES/KOHN_SHAM_MATRIX"),
cp_p_file))
THEN
684 after = min(max(after, 1), 16)
685 DO ispin = 1, dft_control%nspins
686 DO img = 1,
SIZE(matrix_ks, 2)
688 output_unit=iw, omit_headers=omit_headers)
701 cpwarn(
"XC potential cube file not available for TB methods.")
710 cpwarn(
"Electric field gradient not implemented for TB methods.")
719 cpwarn(
"Kinetic energy not available for TB methods.")
728 cpwarn(
"Xray diffraction spectrum not implemented for TB methods.")
737 cpwarn(
"Hyperfine Coupling not implemented for TB methods.")
746 cpwarn(
"DFT+U method not implemented for TB methods.")
757 CALL timestop(handle)
768 SUBROUTINE tb_dipole(qs_env, input, unit_nr, charges)
772 INTEGER,
INTENT(in) :: unit_nr
773 REAL(kind=
dp),
DIMENSION(:),
INTENT(in) :: charges
775 CHARACTER(LEN=default_string_length) :: description, dipole_type
776 COMPLEX(KIND=dp) :: dzeta, dzphase(3), zeta, zphase(3)
777 COMPLEX(KIND=dp),
DIMENSION(3) :: dggamma, ggamma
778 INTEGER :: i, iat, ikind, j, nat, reference
780 REAL(kind=
dp) :: charge_tot, ci(3), dci(3), dipole(3), dipole_deriv(3), drcc(3), dria(3), &
781 dtheta, gvec(3), q, rcc(3), ria(3), theta, tmp(3), via(3)
782 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ref_point
788 NULLIFY (atomic_kind_set, cell, results)
789 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, &
790 particle_set=particle_set, cell=cell, results=results)
795 description =
'[DIPOLE]'
799 CALL get_reference_point(rcc, drcc, qs_env=qs_env, reference=reference, ref_point=ref_point)
802 dipole_deriv = 0.0_dp
805 dipole_type =
"periodic (Berry phase)"
808 charge_tot = sum(charges)
809 ria =
twopi*matmul(cell%h_inv, rcc)
810 zphase = cmplx(cos(ria), sin(ria),
dp)**charge_tot
812 dria =
twopi*matmul(cell%h_inv, drcc)
813 dzphase = charge_tot*cmplx(-sin(ria), cos(ria),
dp)**(charge_tot - 1.0_dp)*dria
817 DO ikind = 1,
SIZE(atomic_kind_set)
820 iat = atomic_kind_set(ikind)%atom_list(i)
821 ria = particle_set(iat)%r(:)
823 via = particle_set(iat)%v(:)
826 gvec =
twopi*cell%h_inv(j, :)
827 theta = sum(ria(:)*gvec(:))
828 dtheta = sum(via(:)*gvec(:))
829 zeta = cmplx(cos(theta), sin(theta), kind=
dp)**(-q)
830 dzeta = -q*cmplx(-sin(theta), cos(theta), kind=
dp)**(-q - 1.0_dp)*dtheta
831 dggamma(j) = dggamma(j)*zeta + ggamma(j)*dzeta
832 ggamma(j) = ggamma(j)*zeta
836 dggamma = dggamma*zphase + ggamma*dzphase
837 ggamma = ggamma*zphase
838 IF (all(real(ggamma, kind=
dp) /= 0.0_dp))
THEN
839 tmp = aimag(ggamma)/real(ggamma, kind=
dp)
841 dci = -(1.0_dp/(1.0_dp + tmp**2))* &
842 (aimag(dggamma)*real(ggamma, kind=
dp) - aimag(ggamma)*real(dggamma, kind=
dp))/(real(ggamma, kind=
dp))**2
843 dipole = matmul(cell%hmat, ci)/
twopi
844 dipole_deriv = matmul(cell%hmat, dci)/
twopi
847 dipole_type =
"non-periodic"
848 DO i = 1,
SIZE(particle_set)
850 ria = particle_set(i)%r(:)
852 dipole = dipole + q*(ria - rcc)
853 dipole_deriv(:) = dipole_deriv(:) + q*(particle_set(i)%v(:) - drcc)
857 CALL put_results(results=results, description=description, &
859 IF (unit_nr > 0)
THEN
860 WRITE (unit_nr,
'(/,T2,A,T31,A50)') &
861 'TB_DIPOLE| Dipole type', adjustr(trim(dipole_type))
862 WRITE (unit_nr,
"(T2,A,T30,3(1X,F16.8))")
"TB_DIPOLE| Ref. Point [Bohr]", rcc
863 WRITE (unit_nr,
'(T2,A,T30,3(1X,F16.8))') &
864 'TB_DIPOLE| Moment [a.u.]', dipole(1:3)
865 WRITE (unit_nr,
'(T2,A,T30,3(1X,F16.8))') &
866 'TB_DIPOLE| Moment [Debye]', dipole(1:3)*
debye
867 WRITE (unit_nr,
'(T2,A,T30,3(1X,F16.8))') &
868 'TB_DIPOLE| Derivative [a.u.]', dipole_deriv(1:3)
871 END SUBROUTINE tb_dipole
882 SUBROUTINE wfn_mix_tb(qs_env, dft_section, scf_env)
888 INTEGER :: ispin, nao, nmo, output_unit
889 REAL(
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
892 TYPE(
cp_fm_type) :: ks_tmp, mo_tmp, s_tmp, work
893 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: lumos
896 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
900 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
904 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s, matrix_ks=matrix_ks, &
905 particle_set=particle_set, atomic_kind_set=atomic_kind_set, &
906 qs_kind_set=qs_kind_set, mos=mos, para_env=para_env)
910 CALL get_mo_set(mos(1), mo_coeff=mo_coeff, nao=nao)
913 template_fmstruct=mo_coeff%matrix_struct)
918 ALLOCATE (lumos(
SIZE(mos)))
923 DO ispin = 1,
SIZE(mos)
924 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, eigenvalues=mo_eigenvalues, nmo=nmo)
925 CALL cp_fm_struct_create(fmstruct=ao_lumo_struct, nrow_global=nao, ncol_global=nao - nmo, &
926 template_fmstruct=mo_coeff%matrix_struct)
928 CALL cp_fm_create(lumos(ispin), matrix_struct=ao_lumo_struct)
940 CALL wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, output_unit, &
941 unoccupied_orbs=lumos, scf_env=scf_env, matrix_s=matrix_s)
950 END SUBROUTINE wfn_mix_tb
961 SUBROUTINE make_lumo_tb(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
965 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: unoccupied_orbs
966 TYPE(
cp_1d_r_p_type),
DIMENSION(:),
INTENT(INOUT) :: unoccupied_evals
968 INTEGER,
INTENT(OUT) :: nlumos
970 INTEGER :: homo, iounit, ispin, n, nao, nmo
975 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_s
982 NULLIFY (mos, ks_rmpv, scf_control, dft_control, para_env, blacs_env)
986 scf_control=scf_control, &
987 dft_control=dft_control, &
995 DO ispin = 1, dft_control%nspins
996 NULLIFY (unoccupied_evals(ispin)%array)
998 IF (iounit > 0)
WRITE (iounit, *)
" "
999 IF (iounit > 0)
WRITE (iounit, *)
" Lowest Eigenvalues of the unoccupied subspace spin ", ispin
1000 IF (iounit > 0)
WRITE (iounit, fmt=
'(1X,A)')
"-----------------------------------------------------"
1001 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=homo, nao=nao, nmo=nmo)
1003 nlumos = max(1, min(nlumo, nao - nmo))
1004 IF (nlumo == -1) nlumos = nao - nmo
1005 ALLOCATE (unoccupied_evals(ispin)%array(nlumos))
1007 nrow_global=n, ncol_global=nlumos)
1008 CALL cp_fm_create(unoccupied_orbs(ispin), fm_struct_tmp, name=
"lumos")
1013 NULLIFY (local_preconditioner)
1014 IF (
ASSOCIATED(scf_env%ot_preconditioner))
THEN
1015 local_preconditioner => scf_env%ot_preconditioner(1)%preconditioner
1018 NULLIFY (local_preconditioner)
1022 CALL ot_eigensolver(matrix_h=ks_rmpv(ispin)%matrix, matrix_s=matrix_s(1)%matrix, &
1023 matrix_c_fm=unoccupied_orbs(ispin), &
1024 matrix_orthogonal_space_fm=mo_coeff, &
1025 eps_gradient=scf_control%eps_lumos, &
1027 iter_max=scf_control%max_iter_lumos, &
1028 size_ortho_space=nmo)
1031 unoccupied_evals(ispin)%array, scr=iounit, &
1046 LOGICAL :: skip_load_balance_distributed
1054 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=new_pw_env)
1055 IF (.NOT.
ASSOCIATED(new_pw_env))
THEN
1060 CALL get_qs_env(qs_env, pw_env=new_pw_env, dft_control=dft_control, cell=cell)
1062 new_pw_env%cell_hmat = cell%hmat
1067 IF (.NOT.
ASSOCIATED(task_list))
THEN
1071 skip_load_balance_distributed = dft_control%qs_control%skip_load_balance_distributed
1073 reorder_rs_grid_ranks=.true., &
1074 skip_load_balance_distributed=skip_load_balance_distributed)
1076 CALL qs_rho_rebuild(rho, qs_env=qs_env, rebuild_ao=.false., rebuild_grids=.true.)
1086 SUBROUTINE print_e_density(qs_env, zcharge, cube_section)
1089 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: zcharge
1092 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube
1093 INTEGER :: iounit, ispin, unit_nr
1094 LOGICAL :: append_cube, mpi_io
1095 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_r
1098 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
1110 CALL get_qs_env(qs_env, dft_control=dft_control)
1113 my_pos_cube =
"REWIND"
1114 IF (append_cube) my_pos_cube =
"APPEND"
1120 CALL get_qs_env(qs_env, ks_env=ks_env, rho=rho)
1121 NULLIFY (rho_r, rho_g, tot_rho_r)
1123 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1124 DO ispin = 1, dft_control%nspins
1125 rho_ao => rho_ao_kp(ispin, :)
1128 rho_gspace=rho_g(ispin), &
1129 total_rho=tot_rho_r(ispin), &
1132 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1137 IF (dft_control%nspins > 1)
THEN
1138 IF (iounit > 0)
THEN
1139 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,2F15.6)") &
1140 "Integrated alpha and beta electronic density:", tot_rho_r(1:2)
1142 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1143 CALL pw_env_get(pw_env=pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1146 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
1147 CALL pw_copy(rho_r(1), rho_elec_rspace)
1148 CALL pw_axpy(rho_r(2), rho_elec_rspace)
1149 filename =
"ELECTRON_DENSITY"
1152 extension=
".cube", middle_name=trim(filename), &
1153 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1155 IF (iounit > 0)
THEN
1156 IF (.NOT. mpi_io)
THEN
1157 INQUIRE (unit=unit_nr, name=filename)
1159 filename = mpi_filename
1161 WRITE (unit=iounit, fmt=
"(T2,A,/,T2,A79)") &
1162 "The sum of alpha and beta density is written in cube file format to the file:", adjustr(trim(filename))
1164 CALL cp_pw_to_cube(rho_elec_rspace, unit_nr,
"SUM OF ALPHA AND BETA DENSITY", &
1165 particles=particles, zeff=zcharge, stride=
section_get_ivals(cube_section,
"STRIDE"), &
1168 CALL pw_copy(rho_r(1), rho_elec_rspace)
1169 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
1170 filename =
"SPIN_DENSITY"
1173 extension=
".cube", middle_name=trim(filename), &
1174 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1176 IF (iounit > 0)
THEN
1177 IF (.NOT. mpi_io)
THEN
1178 INQUIRE (unit=unit_nr, name=filename)
1180 filename = mpi_filename
1182 WRITE (unit=iounit, fmt=
"(T2,A,/,T2,A79)") &
1183 "The spin density is written in cube file format to the file:", adjustr(trim(filename))
1185 CALL cp_pw_to_cube(rho_elec_rspace, unit_nr,
"SPIN DENSITY", &
1186 particles=particles, zeff=zcharge, &
1189 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
1192 IF (iounit > 0)
THEN
1193 WRITE (unit=iounit, fmt=
"(/,T2,A,T66,F15.6)") &
1194 "Integrated electronic density:", tot_rho_r(1)
1196 filename =
"ELECTRON_DENSITY"
1199 extension=
".cube", middle_name=trim(filename), &
1200 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1202 IF (iounit > 0)
THEN
1203 IF (.NOT. mpi_io)
THEN
1204 INQUIRE (unit=unit_nr, name=filename)
1206 filename = mpi_filename
1208 WRITE (unit=iounit, fmt=
"(T2,A,/,T2,A79)") &
1209 "The electron density is written in cube file format to the file:", adjustr(trim(filename))
1212 particles=particles, zeff=zcharge, &
1217 END SUBROUTINE print_e_density
1227 SUBROUTINE print_density_cubes(qs_env, zcharge, cube_section, total_density, v_hartree, efield)
1229 TYPE(qs_environment_type),
POINTER :: qs_env
1230 REAL(kind=dp),
DIMENSION(:),
INTENT(IN) :: zcharge
1231 TYPE(section_vals_type),
POINTER :: cube_section
1232 LOGICAL,
INTENT(IN),
OPTIONAL :: total_density, v_hartree, efield
1234 CHARACTER(len=1),
DIMENSION(3),
PARAMETER :: cdir = [
"x",
"y",
"z"]
1236 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube
1237 INTEGER :: id, iounit, ispin, nd(3), unit_nr
1238 LOGICAL :: append_cube, mpi_io, my_efield, &
1239 my_total_density, my_v_hartree
1240 REAL(kind=dp) :: total_rho_core_rspace, udvol
1241 REAL(kind=dp),
DIMENSION(:),
POINTER :: tot_rho_r
1242 TYPE(cell_type),
POINTER :: cell
1243 TYPE(cp_logger_type),
POINTER :: logger
1244 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao
1245 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
1246 TYPE(dft_control_type),
POINTER :: dft_control
1247 TYPE(particle_list_type),
POINTER :: particles
1248 TYPE(pw_c1d_gs_type) :: rho_core
1249 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g
1250 TYPE(pw_env_type),
POINTER :: pw_env
1251 TYPE(pw_poisson_parameter_type) :: poisson_params
1252 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
1253 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
1254 TYPE(pw_r3d_rs_type) :: rho_tot_rspace
1255 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
1256 TYPE(qs_ks_env_type),
POINTER :: ks_env
1257 TYPE(qs_rho_type),
POINTER :: rho
1258 TYPE(qs_subsys_type),
POINTER :: subsys
1260 CALL get_qs_env(qs_env, cell=cell, dft_control=dft_control)
1262 append_cube = section_get_lval(cube_section,
"APPEND")
1263 my_pos_cube =
"REWIND"
1264 IF (append_cube) my_pos_cube =
"APPEND"
1266 IF (
PRESENT(total_density))
THEN
1267 my_total_density = total_density
1269 my_total_density = .false.
1271 IF (
PRESENT(v_hartree))
THEN
1272 my_v_hartree = v_hartree
1274 my_v_hartree = .false.
1276 IF (
PRESENT(efield))
THEN
1282 logger => cp_get_default_logger()
1283 iounit = cp_logger_get_default_io_unit(logger)
1286 CALL get_qs_env(qs_env, ks_env=ks_env, rho=rho)
1287 NULLIFY (rho_r, rho_g, tot_rho_r)
1288 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1289 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1290 DO ispin = 1, dft_control%nspins
1291 rho_ao => rho_ao_kp(ispin, :)
1292 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1294 rho_gspace=rho_g(ispin), &
1295 total_rho=tot_rho_r(ispin), &
1298 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1300 CALL get_qs_env(qs_env, subsys=subsys)
1301 CALL qs_subsys_get(subsys, particles=particles)
1303 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1304 CALL pw_env_get(pw_env=pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1305 CALL auxbas_pw_pool%create_pw(pw=rho_core)
1306 CALL calculate_rho_core(rho_core, total_rho_core_rspace, qs_env)
1308 IF (iounit > 0)
THEN
1309 WRITE (unit=iounit, fmt=
"(/,T2,A,T66,F15.6)") &
1310 "Integrated electronic density:", sum(tot_rho_r(:))
1311 WRITE (unit=iounit, fmt=
"(T2,A,T66,F15.6)") &
1312 "Integrated core density:", total_rho_core_rspace
1315 CALL auxbas_pw_pool%create_pw(pw=rho_tot_rspace)
1316 CALL pw_transfer(rho_core, rho_tot_rspace)
1317 DO ispin = 1, dft_control%nspins
1318 CALL pw_axpy(rho_r(ispin), rho_tot_rspace)
1321 IF (my_total_density)
THEN
1322 filename =
"TOTAL_DENSITY"
1324 unit_nr = cp_print_key_unit_nr(logger, cube_section,
'', &
1325 extension=
".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1326 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1327 IF (iounit > 0)
THEN
1328 IF (.NOT. mpi_io)
THEN
1329 INQUIRE (unit=unit_nr, name=filename)
1331 filename = mpi_filename
1333 WRITE (unit=iounit, fmt=
"(T2,A,/,T2,A79)") &
1334 "The total density is written in cube file format to the file:", adjustr(trim(filename))
1336 CALL cp_pw_to_cube(rho_tot_rspace, unit_nr,
"TOTAL DENSITY", &
1337 particles=particles, zeff=zcharge, &
1338 stride=section_get_ivals(cube_section,
"STRIDE"), mpi_io=mpi_io)
1339 CALL cp_print_key_finished_output(unit_nr, logger, cube_section,
'', mpi_io=mpi_io)
1341 IF (my_v_hartree .OR. my_efield)
THEN
1343 TYPE(pw_c1d_gs_type) :: rho_tot_gspace
1344 CALL auxbas_pw_pool%create_pw(pw=rho_tot_gspace)
1345 CALL pw_transfer(rho_tot_rspace, rho_tot_gspace)
1346 poisson_params%solver = pw_poisson_analytic
1347 poisson_params%periodic = cell%perd
1348 poisson_params%ewald_type = do_ewald_none
1350 TYPE(greens_fn_type) :: green_fft
1351 TYPE(pw_grid_type),
POINTER :: pwdummy
1353 CALL pw_green_create(green_fft, poisson_params, cell%hmat, auxbas_pw_pool, pwdummy, pwdummy)
1354 rho_tot_gspace%array(:) = rho_tot_gspace%array(:)*green_fft%influence_fn%array(:)
1355 CALL pw_green_release(green_fft, auxbas_pw_pool)
1357 IF (my_v_hartree)
THEN
1359 TYPE(pw_r3d_rs_type) :: vhartree
1360 CALL auxbas_pw_pool%create_pw(pw=vhartree)
1361 CALL pw_transfer(rho_tot_gspace, vhartree)
1362 filename =
"V_HARTREE"
1364 unit_nr = cp_print_key_unit_nr(logger, cube_section,
'', &
1365 extension=
".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1366 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1367 IF (iounit > 0)
THEN
1368 IF (.NOT. mpi_io)
THEN
1369 INQUIRE (unit=unit_nr, name=filename)
1371 filename = mpi_filename
1373 WRITE (unit=iounit, fmt=
"(T2,A,/,T2,A79)") &
1374 "The Hartree potential is written in cube file format to the file:", adjustr(trim(filename))
1376 CALL cp_pw_to_cube(vhartree, unit_nr,
"Hartree Potential", &
1377 particles=particles, zeff=zcharge, &
1378 stride=section_get_ivals(cube_section,
"STRIDE"), mpi_io=mpi_io)
1379 CALL cp_print_key_finished_output(unit_nr, logger, cube_section,
'', mpi_io=mpi_io)
1380 CALL auxbas_pw_pool%give_back_pw(vhartree)
1385 TYPE(pw_c1d_gs_type) :: vhartree
1386 CALL auxbas_pw_pool%create_pw(pw=vhartree)
1387 udvol = 1.0_dp/rho_tot_rspace%pw_grid%dvol
1389 CALL pw_transfer(rho_tot_gspace, vhartree)
1392 CALL pw_derive(vhartree, nd)
1393 CALL pw_transfer(vhartree, rho_tot_rspace)
1394 CALL pw_scale(rho_tot_rspace, udvol)
1396 filename =
"EFIELD_"//cdir(id)
1398 unit_nr = cp_print_key_unit_nr(logger, cube_section,
'', &
1399 extension=
".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1400 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1401 IF (iounit > 0)
THEN
1402 IF (.NOT. mpi_io)
THEN
1403 INQUIRE (unit=unit_nr, name=filename)
1405 filename = mpi_filename
1407 WRITE (unit=iounit, fmt=
"(T2,A,/,T2,A79)") &
1408 "The Efield is written in cube file format to the file:", adjustr(trim(filename))
1410 CALL cp_pw_to_cube(rho_tot_rspace, unit_nr,
"EFIELD "//cdir(id), &
1411 particles=particles, zeff=zcharge, &
1412 stride=section_get_ivals(cube_section,
"STRIDE"), mpi_io=mpi_io)
1413 CALL cp_print_key_finished_output(unit_nr, logger, cube_section,
'', mpi_io=mpi_io)
1415 CALL auxbas_pw_pool%give_back_pw(vhartree)
1418 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
1422 CALL auxbas_pw_pool%give_back_pw(rho_tot_rspace)
1423 CALL auxbas_pw_pool%give_back_pw(rho_core)
1425 END SUBROUTINE print_density_cubes
1433 SUBROUTINE print_elf(qs_env, zcharge, elf_section)
1435 TYPE(qs_environment_type),
POINTER :: qs_env
1436 REAL(kind=dp),
DIMENSION(:),
INTENT(IN) :: zcharge
1437 TYPE(section_vals_type),
POINTER :: elf_section
1439 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
1441 INTEGER :: iounit, ispin, unit_nr
1442 LOGICAL :: append_cube, mpi_io
1443 REAL(kind=dp) :: rho_cutoff
1444 REAL(kind=dp),
DIMENSION(:),
POINTER :: tot_rho_r
1445 TYPE(cp_logger_type),
POINTER :: logger
1446 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao
1447 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
1448 TYPE(dft_control_type),
POINTER :: dft_control
1449 TYPE(particle_list_type),
POINTER :: particles
1450 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g
1451 TYPE(pw_env_type),
POINTER :: pw_env
1452 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
1453 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
1454 TYPE(pw_r3d_rs_type),
ALLOCATABLE,
DIMENSION(:) :: elf_r
1455 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
1456 TYPE(qs_ks_env_type),
POINTER :: ks_env
1457 TYPE(qs_rho_type),
POINTER :: rho
1458 TYPE(qs_subsys_type),
POINTER :: subsys
1460 logger => cp_get_default_logger()
1461 iounit = cp_logger_get_default_io_unit(logger)
1464 CALL get_qs_env(qs_env, dft_control=dft_control, ks_env=ks_env, rho=rho)
1465 NULLIFY (rho_r, rho_g, tot_rho_r)
1466 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1467 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1468 DO ispin = 1, dft_control%nspins
1469 rho_ao => rho_ao_kp(ispin, :)
1470 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1472 rho_gspace=rho_g(ispin), &
1473 total_rho=tot_rho_r(ispin), &
1476 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1478 CALL get_qs_env(qs_env, subsys=subsys)
1479 CALL qs_subsys_get(subsys, particles=particles)
1481 ALLOCATE (elf_r(dft_control%nspins))
1482 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1483 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1484 DO ispin = 1, dft_control%nspins
1485 CALL auxbas_pw_pool%create_pw(elf_r(ispin))
1486 CALL pw_zero(elf_r(ispin))
1489 IF (iounit > 0)
THEN
1490 WRITE (unit=iounit, fmt=
"(/,T2,A)") &
1491 "ELF is computed on the real space grid -----"
1493 rho_cutoff = section_get_rval(elf_section,
"density_cutoff")
1494 CALL qs_elf_calc(qs_env, elf_r, rho_cutoff)
1497 append_cube = section_get_lval(elf_section,
"APPEND")
1498 my_pos_cube =
"REWIND"
1499 IF (append_cube) my_pos_cube =
"APPEND"
1500 DO ispin = 1, dft_control%nspins
1501 WRITE (filename,
'(a5,I1.1)')
"ELF_S", ispin
1502 WRITE (title, *)
"ELF spin ", ispin
1504 unit_nr = cp_print_key_unit_nr(logger, elf_section,
'', extension=
".cube", &
1505 middle_name=trim(filename), file_position=my_pos_cube, &
1506 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1507 IF (iounit > 0)
THEN
1508 IF (.NOT. mpi_io)
THEN
1509 INQUIRE (unit=unit_nr, name=filename)
1511 filename = mpi_filename
1513 WRITE (unit=iounit, fmt=
"(T2,A,/,T2,A79)") &
1514 "ELF is written in cube file format to the file:", adjustr(trim(filename))
1517 CALL cp_pw_to_cube(elf_r(ispin), unit_nr, title, particles=particles, zeff=zcharge, &
1518 stride=section_get_ivals(elf_section,
"STRIDE"), mpi_io=mpi_io)
1519 CALL cp_print_key_finished_output(unit_nr, logger, elf_section,
'', mpi_io=mpi_io)
1521 CALL auxbas_pw_pool%give_back_pw(elf_r(ispin))
1526 END SUBROUTINE print_elf
1533 SUBROUTINE print_mo_cubes(qs_env, zcharge, cube_section)
1535 TYPE(qs_environment_type),
POINTER :: qs_env
1536 REAL(kind=dp),
DIMENSION(:),
INTENT(IN) :: zcharge
1537 TYPE(section_vals_type),
POINTER :: cube_section
1539 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1540 INTEGER :: homo, i, ifirst, ilast, iounit, ir, &
1541 ispin, ivector, n_rep, nhomo, nlist, &
1542 nlumo, nmo, shomo, unit_nr
1543 INTEGER,
DIMENSION(:),
POINTER ::
list, list_index
1544 LOGICAL :: append_cube, mpi_io, write_cube
1545 REAL(kind=dp) :: homo_lumo(2, 2)
1546 REAL(kind=dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
1547 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1548 TYPE(cell_type),
POINTER :: cell
1549 TYPE(cp_fm_type),
POINTER :: mo_coeff
1550 TYPE(cp_logger_type),
POINTER :: logger
1551 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, mo_derivs
1552 TYPE(dft_control_type),
POINTER :: dft_control
1553 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
1554 TYPE(particle_list_type),
POINTER :: particles
1555 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1556 TYPE(pw_c1d_gs_type) :: wf_g
1557 TYPE(pw_env_type),
POINTER :: pw_env
1558 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
1559 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
1560 TYPE(pw_r3d_rs_type) :: wf_r
1561 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1562 TYPE(qs_subsys_type),
POINTER :: subsys
1563 TYPE(scf_control_type),
POINTER :: scf_control
1565 logger => cp_get_default_logger()
1566 iounit = cp_logger_get_default_io_unit(logger)
1568 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv, scf_control=scf_control)
1569 CALL get_qs_env(qs_env, dft_control=dft_control, mo_derivs=mo_derivs)
1570 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
1571 NULLIFY (mo_eigenvalues)
1573 DO ispin = 1, dft_control%nspins
1574 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=shomo)
1575 homo_lumo(ispin, 1) = mo_eigenvalues(shomo)
1576 homo = max(homo, shomo)
1578 write_cube = section_get_lval(cube_section,
"WRITE_CUBE")
1579 nlumo = section_get_ival(cube_section,
"NLUMO")
1580 nhomo = section_get_ival(cube_section,
"NHOMO")
1581 NULLIFY (list_index)
1582 CALL section_vals_val_get(cube_section,
"HOMO_LIST", n_rep_val=n_rep)
1587 CALL section_vals_val_get(cube_section,
"HOMO_LIST", i_rep_val=ir, i_vals=
list)
1588 IF (
ASSOCIATED(
list))
THEN
1589 CALL reallocate(list_index, 1, nlist +
SIZE(
list))
1590 DO i = 1,
SIZE(
list)
1591 list_index(i + nlist) =
list(i)
1593 nlist = nlist +
SIZE(
list)
1596 nhomo = maxval(list_index)
1598 IF (nhomo == -1) nhomo = homo
1599 nlist = homo - max(1, homo - nhomo + 1) + 1
1600 ALLOCATE (list_index(nlist))
1602 list_index(i) = max(1, homo - nhomo + 1) + i - 1
1606 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1607 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1608 CALL auxbas_pw_pool%create_pw(wf_r)
1609 CALL auxbas_pw_pool%create_pw(wf_g)
1611 CALL get_qs_env(qs_env, subsys=subsys)
1612 CALL qs_subsys_get(subsys, particles=particles)
1614 append_cube = section_get_lval(cube_section,
"APPEND")
1615 my_pos_cube =
"REWIND"
1616 IF (append_cube)
THEN
1617 my_pos_cube =
"APPEND"
1620 CALL get_qs_env(qs_env=qs_env, &
1621 atomic_kind_set=atomic_kind_set, &
1622 qs_kind_set=qs_kind_set, &
1624 particle_set=particle_set)
1626 IF (nhomo >= 0)
THEN
1627 DO ispin = 1, dft_control%nspins
1629 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1630 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
1631 IF (write_cube)
THEN
1633 ivector = list_index(i)
1634 IF (ivector > homo) cycle
1635 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, qs_kind_set, &
1636 cell, dft_control, particle_set, pw_env)
1637 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", ivector,
"_", ispin
1639 unit_nr = cp_print_key_unit_nr(logger, cube_section,
'', extension=
".cube", &
1640 middle_name=trim(filename), file_position=my_pos_cube, &
1641 log_filename=.false., mpi_io=mpi_io)
1642 WRITE (title, *)
"WAVEFUNCTION ", ivector,
" spin ", ispin,
" i.e. HOMO - ", ivector - homo
1643 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, zeff=zcharge, &
1644 stride=section_get_ivals(cube_section,
"STRIDE"), mpi_io=mpi_io)
1645 CALL cp_print_key_finished_output(unit_nr, logger, cube_section,
'', mpi_io=mpi_io)
1651 IF (nlumo /= 0)
THEN
1652 DO ispin = 1, dft_control%nspins
1654 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1655 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
1656 IF (write_cube)
THEN
1658 IF (nlumo == -1)
THEN
1661 ilast = ifirst + nlumo - 1
1662 ilast = min(nmo, ilast)
1664 DO ivector = ifirst, ilast
1665 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, &
1666 qs_kind_set, cell, dft_control, particle_set, pw_env)
1667 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", ivector,
"_", ispin
1669 unit_nr = cp_print_key_unit_nr(logger, cube_section,
'', extension=
".cube", &
1670 middle_name=trim(filename), file_position=my_pos_cube, &
1671 log_filename=.false., mpi_io=mpi_io)
1672 WRITE (title, *)
"WAVEFUNCTION ", ivector,
" spin ", ispin,
" i.e. LUMO + ", ivector - ifirst
1673 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, zeff=zcharge, &
1674 stride=section_get_ivals(cube_section,
"STRIDE"), mpi_io=mpi_io)
1675 CALL cp_print_key_finished_output(unit_nr, logger, cube_section,
'', mpi_io=mpi_io)
1681 CALL auxbas_pw_pool%give_back_pw(wf_g)
1682 CALL auxbas_pw_pool%give_back_pw(wf_r)
1683 IF (
ASSOCIATED(list_index))
DEALLOCATE (list_index)
1685 END SUBROUTINE print_mo_cubes
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Handles all functions related to the CELL.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_write_sparse_matrix(sparse_matrix, before, after, qs_env, para_env, first_row, last_row, first_col, last_col, scale, output_unit, omit_headers, cartesian_basis)
...
various cholesky decomposition related routines
subroutine, public cp_fm_cholesky_restore(fm_matrix, neig, fm_matrixb, fm_matrixout, op, pos, transa)
apply Cholesky decomposition op can be "SOLVE" (out = U^-1 * in) or "MULTIPLY" (out = U * in) pos can...
subroutine, public cp_fm_cholesky_decompose(matrix, n, info_out)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
subroutine, public cp_fm_cholesky_reduce(matrix, matrixb, itype)
reduce a matrix pencil A,B to normal form B has to be cholesky decomposed with cp_fm_cholesky_decompo...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
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_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the matrix
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_init_random(matrix, ncol, start_col)
fills a matrix with random numbers
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_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,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
...
set of type/routines to handle the storage of results in force_envs
subroutine, public cp_results_erase(results, description, nval)
erase a part of result_list
set of type/routines to handle the storage of results in force_envs
Calculation of charge equilibration method.
subroutine, public eeq_print(qs_env, iounit, print_level, ext)
...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Utility routines for the memory handling.
Interface to the message passing library MPI.
Functions handling the MOLDEN format. Split from mode_selective.
subroutine, public write_mos_molden(mos, qs_kind_set, particle_set, print_section, cell, unoccupied_orbs, unoccupied_evals, qs_env, calc_energies)
Write out the MOs in molden format for visualisation.
Calculates the moment integrals <a|r^m|b>
subroutine, public get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, ifirst, ilast)
...
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
represent a simple array based list of the given type
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public debye
Provide various population analyses and print the requested output information.
subroutine, public lowdin_population_analysis(qs_env, output_unit, print_level)
Perform a Lowdin population analysis based on a symmetric orthogonalisation of the density matrix usi...
computes preconditioners, and implements methods to apply them currently used in qs_ot
methods of pw_env that have dependence on qs_env
subroutine, public pw_env_rebuild(pw_env, qs_env, external_para_env)
rebuilds the pw_env data (necessary if cell or cutoffs change)
subroutine, public pw_env_create(pw_env)
creates a pw_env, if qs_env is given calls pw_env_rebuild
container for various plainwaves related things
subroutine, public pw_env_release(pw_env, para_env)
releases the given pw_env (see doc/ReferenceCounting.html)
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
subroutine, public pw_derive(pw, n)
Calculate the derivative of a plane wave vector.
functions related to the poisson solver on regular grids
subroutine, public pw_green_create(green, poisson_params, cell_hmat, pw_pool, mt_super_ref_pw_grid, dct_pw_grid)
Allocates and sets up the green functions for the fft based poisson solvers.
subroutine, public pw_green_release(gftype, pw_pool)
destroys the type (deallocates data)
integer, parameter, public do_ewald_none
integer, parameter, public pw_poisson_analytic
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
subroutine, public calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type)
maps a given wavefunction on the grid
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
Utilities for broadened DOS and PDOS output.
subroutine, public get_dos_pdos_flags(dos_section, do_dos_output, do_projected_dos, do_pdos, do_curve)
Resolve projected-DOS requests from a DOS print section.
Calculation and writing of density of states.
subroutine, public calculate_dos_kp(qs_env, dft_section, write_curve_output)
Compute and write density of states (kpoints)
subroutine, public calculate_dos(mos, dft_section, unoccupied_evals, smearing_enabled, write_curve_output)
Compute and write density of states.
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public qs_elf_calc(qs_env, elf_r, rho_cutoff)
...
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public energy_windows(qs_env)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_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, xcint_weights, 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, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
collects routines that perform operations directly related to MOs
subroutine, public make_mo_eig(mos, nspins, ks_rmpv, scf_control, mo_derivs, admm_env, hairy_probes, probe)
Calculate KS eigenvalues starting from OF MOS.
Set occupation of molecular orbitals.
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.
an eigen-space solver for the generalised symmetric eigenvalue problem for sparse matrices,...
subroutine, public ot_eigensolver(matrix_h, matrix_s, matrix_orthogonal_space_fm, matrix_c_fm, preconditioner, eps_gradient, iter_max, size_ortho_space, silent, ot_settings)
...
Calculation and writing of projected density of states The DOS is computed per angular momentum and p...
subroutine, public calculate_projected_dos_kp(qs_env, dft_section, pdos_print_key, write_pdos, write_pdos_curve)
Compute and write broadened projected density of states for k-point calculations.
subroutine, public calculate_projected_dos(mo_set, atomic_kind_set, qs_kind_set, particle_set, qs_env, dft_section, ispin, xas_mittle, external_matrix_shalf, unoccupied_orbs, unoccupied_evals, pdos_print_key, write_pdos, write_pdos_curve)
Compute and write projected density of states.
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_rebuild(rho, qs_env, rebuild_ao, rebuild_grids, admm, pw_env_external)
rebuilds rho (if necessary allocating and initializing it)
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(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)
...
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...
Functions to print the KS and S matrix in the CSR format to file.
subroutine, public write_s_matrix_csr(qs_env, input)
writing the overlap matrix in csr format into a file
subroutine, public write_ks_matrix_csr(qs_env, input)
writing the KS matrix in csr format into a file
subroutine, public write_p_matrix_csr(qs_env, input)
writing the density matrix in csr format into a file
subroutine, public write_hcore_matrix_csr(qs_env, input)
writing the core Hamiltonian matrix in csr format into a file
subroutine, public qs_scf_write_mos(qs_env, scf_env, final_mos)
Write the MO eigenvector, eigenvalues, and occupation numbers to the output unit.
Does all kind of post scf calculations for DFTB.
subroutine, public scf_post_calculation_tb(qs_env, tb_type, no_mos)
collects possible post - scf calculations and prints info / computes properties.
subroutine, public rebuild_pw_env(qs_env)
...
subroutine, public make_lumo_tb(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
Gets the lumos, and eigenvalues for the lumos.
module that contains the definitions of the scf types
integer, parameter, public ot_method_nr
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, output_unit, unoccupied_orbs, scf_env, matrix_s, marked_states, for_rtp)
writes a new 'mixed' set of mos to restart file, without touching the current MOs
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
Calculation of STM image as post processing of an electronic structure calculation,...
subroutine, public th_stm_image(qs_env, stm_section, particles, unoccupied_orbs, unoccupied_evals)
Driver for the calculation of STM image, as post processing of a ground-state electronic structure ca...
generate the tasks lists used by collocate and integrate routines
subroutine, public generate_qs_task_list(ks_env, task_list, basis_type, reorder_rs_grid_ranks, skip_load_balance_distributed, pw_env_external, sab_orb_external, ext_kpoints)
...
subroutine, public allocate_task_list(task_list)
allocates and initialised the components of the task_list_type
Calculation of charge response in xTB (EEQ only) Reference: Stefan Grimme, Christoph Bannwarth,...
subroutine, public build_xtb_qresp(qs_env, qresp)
...
Definition of the xTB parameter types.
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, xi, kappa0, alpg, occupation, electronegativity, chmax, en, kqat2, kcn, kq)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
represent a pointer to a 1d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
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...
contains arbitrary information which need to be stored
stores all the informations relevant to an mpi environment
represent a list of objects
contained for different pw related things
contains all the informations needed by the fft based poisson solvers
parameters for the poisson solver independet of input_section
to create arrays of pools
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.