209#include "./base/base_uses.f90"
215 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_post_gpw'
223 CHARACTER(len=*),
PARAMETER :: &
224 str_mo_cubes =
"PRINT%MO_CUBES", &
225 str_mo_openpmd =
"PRINT%MO_OPENPMD", &
226 str_elf_cubes =
"PRINT%ELF_CUBE", &
227 str_elf_openpmd =
"PRINT%ELF_OPENPMD", &
228 str_e_density_cubes =
"PRINT%E_DENSITY_CUBE", &
229 str_e_density_openpmd =
"PRINT%E_DENSITY_OPENPMD"
231 INTEGER,
PARAMETER :: grid_output_cubes = 1, grid_output_openpmd = 2
237 CHARACTER(len=default_string_length) :: relative_section_key =
""
238 CHARACTER(len=default_string_length) :: absolute_section_key =
""
239 CHARACTER(len=7) :: format_name =
""
240 INTEGER :: grid_output = -1
241 LOGICAL :: do_output = .false.
244 PROCEDURE,
PUBLIC :: print_key_unit_nr => cp_forward_print_key_unit_nr
246 PROCEDURE,
PUBLIC :: write_pw => cp_forward_write_pw
248 PROCEDURE,
PUBLIC :: print_key_finished_output => cp_forward_print_key_finished_output
250 PROCEDURE,
PUBLIC :: do_openpmd => cp_section_key_do_openpmd
251 PROCEDURE,
PUBLIC :: do_cubes => cp_section_key_do_cubes
252 PROCEDURE,
PUBLIC :: concat_to_relative => cp_section_key_concat_to_relative
254 END TYPE cp_section_key
265 CLASS(cp_section_key),
INTENT(IN) :: self
266 CHARACTER(*),
INTENT(IN) :: extend_by
267 CHARACTER(len=default_string_length) :: res
269 IF (len(trim(extend_by)) > 0 .AND. extend_by(1:1) ==
"%")
THEN
270 res = trim(self%absolute_section_key)//trim(extend_by)
272 res = trim(self%absolute_section_key)//
"%"//trim(extend_by)
282 FUNCTION cp_section_key_concat_to_relative(self, extend_by)
RESULT(res)
283 CLASS(cp_section_key),
INTENT(IN) :: self
284 CHARACTER(*),
INTENT(IN) :: extend_by
285 CHARACTER(len=default_string_length) :: res
287 IF (len(trim(extend_by)) > 0 .AND. extend_by(1:1) ==
"%")
THEN
288 res = trim(self%relative_section_key)//trim(extend_by)
290 res = trim(self%relative_section_key)//
"%"//trim(extend_by)
292 END FUNCTION cp_section_key_concat_to_relative
299 FUNCTION cp_section_key_do_cubes(self)
RESULT(res)
300 CLASS(cp_section_key) :: self
303 res = self%do_output .AND. self%grid_output == grid_output_cubes
304 END FUNCTION cp_section_key_do_cubes
311 FUNCTION cp_section_key_do_openpmd(self)
RESULT(res)
312 CLASS(cp_section_key) :: self
315 res = self%do_output .AND. self%grid_output == grid_output_openpmd
316 END FUNCTION cp_section_key_do_openpmd
343 FUNCTION cp_forward_print_key_unit_nr(self, logger, basis_section, print_key_path, extension, &
344 middle_name, local, log_filename, ignore_should_output, file_form, file_position, &
345 file_action, file_status, do_backup, on_file, is_new_file, mpi_io, &
346 fout, openpmd_basename)
RESULT(res)
347 CLASS(cp_section_key),
INTENT(IN) :: self
350 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: print_key_path
351 CHARACTER(len=*),
INTENT(IN) :: extension
352 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: middle_name
353 LOGICAL,
INTENT(IN),
OPTIONAL :: local, log_filename, ignore_should_output
354 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: file_form, file_position, file_action, &
356 LOGICAL,
INTENT(IN),
OPTIONAL :: do_backup, on_file
357 LOGICAL,
INTENT(OUT),
OPTIONAL :: is_new_file
358 LOGICAL,
INTENT(INOUT),
OPTIONAL :: mpi_io
359 CHARACTER(len=default_path_length),
INTENT(OUT), &
361 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: openpmd_basename
364 IF (self%grid_output == grid_output_cubes)
THEN
366 logger, basis_section, print_key_path, extension=extension, &
367 middle_name=middle_name, local=local, log_filename=log_filename, &
368 ignore_should_output=ignore_should_output, file_form=file_form, &
369 file_position=file_position, file_action=file_action, &
370 file_status=file_status, do_backup=do_backup, on_file=on_file, &
371 is_new_file=is_new_file, mpi_io=mpi_io, fout=fout)
374 middle_name=middle_name, ignore_should_output=ignore_should_output, &
375 mpi_io=mpi_io, fout=fout, openpmd_basename=openpmd_basename)
377 END FUNCTION cp_forward_print_key_unit_nr
395 SUBROUTINE cp_forward_write_pw( &
408 CLASS(cp_section_key),
INTENT(IN) :: self
410 INTEGER,
INTENT(IN) :: unit_nr
411 CHARACTER(*),
INTENT(IN),
OPTIONAL :: title
413 INTEGER,
DIMENSION(:),
OPTIONAL,
POINTER :: stride
414 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: max_file_size_mb
415 LOGICAL,
INTENT(IN),
OPTIONAL :: zero_tails, silent, mpi_io
416 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: zeff
418 IF (self%grid_output == grid_output_cubes)
THEN
419 CALL cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
421 CALL cp_pw_to_openpmd(pw, unit_nr, title, particles, zeff, stride, zero_tails, silent, mpi_io)
423 END SUBROUTINE cp_forward_write_pw
439 SUBROUTINE cp_forward_print_key_finished_output(self, unit_nr, logger, basis_section, &
440 print_key_path, local, ignore_should_output, on_file, &
442 CLASS(cp_section_key),
INTENT(IN) :: self
443 INTEGER,
INTENT(INOUT) :: unit_nr
446 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: print_key_path
447 LOGICAL,
INTENT(IN),
OPTIONAL :: local, ignore_should_output, on_file, &
450 IF (self%grid_output == grid_output_cubes)
THEN
455 END SUBROUTINE cp_forward_print_key_finished_output
475 FUNCTION cube_or_openpmd(input, str_cubes, str_openpmd, logger)
RESULT(res)
477 CHARACTER(len=*),
INTENT(IN) :: str_cubes, str_openpmd
479 TYPE(cp_section_key) :: res
481 LOGICAL :: do_cubes, do_openpmd
484 logger%iter_info, input, &
485 "DFT%"//trim(adjustl(str_cubes))),
cp_p_file)
487 logger%iter_info, input, &
488 "DFT%"//trim(adjustl(str_openpmd))),
cp_p_file)
492 cpassert(.NOT. (do_cubes .AND. do_openpmd))
493 res%do_output = do_cubes .OR. do_openpmd
495 res%grid_output = grid_output_openpmd
496 res%relative_section_key = trim(adjustl(str_openpmd))
497 res%format_name =
"openPMD"
499 res%grid_output = grid_output_cubes
500 res%relative_section_key = trim(adjustl(str_cubes))
501 res%format_name =
"Cube"
503 res%absolute_section_key =
"DFT%"//trim(adjustl(res%relative_section_key))
504 END FUNCTION cube_or_openpmd
512 FUNCTION section_key_do_write(grid_output)
RESULT(res)
513 INTEGER,
INTENT(IN) :: grid_output
514 CHARACTER(len=32) :: res
516 IF (grid_output == grid_output_cubes)
THEN
518 ELSE IF (grid_output == grid_output_openpmd)
THEN
519 res =
"%WRITE_OPENPMD"
521 END FUNCTION section_key_do_write
530 SUBROUTINE print_density_output_message(output_unit, prefix, e_density_section, filename)
531 INTEGER,
INTENT(IN) :: output_unit
532 CHARACTER(len=*),
INTENT(IN) :: prefix
533 TYPE(cp_section_key),
INTENT(IN) :: e_density_section
534 CHARACTER(len=*),
INTENT(IN) :: filename
536 IF (e_density_section%grid_output == grid_output_openpmd)
THEN
537 WRITE (unit=output_unit, fmt=
"(/,T2,A)") &
538 trim(prefix)//
" is written in " &
539 //e_density_section%format_name &
540 //
" file format to the file / file pattern:", &
543 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
544 trim(prefix)//
" is written in " &
545 //e_density_section%format_name &
546 //
" file format to the file:", &
549 END SUBROUTINE print_density_output_message
574 CHARACTER(6),
OPTIONAL :: wf_type
575 LOGICAL,
OPTIONAL :: do_mp2
577 CHARACTER(len=*),
PARAMETER :: routinen =
'scf_post_calculation_gpw', &
578 warning_cube_kpoint =
"Print MO cubes not implemented for k-point calculations", &
579 warning_openpmd_kpoint =
"Writing to openPMD not implemented for k-point calculations"
581 INTEGER :: handle, homo, ispin, min_lumos, n_rep, nchk_nmoloc, nhomo, nlumo, nlumo_molden, &
582 nlumo_stm, nlumos, nmo, nspins, output_unit, unit_nr
583 INTEGER,
DIMENSION(:, :, :),
POINTER :: marked_states
584 LOGICAL :: check_write, compute_lumos, do_homo, do_kpoints,
do_mixed, do_stm, &
585 do_wannier_cubes, has_homo, has_lumo, loc_explicit, loc_print_explicit, my_do_mp2, &
586 my_localized_wfn, p_loc, p_loc_homo, p_loc_lumo, p_loc_mixed
588 REAL(kind=
dp) :: gap, homo_lumo(2, 2), total_zeff_corr
589 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
593 TYPE(
cp_1d_r_p_type),
DIMENSION(:),
POINTER :: mixed_evals, occupied_evals, &
594 unoccupied_evals, unoccupied_evals_stm
595 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: mixed_orbs, occupied_orbs
596 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:), &
597 TARGET :: homo_localized, lumo_localized, &
599 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: lumo_ptr, mo_loc_history, &
600 unoccupied_orbs, unoccupied_orbs_stm
603 TYPE(cp_section_key) :: mo_section
604 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_p_mp2, matrix_s, &
606 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: kinetic_m, rho_ao
618 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
626 localize_section, print_key, &
627 sprint_section, stm_section
629 CALL timeset(routinen, handle)
636 IF (
PRESENT(do_mp2)) my_do_mp2 = do_mp2
637 IF (
PRESENT(wf_type))
THEN
638 IF (output_unit > 0)
THEN
639 WRITE (unit=output_unit, fmt=
'(/,(T1,A))') repeat(
"-", 40)
640 WRITE (unit=output_unit, fmt=
'(/,(T3,A,T19,A,T25,A))')
"Properties from ", wf_type,
" density"
641 WRITE (unit=output_unit, fmt=
'(/,(T1,A))') repeat(
"-", 40)
648 my_localized_wfn = .false.
649 NULLIFY (admm_env, dft_control, pw_env, auxbas_pw_pool, pw_pools, mos, rho, &
650 mo_coeff, ks_rmpv, matrix_s, qs_loc_env_homo, qs_loc_env_lumo, scf_control, &
651 unoccupied_orbs, mo_eigenvalues, unoccupied_evals, &
652 unoccupied_evals_stm, molecule_set, mo_derivs, &
653 subsys, particles, input, print_key, kinetic_m, marked_states, &
654 mixed_evals, qs_loc_env_mixed)
655 NULLIFY (lumo_ptr, rho_ao)
662 p_loc_mixed = .false.
664 cpassert(
ASSOCIATED(scf_env))
665 cpassert(
ASSOCIATED(qs_env))
668 dft_control=dft_control, &
669 molecule_set=molecule_set, &
670 scf_control=scf_control, &
671 do_kpoints=do_kpoints, &
676 particle_set=particle_set, &
677 atomic_kind_set=atomic_kind_set, &
678 qs_kind_set=qs_kind_set)
685 CALL get_qs_env(qs_env, matrix_p_mp2=matrix_p_mp2)
686 DO ispin = 1, dft_control%nspins
687 CALL dbcsr_add(rho_ao(ispin, 1)%matrix, matrix_p_mp2(ispin)%matrix, 1.0_dp, 1.0_dp)
692 CALL update_hartree_with_mp2(rho, qs_env)
695 CALL write_available_results(qs_env, scf_env)
699 "DFT%PRINT%KINETIC_ENERGY") /= 0)
THEN
701 cpassert(
ASSOCIATED(kinetic_m))
702 cpassert(
ASSOCIATED(kinetic_m(1, 1)%matrix))
706 IF (unit_nr > 0)
THEN
707 WRITE (unit_nr,
'(T3,A,T55,F25.14)')
"Electronic kinetic energy:", e_kin
710 "DFT%PRINT%KINETIC_ENERGY")
714 CALL qs_scf_post_charges(input, logger, qs_env)
727 IF (loc_print_explicit)
THEN
747 IF (loc_explicit)
THEN
757 p_loc_mixed = .false.
761 IF (n_rep == 0 .AND. p_loc_lumo)
THEN
762 CALL cp_abort(__location__,
"No LIST_UNOCCUPIED was specified, "// &
763 "therefore localization of unoccupied states will be skipped!")
774 mo_section = cube_or_openpmd(input, str_mo_cubes, str_mo_openpmd, logger)
776 IF (loc_print_explicit)
THEN
780 do_wannier_cubes = .false.
782 nlumo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NLUMO"))
783 nhomo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NHOMO"))
786 IF (((mo_section%do_output .OR. do_wannier_cubes) .AND. (nlumo /= 0 .OR. nhomo /= 0)) .OR. p_loc)
THEN
787 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
789 CALL auxbas_pw_pool%create_pw(wf_r)
790 CALL auxbas_pw_pool%create_pw(wf_g)
793 IF (dft_control%restricted)
THEN
797 nspins = dft_control%nspins
800 IF (dft_control%restricted .AND. (mo_section%do_output .OR. p_loc_homo))
THEN
801 CALL cp_abort(__location__,
"Unclear how we define MOs / localization in the restricted case ... ")
806 cpwarn_if(mo_section%do_cubes(), warning_cube_kpoint)
807 cpwarn_if(mo_section%do_openpmd(), warning_openpmd_kpoint)
812 IF ((mo_section%do_output .AND. nhomo /= 0) .OR. do_stm)
THEN
814 IF (dft_control%do_admm)
THEN
816 CALL make_mo_eig(mos, nspins, ks_rmpv, scf_control, mo_derivs, admm_env=admm_env)
818 IF (dft_control%hairy_probes)
THEN
819 scf_control%smear%do_smear = .false.
820 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs, &
822 probe=dft_control%probe)
824 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
827 DO ispin = 1, dft_control%nspins
828 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=homo)
829 homo_lumo(ispin, 1) = mo_eigenvalues(homo)
833 IF (mo_section%do_output .AND. nhomo /= 0)
THEN
836 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
837 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
838 CALL qs_scf_post_occ_cubes(input, dft_section, dft_control, logger, qs_env, &
839 mo_coeff, wf_g, wf_r, particles, homo, ispin, mo_section)
850 cpwarn(
"Localization not implemented for k-point calculations!")
851 ELSEIF (dft_control%restricted &
854 cpabort(
"ROKS works only with LOCALIZE METHOD NONE or JACOBI")
856 ALLOCATE (occupied_orbs(dft_control%nspins))
857 ALLOCATE (occupied_evals(dft_control%nspins))
858 ALLOCATE (homo_localized(dft_control%nspins))
859 DO ispin = 1, dft_control%nspins
860 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
861 eigenvalues=mo_eigenvalues)
862 occupied_orbs(ispin) = mo_coeff
863 occupied_evals(ispin)%array => mo_eigenvalues
864 CALL cp_fm_create(homo_localized(ispin), occupied_orbs(ispin)%matrix_struct)
865 CALL cp_fm_to_fm(occupied_orbs(ispin), homo_localized(ispin))
868 CALL get_qs_env(qs_env, mo_loc_history=mo_loc_history)
871 ALLOCATE (qs_loc_env_homo)
874 CALL qs_loc_init(qs_env, qs_loc_env_homo, localize_section, homo_localized, do_homo, &
875 mo_section%do_output, mo_loc_history=mo_loc_history)
877 wf_r, wf_g, particles, occupied_orbs, occupied_evals, marked_states)
880 IF (qs_loc_env_homo%localized_wfn_control%use_history)
THEN
882 CALL set_qs_env(qs_env, mo_loc_history=mo_loc_history)
887 homo_localized, do_homo)
889 DEALLOCATE (occupied_orbs)
890 DEALLOCATE (occupied_evals)
892 IF (qs_loc_env_homo%do_localize)
THEN
893 CALL loc_dipole(input, dft_control, qs_loc_env_homo, logger, qs_env)
900 IF (mo_section%do_output .OR. p_loc_lumo)
THEN
902 cpwarn(
"Localization and MO related output not implemented for k-point calculations!")
905 compute_lumos = mo_section%do_output .AND. nlumo /= 0
906 compute_lumos = compute_lumos .OR. p_loc_lumo
908 DO ispin = 1, dft_control%nspins
909 CALL get_mo_set(mo_set=mos(ispin), homo=homo, nmo=nmo)
910 compute_lumos = compute_lumos .AND. homo == nmo
913 IF (mo_section%do_output .AND. .NOT. compute_lumos)
THEN
915 nlumo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NLUMO"))
916 DO ispin = 1, dft_control%nspins
918 CALL get_mo_set(mo_set=mos(ispin), homo=homo, nmo=nmo, eigenvalues=mo_eigenvalues)
919 IF (nlumo > nmo - homo)
THEN
922 IF (nlumo == -1)
THEN
925 IF (output_unit > 0)
WRITE (output_unit, *)
" "
926 IF (output_unit > 0)
WRITE (output_unit, *)
" Lowest eigenvalues of the unoccupied subspace spin ", ispin
927 IF (output_unit > 0)
WRITE (output_unit, *)
"---------------------------------------------"
928 IF (output_unit > 0)
WRITE (output_unit,
'(4(1X,1F16.8))') mo_eigenvalues(homo + 1:homo + nlumo)
931 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
932 CALL qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
933 mo_coeff, wf_g, wf_r, particles, nlumo, homo, ispin, lumo=homo + 1, mo_section=mo_section)
939 IF (compute_lumos)
THEN
942 IF (nlumo == 0) check_write = .false.
945 ALLOCATE (qs_loc_env_lumo)
948 min_lumos = max(maxval(qs_loc_env_lumo%localized_wfn_control%loc_states(:, :)), nlumo)
951 ALLOCATE (unoccupied_orbs(dft_control%nspins))
952 ALLOCATE (unoccupied_evals(dft_control%nspins))
953 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, min_lumos, nlumos)
954 lumo_ptr => unoccupied_orbs
955 DO ispin = 1, dft_control%nspins
957 homo_lumo(ispin, 2) = unoccupied_evals(ispin)%array(1)
959 IF (check_write)
THEN
960 IF (p_loc_lumo .AND. nlumo /= -1) nlumos = min(nlumo, nlumos)
962 CALL qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
963 unoccupied_orbs(ispin), wf_g, wf_r, particles, nlumos, homo, ispin, mo_section=mo_section)
968 ALLOCATE (lumo_localized(dft_control%nspins))
969 DO ispin = 1, dft_control%nspins
970 CALL cp_fm_create(lumo_localized(ispin), unoccupied_orbs(ispin)%matrix_struct)
971 CALL cp_fm_to_fm(unoccupied_orbs(ispin), lumo_localized(ispin))
973 CALL qs_loc_init(qs_env, qs_loc_env_lumo, localize_section, lumo_localized, do_homo, mo_section%do_output, &
974 evals=unoccupied_evals)
975 CALL qs_loc_env_init(qs_loc_env_lumo, qs_loc_env_lumo%localized_wfn_control, qs_env, &
976 loc_coeff=unoccupied_orbs)
978 lumo_localized, wf_r, wf_g, particles, &
979 unoccupied_orbs, unoccupied_evals, marked_states)
980 CALL loc_write_restart(qs_loc_env_lumo, loc_print_section, mos, homo_localized, do_homo, &
981 evals=unoccupied_evals)
982 lumo_ptr => lumo_localized
986 IF (has_homo .AND. has_lumo)
THEN
987 IF (output_unit > 0)
WRITE (output_unit, *)
" "
988 DO ispin = 1, dft_control%nspins
989 IF (.NOT. scf_control%smear%do_smear)
THEN
990 gap = homo_lumo(ispin, 2) - homo_lumo(ispin, 1)
991 IF (output_unit > 0)
WRITE (output_unit,
'(T2,A,F12.6)') &
992 "HOMO - LUMO gap [eV] :", gap*
evolt
998 IF (p_loc_mixed)
THEN
1000 cpwarn(
"Localization not implemented for k-point calculations!")
1001 ELSEIF (dft_control%restricted)
THEN
1002 IF (output_unit > 0)
WRITE (output_unit, *) &
1003 " Unclear how we define MOs / localization in the restricted case... skipping"
1006 ALLOCATE (mixed_orbs(dft_control%nspins))
1007 ALLOCATE (mixed_evals(dft_control%nspins))
1008 ALLOCATE (mixed_localized(dft_control%nspins))
1009 DO ispin = 1, dft_control%nspins
1010 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1011 eigenvalues=mo_eigenvalues)
1012 mixed_orbs(ispin) = mo_coeff
1013 mixed_evals(ispin)%array => mo_eigenvalues
1014 CALL cp_fm_create(mixed_localized(ispin), mixed_orbs(ispin)%matrix_struct)
1015 CALL cp_fm_to_fm(mixed_orbs(ispin), mixed_localized(ispin))
1018 CALL get_qs_env(qs_env, mo_loc_history=mo_loc_history)
1021 total_zeff_corr = scf_env%sum_zeff_corr
1022 ALLOCATE (qs_loc_env_mixed)
1025 CALL qs_loc_init(qs_env, qs_loc_env_mixed, localize_section, mixed_localized, do_homo, &
1026 mo_section%do_output, mo_loc_history=mo_loc_history, tot_zeff_corr=total_zeff_corr, &
1029 DO ispin = 1, dft_control%nspins
1030 CALL cp_fm_get_info(mixed_localized(ispin), ncol_global=nchk_nmoloc)
1034 wf_r, wf_g, particles, mixed_orbs, mixed_evals, marked_states)
1037 IF (qs_loc_env_mixed%localized_wfn_control%use_history)
THEN
1039 CALL set_qs_env(qs_env, mo_loc_history=mo_loc_history)
1046 DEALLOCATE (mixed_orbs)
1047 DEALLOCATE (mixed_evals)
1057 IF (((mo_section%do_output .OR. do_wannier_cubes) .AND. (nlumo /= 0 .OR. nhomo /= 0)) .OR. p_loc)
THEN
1058 CALL auxbas_pw_pool%give_back_pw(wf_r)
1059 CALL auxbas_pw_pool%give_back_pw(wf_g)
1063 IF (.NOT. do_kpoints)
THEN
1064 IF (p_loc_homo)
THEN
1066 DEALLOCATE (qs_loc_env_homo)
1068 IF (p_loc_lumo)
THEN
1070 DEALLOCATE (qs_loc_env_lumo)
1072 IF (p_loc_mixed)
THEN
1074 DEALLOCATE (qs_loc_env_mixed)
1079 IF (do_kpoints)
THEN
1082 CALL get_qs_env(qs_env, matrix_s=matrix_s, para_env=para_env)
1083 CALL wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, &
1084 output_unit, unoccupied_orbs=lumo_ptr, scf_env=scf_env, &
1085 matrix_s=matrix_s, marked_states=marked_states)
1089 IF (
ASSOCIATED(marked_states))
THEN
1090 DEALLOCATE (marked_states)
1094 IF (.NOT. do_kpoints)
THEN
1095 IF (compute_lumos)
THEN
1096 DO ispin = 1, dft_control%nspins
1097 DEALLOCATE (unoccupied_evals(ispin)%array)
1100 DEALLOCATE (unoccupied_evals)
1101 DEALLOCATE (unoccupied_orbs)
1107 IF (do_kpoints)
THEN
1108 cpwarn(
"STM not implemented for k-point calculations!")
1110 NULLIFY (unoccupied_orbs_stm, unoccupied_evals_stm)
1111 IF (nlumo_stm > 0)
THEN
1112 ALLOCATE (unoccupied_orbs_stm(dft_control%nspins))
1113 ALLOCATE (unoccupied_evals_stm(dft_control%nspins))
1114 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs_stm, unoccupied_evals_stm, &
1118 CALL th_stm_image(qs_env, stm_section, particles, unoccupied_orbs_stm, &
1119 unoccupied_evals_stm)
1121 IF (nlumo_stm > 0)
THEN
1122 DO ispin = 1, dft_control%nspins
1123 DEALLOCATE (unoccupied_evals_stm(ispin)%array)
1125 DEALLOCATE (unoccupied_evals_stm)
1132 IF (.NOT. do_kpoints)
THEN
1135 IF (nlumo_molden /= 0 .AND. scf_env%method ==
ot_method_nr)
THEN
1136 CALL get_qs_env(qs_env, mos=mos, qs_kind_set=qs_kind_set, &
1137 particle_set=particle_set, cell=cell)
1138 ALLOCATE (unoccupied_orbs(dft_control%nspins))
1139 ALLOCATE (unoccupied_evals(dft_control%nspins))
1140 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, &
1141 nlumo_molden, nlumos)
1142 IF (output_unit > 0)
THEN
1143 WRITE (output_unit,
'(/,T2,A,I6,A)') &
1144 "MO_MOLDEN| Writing ", nlumos,
" unoccupied orbitals to molden file"
1146 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell, &
1147 unoccupied_orbs=unoccupied_orbs, &
1148 unoccupied_evals=unoccupied_evals)
1149 DO ispin = 1, dft_control%nspins
1150 DEALLOCATE (unoccupied_evals(ispin)%array)
1153 DEALLOCATE (unoccupied_evals)
1154 DEALLOCATE (unoccupied_orbs)
1159 CALL qs_scf_post_xray(input, dft_section, logger, qs_env, output_unit)
1162 CALL qs_scf_post_efg(input, logger, qs_env)
1165 CALL qs_scf_post_et(input, qs_env, dft_control)
1168 CALL qs_scf_post_epr(input, logger, qs_env)
1171 CALL qs_scf_post_molopt(input, logger, qs_env)
1174 CALL qs_scf_post_elf(input, logger, qs_env)
1181 DO ispin = 1, dft_control%nspins
1182 CALL dbcsr_add(rho_ao(ispin, 1)%matrix, matrix_p_mp2(ispin)%matrix, 1.0_dp, -1.0_dp)
1190 CALL timestop(handle)
1203 SUBROUTINE make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
1207 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: unoccupied_orbs
1209 INTEGER,
INTENT(IN) :: nlumo
1210 INTEGER,
INTENT(OUT) :: nlumos
1212 CHARACTER(len=*),
PARAMETER :: routinen =
'make_lumo_gpw'
1214 INTEGER :: handle, homo, ispin, n, nao, nmo, &
1221 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_s
1228 CALL timeset(routinen, handle)
1230 NULLIFY (mos, ks_rmpv, scf_control, dft_control, admm_env, para_env, blacs_env)
1233 matrix_ks=ks_rmpv, &
1234 scf_control=scf_control, &
1235 dft_control=dft_control, &
1236 matrix_s=matrix_s, &
1237 admm_env=admm_env, &
1238 para_env=para_env, &
1239 blacs_env=blacs_env)
1244 DO ispin = 1, dft_control%nspins
1245 NULLIFY (unoccupied_evals(ispin)%array)
1247 IF (output_unit > 0)
WRITE (output_unit, *)
" "
1248 IF (output_unit > 0)
WRITE (output_unit, *)
" Lowest Eigenvalues of the unoccupied subspace spin ", ispin
1249 IF (output_unit > 0)
WRITE (output_unit, fmt=
'(1X,A)')
"-----------------------------------------------------"
1250 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=homo, nao=nao, nmo=nmo)
1252 nlumos = max(1, min(nlumo, nao - nmo))
1253 IF (nlumo == -1) nlumos = nao - nmo
1254 ALLOCATE (unoccupied_evals(ispin)%array(nlumos))
1256 nrow_global=n, ncol_global=nlumos)
1257 CALL cp_fm_create(unoccupied_orbs(ispin), fm_struct_tmp, name=
"lumos")
1262 NULLIFY (local_preconditioner)
1263 IF (
ASSOCIATED(scf_env%ot_preconditioner))
THEN
1264 local_preconditioner => scf_env%ot_preconditioner(1)%preconditioner
1267 NULLIFY (local_preconditioner)
1272 IF (dft_control%do_admm)
THEN
1276 CALL ot_eigensolver(matrix_h=ks_rmpv(ispin)%matrix, matrix_s=matrix_s(1)%matrix, &
1277 matrix_c_fm=unoccupied_orbs(ispin), &
1278 matrix_orthogonal_space_fm=mo_coeff, &
1279 eps_gradient=scf_control%eps_lumos, &
1281 iter_max=scf_control%max_iter_lumos, &
1282 size_ortho_space=nmo)
1285 unoccupied_evals(ispin)%array, scr=output_unit, &
1286 ionode=output_unit > 0)
1289 IF (dft_control%do_admm)
THEN
1295 CALL timestop(handle)
1304 SUBROUTINE qs_scf_post_charges(input, logger, qs_env)
1309 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_charges'
1311 INTEGER :: handle, print_level, unit_nr
1312 LOGICAL :: do_kpoints, print_it
1315 CALL timeset(routinen, handle)
1317 CALL get_qs_env(qs_env=qs_env, do_kpoints=do_kpoints)
1325 log_filename=.false.)
1328 IF (print_it) print_level = 2
1330 IF (print_it) print_level = 3
1331 IF (do_kpoints)
THEN
1332 cpwarn(
"Lowdin charges not implemented for k-point calculations!")
1345 unit_nr =
cp_print_key_unit_nr(logger, input,
"PROPERTIES%FIT_CHARGE", extension=
".Fitcharge", &
1346 log_filename=.false.)
1348 CALL get_ddapc(qs_env, .false., density_fit_section, iwc=unit_nr)
1352 CALL timestop(handle)
1354 END SUBROUTINE qs_scf_post_charges
1371 SUBROUTINE qs_scf_post_occ_cubes(input, dft_section, dft_control, logger, qs_env, &
1372 mo_coeff, wf_g, wf_r, particles, homo, ispin, mo_section)
1381 INTEGER,
INTENT(IN) :: homo, ispin
1382 TYPE(cp_section_key) :: mo_section
1384 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_occ_cubes'
1386 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1387 INTEGER :: handle, i, ir, ivector, n_rep, nhomo, &
1389 INTEGER,
DIMENSION(:),
POINTER ::
list, list_index
1390 LOGICAL :: append_cube, mpi_io
1395 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1397 CALL timeset(routinen, handle)
1402 cpassert(mo_section%grid_output /= grid_output_openpmd)
1405 NULLIFY (list_index)
1408 ,
cp_p_file) .AND.
section_get_lval(dft_section, mo_section%concat_to_relative(section_key_do_write(mo_section%grid_output))))
THEN
1409 nhomo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NHOMO"))
1411 IF (mo_section%grid_output == grid_output_cubes)
THEN
1412 append_cube =
section_get_lval(dft_section, mo_section%concat_to_relative(
"%APPEND"))
1414 my_pos_cube =
"REWIND"
1415 IF (append_cube)
THEN
1416 my_pos_cube =
"APPEND"
1418 CALL section_vals_val_get(dft_section, mo_section%concat_to_relative(
"%HOMO_LIST"), n_rep_val=n_rep)
1423 CALL section_vals_val_get(dft_section, mo_section%concat_to_relative(
"%HOMO_LIST"), i_rep_val=ir, &
1425 IF (
ASSOCIATED(
list))
THEN
1427 DO i = 1,
SIZE(
list)
1428 list_index(i + nlist) =
list(i)
1430 nlist = nlist +
SIZE(
list)
1435 IF (nhomo == -1) nhomo = homo
1436 nlist = homo - max(1, homo - nhomo + 1) + 1
1437 ALLOCATE (list_index(nlist))
1439 list_index(i) = max(1, homo - nhomo + 1) + i - 1
1443 ivector = list_index(i)
1445 atomic_kind_set=atomic_kind_set, &
1446 qs_kind_set=qs_kind_set, &
1448 particle_set=particle_set, &
1451 cell, dft_control, particle_set, pw_env)
1452 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", ivector,
"_", ispin
1455 unit_nr = mo_section%print_key_unit_nr(logger, input, mo_section%absolute_section_key, extension=
".cube", &
1456 middle_name=trim(filename), file_position=my_pos_cube, log_filename=.false., &
1457 mpi_io=mpi_io, openpmd_basename=
"dft-mo")
1458 WRITE (title, *)
"WAVEFUNCTION ", ivector,
" spin ", ispin,
" i.e. HOMO - ", ivector - homo
1459 CALL mo_section%write_pw(wf_r, unit_nr, title, particles=particles, &
1460 stride=
section_get_ivals(dft_section, mo_section%concat_to_relative(
"%STRIDE")), &
1461 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%MO_CUBES%MAX_FILE_SIZE_MB"), &
1463 CALL mo_section%print_key_finished_output(unit_nr, logger, input, mo_section%absolute_section_key, mpi_io=mpi_io)
1465 IF (
ASSOCIATED(list_index))
DEALLOCATE (list_index)
1468 CALL timestop(handle)
1470 END SUBROUTINE qs_scf_post_occ_cubes
1489 SUBROUTINE qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
1490 unoccupied_orbs, wf_g, wf_r, particles, nlumos, homo, ispin, lumo, mo_section)
1496 TYPE(
cp_fm_type),
INTENT(IN) :: unoccupied_orbs
1500 INTEGER,
INTENT(IN) :: nlumos, homo, ispin
1501 INTEGER,
INTENT(IN),
OPTIONAL :: lumo
1502 TYPE(cp_section_key) :: mo_section
1504 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_unocc_cubes'
1506 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1507 INTEGER :: handle, ifirst, index_mo, ivector, &
1509 LOGICAL :: append_cube, mpi_io
1514 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1516 CALL timeset(routinen, handle)
1521 cpassert(mo_section%grid_output /= grid_output_openpmd)
1525 .AND.
section_get_lval(dft_section, mo_section%concat_to_relative(section_key_do_write(mo_section%grid_output))))
THEN
1526 NULLIFY (qs_kind_set, particle_set, pw_env, cell)
1528 IF (mo_section%grid_output == grid_output_cubes)
THEN
1529 append_cube =
section_get_lval(dft_section, mo_section%concat_to_relative(
"%APPEND"))
1531 my_pos_cube =
"REWIND"
1532 IF (append_cube)
THEN
1533 my_pos_cube =
"APPEND"
1536 IF (
PRESENT(lumo)) ifirst = lumo
1537 DO ivector = ifirst, ifirst + nlumos - 1
1539 atomic_kind_set=atomic_kind_set, &
1540 qs_kind_set=qs_kind_set, &
1542 particle_set=particle_set, &
1545 qs_kind_set, cell, dft_control, particle_set, pw_env)
1547 IF (ifirst == 1)
THEN
1548 index_mo = homo + ivector
1552 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", index_mo,
"_", ispin
1555 unit_nr = mo_section%print_key_unit_nr(logger, input, mo_section%absolute_section_key, extension=
".cube", &
1556 middle_name=trim(filename), file_position=my_pos_cube, log_filename=.false., &
1557 mpi_io=mpi_io, openpmd_basename=
"dft-mo")
1558 WRITE (title, *)
"WAVEFUNCTION ", index_mo,
" spin ", ispin,
" i.e. LUMO + ", ifirst + ivector - 2
1559 CALL mo_section%write_pw(wf_r, unit_nr, title, particles=particles, &
1560 stride=
section_get_ivals(dft_section, mo_section%concat_to_relative(
"%STRIDE")), &
1561 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%MO_CUBES%MAX_FILE_SIZE_MB"), &
1563 CALL mo_section%print_key_finished_output(unit_nr, logger, input, mo_section%absolute_section_key, mpi_io=mpi_io)
1568 CALL timestop(handle)
1570 END SUBROUTINE qs_scf_post_unocc_cubes
1583 INTEGER,
INTENT(IN) :: output_unit
1585 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_moments'
1587 CHARACTER(LEN=default_path_length) :: filename
1588 INTEGER :: handle, max_nmo, maxmom, reference, &
1590 LOGICAL :: com_nl, do_kpoints, magnetic, periodic, &
1591 second_ref_point, vel_reprs
1592 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ref_point
1595 CALL timeset(routinen, handle)
1598 subsection_name=
"DFT%PRINT%MOMENTS")
1603 keyword_name=
"DFT%PRINT%MOMENTS%MAX_MOMENT")
1605 keyword_name=
"DFT%PRINT%MOMENTS%PERIODIC")
1607 keyword_name=
"DFT%PRINT%MOMENTS%REFERENCE")
1609 keyword_name=
"DFT%PRINT%MOMENTS%MAGNETIC")
1611 keyword_name=
"DFT%PRINT%MOMENTS%VEL_REPRS")
1613 keyword_name=
"DFT%PRINT%MOMENTS%COM_NL")
1615 keyword_name=
"DFT%PRINT%MOMENTS%SECOND_REFERENCE_POINT")
1617 keyword_name=
"DFT%PRINT%MOMENTS%MAX_NMO")
1622 print_key_path=
"DFT%PRINT%MOMENTS", extension=
".dat", &
1623 middle_name=
"moments", log_filename=.false.)
1625 IF (output_unit > 0)
THEN
1626 IF (unit_nr /= output_unit)
THEN
1627 INQUIRE (unit=unit_nr, name=filename)
1628 WRITE (unit=output_unit, fmt=
"(/,T2,A,2(/,T3,A),/)") &
1629 "MOMENTS",
"The electric/magnetic moments are written to file:", &
1632 WRITE (unit=output_unit, fmt=
"(/,T2,A)")
"ELECTRIC/MAGNETIC MOMENTS"
1636 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
1638 IF (do_kpoints)
THEN
1644 CALL qs_moment_locop(qs_env, magnetic, maxmom, reference, ref_point, unit_nr, vel_reprs, com_nl)
1649 basis_section=input, print_key_path=
"DFT%PRINT%MOMENTS")
1651 IF (second_ref_point)
THEN
1653 keyword_name=
"DFT%PRINT%MOMENTS%REFERENCE_2")
1658 print_key_path=
"DFT%PRINT%MOMENTS", extension=
".dat", &
1659 middle_name=
"moments_refpoint_2", log_filename=.false.)
1661 IF (output_unit > 0)
THEN
1662 IF (unit_nr /= output_unit)
THEN
1663 INQUIRE (unit=unit_nr, name=filename)
1664 WRITE (unit=output_unit, fmt=
"(/,T2,A,2(/,T3,A),/)") &
1665 "MOMENTS",
"The electric/magnetic moments for the second reference point are written to file:", &
1668 WRITE (unit=output_unit, fmt=
"(/,T2,A)")
"ELECTRIC/MAGNETIC MOMENTS"
1671 IF (do_kpoints)
THEN
1677 CALL qs_moment_locop(qs_env, magnetic, maxmom, reference, ref_point, unit_nr, vel_reprs, com_nl)
1681 basis_section=input, print_key_path=
"DFT%PRINT%MOMENTS")
1686 CALL timestop(handle)
1698 SUBROUTINE qs_scf_post_xray(input, dft_section, logger, qs_env, output_unit)
1703 INTEGER,
INTENT(IN) :: output_unit
1705 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_scf_post_xray'
1707 CHARACTER(LEN=default_path_length) :: filename
1708 INTEGER :: handle, unit_nr
1709 REAL(kind=
dp) :: q_max
1712 CALL timeset(routinen, handle)
1715 subsection_name=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM")
1719 keyword_name=
"PRINT%XRAY_DIFFRACTION_SPECTRUM%Q_MAX")
1721 basis_section=input, &
1722 print_key_path=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM", &
1724 middle_name=
"xrd", &
1725 log_filename=.false.)
1726 IF (output_unit > 0)
THEN
1727 INQUIRE (unit=unit_nr, name=filename)
1728 WRITE (unit=output_unit, fmt=
"(/,/,T2,A)") &
1729 "X-RAY DIFFRACTION SPECTRUM"
1730 IF (unit_nr /= output_unit)
THEN
1731 WRITE (unit=output_unit, fmt=
"(/,T3,A,/,/,T3,A,/)") &
1732 "The coherent X-ray diffraction spectrum is written to the file:", &
1737 unit_number=unit_nr, &
1741 basis_section=input, &
1742 print_key_path=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM")
1745 CALL timestop(handle)
1747 END SUBROUTINE qs_scf_post_xray
1755 SUBROUTINE qs_scf_post_efg(input, logger, qs_env)
1760 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_efg'
1765 CALL timeset(routinen, handle)
1768 subsection_name=
"DFT%PRINT%ELECTRIC_FIELD_GRADIENT")
1774 CALL timestop(handle)
1776 END SUBROUTINE qs_scf_post_efg
1784 SUBROUTINE qs_scf_post_et(input, qs_env, dft_control)
1789 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_et'
1791 INTEGER :: handle, ispin
1793 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: my_mos
1796 CALL timeset(routinen, handle)
1802 IF (qs_env%et_coupling%first_run)
THEN
1804 ALLOCATE (my_mos(dft_control%nspins))
1805 ALLOCATE (qs_env%et_coupling%et_mo_coeff(dft_control%nspins))
1806 DO ispin = 1, dft_control%nspins
1808 matrix_struct=qs_env%mos(ispin)%mo_coeff%matrix_struct, &
1809 name=
"FIRST_RUN_COEFF"//trim(adjustl(
cp_to_string(ispin)))//
"MATRIX")
1818 CALL timestop(handle)
1820 END SUBROUTINE qs_scf_post_et
1831 SUBROUTINE qs_scf_post_elf(input, logger, qs_env)
1836 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_elf'
1838 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
1840 INTEGER :: handle, ispin, output_unit, unit_nr
1841 LOGICAL :: append_cube, gapw, mpi_io
1842 REAL(
dp) :: rho_cutoff
1843 TYPE(cp_section_key) :: elf_section_key
1853 CALL timeset(routinen, handle)
1856 elf_section_key = cube_or_openpmd(input, str_elf_cubes, str_elf_openpmd, logger)
1859 IF (elf_section_key%do_output)
THEN
1861 NULLIFY (dft_control, pw_env, auxbas_pw_pool, pw_pools, particles, subsys)
1862 CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env, subsys=subsys)
1865 gapw = dft_control%qs_control%gapw
1866 IF (.NOT. gapw)
THEN
1868 ALLOCATE (elf_r(dft_control%nspins))
1869 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
1871 DO ispin = 1, dft_control%nspins
1872 CALL auxbas_pw_pool%create_pw(elf_r(ispin))
1876 IF (output_unit > 0)
THEN
1877 WRITE (unit=output_unit, fmt=
"(/,T15,A,/)") &
1878 " ----- ELF is computed on the real space grid -----"
1886 IF (elf_section_key%grid_output == grid_output_cubes)
THEN
1889 my_pos_cube =
"REWIND"
1890 IF (append_cube)
THEN
1891 my_pos_cube =
"APPEND"
1894 DO ispin = 1, dft_control%nspins
1895 WRITE (filename,
'(a5,I1.1)')
"ELF_S", ispin
1896 WRITE (title, *)
"ELF spin ", ispin
1898 unit_nr = elf_section_key%print_key_unit_nr( &
1899 logger, input, elf_section_key%absolute_section_key, extension=
".cube", &
1900 middle_name=trim(filename), file_position=my_pos_cube, log_filename=.false., &
1901 mpi_io=mpi_io, fout=mpi_filename, openpmd_basename=
"dft-elf")
1902 IF (output_unit > 0)
THEN
1903 IF (.NOT. mpi_io)
THEN
1904 INQUIRE (unit=unit_nr, name=filename)
1906 filename = mpi_filename
1908 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
1909 "ELF is written in "//elf_section_key%format_name//
" file format to the file:", &
1913 CALL elf_section_key%write_pw(elf_r(ispin), unit_nr, title, particles=particles, &
1915 CALL elf_section_key%print_key_finished_output( &
1919 elf_section_key%absolute_section_key, &
1922 CALL auxbas_pw_pool%give_back_pw(elf_r(ispin))
1930 cpwarn(
"ELF not implemented for GAPW calculations!")
1935 CALL timestop(handle)
1937 END SUBROUTINE qs_scf_post_elf
1949 SUBROUTINE qs_scf_post_molopt(input, logger, qs_env)
1954 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_molopt'
1956 INTEGER :: handle, nao, unit_nr
1957 REAL(kind=
dp) :: s_cond_number
1958 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
1967 CALL timeset(routinen, handle)
1970 subsection_name=
"DFT%PRINT%BASIS_MOLOPT_QUANTITIES")
1974 CALL get_qs_env(qs_env, energy=energy, matrix_s=matrix_s, mos=mos)
1977 CALL get_mo_set(mo_set=mos(1), mo_coeff=mo_coeff, nao=nao)
1979 nrow_global=nao, ncol_global=nao, &
1980 template_fmstruct=mo_coeff%matrix_struct)
1981 CALL cp_fm_create(fm_s, matrix_struct=ao_ao_fmstruct, &
1983 CALL cp_fm_create(fm_work, matrix_struct=ao_ao_fmstruct, &
1986 ALLOCATE (eigenvalues(nao))
1994 s_cond_number = maxval(abs(eigenvalues))/max(minval(abs(eigenvalues)), epsilon(0.0_dp))
1997 extension=
".molopt")
1999 IF (unit_nr > 0)
THEN
2002 WRITE (unit_nr,
'(T2,A28,2A25)')
"",
"Tot. Ener.",
"S Cond. Numb."
2003 WRITE (unit_nr,
'(T2,A28,2E25.17)')
"BASIS_MOLOPT_QUANTITIES", energy%total, s_cond_number
2007 "DFT%PRINT%BASIS_MOLOPT_QUANTITIES")
2011 CALL timestop(handle)
2013 END SUBROUTINE qs_scf_post_molopt
2021 SUBROUTINE qs_scf_post_epr(input, logger, qs_env)
2026 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_epr'
2031 CALL timeset(routinen, handle)
2034 subsection_name=
"DFT%PRINT%HYPERFINE_COUPLING_TENSOR")
2040 CALL timestop(handle)
2042 END SUBROUTINE qs_scf_post_epr
2051 SUBROUTINE write_available_results(qs_env, scf_env)
2055 CHARACTER(len=*),
PARAMETER :: routinen =
'write_available_results'
2059 CALL timeset(routinen, handle)
2067 CALL timestop(handle)
2069 END SUBROUTINE write_available_results
2082 CHARACTER(len=*),
PARAMETER :: routinen =
'write_mo_dependent_results'
2084 INTEGER :: handle, homo, ispin, nlumo_molden, nmo, &
2086 LOGICAL :: all_equal, defer_molden, do_kpoints, &
2088 REAL(kind=
dp) :: maxocc, s_square, s_square_ideal, &
2089 total_abs_spin_dens, total_spin_dens
2090 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, occupation_numbers
2096 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_s
2109 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2118 CALL timeset(routinen, handle)
2120 NULLIFY (cell, dft_control, pw_env, auxbas_pw_pool, pw_pools, mo_coeff, &
2121 mo_coeff_deriv, mo_eigenvalues, mos, atomic_kind_set, qs_kind_set, &
2122 particle_set, rho, ks_rmpv, matrix_s, scf_control, dft_section, &
2123 molecule_set, input, particles, subsys, rho_r)
2128 cpassert(
ASSOCIATED(qs_env))
2130 dft_control=dft_control, &
2131 molecule_set=molecule_set, &
2132 atomic_kind_set=atomic_kind_set, &
2133 particle_set=particle_set, &
2134 qs_kind_set=qs_kind_set, &
2135 admm_env=admm_env, &
2136 scf_control=scf_control, &
2145 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
2149 IF (.NOT. qs_env%run_rtp)
THEN
2157 IF (.NOT. do_kpoints)
THEN
2158 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv)
2161 defer_molden = .false.
2163 IF (nlumo_molden /= 0 .AND.
PRESENT(scf_env))
THEN
2164 IF (scf_env%method ==
ot_method_nr) defer_molden = .true.
2166 IF (.NOT. defer_molden)
THEN
2167 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell)
2176 cpwarn(
"Molden format output is not possible for k-point calculations.")
2180 cpwarn(
"Chargemol .wfx format output is not possible for k-point calculations.")
2187 IF (do_kpoints)
THEN
2191 cpwarn(
"MO_KP is only available for k-point calculations, ignored for Gamma-only")
2198 IF (do_kpoints)
THEN
2209 IF (do_kpoints)
THEN
2210 cpwarn(
"Projected density of states (pDOS) is not implemented for k points")
2215 DO ispin = 1, dft_control%nspins
2217 IF (dft_control%do_admm)
THEN
2220 IF (
PRESENT(scf_env))
THEN
2222 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
2223 eigenvalues=mo_eigenvalues)
2224 IF (
ASSOCIATED(qs_env%mo_derivs))
THEN
2225 mo_coeff_deriv => qs_env%mo_derivs(ispin)%matrix
2227 mo_coeff_deriv => null()
2230 do_rotation=.true., &
2231 co_rotate_dbcsr=mo_coeff_deriv)
2235 IF (dft_control%nspins == 2)
THEN
2237 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin)
2240 qs_kind_set, particle_set, qs_env, dft_section)
2243 IF (dft_control%do_admm)
THEN
2252 IF (dft_control%nspins == 2)
THEN
2254 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
2255 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
2257 CALL auxbas_pw_pool%create_pw(wf_r)
2259 CALL pw_axpy(rho_r(2), wf_r, alpha=-1._dp)
2261 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'(/,(T3,A,T61,F20.10))') &
2262 "Integrated spin density: ", total_spin_dens
2264 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'((T3,A,T61,F20.10))') &
2265 "Integrated absolute spin density: ", total_abs_spin_dens
2266 CALL auxbas_pw_pool%give_back_pw(wf_r)
2272 IF (do_kpoints)
THEN
2273 cpwarn(
"Spin contamination estimate not implemented for k-points.")
2276 DO ispin = 1, dft_control%nspins
2278 occupation_numbers=occupation_numbers, &
2283 all_equal = all_equal .AND. &
2284 (all(occupation_numbers(1:homo) == maxocc) .AND. &
2285 all(occupation_numbers(homo + 1:nmo) == 0.0_dp))
2288 IF (.NOT. all_equal)
THEN
2289 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
"(T3,A)") &
2290 "WARNING: S**2 computation does not yet treat fractional occupied orbitals"
2293 matrix_s=matrix_s, &
2296 s_square_ideal=s_square_ideal)
2297 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'(T3,A,T51,2F15.6)') &
2298 "Ideal and single determinant S**2 : ", s_square_ideal, s_square
2299 energy%s_square = s_square
2304 CALL timestop(handle)
2316 CHARACTER(len=*),
PARAMETER :: routinen =
'write_mo_free_results'
2317 CHARACTER(len=1),
DIMENSION(3),
PARAMETER :: cdir = [
"x",
"y",
"z"]
2319 CHARACTER(LEN=2) :: element_symbol
2320 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
2322 CHARACTER(LEN=default_string_length) :: name, print_density
2323 INTEGER :: after, handle, i, iat, iatom, id, ikind, img, iso, ispin, iw, l, n_rep_hf, nat, &
2324 natom, nd(3), ngto, niso, nkind, np, nr, output_unit, print_level, should_print_bqb, &
2325 should_print_voro, unit_nr, unit_nr_voro
2326 LOGICAL :: append_cube, append_voro, do_hfx, do_kpoints, mpi_io, omit_headers, print_it, &
2327 rho_r_valid, voro_print_txt, write_ks, write_xc, xrd_interface
2329 rho_total, rho_total_rspace, udvol, &
2331 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
2332 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: bfun
2333 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: aedens, ccdens, ppdens
2334 REAL(kind=
dp),
DIMENSION(3) :: dr
2335 REAL(kind=
dp),
DIMENSION(:),
POINTER :: my_q0
2340 TYPE(cp_section_key) :: e_density_section
2342 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: ks_rmpv, matrix_vxc, rho_ao
2350 TYPE(
pw_c1d_gs_type),
POINTER :: rho0_s_gs, rho_core, rhoz_cneo_s_gs
2357 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2365 print_key, print_key_bqb, &
2366 print_key_voro, xc_section
2368 CALL timeset(routinen, handle)
2369 NULLIFY (cell, dft_control, pw_env, auxbas_pw_pool, pw_pools, hfx_section, &
2370 atomic_kind_set, qs_kind_set, particle_set, rho, ks_rmpv, rho_ao, rho_r, &
2371 dft_section, xc_section, input, particles, subsys, matrix_vxc, v_hartree_rspace, &
2377 cpassert(
ASSOCIATED(qs_env))
2379 atomic_kind_set=atomic_kind_set, &
2380 qs_kind_set=qs_kind_set, &
2381 particle_set=particle_set, &
2383 para_env=para_env, &
2384 dft_control=dft_control, &
2386 do_kpoints=do_kpoints, &
2394 CALL get_qs_env(qs_env, nkind=nkind, natom=natom)
2395 ALLOCATE (zcharge(natom))
2400 iat = atomic_kind_set(ikind)%atom_list(iatom)
2407 "DFT%PRINT%TOT_DENSITY_CUBE"),
cp_p_file))
THEN
2408 NULLIFY (rho_core, rho0_s_gs, rhoz_cneo_s_gs)
2410 my_pos_cube =
"REWIND"
2411 IF (append_cube)
THEN
2412 my_pos_cube =
"APPEND"
2415 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, rho_core=rho_core, &
2416 rho0_s_gs=rho0_s_gs, rhoz_cneo_s_gs=rhoz_cneo_s_gs)
2417 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
2419 CALL auxbas_pw_pool%create_pw(wf_r)
2420 IF (dft_control%qs_control%gapw)
THEN
2421 IF (dft_control%qs_control%gapw_control%nopaw_as_gpw)
THEN
2422 CALL pw_axpy(rho_core, rho0_s_gs)
2423 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2424 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs)
2427 CALL pw_axpy(rho_core, rho0_s_gs, -1.0_dp)
2428 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2429 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs, -1.0_dp)
2432 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2433 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs)
2436 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2437 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs, -1.0_dp)
2443 DO ispin = 1, dft_control%nspins
2444 CALL pw_axpy(rho_r(ispin), wf_r)
2446 filename =
"TOTAL_DENSITY"
2449 extension=
".cube", middle_name=trim(filename), file_position=my_pos_cube, &
2450 log_filename=.false., mpi_io=mpi_io)
2452 particles=particles, zeff=zcharge, &
2454 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%TOT_DENSITY_CUBE%MAX_FILE_SIZE_MB"), &
2457 "DFT%PRINT%TOT_DENSITY_CUBE", mpi_io=mpi_io)
2458 CALL auxbas_pw_pool%give_back_pw(wf_r)
2461 e_density_section = cube_or_openpmd(input, str_e_density_cubes, str_e_density_openpmd, logger)
2464 IF (e_density_section%do_output)
THEN
2466 keyword_name=e_density_section%concat_to_relative(
"%DENSITY_INCLUDE"), &
2467 c_val=print_density)
2468 print_density = trim(print_density)
2470 IF (e_density_section%grid_output == grid_output_cubes)
THEN
2471 append_cube =
section_get_lval(input, e_density_section%concat_to_absolute(
"%APPEND"))
2473 my_pos_cube =
"REWIND"
2474 IF (append_cube)
THEN
2475 my_pos_cube =
"APPEND"
2479 IF (e_density_section%grid_output == grid_output_cubes)
THEN
2480 xrd_interface =
section_get_lval(input, e_density_section%concat_to_absolute(
"%XRD_INTERFACE"))
2483 xrd_interface = .false.
2486 IF (xrd_interface)
THEN
2488 IF (dft_control%qs_control%gapw) print_density =
"SOFT_DENSITY"
2490 filename =
"ELECTRON_DENSITY"
2492 extension=
".xrd", middle_name=trim(filename), &
2493 file_position=my_pos_cube, log_filename=.false.)
2494 ngto =
section_get_ival(input, e_density_section%concat_to_absolute(
"%NGAUSS"))
2495 IF (output_unit > 0)
THEN
2496 INQUIRE (unit=unit_nr, name=filename)
2497 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
2498 "The electron density (atomic part) is written to the file:", &
2503 nkind =
SIZE(atomic_kind_set)
2504 IF (unit_nr > 0)
THEN
2505 WRITE (unit_nr, *)
"Atomic (core) densities"
2506 WRITE (unit_nr, *)
"Unit cell"
2507 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(1, 1), cell%hmat(1, 2), cell%hmat(1, 3)
2508 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(2, 1), cell%hmat(2, 2), cell%hmat(2, 3)
2509 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(3, 1), cell%hmat(3, 2), cell%hmat(3, 3)
2510 WRITE (unit_nr, *)
"Atomic types"
2511 WRITE (unit_nr, *) nkind
2514 ALLOCATE (ppdens(ngto, 2, nkind), aedens(ngto, 2, nkind), ccdens(ngto, 2, nkind))
2516 atomic_kind => atomic_kind_set(ikind)
2517 qs_kind => qs_kind_set(ikind)
2518 CALL get_atomic_kind(atomic_kind, name=name, element_symbol=element_symbol)
2520 iunit=output_unit, confine=.true.)
2522 iunit=output_unit, allelectron=.true., confine=.true.)
2523 ccdens(:, 1, ikind) = aedens(:, 1, ikind)
2524 ccdens(:, 2, ikind) = 0._dp
2525 CALL project_function_a(ccdens(1:ngto, 2, ikind), ccdens(1:ngto, 1, ikind), &
2526 ppdens(1:ngto, 2, ikind), ppdens(1:ngto, 1, ikind), 0)
2527 ccdens(:, 2, ikind) = aedens(:, 2, ikind) - ccdens(:, 2, ikind)
2528 IF (unit_nr > 0)
THEN
2529 WRITE (unit_nr, fmt=
"(I6,A10,A20)") ikind, trim(element_symbol), trim(name)
2530 WRITE (unit_nr, fmt=
"(I6)") ngto
2531 WRITE (unit_nr, *)
" Total density"
2532 WRITE (unit_nr, fmt=
"(2G24.12)") (aedens(i, 1, ikind), aedens(i, 2, ikind), i=1, ngto)
2533 WRITE (unit_nr, *)
" Core density"
2534 WRITE (unit_nr, fmt=
"(2G24.12)") (ccdens(i, 1, ikind), ccdens(i, 2, ikind), i=1, ngto)
2536 NULLIFY (atomic_kind)
2539 IF (dft_control%qs_control%gapw)
THEN
2540 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom_set)
2542 IF (unit_nr > 0)
THEN
2543 WRITE (unit_nr, *)
"Coordinates and GAPW density"
2545 np = particles%n_els
2547 CALL get_atomic_kind(particles%els(iat)%atomic_kind, kind_number=ikind)
2548 CALL get_qs_kind(qs_kind_set(ikind), grid_atom=grid_atom)
2549 rho_atom => rho_atom_set(iat)
2550 IF (
ASSOCIATED(rho_atom%rho_rad_h(1)%r_coef))
THEN
2551 nr =
SIZE(rho_atom%rho_rad_h(1)%r_coef, 1)
2552 niso =
SIZE(rho_atom%rho_rad_h(1)%r_coef, 2)
2557 CALL para_env%sum(nr)
2558 CALL para_env%sum(niso)
2560 ALLOCATE (bfun(nr, niso))
2562 DO ispin = 1, dft_control%nspins
2563 IF (
ASSOCIATED(rho_atom%rho_rad_h(1)%r_coef))
THEN
2564 bfun(:, :) = bfun + rho_atom%rho_rad_h(ispin)%r_coef - rho_atom%rho_rad_s(ispin)%r_coef
2567 CALL para_env%sum(bfun)
2568 ccdens(:, 1, ikind) = ppdens(:, 1, ikind)
2569 ccdens(:, 2, ikind) = 0._dp
2570 IF (unit_nr > 0)
THEN
2571 WRITE (unit_nr,
'(I10,I5,3f12.6)') iat, ikind, particles%els(iat)%r
2575 CALL project_function_b(ccdens(:, 2, ikind), ccdens(:, 1, ikind), bfun(:, iso), grid_atom, l)
2576 IF (unit_nr > 0)
THEN
2577 WRITE (unit_nr, fmt=
"(3I6)") iso, l, ngto
2578 WRITE (unit_nr, fmt=
"(2G24.12)") (ccdens(i, 1, ikind), ccdens(i, 2, ikind), i=1, ngto)
2584 IF (unit_nr > 0)
THEN
2585 WRITE (unit_nr, *)
"Coordinates"
2586 np = particles%n_els
2588 CALL get_atomic_kind(particles%els(iat)%atomic_kind, kind_number=ikind)
2589 WRITE (unit_nr,
'(I10,I5,3f12.6)') iat, ikind, particles%els(iat)%r
2594 DEALLOCATE (ppdens, aedens, ccdens)
2597 e_density_section%absolute_section_key)
2600 IF (dft_control%qs_control%gapw .AND. print_density ==
"TOTAL_DENSITY")
THEN
2602 cpassert(.NOT. do_kpoints)
2607 auxbas_pw_pool=auxbas_pw_pool, &
2609 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
2611 CALL auxbas_pw_pool%create_pw(pw=rho_elec_gspace)
2616 q_max = sqrt(sum((
pi/dr(:))**2))
2618 auxbas_pw_pool=auxbas_pw_pool, &
2619 rhotot_elec_gspace=rho_elec_gspace, &
2621 rho_hard=rho_hard, &
2623 rho_total = rho_hard + rho_soft
2628 CALL pw_scale(rho_elec_gspace, 1.0_dp/volume)
2630 CALL pw_transfer(rho_elec_gspace, rho_elec_rspace)
2632 filename =
"TOTAL_ELECTRON_DENSITY"
2634 unit_nr = e_density_section%print_key_unit_nr(logger, input, e_density_section%absolute_section_key, &
2635 extension=
".cube", middle_name=trim(filename), &
2636 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
2637 fout=mpi_filename, openpmd_basename=
"dft-total-electron-density")
2638 IF (output_unit > 0)
THEN
2639 IF (.NOT. mpi_io)
THEN
2640 INQUIRE (unit=unit_nr, name=filename)
2642 filename = mpi_filename
2644 CALL print_density_output_message(output_unit,
"The total electron density", &
2645 e_density_section, filename)
2646 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
2647 "q(max) [1/Angstrom] :", q_max/
angstrom, &
2648 "Soft electronic charge (G-space) :", rho_soft, &
2649 "Hard electronic charge (G-space) :", rho_hard, &
2650 "Total electronic charge (G-space):", rho_total, &
2651 "Total electronic charge (R-space):", rho_total_rspace
2653 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"TOTAL ELECTRON DENSITY", &
2654 particles=particles, zeff=zcharge, &
2655 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2656 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2657 e_density_section%absolute_section_key, mpi_io=mpi_io)
2659 IF (dft_control%nspins > 1)
THEN
2663 auxbas_pw_pool=auxbas_pw_pool, &
2664 rhotot_elec_gspace=rho_elec_gspace, &
2666 rho_hard=rho_hard, &
2667 rho_soft=rho_soft, &
2669 rho_total = rho_hard + rho_soft
2673 CALL pw_scale(rho_elec_gspace, 1.0_dp/volume)
2675 CALL pw_transfer(rho_elec_gspace, rho_elec_rspace)
2677 filename =
"TOTAL_SPIN_DENSITY"
2679 unit_nr = e_density_section%print_key_unit_nr(logger, input, e_density_section%absolute_section_key, &
2680 extension=
".cube", middle_name=trim(filename), &
2681 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
2682 fout=mpi_filename, openpmd_basename=
"dft-total-spin-density")
2683 IF (output_unit > 0)
THEN
2684 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2685 INQUIRE (unit=unit_nr, name=filename)
2687 filename = mpi_filename
2689 CALL print_density_output_message(output_unit,
"The total spin density", &
2690 e_density_section, filename)
2691 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
2692 "q(max) [1/Angstrom] :", q_max/
angstrom, &
2693 "Soft part of the spin density (G-space):", rho_soft, &
2694 "Hard part of the spin density (G-space):", rho_hard, &
2695 "Total spin density (G-space) :", rho_total, &
2696 "Total spin density (R-space) :", rho_total_rspace
2698 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"TOTAL SPIN DENSITY", &
2699 particles=particles, zeff=zcharge, &
2700 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2701 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2702 e_density_section%absolute_section_key, mpi_io=mpi_io)
2704 CALL auxbas_pw_pool%give_back_pw(rho_elec_gspace)
2705 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
2707 ELSE IF (print_density ==
"SOFT_DENSITY" .OR. .NOT. dft_control%qs_control%gapw)
THEN
2708 IF (dft_control%nspins > 1)
THEN
2712 auxbas_pw_pool=auxbas_pw_pool, &
2714 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
2715 CALL pw_copy(rho_r(1), rho_elec_rspace)
2716 CALL pw_axpy(rho_r(2), rho_elec_rspace)
2717 filename =
"ELECTRON_DENSITY"
2719 unit_nr = e_density_section%print_key_unit_nr(logger, input, e_density_section%absolute_section_key, &
2720 extension=
".cube", middle_name=trim(filename), &
2721 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
2722 fout=mpi_filename, openpmd_basename=
"dft-electron-density")
2723 IF (output_unit > 0)
THEN
2724 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2725 INQUIRE (unit=unit_nr, name=filename)
2727 filename = mpi_filename
2729 CALL print_density_output_message(output_unit,
"The sum of alpha and beta density", &
2730 e_density_section, filename)
2732 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SUM OF ALPHA AND BETA DENSITY", &
2733 particles=particles, zeff=zcharge, stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), &
2735 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2736 e_density_section%absolute_section_key, mpi_io=mpi_io)
2737 CALL pw_copy(rho_r(1), rho_elec_rspace)
2738 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
2739 filename =
"SPIN_DENSITY"
2741 unit_nr = e_density_section%print_key_unit_nr(logger, input, e_density_section%absolute_section_key, &
2742 extension=
".cube", middle_name=trim(filename), &
2743 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
2744 fout=mpi_filename, openpmd_basename=
"dft-spin-density")
2745 IF (output_unit > 0)
THEN
2746 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2747 INQUIRE (unit=unit_nr, name=filename)
2749 filename = mpi_filename
2751 CALL print_density_output_message(output_unit,
"The spin density", &
2752 e_density_section, filename)
2754 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SPIN DENSITY", &
2755 particles=particles, zeff=zcharge, &
2756 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2757 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2758 e_density_section%absolute_section_key, mpi_io=mpi_io)
2759 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
2761 filename =
"ELECTRON_DENSITY"
2763 unit_nr = e_density_section%print_key_unit_nr(logger, input, e_density_section%absolute_section_key, &
2764 extension=
".cube", middle_name=trim(filename), &
2765 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
2766 fout=mpi_filename, openpmd_basename=
"dft-electron-density")
2767 IF (output_unit > 0)
THEN
2768 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2769 INQUIRE (unit=unit_nr, name=filename)
2771 filename = mpi_filename
2773 CALL print_density_output_message(output_unit,
"The electron density", &
2774 e_density_section, filename)
2776 CALL e_density_section%write_pw(rho_r(1), unit_nr,
"ELECTRON DENSITY", &
2777 particles=particles, zeff=zcharge, &
2778 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2779 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2780 e_density_section%absolute_section_key, mpi_io=mpi_io)
2783 ELSE IF (dft_control%qs_control%gapw .AND. print_density ==
"TOTAL_HARD_APPROX")
THEN
2784 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, rho0_mpole=rho0_mpole, natom=natom)
2785 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
2786 CALL auxbas_pw_pool%create_pw(rho_elec_rspace)
2789 ALLOCATE (my_q0(natom))
2797 my_q0(iat) = sum(rho0_mpole%mp_rho(iat)%Q0(1:dft_control%nspins))*
norm_factor
2801 CALL calculate_rho_resp_all(rho_elec_rspace, coeff=my_q0, natom=natom, eta=rho0_mpole%zet0_h, qs_env=qs_env)
2805 DO ispin = 1, dft_control%nspins
2806 CALL pw_axpy(rho_r(ispin), rho_elec_rspace)
2810 rho_total_rspace = rho_soft + rho_hard
2812 filename =
"ELECTRON_DENSITY"
2814 unit_nr = e_density_section%print_key_unit_nr(logger, input, e_density_section%absolute_section_key, &
2815 extension=
".cube", middle_name=trim(filename), &
2816 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
2817 fout=mpi_filename, openpmd_basename=
"dft-electron-density")
2818 IF (output_unit > 0)
THEN
2819 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2820 INQUIRE (unit=unit_nr, name=filename)
2822 filename = mpi_filename
2824 CALL print_density_output_message(output_unit,
"The electron density", &
2825 e_density_section, filename)
2826 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
2827 "Soft electronic charge (R-space) :", rho_soft, &
2828 "Hard electronic charge (R-space) :", rho_hard, &
2829 "Total electronic charge (R-space):", rho_total_rspace
2831 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"ELECTRON DENSITY", &
2832 particles=particles, zeff=zcharge, stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), &
2834 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2835 e_density_section%absolute_section_key, mpi_io=mpi_io)
2838 IF (dft_control%nspins > 1)
THEN
2840 my_q0(iat) = (rho0_mpole%mp_rho(iat)%Q0(1) - rho0_mpole%mp_rho(iat)%Q0(2))*
norm_factor
2843 CALL calculate_rho_resp_all(rho_elec_rspace, coeff=my_q0, natom=natom, eta=rho0_mpole%zet0_h, qs_env=qs_env)
2846 CALL pw_axpy(rho_r(1), rho_elec_rspace)
2847 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
2851 rho_total_rspace = rho_soft + rho_hard
2853 filename =
"SPIN_DENSITY"
2855 unit_nr = e_density_section%print_key_unit_nr(logger, input, e_density_section%absolute_section_key, &
2856 extension=
".cube", middle_name=trim(filename), &
2857 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
2858 fout=mpi_filename, openpmd_basename=
"dft-spin-density")
2859 IF (output_unit > 0)
THEN
2860 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2861 INQUIRE (unit=unit_nr, name=filename)
2863 filename = mpi_filename
2865 CALL print_density_output_message(output_unit,
"The spin density", &
2866 e_density_section, filename)
2867 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
2868 "Soft part of the spin density :", rho_soft, &
2869 "Hard part of the spin density :", rho_hard, &
2870 "Total spin density (R-space) :", rho_total_rspace
2872 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SPIN DENSITY", &
2873 particles=particles, zeff=zcharge, &
2874 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2875 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2876 e_density_section%absolute_section_key, mpi_io=mpi_io)
2878 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
2884 dft_section,
"PRINT%ENERGY_WINDOWS"),
cp_p_file) .AND. .NOT. do_kpoints)
THEN
2890 "DFT%PRINT%V_HARTREE_CUBE"),
cp_p_file))
THEN
2894 v_hartree_rspace=v_hartree_rspace)
2895 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
2896 CALL auxbas_pw_pool%create_pw(aux_r)
2899 my_pos_cube =
"REWIND"
2900 IF (append_cube)
THEN
2901 my_pos_cube =
"APPEND"
2904 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
2907 extension=
".cube", middle_name=
"v_hartree", file_position=my_pos_cube, mpi_io=mpi_io)
2908 udvol = 1.0_dp/v_hartree_rspace%pw_grid%dvol
2910 CALL pw_copy(v_hartree_rspace, aux_r)
2913 CALL cp_pw_to_cube(aux_r, unit_nr,
"HARTREE POTENTIAL", particles=particles, zeff=zcharge, &
2915 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%V_HARTREE_CUBE%MAX_FILE_SIZE_MB"), &
2918 "DFT%PRINT%V_HARTREE_CUBE", mpi_io=mpi_io)
2920 CALL auxbas_pw_pool%give_back_pw(aux_r)
2925 "DFT%PRINT%EXTERNAL_POTENTIAL_CUBE"),
cp_p_file))
THEN
2926 IF (dft_control%apply_external_potential)
THEN
2927 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, vee=vee)
2928 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
2929 CALL auxbas_pw_pool%create_pw(aux_r)
2931 append_cube =
section_get_lval(input,
"DFT%PRINT%EXTERNAL_POTENTIAL_CUBE%APPEND")
2932 my_pos_cube =
"REWIND"
2933 IF (append_cube)
THEN
2934 my_pos_cube =
"APPEND"
2939 extension=
".cube", middle_name=
"ext_pot", file_position=my_pos_cube, mpi_io=mpi_io)
2943 CALL cp_pw_to_cube(aux_r, unit_nr,
"EXTERNAL POTENTIAL", particles=particles, zeff=zcharge, &
2944 stride=
section_get_ivals(dft_section,
"PRINT%EXTERNAL_POTENTIAL_CUBE%STRIDE"), &
2945 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%EXTERNAL_POTENTIAL_CUBE%MAX_FILE_SIZE_MB"), &
2948 "DFT%PRINT%EXTERNAL_POTENTIAL_CUBE", mpi_io=mpi_io)
2950 CALL auxbas_pw_pool%give_back_pw(aux_r)
2956 "DFT%PRINT%EFIELD_CUBE"),
cp_p_file))
THEN
2958 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
2959 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
2960 CALL auxbas_pw_pool%create_pw(aux_r)
2961 CALL auxbas_pw_pool%create_pw(aux_g)
2964 my_pos_cube =
"REWIND"
2965 IF (append_cube)
THEN
2966 my_pos_cube =
"APPEND"
2968 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, &
2969 v_hartree_rspace=v_hartree_rspace)
2971 udvol = 1.0_dp/v_hartree_rspace%pw_grid%dvol
2975 extension=
".cube", middle_name=
"efield_"//cdir(id), file_position=my_pos_cube, &
2985 CALL cp_pw_to_cube(aux_r, unit_nr,
"ELECTRIC FIELD", particles=particles, zeff=zcharge, &
2987 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%EFIELD_CUBE%MAX_FILE_SIZE_MB"), &
2990 "DFT%PRINT%EFIELD_CUBE", mpi_io=mpi_io)
2993 CALL auxbas_pw_pool%give_back_pw(aux_r)
2994 CALL auxbas_pw_pool%give_back_pw(aux_g)
2998 CALL qs_scf_post_local_energy(input, logger, qs_env)
3001 CALL qs_scf_post_local_stress(input, logger, qs_env)
3004 CALL qs_scf_post_ps_implicit(input, logger, qs_env)
3012 "DFT%PRINT%AO_MATRICES/DENSITY"),
cp_p_file))
THEN
3017 after = min(max(after, 1), 16)
3018 DO ispin = 1, dft_control%nspins
3019 DO img = 1, dft_control%nimages
3021 para_env, output_unit=iw, omit_headers=omit_headers)
3025 "DFT%PRINT%AO_MATRICES/DENSITY")
3030 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX"),
cp_p_file)
3032 "DFT%PRINT%AO_MATRICES/MATRIX_VXC"),
cp_p_file)
3034 IF (write_ks .OR. write_xc)
THEN
3035 IF (write_xc) qs_env%requires_matrix_vxc = .true.
3038 just_energy=.false.)
3039 IF (write_xc) qs_env%requires_matrix_vxc = .false.
3046 CALL get_qs_env(qs_env=qs_env, matrix_ks_kp=ks_rmpv)
3048 after = min(max(after, 1), 16)
3049 DO ispin = 1, dft_control%nspins
3050 DO img = 1, dft_control%nimages
3052 para_env, output_unit=iw, omit_headers=omit_headers)
3056 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX")
3061 IF (.NOT. dft_control%qs_control%pao)
THEN
3069 CALL write_adjacency_matrix(qs_env, input)
3073 CALL get_qs_env(qs_env=qs_env, matrix_vxc_kp=matrix_vxc)
3074 cpassert(
ASSOCIATED(matrix_vxc))
3078 after = min(max(after, 1), 16)
3079 DO ispin = 1, dft_control%nspins
3080 DO img = 1, dft_control%nimages
3082 para_env, output_unit=iw, omit_headers=omit_headers)
3086 "DFT%PRINT%AO_MATRICES/MATRIX_VXC")
3091 "DFT%PRINT%AO_MATRICES/COMMUTATOR_HR"),
cp_p_file))
THEN
3097 after = min(max(after, 1), 16)
3100 para_env, output_unit=iw, omit_headers=omit_headers)
3104 "DFT%PRINT%AO_MATRICES/COMMUTATOR_HR")
3110 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MULLIKEN", extension=
".mulliken", log_filename=.false.)
3113 IF (print_it) print_level = 2
3115 IF (print_it) print_level = 3
3126 CALL qs_rho_get(rho, rho_r_valid=rho_r_valid)
3127 IF (rho_r_valid)
THEN
3128 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%HIRSHFELD", extension=
".hirshfeld", log_filename=.false.)
3129 CALL hirshfeld_charges(qs_env, print_key, unit_nr)
3137 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%EEQ_CHARGES", extension=
".eeq", log_filename=.false.)
3139 CALL eeq_print(qs_env, unit_nr, print_level, ext=.false.)
3147 should_print_voro = 1
3149 should_print_voro = 0
3152 should_print_bqb = 1
3154 should_print_bqb = 0
3156 IF ((should_print_voro /= 0) .OR. (should_print_bqb /= 0))
THEN
3161 CALL qs_rho_get(rho, rho_r_valid=rho_r_valid)
3162 IF (rho_r_valid)
THEN
3164 IF (dft_control%nspins > 1)
THEN
3168 auxbas_pw_pool=auxbas_pw_pool, &
3172 CALL auxbas_pw_pool%create_pw(pw=mb_rho)
3173 CALL pw_copy(rho_r(1), mb_rho)
3174 CALL pw_axpy(rho_r(2), mb_rho)
3181 IF (should_print_voro /= 0)
THEN
3183 IF (voro_print_txt)
THEN
3185 my_pos_voro =
"REWIND"
3186 IF (append_voro)
THEN
3187 my_pos_voro =
"APPEND"
3189 unit_nr_voro =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%VORONOI", extension=
".voronoi", &
3190 file_position=my_pos_voro, log_filename=.false.)
3198 CALL entry_voronoi_or_bqb(should_print_voro, should_print_bqb, print_key_voro, print_key_bqb, &
3199 unit_nr_voro, qs_env, mb_rho)
3201 IF (dft_control%nspins > 1)
THEN
3202 CALL auxbas_pw_pool%give_back_pw(mb_rho)
3206 IF (unit_nr_voro > 0)
THEN
3216 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MAO_ANALYSIS", extension=
".mao", log_filename=.false.)
3224 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MINBAS_ANALYSIS", extension=
".mao", log_filename=.false.)
3232 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IAO_ANALYSIS", extension=
".iao", log_filename=.false.)
3234 IF (iao_env%do_iao)
THEN
3244 extension=
".mao", log_filename=.false.)
3255 IF (qs_env%x_data(i, 1)%do_hfx_ri)
CALL print_ri_hfx(qs_env%x_data(i, 1)%ri_data, qs_env)
3259 DEALLOCATE (zcharge)
3261 CALL timestop(handle)
3271 SUBROUTINE hirshfeld_charges(qs_env, input_section, unit_nr)
3274 INTEGER,
INTENT(IN) :: unit_nr
3276 INTEGER :: i, iat, ikind, natom, nkind, nspin, &
3277 radius_type, refc, shapef
3278 INTEGER,
DIMENSION(:),
POINTER :: atom_list
3279 LOGICAL :: do_radius, do_sc, paw_atom
3280 REAL(kind=
dp) :: zeff
3281 REAL(kind=
dp),
DIMENSION(:),
POINTER :: radii
3282 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: charges
3285 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
3291 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3295 NULLIFY (hirshfeld_env)
3299 CALL get_qs_env(qs_env, nkind=nkind, natom=natom)
3300 ALLOCATE (hirshfeld_env%charges(natom))
3309 IF (.NOT.
SIZE(radii) == nkind) &
3310 CALL cp_abort(__location__, &
3311 "Length of keyword HIRSHFELD\ATOMIC_RADII does not "// &
3312 "match number of atomic kinds in the input coordinate file.")
3317 iterative=do_sc, ref_charge=refc, &
3318 radius_type=radius_type)
3320 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set)
3326 nspin =
SIZE(matrix_p, 1)
3327 ALLOCATE (charges(natom, nspin))
3332 atomic_kind => atomic_kind_set(ikind)
3334 DO iat = 1,
SIZE(atom_list)
3336 hirshfeld_env%charges(i) = zeff
3340 CALL get_qs_env(qs_env, matrix_s_kp=matrix_s, para_env=para_env)
3343 hirshfeld_env%charges(iat) = sum(charges(iat, :))
3346 cpabort(
"Unknown type of reference charge for Hirshfeld partitioning.")
3350 IF (hirshfeld_env%iterative)
THEN
3357 CALL get_qs_env(qs_env, particle_set=particle_set, dft_control=dft_control)
3358 IF (dft_control%qs_control%gapw)
THEN
3360 CALL get_qs_env(qs_env, rho0_mpole=rho0_mpole)
3363 atomic_kind => particle_set(iat)%atomic_kind
3365 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
3367 charges(iat, 1:nspin) = charges(iat, 1:nspin) + mp_rho(iat)%q0(1:nspin)
3372 IF (unit_nr > 0)
THEN
3374 qs_kind_set, unit_nr)
3380 DEALLOCATE (charges)
3382 END SUBROUTINE hirshfeld_charges
3392 SUBROUTINE project_function_a(ca, a, cb, b, l)
3394 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: ca
3395 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: a, cb, b
3396 INTEGER,
INTENT(IN) :: l
3399 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ipiv
3400 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat, tmat, v
3403 ALLOCATE (smat(n, n), tmat(n, n), v(n, 1), ipiv(n))
3407 v(:, 1) = matmul(tmat, cb)
3408 CALL dgesv(n, 1, smat, n, ipiv, v, n, info)
3412 DEALLOCATE (smat, tmat, v, ipiv)
3414 END SUBROUTINE project_function_a
3424 SUBROUTINE project_function_b(ca, a, bfun, grid_atom, l)
3426 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: ca
3427 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: a, bfun
3429 INTEGER,
INTENT(IN) :: l
3431 INTEGER :: i, info, n, nr
3432 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ipiv
3433 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: afun
3434 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat, v
3438 ALLOCATE (smat(n, n), v(n, 1), ipiv(n), afun(nr))
3442 afun(:) = grid_atom%rad(:)**l*exp(-a(i)*grid_atom%rad2(:))
3443 v(i, 1) = sum(afun(:)*bfun(:)*grid_atom%wr(:))
3445 CALL dgesv(n, 1, smat, n, ipiv, v, n, info)
3449 DEALLOCATE (smat, v, ipiv, afun)
3451 END SUBROUTINE project_function_b
3462 SUBROUTINE qs_scf_post_local_energy(input, logger, qs_env)
3467 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_local_energy'
3469 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3470 INTEGER :: handle, io_unit, natom, unit_nr
3471 LOGICAL :: append_cube, gapw, gapw_xc, mpi_io
3480 CALL timeset(routinen, handle)
3483 "DFT%PRINT%LOCAL_ENERGY_CUBE"),
cp_p_file))
THEN
3485 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, natom=natom)
3486 gapw = dft_control%qs_control%gapw
3487 gapw_xc = dft_control%qs_control%gapw_xc
3488 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3490 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3491 CALL auxbas_pw_pool%create_pw(eden)
3495 append_cube =
section_get_lval(input,
"DFT%PRINT%LOCAL_ENERGY_CUBE%APPEND")
3496 IF (append_cube)
THEN
3497 my_pos_cube =
"APPEND"
3499 my_pos_cube =
"REWIND"
3503 extension=
".cube", middle_name=
"local_energy", &
3504 file_position=my_pos_cube, mpi_io=mpi_io)
3505 CALL cp_pw_to_cube(eden, unit_nr,
"LOCAL ENERGY", particles=particles, &
3507 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%LOCAL_ENERGY_CUBE%MAX_FILE_SIZE_MB"), &
3509 IF (io_unit > 0)
THEN
3510 INQUIRE (unit=unit_nr, name=filename)
3511 IF (gapw .OR. gapw_xc)
THEN
3512 WRITE (unit=io_unit, fmt=
"(/,T3,A,A)") &
3513 "The soft part of the local energy is written to the file: ", trim(adjustl(filename))
3515 WRITE (unit=io_unit, fmt=
"(/,T3,A,A)") &
3516 "The local energy is written to the file: ", trim(adjustl(filename))
3520 "DFT%PRINT%LOCAL_ENERGY_CUBE", mpi_io=mpi_io)
3522 CALL auxbas_pw_pool%give_back_pw(eden)
3524 CALL timestop(handle)
3526 END SUBROUTINE qs_scf_post_local_energy
3537 SUBROUTINE qs_scf_post_local_stress(input, logger, qs_env)
3542 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_local_stress'
3544 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3545 INTEGER :: handle, io_unit, natom, unit_nr
3546 LOGICAL :: append_cube, gapw, gapw_xc, mpi_io
3547 REAL(kind=
dp) :: beta
3556 CALL timeset(routinen, handle)
3559 "DFT%PRINT%LOCAL_STRESS_CUBE"),
cp_p_file))
THEN
3561 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, natom=natom)
3562 gapw = dft_control%qs_control%gapw
3563 gapw_xc = dft_control%qs_control%gapw_xc
3564 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3566 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3567 CALL auxbas_pw_pool%create_pw(stress)
3573 append_cube =
section_get_lval(input,
"DFT%PRINT%LOCAL_STRESS_CUBE%APPEND")
3574 IF (append_cube)
THEN
3575 my_pos_cube =
"APPEND"
3577 my_pos_cube =
"REWIND"
3581 extension=
".cube", middle_name=
"local_stress", &
3582 file_position=my_pos_cube, mpi_io=mpi_io)
3583 CALL cp_pw_to_cube(stress, unit_nr,
"LOCAL STRESS", particles=particles, &
3585 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%LOCAL_STRESS_CUBE%MAX_FILE_SIZE_MB"), &
3587 IF (io_unit > 0)
THEN
3588 INQUIRE (unit=unit_nr, name=filename)
3589 WRITE (unit=io_unit, fmt=
"(/,T3,A)")
"Write 1/3*Tr(sigma) to cube file"
3590 IF (gapw .OR. gapw_xc)
THEN
3591 WRITE (unit=io_unit, fmt=
"(T3,A,A)") &
3592 "The soft part of the local stress is written to the file: ", trim(adjustl(filename))
3594 WRITE (unit=io_unit, fmt=
"(T3,A,A)") &
3595 "The local stress is written to the file: ", trim(adjustl(filename))
3599 "DFT%PRINT%LOCAL_STRESS_CUBE", mpi_io=mpi_io)
3601 CALL auxbas_pw_pool%give_back_pw(stress)
3604 CALL timestop(handle)
3606 END SUBROUTINE qs_scf_post_local_stress
3617 SUBROUTINE qs_scf_post_ps_implicit(input, logger, qs_env)
3622 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_ps_implicit'
3624 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3625 INTEGER :: boundary_condition, handle, i, j, &
3626 n_cstr, n_tiles, unit_nr
3627 LOGICAL :: append_cube, do_cstr_charge_cube, do_dielectric_cube, do_dirichlet_bc_cube, &
3628 has_dirichlet_bc, has_implicit_ps, mpi_io, tile_cubes
3638 CALL timeset(routinen, handle)
3640 NULLIFY (pw_env, auxbas_pw_pool, dft_section, particles)
3643 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3645 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3647 has_implicit_ps = .false.
3648 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
3653 "DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE"),
cp_p_file)
3654 IF (has_implicit_ps .AND. do_dielectric_cube)
THEN
3655 append_cube =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%APPEND")
3656 my_pos_cube =
"REWIND"
3657 IF (append_cube)
THEN
3658 my_pos_cube =
"APPEND"
3662 extension=
".cube", middle_name=
"DIELECTRIC_CONSTANT", file_position=my_pos_cube, &
3664 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
3665 CALL auxbas_pw_pool%create_pw(aux_r)
3667 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3668 SELECT CASE (boundary_condition)
3670 CALL pw_copy(poisson_env%implicit_env%dielectric%eps, aux_r)
3672 CALL pw_shrink(pw_env%poisson_env%parameters%ps_implicit_params%neumann_directions, &
3673 pw_env%poisson_env%implicit_env%dct_env%dests_shrink, &
3674 pw_env%poisson_env%implicit_env%dct_env%srcs_shrink, &
3675 pw_env%poisson_env%implicit_env%dct_env%bounds_local_shftd, &
3676 poisson_env%implicit_env%dielectric%eps, aux_r)
3679 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIELECTRIC CONSTANT", particles=particles, &
3680 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%STRIDE"), &
3681 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%MAX_FILE_SIZE_MB"), &
3684 "DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE", mpi_io=mpi_io)
3686 CALL auxbas_pw_pool%give_back_pw(aux_r)
3691 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE"),
cp_p_file)
3693 has_dirichlet_bc = .false.
3694 IF (has_implicit_ps)
THEN
3695 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3697 has_dirichlet_bc = .true.
3701 IF (has_implicit_ps .AND. do_cstr_charge_cube .AND. has_dirichlet_bc)
THEN
3703 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%APPEND")
3704 my_pos_cube =
"REWIND"
3705 IF (append_cube)
THEN
3706 my_pos_cube =
"APPEND"
3710 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE", &
3711 extension=
".cube", middle_name=
"dirichlet_cstr_charge", file_position=my_pos_cube, &
3713 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
3714 CALL auxbas_pw_pool%create_pw(aux_r)
3716 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3717 SELECT CASE (boundary_condition)
3719 CALL pw_copy(poisson_env%implicit_env%cstr_charge, aux_r)
3721 CALL pw_shrink(pw_env%poisson_env%parameters%ps_implicit_params%neumann_directions, &
3722 pw_env%poisson_env%implicit_env%dct_env%dests_shrink, &
3723 pw_env%poisson_env%implicit_env%dct_env%srcs_shrink, &
3724 pw_env%poisson_env%implicit_env%dct_env%bounds_local_shftd, &
3725 poisson_env%implicit_env%cstr_charge, aux_r)
3728 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET CONSTRAINT CHARGE", particles=particles, &
3729 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%STRIDE"), &
3730 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%MAX_FILE_SIZE_MB"), &
3733 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE", mpi_io=mpi_io)
3735 CALL auxbas_pw_pool%give_back_pw(aux_r)
3740 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE"),
cp_p_file)
3741 has_dirichlet_bc = .false.
3742 IF (has_implicit_ps)
THEN
3743 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3745 has_dirichlet_bc = .true.
3749 IF (has_implicit_ps .AND. has_dirichlet_bc .AND. do_dirichlet_bc_cube)
THEN
3750 append_cube =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%APPEND")
3751 my_pos_cube =
"REWIND"
3752 IF (append_cube)
THEN
3753 my_pos_cube =
"APPEND"
3755 tile_cubes =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%TILE_CUBES")
3757 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
3758 CALL auxbas_pw_pool%create_pw(aux_r)
3761 IF (tile_cubes)
THEN
3763 n_cstr =
SIZE(poisson_env%implicit_env%contacts)
3765 n_tiles = poisson_env%implicit_env%contacts(j)%dirichlet_bc%n_tiles
3767 filename =
"dirichlet_cstr_"//trim(adjustl(
cp_to_string(j)))// &
3770 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", &
3771 extension=
".cube", middle_name=filename, file_position=my_pos_cube, &
3774 CALL pw_copy(poisson_env%implicit_env%contacts(j)%dirichlet_bc%tiles(i)%tile%tile_pw, aux_r)
3776 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET TYPE CONSTRAINT", particles=particles, &
3777 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%STRIDE"), &
3778 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%MAX_FILE_SIZE_MB"), &
3781 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", mpi_io=mpi_io)
3786 NULLIFY (dirichlet_tile)
3787 ALLOCATE (dirichlet_tile)
3788 CALL auxbas_pw_pool%create_pw(dirichlet_tile)
3791 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", &
3792 extension=
".cube", middle_name=
"DIRICHLET_CSTR", file_position=my_pos_cube, &
3795 n_cstr =
SIZE(poisson_env%implicit_env%contacts)
3797 n_tiles = poisson_env%implicit_env%contacts(j)%dirichlet_bc%n_tiles
3799 CALL pw_copy(poisson_env%implicit_env%contacts(j)%dirichlet_bc%tiles(i)%tile%tile_pw, dirichlet_tile)
3800 CALL pw_axpy(dirichlet_tile, aux_r)
3804 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET TYPE CONSTRAINT", particles=particles, &
3805 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%STRIDE"), &
3806 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%MAX_FILE_SIZE_MB"), &
3809 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", mpi_io=mpi_io)
3810 CALL auxbas_pw_pool%give_back_pw(dirichlet_tile)
3811 DEALLOCATE (dirichlet_tile)
3814 CALL auxbas_pw_pool%give_back_pw(aux_r)
3817 CALL timestop(handle)
3819 END SUBROUTINE qs_scf_post_ps_implicit
3827 SUBROUTINE write_adjacency_matrix(qs_env, input)
3831 CHARACTER(len=*),
PARAMETER :: routinen =
'write_adjacency_matrix'
3833 INTEGER :: adjm_size, colind, handle, iatom, ikind, &
3834 ind, jatom, jkind, k, natom, nkind, &
3835 output_unit, rowind, unit_nr
3836 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: interact_adjm
3837 LOGICAL :: do_adjm_write, do_symmetric
3843 DIMENSION(:),
POINTER :: nl_iterator
3846 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3849 CALL timeset(routinen, handle)
3851 NULLIFY (dft_section)
3860 IF (do_adjm_write)
THEN
3861 NULLIFY (qs_kind_set, nl_iterator)
3862 NULLIFY (basis_set_list_a, basis_set_list_b, basis_set_a, basis_set_b)
3864 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, sab_orb=nl, natom=natom, para_env=para_env)
3866 nkind =
SIZE(qs_kind_set)
3867 cpassert(
SIZE(nl) > 0)
3869 cpassert(do_symmetric)
3870 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
3874 adjm_size = ((natom + 1)*natom)/2
3875 ALLOCATE (interact_adjm(4*adjm_size))
3878 NULLIFY (nl_iterator)
3882 ikind=ikind, jkind=jkind, &
3883 iatom=iatom, jatom=jatom)
3885 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
3886 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
3887 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
3888 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
3891 IF (iatom <= jatom)
THEN
3898 ikind = ikind + jkind
3899 jkind = ikind - jkind
3900 ikind = ikind - jkind
3904 ind = adjm_size - (natom - rowind + 1)*((natom - rowind + 1) + 1)/2 + colind - rowind + 1
3907 interact_adjm((ind - 1)*4 + 1) = rowind
3908 interact_adjm((ind - 1)*4 + 2) = colind
3909 interact_adjm((ind - 1)*4 + 3) = ikind
3910 interact_adjm((ind - 1)*4 + 4) = jkind
3913 CALL para_env%sum(interact_adjm)
3916 extension=
".adjmat", file_form=
"FORMATTED", &
3917 file_status=
"REPLACE")
3918 IF (unit_nr > 0)
THEN
3919 WRITE (unit_nr,
"(1A,2X,1A,5X,1A,4X,A5,3X,A5)")
"#",
"iatom",
"jatom",
"ikind",
"jkind"
3920 DO k = 1, 4*adjm_size, 4
3922 IF (interact_adjm(k) > 0 .AND. interact_adjm(k + 1) > 0)
THEN
3923 WRITE (unit_nr,
"(I8,2X,I8,3X,I6,2X,I6)") interact_adjm(k:k + 3)
3931 DEALLOCATE (basis_set_list_a, basis_set_list_b)
3934 CALL timestop(handle)
3936 END SUBROUTINE write_adjacency_matrix
3944 SUBROUTINE update_hartree_with_mp2(rho, qs_env)
3948 LOGICAL :: use_virial
3958 NULLIFY (auxbas_pw_pool, pw_env, poisson_env, energy, rho_core, v_hartree_rspace, virial)
3959 CALL get_qs_env(qs_env, pw_env=pw_env, energy=energy, &
3960 rho_core=rho_core, virial=virial, &
3961 v_hartree_rspace=v_hartree_rspace)
3963 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
3965 IF (.NOT. use_virial)
THEN
3967 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
3968 poisson_env=poisson_env)
3969 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
3970 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
3974 v_hartree_gspace, rho_core=rho_core)
3976 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
3977 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
3979 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
3980 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
3983 END SUBROUTINE update_hartree_with_mp2
static double norm_factor(double alpha, int L)
Types and set/get functions for auxiliary density matrix methods.
Contains methods used in the context of density fitting.
subroutine, public admm_uncorrect_for_eigenvalues(ispin, admm_env, ks_matrix)
...
subroutine, public admm_correct_for_eigenvalues(ispin, admm_env, ks_matrix)
...
subroutine, public sg_overlap(smat, l, pa, pb)
...
calculate the orbitals for a given atomic kind type
subroutine, public calculate_atomic_density(density, atomic_kind, qs_kind, ngto, iunit, optbasis, allelectron, confine)
...
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...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
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)
...
Density Derived atomic point charges from a QM calculation (see Bloechl, J. Chem. Phys....
recursive subroutine, public get_ddapc(qs_env, calc_force, density_fit_section, density_type, qout1, qout2, out_radii, dq_out, ext_rho_tot_g, itype_of_density, iwc)
Computes the Density Derived Atomic Point Charges.
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_create(matrix, matrix_struct, name, use_sp, 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...
subroutine, public cp_openpmd_close_iterations()
integer function, public cp_openpmd_print_key_unit_nr(logger, basis_section, print_key_path, middle_name, ignore_should_output, mpi_io, fout, openpmd_basename)
...
subroutine, public cp_openpmd_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, mpi_io)
should be called after you finish working with a unit obtained with cp_openpmd_print_key_unit_nr,...
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)
...
A wrapper around pw_to_openpmd() which accepts particle_list_type.
subroutine, public cp_pw_to_openpmd(pw, unit_nr, title, particles, zeff, stride, zero_tails, silent, mpi_io)
...
the type I Discrete Cosine Transform (DCT-I)
subroutine, public pw_shrink(neumann_directions, dests_shrink, srcs_shrink, bounds_local_shftd, pw_in, pw_shrinked)
shrinks an evenly symmetric pw_r3d_rs_type data to a pw_r3d_rs_type data that is 8 times smaller (the...
Calculate Energy Decomposition analysis.
subroutine, public edmf_analysis(qs_env, input_section, unit_nr)
...
Calculation of charge equilibration method.
subroutine, public eeq_print(qs_env, iounit, print_level, ext)
...
Definition and initialisation of the et_coupling data type.
subroutine, public set_et_coupling_type(et_coupling, et_mo_coeff, rest_mat)
...
subroutine, public print_ri_hfx(ri_data, qs_env)
Print RI-HFX quantities, as required by the PRINT subsection.
Calculate Hirshfeld charges and related functions.
subroutine, public comp_hirshfeld_charges(qs_env, hirshfeld_env, charges)
...
subroutine, public create_shape_function(hirshfeld_env, qs_kind_set, atomic_kind_set, radius, radii_list)
creates kind specific shape functions for Hirshfeld charges
subroutine, public write_hirshfeld_charges(charges, hirshfeld_env, particle_set, qs_kind_set, unit_nr)
...
subroutine, public comp_hirshfeld_i_charges(qs_env, hirshfeld_env, charges, ounit)
...
subroutine, public save_hirshfeld_charges(charges, particle_set, qs_kind_set, qs_env)
saves the Hirshfeld charges to the results structure
The types needed for the calculation of Hirshfeld charges and related functions.
subroutine, public create_hirshfeld_type(hirshfeld_env)
...
subroutine, public set_hirshfeld_info(hirshfeld_env, shape_function_type, iterative, ref_charge, fnorm, radius_type, use_bohr)
Set values of a Hirshfeld env.
subroutine, public release_hirshfeld_type(hirshfeld_env)
...
Calculate intrinsic atomic orbitals and analyze wavefunctions.
subroutine, public iao_wfn_analysis(qs_env, iao_env, unit_nr, c_iao_coef, mos, bond_centers)
...
Calculate ntrinsic atomic orbitals and analyze wavefunctions.
subroutine, public iao_read_input(iao_env, iao_section, cell)
...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
K-point MO wavefunction dump to TEXT file for post-processing (PDOS, etc.)
subroutine, public write_kpoint_mo_data(qs_env, print_section)
Write k-point resolved MO data to formatted text file.
Types and basic routines needed for a kpoint calculation.
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Calculate MAO's and analyze wavefunctions.
subroutine, public mao_analysis(qs_env, input_section, unit_nr)
...
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Utility routines for the memory handling.
Interface to the message passing library MPI.
Calculate localized minimal basis and analyze wavefunctions.
subroutine, public minbas_analysis(qs_env, input_section, unit_nr)
...
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)
Write out the MOs in molden format for visualisation.
Define the data structure for the molecule information.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:, :), allocatable, public indso
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 evolt
real(kind=dp), parameter, public angstrom
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...
subroutine, public mulliken_population_analysis(qs_env, output_unit, print_level)
Perform a Mulliken population analysis.
computes preconditioners, and implements methods to apply them currently used in qs_ot
Types containing essential information for running implicit (iterative) Poisson solver.
integer, parameter, public neumann_bc
integer, parameter, public mixed_bc
integer, parameter, public mixed_periodic_bc
integer, parameter, public periodic_bc
container for various plainwaves related things
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
This module defines the grid data type and some basic operations on it.
subroutine, public get_pw_grid_info(pw_grid, id_nr, mode, vol, dvol, npts, ngpts, ngpts_cut, dr, cutoff, orthorhombic, gvectors, gsquare)
Access to information stored in the pw_grid_type.
subroutine, public pw_derive(pw, n)
Calculate the derivative of a plane wave vector.
functions related to the poisson solver on regular grids
integer, parameter, public pw_poisson_implicit
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Write wfx file, works as interface to chargemol and multiwfn.
subroutine, public write_wfx(qs_env, dft_section)
...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
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
Calculation of commutator [H,r] matrices.
subroutine, public build_com_hr_matrix(qs_env, matrix_hr)
Calculation of the [H,r] commutators matrices over Cartesian Gaussian functions.
Calculation of the energies concerning the core charge distribution.
Calculation and writing of density of states.
subroutine, public calculate_dos(mos, dft_section)
Compute and write density of states.
subroutine, public calculate_dos_kp(qs_env, dft_section)
Compute and write density of states (kpoints)
Calculates electric field gradients H.M. Petrili, P.E. Blochl, P. Blaha, K. Schwarz,...
subroutine, public qs_efg_calc(qs_env)
...
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.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
Calculates hyperfine values.
subroutine, public qs_epr_hyp_calc(qs_env)
...
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
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.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
subroutine, public calc_rho_tot_gspace(rho_tot_gspace, qs_env, rho, skip_nuclear_density)
...
subroutine, public qs_ks_did_change(ks_env, s_mstruct_changed, rho_changed, potential_changed, full_reset)
tells that some of the things relevant to the ks calculation did change. has to be called when change...
subroutine, public loc_dipole(input, dft_control, qs_loc_env, logger, qs_env)
Computes and prints the Dipole (using localized charges)
subroutine, public get_localization_info(qs_env, qs_loc_env, loc_section, mo_local, wf_r, wf_g, particles, coeff, evals, marked_states)
Performs localization of the orbitals.
New version of the module for the localization of the molecular orbitals This should be able to use d...
subroutine, public qs_loc_env_release(qs_loc_env)
...
subroutine, public qs_loc_env_create(qs_loc_env)
...
Some utilities for the construction of the localization environment.
subroutine, public loc_write_restart(qs_loc_env, section, mo_array, coeff_localized, do_homo, evals, do_mixed)
...
subroutine, public qs_loc_env_init(qs_loc_env, localized_wfn_control, qs_env, myspin, do_localize, loc_coeff, mo_loc_history)
allocates the data, and initializes the operators
subroutine, public qs_loc_control_init(qs_loc_env, loc_section, do_homo, do_mixed, do_xas, nloc_xas, spin_xas)
initializes everything needed for localization of the HOMOs
subroutine, public retain_history(mo_loc_history, mo_loc)
copy old mos to new ones, allocating as necessary
subroutine, public qs_loc_init(qs_env, qs_loc_env, localize_section, mos_localized, do_homo, do_mo_cubes, mo_loc_history, evals, tot_zeff_corr, do_mixed)
initializes everything needed for localization of the molecular orbitals
Routines for calculating local energy and stress tensor.
subroutine, public qs_local_stress(qs_env, stress_tensor, beta)
Routine to calculate the local stress.
subroutine, public qs_local_energy(qs_env, energy_density)
Routine to calculate the local energy.
Definition and initialisation of the mo data type.
subroutine, public write_dm_binary_restart(mo_array, dft_section, tmpl_matrix)
calculates density matrix from mo set and writes the density matrix into a binary restart file
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.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>
subroutine, public qs_moment_locop(qs_env, magnetic, nmoments, reference, ref_point, unit_number, vel_reprs, com_nl)
...
subroutine, public qs_moment_kpoints(qs_env, nmoments, reference, ref_point, max_nmo, unit_number)
Calculate and print dipole moment elements d_nm(k) for k-point calculations.
subroutine, public qs_moment_berry_phase(qs_env, magnetic, nmoments, reference, ref_point, unit_number)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
subroutine, public get_neighbor_list_set_p(neighbor_list_sets, nlist, symmetric)
Return the components of the first neighbor list set.
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
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(mo_set, atomic_kind_set, qs_kind_set, particle_set, qs_env, dft_section, ispin, xas_mittle, external_matrix_shalf)
Compute and write projected density of states.
provides a resp fit for gas phase systems
subroutine, public resp_fit(qs_env)
performs resp fit and generates RESP charges
subroutine, public get_rho0_mpole(rho0_mpole, g0_h, vg0_h, iat, ikind, lmax_0, l0_ikind, mp_gau_ikind, mp_rho, norm_g0l_h, qlm_gg, qlm_car, qlm_tot, zet0_h, igrid_zet0_s, rpgf0_h, rpgf0_s, max_rpgf0_s, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs)
...
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
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...
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 GPW/GAPW.
subroutine, public make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
Gets the lumos, and eigenvalues for the lumos.
subroutine, public write_mo_free_results(qs_env)
Write QS results always available (if switched on through the print_keys) Can be called from ls_scf.
subroutine, public qs_scf_post_moments(input, logger, qs_env, output_unit)
Computes and prints electric moments.
subroutine, public write_mo_dependent_results(qs_env, scf_env)
Write QS results available if MO's are present (if switched on through the print_keys) Writes only MO...
subroutine, public scf_post_calculation_gpw(qs_env, wf_type, do_mp2)
collects possible post - scf calculations and prints info / computes properties.
character(len=default_string_length) function cp_section_key_concat_to_absolute(self, extend_by)
Append extend_by to the absolute path of the base section.
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)
...
Interface to Wannier90 code.
subroutine, public wannier90_interface(input, logger, qs_env)
...
Methods related to (\cal S)^2 (i.e. spin)
subroutine, public compute_s_square(mos, matrix_s, s_square, s_square_ideal, mo_derivs, strength)
Compute the expectation value <(\cal S)^2> of the single determinant defined by the spin up (alpha) a...
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...
routines for DFT+NEGF calculations (coupling with the quantum transport code OMEN)
subroutine, public qs_scf_post_transport(qs_env)
post scf calculations for transport
The module to read/write TREX IO files for interfacing CP2K with other programs.
subroutine, public write_trexio(qs_env, trexio_section, energy_derivative)
Write a trexio file.
Interface for Voronoi Integration and output of BQB files.
subroutine, public entry_voronoi_or_bqb(do_voro, do_bqb, input_voro, input_bqb, unit_voro, qs_env, rspace_pw)
Does a Voronoi integration of density or stores the density to compressed BQB format.
subroutine, public xray_diffraction_spectrum(qs_env, unit_number, q_max)
Calculate the coherent X-ray diffraction spectrum using the total electronic density in reciprocal sp...
subroutine, public calculate_rhotot_elec_gspace(qs_env, auxbas_pw_pool, rhotot_elec_gspace, q_max, rho_hard, rho_soft, fsign)
The total electronic density in reciprocal space (g-space) is calculated.
stores some data used in wavefunction fitting
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...
quantities needed for a Hirshfeld based partitioning of real space
Contains information about kpoints.
stores all the informations relevant to an mpi environment
represent a list of objects
contained for different pw related things
environment for the poisson solver
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.
contains all the info needed by quickstep to calculate the spread of a selected set of orbitals and i...
keeps the density in various representations, keeping track of which ones are valid.