217#include "./base/base_uses.f90"
223 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_post_gpw'
230 CHARACTER(len=*),
PARAMETER :: &
231 str_mo_cubes =
"PRINT%MO_CUBES", &
232 str_mo_openpmd =
"PRINT%MO_OPENPMD", &
233 str_elf_cubes =
"PRINT%ELF_CUBE", &
234 str_elf_openpmd =
"PRINT%ELF_OPENPMD", &
235 str_e_density_cubes =
"PRINT%E_DENSITY_CUBE", &
236 str_e_density_openpmd =
"PRINT%E_DENSITY_OPENPMD"
238 INTEGER,
PARAMETER :: grid_output_cubes = 1, grid_output_openpmd = 2
240 REAL(kind=
dp),
DIMENSION(7),
PARAMETER :: openpmd_unit_dimension_density = &
241 [-3, 0, 0, 0, 0, 0, 0]
242 REAL(kind=
dp),
DIMENSION(7),
PARAMETER :: openpmd_unit_dimension_dimensionless = &
243 [0, 0, 0, 0, 0, 0, 0]
244 REAL(kind=
dp),
DIMENSION(7),
PARAMETER :: openpmd_unit_dimension_wavefunction = &
245 [-1.5_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp]
246 REAL(kind=
dp),
PARAMETER :: openpmd_unit_si_density =
a_bohr**(-3)
247 REAL(kind=
dp),
PARAMETER :: openpmd_unit_si_dimensionless = 1.0_dp
248 REAL(kind=
dp),
PARAMETER :: openpmd_unit_si_wavefunction =
a_bohr**(-1.5_dp)
254 CHARACTER(len=default_string_length) :: relative_section_key =
""
255 CHARACTER(len=default_string_length) :: absolute_section_key =
""
256 CHARACTER(len=7) :: format_name =
""
257 INTEGER :: grid_output = -1
258 LOGICAL :: do_output = .false.
261 PROCEDURE,
PUBLIC :: print_key_unit_nr => cp_forward_print_key_unit_nr
263 PROCEDURE,
PUBLIC :: write_pw => cp_forward_write_pw
265 PROCEDURE,
PUBLIC :: print_key_finished_output => cp_forward_print_key_finished_output
267 PROCEDURE,
PUBLIC :: do_openpmd => cp_section_key_do_openpmd
268 PROCEDURE,
PUBLIC :: do_cubes => cp_section_key_do_cubes
269 PROCEDURE,
PUBLIC :: concat_to_relative => cp_section_key_concat_to_relative
271 END TYPE cp_section_key
282 CLASS(cp_section_key),
INTENT(IN) :: self
283 CHARACTER(*),
INTENT(IN) :: extend_by
284 CHARACTER(len=default_string_length) :: res
286 IF (len(trim(extend_by)) > 0 .AND. extend_by(1:1) ==
"%")
THEN
287 res = trim(self%absolute_section_key)//trim(extend_by)
289 res = trim(self%absolute_section_key)//
"%"//trim(extend_by)
299 FUNCTION cp_section_key_concat_to_relative(self, extend_by)
RESULT(res)
300 CLASS(cp_section_key),
INTENT(IN) :: self
301 CHARACTER(*),
INTENT(IN) :: extend_by
302 CHARACTER(len=default_string_length) :: res
304 IF (len(trim(extend_by)) > 0 .AND. extend_by(1:1) ==
"%")
THEN
305 res = trim(self%relative_section_key)//trim(extend_by)
307 res = trim(self%relative_section_key)//
"%"//trim(extend_by)
309 END FUNCTION cp_section_key_concat_to_relative
316 FUNCTION cp_section_key_do_cubes(self)
RESULT(res)
317 CLASS(cp_section_key) :: self
320 res = self%do_output .AND. self%grid_output == grid_output_cubes
321 END FUNCTION cp_section_key_do_cubes
328 FUNCTION cp_section_key_do_openpmd(self)
RESULT(res)
329 CLASS(cp_section_key) :: self
332 res = self%do_output .AND. self%grid_output == grid_output_openpmd
333 END FUNCTION cp_section_key_do_openpmd
363 FUNCTION cp_forward_print_key_unit_nr( &
372 ignore_should_output, &
383 openpmd_unit_dimension, &
385 sim_time)
RESULT(res)
387 CLASS(cp_section_key),
INTENT(IN) :: self
390 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: print_key_path
391 CHARACTER(len=*),
INTENT(IN) :: extension
392 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: middle_name
393 LOGICAL,
INTENT(IN),
OPTIONAL :: local, log_filename, ignore_should_output
394 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: file_form, file_position, file_action, &
396 LOGICAL,
INTENT(IN),
OPTIONAL :: do_backup, on_file
397 LOGICAL,
INTENT(OUT),
OPTIONAL :: is_new_file
398 LOGICAL,
INTENT(INOUT),
OPTIONAL :: mpi_io
399 CHARACTER(len=default_path_length),
INTENT(OUT), &
401 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: openpmd_basename
402 REAL(kind=
dp),
DIMENSION(7),
OPTIONAL,
INTENT(IN) :: openpmd_unit_dimension
403 REAL(kind=
dp),
OPTIONAL,
INTENT(IN) :: openpmd_unit_si
404 REAL(kind=
dp),
OPTIONAL,
INTENT(IN) :: sim_time
407 IF (self%grid_output == grid_output_cubes)
THEN
409 logger, basis_section, print_key_path, extension=extension, &
410 middle_name=middle_name, local=local, log_filename=log_filename, &
411 ignore_should_output=ignore_should_output, file_form=file_form, &
412 file_position=file_position, file_action=file_action, &
413 file_status=file_status, do_backup=do_backup, on_file=on_file, &
414 is_new_file=is_new_file, mpi_io=mpi_io, fout=fout)
420 middle_name=middle_name, &
421 ignore_should_output=ignore_should_output, &
424 openpmd_basename=openpmd_basename, &
425 openpmd_unit_dimension=openpmd_unit_dimension, &
426 openpmd_unit_si=openpmd_unit_si, &
429 END FUNCTION cp_forward_print_key_unit_nr
447 SUBROUTINE cp_forward_write_pw( &
460 CLASS(cp_section_key),
INTENT(IN) :: self
462 INTEGER,
INTENT(IN) :: unit_nr
463 CHARACTER(*),
INTENT(IN),
OPTIONAL :: title
465 INTEGER,
DIMENSION(:),
OPTIONAL,
POINTER :: stride
466 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: max_file_size_mb
467 LOGICAL,
INTENT(IN),
OPTIONAL :: zero_tails, silent, mpi_io
468 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: zeff
470 IF (self%grid_output == grid_output_cubes)
THEN
471 CALL cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
473 CALL cp_pw_to_openpmd(pw, unit_nr, title, particles, zeff, stride, zero_tails, silent, mpi_io)
475 END SUBROUTINE cp_forward_write_pw
491 SUBROUTINE cp_forward_print_key_finished_output(self, unit_nr, logger, basis_section, &
492 print_key_path, local, ignore_should_output, on_file, &
494 CLASS(cp_section_key),
INTENT(IN) :: self
495 INTEGER,
INTENT(INOUT) :: unit_nr
498 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: print_key_path
499 LOGICAL,
INTENT(IN),
OPTIONAL :: local, ignore_should_output, on_file, &
502 IF (self%grid_output == grid_output_cubes)
THEN
507 END SUBROUTINE cp_forward_print_key_finished_output
527 FUNCTION cube_or_openpmd(input, str_cubes, str_openpmd, logger)
RESULT(res)
529 CHARACTER(len=*),
INTENT(IN) :: str_cubes, str_openpmd
531 TYPE(cp_section_key) :: res
533 LOGICAL :: do_cubes, do_openpmd
536 logger%iter_info, input, &
537 "DFT%"//trim(adjustl(str_cubes))),
cp_p_file)
539 logger%iter_info, input, &
540 "DFT%"//trim(adjustl(str_openpmd))),
cp_p_file)
544 cpassert(.NOT. (do_cubes .AND. do_openpmd))
545 res%do_output = do_cubes .OR. do_openpmd
547 res%grid_output = grid_output_openpmd
548 res%relative_section_key = trim(adjustl(str_openpmd))
549 res%format_name =
"openPMD"
551 res%grid_output = grid_output_cubes
552 res%relative_section_key = trim(adjustl(str_cubes))
553 res%format_name =
"Cube"
555 res%absolute_section_key =
"DFT%"//trim(adjustl(res%relative_section_key))
556 END FUNCTION cube_or_openpmd
564 FUNCTION section_key_do_write(grid_output)
RESULT(res)
565 INTEGER,
INTENT(IN) :: grid_output
566 CHARACTER(len=32) :: res
568 IF (grid_output == grid_output_cubes)
THEN
570 ELSE IF (grid_output == grid_output_openpmd)
THEN
571 res =
"%WRITE_OPENPMD"
573 END FUNCTION section_key_do_write
582 SUBROUTINE print_density_output_message(output_unit, prefix, e_density_section, filename)
583 INTEGER,
INTENT(IN) :: output_unit
584 CHARACTER(len=*),
INTENT(IN) :: prefix
585 TYPE(cp_section_key),
INTENT(IN) :: e_density_section
586 CHARACTER(len=*),
INTENT(IN) :: filename
588 IF (e_density_section%grid_output == grid_output_openpmd)
THEN
589 WRITE (unit=output_unit, fmt=
"(/,T2,A)") &
590 trim(prefix)//
" is written in " &
591 //e_density_section%format_name &
592 //
" file format to the file / file pattern:", &
595 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
596 trim(prefix)//
" is written in " &
597 //e_density_section%format_name &
598 //
" file format to the file:", &
601 END SUBROUTINE print_density_output_message
624 CHARACTER(6),
OPTIONAL :: wf_type
625 LOGICAL,
OPTIONAL :: do_mp2
627 CHARACTER(len=*),
PARAMETER :: routinen =
'scf_post_calculation_gpw', &
628 warning_cube_kpoint =
"Print MO cubes not implemented for k-point calculations", &
629 warning_openpmd_kpoint =
"Writing to openPMD not implemented for k-point calculations"
631 INTEGER :: handle, homo, ispin, min_lumos, n_rep, &
632 nchk_nmoloc, nhomo, nlumo, nlumo_stm, &
633 nlumos, nmo, nspins, output_unit, &
635 INTEGER,
DIMENSION(:, :, :),
POINTER :: marked_states
636 LOGICAL :: check_write, compute_lumos, do_homo, do_kpoints,
do_mixed, do_stm, &
637 do_wannier_cubes, has_homo, has_lumo, loc_explicit, loc_print_explicit, my_do_mp2, &
638 my_localized_wfn, p_loc, p_loc_homo, p_loc_lumo, p_loc_mixed
640 REAL(kind=
dp) :: gap, homo_lumo(2, 2), total_zeff_corr
641 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
644 TYPE(
cp_1d_r_p_type),
DIMENSION(:),
POINTER :: mixed_evals, occupied_evals, &
645 unoccupied_evals, unoccupied_evals_stm
646 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: mixed_orbs, occupied_orbs
647 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:), &
648 TARGET :: homo_localized, lumo_localized, &
650 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: lumo_ptr, mo_loc_history, &
651 unoccupied_orbs, unoccupied_orbs_stm
654 TYPE(cp_section_key) :: mo_section
655 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_p_mp2, matrix_s, &
657 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: kinetic_m, rho_ao
669 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
678 localize_section, print_key, &
681 CALL timeset(routinen, handle)
688 IF (
PRESENT(do_mp2)) my_do_mp2 = do_mp2
689 IF (
PRESENT(wf_type))
THEN
690 IF (output_unit > 0)
THEN
691 WRITE (unit=output_unit, fmt=
'(/,(T1,A))') repeat(
"-", 40)
692 WRITE (unit=output_unit, fmt=
'(/,(T3,A,T19,A,T25,A))')
"Properties from ", wf_type,
" density"
693 WRITE (unit=output_unit, fmt=
'(/,(T1,A))') repeat(
"-", 40)
700 my_localized_wfn = .false.
701 NULLIFY (admm_env, dft_control, pw_env, auxbas_pw_pool, pw_pools, mos, rho, &
702 mo_coeff, ks_rmpv, matrix_s, qs_loc_env_homo, qs_loc_env_lumo, scf_control, &
703 unoccupied_orbs, mo_eigenvalues, unoccupied_evals, &
704 unoccupied_evals_stm, molecule_set, mo_derivs, &
705 subsys, particles, input, print_key, kinetic_m, marked_states, &
706 mixed_evals, qs_loc_env_mixed)
707 NULLIFY (lumo_ptr, rho_ao)
714 p_loc_mixed = .false.
716 cpassert(
ASSOCIATED(scf_env))
717 cpassert(
ASSOCIATED(qs_env))
720 dft_control=dft_control, &
721 molecule_set=molecule_set, &
722 scf_control=scf_control, &
723 do_kpoints=do_kpoints, &
728 particle_set=particle_set, &
729 atomic_kind_set=atomic_kind_set, &
730 qs_kind_set=qs_kind_set)
731 rtp_control => dft_control%rtp_control
738 CALL get_qs_env(qs_env, matrix_p_mp2=matrix_p_mp2)
739 DO ispin = 1, dft_control%nspins
740 CALL dbcsr_add(rho_ao(ispin, 1)%matrix, matrix_p_mp2(ispin)%matrix, 1.0_dp, 1.0_dp)
745 CALL update_hartree_with_mp2(rho, qs_env)
748 CALL write_available_results(qs_env, scf_env)
752 "DFT%PRINT%KINETIC_ENERGY") /= 0)
THEN
754 cpassert(
ASSOCIATED(kinetic_m))
755 cpassert(
ASSOCIATED(kinetic_m(1, 1)%matrix))
759 IF (unit_nr > 0)
THEN
760 WRITE (unit_nr,
'(T3,A,T55,F25.14)')
"Electronic kinetic energy:", e_kin
763 "DFT%PRINT%KINETIC_ENERGY")
767 CALL qs_scf_post_charges(input, logger, qs_env)
780 IF (loc_print_explicit)
THEN
802 IF (loc_explicit)
THEN
812 p_loc_mixed = .false.
816 IF (n_rep == 0 .AND. p_loc_lumo)
THEN
817 CALL cp_abort(__location__,
"No LIST_UNOCCUPIED was specified, "// &
818 "therefore localization of unoccupied states will be skipped!")
829 mo_section = cube_or_openpmd(input, str_mo_cubes, str_mo_openpmd, logger)
831 IF (loc_print_explicit)
THEN
835 do_wannier_cubes = .false.
837 nlumo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NLUMO"))
838 nhomo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NHOMO"))
841 IF (((mo_section%do_output .OR. do_wannier_cubes) .AND. (nlumo /= 0 .OR. nhomo /= 0)) .OR. p_loc)
THEN
842 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
844 CALL auxbas_pw_pool%create_pw(wf_r)
845 CALL auxbas_pw_pool%create_pw(wf_g)
848 IF (dft_control%restricted)
THEN
852 nspins = dft_control%nspins
855 IF (dft_control%restricted .AND. (mo_section%do_output .OR. p_loc_homo))
THEN
856 CALL cp_abort(__location__,
"Unclear how we define MOs / localization in the restricted case ... ")
861 cpwarn_if(mo_section%do_cubes(), warning_cube_kpoint)
862 cpwarn_if(mo_section%do_openpmd(), warning_openpmd_kpoint)
867 IF ((mo_section%do_output .AND. nhomo /= 0) .OR. do_stm)
THEN
869 IF (dft_control%do_admm)
THEN
871 CALL make_mo_eig(mos, nspins, ks_rmpv, scf_control, mo_derivs, admm_env=admm_env)
873 IF (dft_control%hairy_probes)
THEN
874 scf_control%smear%do_smear = .false.
875 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs, &
877 probe=dft_control%probe)
879 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
882 DO ispin = 1, dft_control%nspins
883 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=homo)
884 homo_lumo(ispin, 1) = mo_eigenvalues(homo)
888 IF (mo_section%do_output .AND. nhomo /= 0)
THEN
891 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
892 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
893 CALL qs_scf_post_occ_cubes(input, dft_section, dft_control, logger, qs_env, &
894 mo_coeff, wf_g, wf_r, particles, homo, ispin, mo_section)
905 cpwarn(
"Localization not implemented for k-point calculations!")
906 ELSEIF (dft_control%restricted &
909 cpabort(
"ROKS works only with LOCALIZE METHOD NONE or JACOBI")
911 ALLOCATE (occupied_orbs(dft_control%nspins))
912 ALLOCATE (occupied_evals(dft_control%nspins))
913 ALLOCATE (homo_localized(dft_control%nspins))
914 DO ispin = 1, dft_control%nspins
915 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
916 eigenvalues=mo_eigenvalues)
917 occupied_orbs(ispin) = mo_coeff
918 occupied_evals(ispin)%array => mo_eigenvalues
919 CALL cp_fm_create(homo_localized(ispin), occupied_orbs(ispin)%matrix_struct)
920 CALL cp_fm_to_fm(occupied_orbs(ispin), homo_localized(ispin))
923 CALL get_qs_env(qs_env, mo_loc_history=mo_loc_history)
926 ALLOCATE (qs_loc_env_homo)
929 CALL qs_loc_init(qs_env, qs_loc_env_homo, localize_section, homo_localized, do_homo, &
930 mo_section%do_output, mo_loc_history=mo_loc_history)
932 wf_r, wf_g, particles, occupied_orbs, occupied_evals, marked_states)
935 IF (qs_loc_env_homo%localized_wfn_control%use_history)
THEN
937 CALL set_qs_env(qs_env, mo_loc_history=mo_loc_history)
942 homo_localized, do_homo)
944 DEALLOCATE (occupied_orbs)
945 DEALLOCATE (occupied_evals)
947 IF (qs_loc_env_homo%do_localize)
THEN
948 CALL loc_dipole(input, dft_control, qs_loc_env_homo, logger, qs_env)
955 IF (mo_section%do_output .OR. p_loc_lumo)
THEN
957 cpwarn(
"Localization and MO related output not implemented for k-point calculations!")
960 compute_lumos = mo_section%do_output .AND. nlumo /= 0
961 compute_lumos = compute_lumos .OR. p_loc_lumo
963 DO ispin = 1, dft_control%nspins
964 CALL get_mo_set(mo_set=mos(ispin), homo=homo, nmo=nmo)
965 compute_lumos = compute_lumos .AND. homo == nmo
968 IF (mo_section%do_output .AND. .NOT. compute_lumos)
THEN
970 nlumo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NLUMO"))
971 DO ispin = 1, dft_control%nspins
973 CALL get_mo_set(mo_set=mos(ispin), homo=homo, nmo=nmo, eigenvalues=mo_eigenvalues)
974 IF (nlumo > nmo - homo)
THEN
977 IF (nlumo == -1)
THEN
980 IF (output_unit > 0)
WRITE (output_unit, *)
" "
981 IF (output_unit > 0)
WRITE (output_unit, *)
" Lowest eigenvalues of the unoccupied subspace spin ", ispin
982 IF (output_unit > 0)
WRITE (output_unit, *)
"---------------------------------------------"
983 IF (output_unit > 0)
WRITE (output_unit,
'(4(1X,1F16.8))') mo_eigenvalues(homo + 1:homo + nlumo)
986 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
987 CALL qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
988 mo_coeff, wf_g, wf_r, particles, nlumo, homo, ispin, lumo=homo + 1, mo_section=mo_section)
994 IF (compute_lumos)
THEN
997 IF (nlumo == 0) check_write = .false.
1000 ALLOCATE (qs_loc_env_lumo)
1003 min_lumos = max(maxval(qs_loc_env_lumo%localized_wfn_control%loc_states(:, :)), nlumo)
1006 ALLOCATE (unoccupied_orbs(dft_control%nspins))
1007 ALLOCATE (unoccupied_evals(dft_control%nspins))
1008 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, min_lumos, nlumos)
1009 lumo_ptr => unoccupied_orbs
1010 DO ispin = 1, dft_control%nspins
1012 homo_lumo(ispin, 2) = unoccupied_evals(ispin)%array(1)
1013 CALL get_mo_set(mo_set=mos(ispin), homo=homo)
1014 IF (check_write)
THEN
1015 IF (p_loc_lumo .AND. nlumo /= -1) nlumos = min(nlumo, nlumos)
1017 CALL qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
1018 unoccupied_orbs(ispin), wf_g, wf_r, particles, nlumos, homo, ispin, mo_section=mo_section)
1022 IF (p_loc_lumo)
THEN
1023 ALLOCATE (lumo_localized(dft_control%nspins))
1024 DO ispin = 1, dft_control%nspins
1025 CALL cp_fm_create(lumo_localized(ispin), unoccupied_orbs(ispin)%matrix_struct)
1026 CALL cp_fm_to_fm(unoccupied_orbs(ispin), lumo_localized(ispin))
1028 CALL qs_loc_init(qs_env, qs_loc_env_lumo, localize_section, lumo_localized, do_homo, mo_section%do_output, &
1029 evals=unoccupied_evals)
1030 CALL qs_loc_env_init(qs_loc_env_lumo, qs_loc_env_lumo%localized_wfn_control, qs_env, &
1031 loc_coeff=unoccupied_orbs)
1033 lumo_localized, wf_r, wf_g, particles, &
1034 unoccupied_orbs, unoccupied_evals, marked_states)
1035 CALL loc_write_restart(qs_loc_env_lumo, loc_print_section, mos, homo_localized, do_homo, &
1036 evals=unoccupied_evals)
1037 lumo_ptr => lumo_localized
1041 IF (has_homo .AND. has_lumo)
THEN
1042 IF (output_unit > 0)
WRITE (output_unit, *)
" "
1043 DO ispin = 1, dft_control%nspins
1044 IF (.NOT. scf_control%smear%do_smear)
THEN
1045 gap = homo_lumo(ispin, 2) - homo_lumo(ispin, 1)
1046 IF (output_unit > 0)
WRITE (output_unit,
'(T2,A,F12.6)') &
1047 "HOMO - LUMO gap [eV] :", gap*
evolt
1053 IF (p_loc_mixed)
THEN
1054 IF (do_kpoints)
THEN
1055 cpwarn(
"Localization not implemented for k-point calculations!")
1056 ELSEIF (dft_control%restricted)
THEN
1057 IF (output_unit > 0)
WRITE (output_unit, *) &
1058 " Unclear how we define MOs / localization in the restricted case... skipping"
1061 ALLOCATE (mixed_orbs(dft_control%nspins))
1062 ALLOCATE (mixed_evals(dft_control%nspins))
1063 ALLOCATE (mixed_localized(dft_control%nspins))
1064 DO ispin = 1, dft_control%nspins
1065 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1066 eigenvalues=mo_eigenvalues)
1067 mixed_orbs(ispin) = mo_coeff
1068 mixed_evals(ispin)%array => mo_eigenvalues
1069 CALL cp_fm_create(mixed_localized(ispin), mixed_orbs(ispin)%matrix_struct)
1070 CALL cp_fm_to_fm(mixed_orbs(ispin), mixed_localized(ispin))
1073 CALL get_qs_env(qs_env, mo_loc_history=mo_loc_history)
1076 total_zeff_corr = scf_env%sum_zeff_corr
1077 ALLOCATE (qs_loc_env_mixed)
1080 CALL qs_loc_init(qs_env, qs_loc_env_mixed, localize_section, mixed_localized, do_homo, &
1081 mo_section%do_output, mo_loc_history=mo_loc_history, tot_zeff_corr=total_zeff_corr, &
1084 DO ispin = 1, dft_control%nspins
1085 CALL cp_fm_get_info(mixed_localized(ispin), ncol_global=nchk_nmoloc)
1089 wf_r, wf_g, particles, mixed_orbs, mixed_evals, marked_states)
1092 IF (qs_loc_env_mixed%localized_wfn_control%use_history)
THEN
1094 CALL set_qs_env(qs_env, mo_loc_history=mo_loc_history)
1101 DEALLOCATE (mixed_orbs)
1102 DEALLOCATE (mixed_evals)
1107 IF (((mo_section%do_output .OR. do_wannier_cubes) .AND. (nlumo /= 0 .OR. nhomo /= 0)) .OR. p_loc)
THEN
1108 CALL auxbas_pw_pool%give_back_pw(wf_r)
1109 CALL auxbas_pw_pool%give_back_pw(wf_g)
1113 IF (.NOT. do_kpoints)
THEN
1114 IF (p_loc_homo)
THEN
1116 DEALLOCATE (qs_loc_env_homo)
1118 IF (p_loc_lumo)
THEN
1120 DEALLOCATE (qs_loc_env_lumo)
1122 IF (p_loc_mixed)
THEN
1124 DEALLOCATE (qs_loc_env_mixed)
1129 IF (do_kpoints)
THEN
1132 CALL get_qs_env(qs_env, matrix_s=matrix_s, para_env=para_env)
1133 CALL wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, &
1134 output_unit, unoccupied_orbs=lumo_ptr, scf_env=scf_env, &
1135 matrix_s=matrix_s, marked_states=marked_states)
1139 IF (
ASSOCIATED(marked_states))
THEN
1140 DEALLOCATE (marked_states)
1144 IF (.NOT. do_kpoints)
THEN
1145 IF (compute_lumos)
THEN
1146 DO ispin = 1, dft_control%nspins
1147 DEALLOCATE (unoccupied_evals(ispin)%array)
1150 DEALLOCATE (unoccupied_evals)
1151 DEALLOCATE (unoccupied_orbs)
1157 IF (do_kpoints)
THEN
1158 cpwarn(
"STM not implemented for k-point calculations!")
1160 NULLIFY (unoccupied_orbs_stm, unoccupied_evals_stm)
1161 IF (nlumo_stm > 0)
THEN
1162 ALLOCATE (unoccupied_orbs_stm(dft_control%nspins))
1163 ALLOCATE (unoccupied_evals_stm(dft_control%nspins))
1164 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs_stm, unoccupied_evals_stm, &
1168 CALL th_stm_image(qs_env, stm_section, particles, unoccupied_orbs_stm, &
1169 unoccupied_evals_stm)
1171 IF (nlumo_stm > 0)
THEN
1172 DO ispin = 1, dft_control%nspins
1173 DEALLOCATE (unoccupied_evals_stm(ispin)%array)
1175 DEALLOCATE (unoccupied_evals_stm)
1182 CALL qs_scf_post_xray(input, dft_section, logger, qs_env, output_unit)
1185 CALL qs_scf_post_efg(input, logger, qs_env)
1188 CALL qs_scf_post_et(input, qs_env, dft_control)
1191 CALL qs_scf_post_epr(input, logger, qs_env)
1194 CALL qs_scf_post_molopt(input, logger, qs_env)
1197 CALL qs_scf_post_elf(input, logger, qs_env)
1204 DO ispin = 1, dft_control%nspins
1205 CALL dbcsr_add(rho_ao(ispin, 1)%matrix, matrix_p_mp2(ispin)%matrix, 1.0_dp, -1.0_dp)
1213 CALL timestop(handle)
1226 SUBROUTINE make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
1230 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: unoccupied_orbs
1232 INTEGER,
INTENT(IN) :: nlumo
1233 INTEGER,
INTENT(OUT) :: nlumos
1235 CHARACTER(len=*),
PARAMETER :: routinen =
'make_lumo_gpw'
1237 INTEGER :: handle, homo, ispin, n, nao, nmo, &
1244 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_s
1251 CALL timeset(routinen, handle)
1253 NULLIFY (ks_rmpv, matrix_s, scf_control, dft_control, admm_env, para_env, blacs_env, mos)
1255 matrix_ks=ks_rmpv, &
1256 matrix_s=matrix_s, &
1257 scf_control=scf_control, &
1258 dft_control=dft_control, &
1259 admm_env=admm_env, &
1260 para_env=para_env, &
1261 blacs_env=blacs_env, &
1267 DO ispin = 1, dft_control%nspins
1268 NULLIFY (unoccupied_evals(ispin)%array)
1269 IF (output_unit > 0)
WRITE (output_unit, *)
" "
1270 IF (output_unit > 0)
WRITE (output_unit, *) &
1271 " Using OT eigensolver for additional unoccupied orbitals spin ", ispin
1272 IF (output_unit > 0)
WRITE (output_unit, *) &
1273 " Lowest Eigenvalues of the unoccupied subspace spin ", ispin
1274 IF (output_unit > 0)
WRITE (output_unit, fmt=
'(1X,A)')
"-----------------------------------------------------"
1275 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=homo, nao=nao, nmo=nmo)
1277 nlumos = max(1, min(nlumo, nao - nmo))
1278 IF (nlumo == -1) nlumos = nao - nmo
1279 ALLOCATE (unoccupied_evals(ispin)%array(nlumos))
1281 nrow_global=n, ncol_global=nlumos)
1282 CALL cp_fm_create(unoccupied_orbs(ispin), fm_struct_tmp, name=
"lumos")
1287 NULLIFY (local_preconditioner)
1288 IF (
ASSOCIATED(scf_env))
THEN
1289 IF (
ASSOCIATED(scf_env%ot_preconditioner))
THEN
1290 local_preconditioner => scf_env%ot_preconditioner(1)%preconditioner
1293 NULLIFY (local_preconditioner)
1299 IF (dft_control%do_admm)
THEN
1303 CALL ot_eigensolver(matrix_h=ks_rmpv(ispin)%matrix, matrix_s=matrix_s(1)%matrix, &
1304 matrix_c_fm=unoccupied_orbs(ispin), &
1305 matrix_orthogonal_space_fm=mo_coeff, &
1306 eps_gradient=scf_control%eps_lumos, &
1308 iter_max=scf_control%max_iter_lumos, &
1309 size_ortho_space=nmo)
1312 unoccupied_evals(ispin)%array, scr=output_unit, &
1313 ionode=output_unit > 0)
1316 IF (dft_control%do_admm)
THEN
1322 CALL timestop(handle)
1332 SUBROUTINE qs_scf_post_charges(input, logger, qs_env)
1337 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_charges'
1339 INTEGER :: handle, print_level, unit_nr
1340 LOGICAL :: do_kpoints, print_it
1343 CALL timeset(routinen, handle)
1345 CALL get_qs_env(qs_env=qs_env, do_kpoints=do_kpoints)
1353 log_filename=.false.)
1356 IF (print_it) print_level = 2
1358 IF (print_it) print_level = 3
1369 unit_nr =
cp_print_key_unit_nr(logger, input,
"PROPERTIES%FIT_CHARGE", extension=
".Fitcharge", &
1370 log_filename=.false.)
1372 CALL get_ddapc(qs_env, .false., density_fit_section, iwc=unit_nr)
1376 CALL timestop(handle)
1378 END SUBROUTINE qs_scf_post_charges
1395 SUBROUTINE qs_scf_post_occ_cubes(input, dft_section, dft_control, logger, qs_env, &
1396 mo_coeff, wf_g, wf_r, particles, homo, ispin, mo_section)
1405 INTEGER,
INTENT(IN) :: homo, ispin
1406 TYPE(cp_section_key) :: mo_section
1408 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_occ_cubes'
1410 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1411 INTEGER :: handle, i, ir, ivector, n_rep, nhomo, &
1413 INTEGER,
DIMENSION(:),
POINTER ::
list, list_index
1414 LOGICAL :: append_cube, mpi_io
1419 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1421 CALL timeset(routinen, handle)
1426 cpassert(mo_section%grid_output /= grid_output_openpmd)
1429 NULLIFY (list_index)
1432 ,
cp_p_file) .AND.
section_get_lval(dft_section, mo_section%concat_to_relative(section_key_do_write(mo_section%grid_output))))
THEN
1433 nhomo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NHOMO"))
1435 IF (mo_section%grid_output == grid_output_cubes)
THEN
1436 append_cube =
section_get_lval(dft_section, mo_section%concat_to_relative(
"%APPEND"))
1438 my_pos_cube =
"REWIND"
1439 IF (append_cube)
THEN
1440 my_pos_cube =
"APPEND"
1442 CALL section_vals_val_get(dft_section, mo_section%concat_to_relative(
"%HOMO_LIST"), n_rep_val=n_rep)
1447 CALL section_vals_val_get(dft_section, mo_section%concat_to_relative(
"%HOMO_LIST"), i_rep_val=ir, &
1449 IF (
ASSOCIATED(
list))
THEN
1451 DO i = 1,
SIZE(
list)
1452 list_index(i + nlist) =
list(i)
1454 nlist = nlist +
SIZE(
list)
1459 IF (nhomo == -1) nhomo = homo
1460 nlist = homo - max(1, homo - nhomo + 1) + 1
1461 ALLOCATE (list_index(nlist))
1463 list_index(i) = max(1, homo - nhomo + 1) + i - 1
1467 ivector = list_index(i)
1469 atomic_kind_set=atomic_kind_set, &
1470 qs_kind_set=qs_kind_set, &
1472 particle_set=particle_set, &
1475 cell, dft_control, particle_set, pw_env)
1476 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", ivector,
"_", ispin
1479 unit_nr = mo_section%print_key_unit_nr( &
1482 mo_section%absolute_section_key, &
1483 extension=
".cube", &
1484 middle_name=trim(filename), &
1485 file_position=my_pos_cube, &
1486 log_filename=.false., &
1488 openpmd_basename=
"dft-mo", &
1489 openpmd_unit_dimension=openpmd_unit_dimension_wavefunction, &
1490 openpmd_unit_si=openpmd_unit_si_wavefunction, &
1491 sim_time=qs_env%sim_time)
1492 WRITE (title, *)
"WAVEFUNCTION ", ivector,
" spin ", ispin,
" i.e. HOMO - ", ivector - homo
1493 CALL mo_section%write_pw(wf_r, unit_nr, title, particles=particles, &
1494 stride=
section_get_ivals(dft_section, mo_section%concat_to_relative(
"%STRIDE")), &
1495 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%MO_CUBES%MAX_FILE_SIZE_MB"), &
1497 CALL mo_section%print_key_finished_output(unit_nr, logger, input, mo_section%absolute_section_key, mpi_io=mpi_io)
1499 IF (
ASSOCIATED(list_index))
DEALLOCATE (list_index)
1502 CALL timestop(handle)
1504 END SUBROUTINE qs_scf_post_occ_cubes
1523 SUBROUTINE qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
1524 unoccupied_orbs, wf_g, wf_r, particles, nlumos, homo, ispin, lumo, mo_section)
1530 TYPE(
cp_fm_type),
INTENT(IN) :: unoccupied_orbs
1534 INTEGER,
INTENT(IN) :: nlumos, homo, ispin
1535 INTEGER,
INTENT(IN),
OPTIONAL :: lumo
1536 TYPE(cp_section_key) :: mo_section
1538 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_unocc_cubes'
1540 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1541 INTEGER :: handle, ifirst, index_mo, ivector, &
1543 LOGICAL :: append_cube, mpi_io
1548 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1550 CALL timeset(routinen, handle)
1555 cpassert(mo_section%grid_output /= grid_output_openpmd)
1559 .AND.
section_get_lval(dft_section, mo_section%concat_to_relative(section_key_do_write(mo_section%grid_output))))
THEN
1560 NULLIFY (qs_kind_set, particle_set, pw_env, cell)
1562 IF (mo_section%grid_output == grid_output_cubes)
THEN
1563 append_cube =
section_get_lval(dft_section, mo_section%concat_to_relative(
"%APPEND"))
1565 my_pos_cube =
"REWIND"
1566 IF (append_cube)
THEN
1567 my_pos_cube =
"APPEND"
1570 IF (
PRESENT(lumo)) ifirst = lumo
1571 DO ivector = ifirst, ifirst + nlumos - 1
1573 atomic_kind_set=atomic_kind_set, &
1574 qs_kind_set=qs_kind_set, &
1576 particle_set=particle_set, &
1579 qs_kind_set, cell, dft_control, particle_set, pw_env)
1581 IF (ifirst == 1)
THEN
1582 index_mo = homo + ivector
1586 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", index_mo,
"_", ispin
1589 unit_nr = mo_section%print_key_unit_nr( &
1592 mo_section%absolute_section_key, &
1593 extension=
".cube", &
1594 middle_name=trim(filename), &
1595 file_position=my_pos_cube, &
1596 log_filename=.false., &
1598 openpmd_basename=
"dft-mo", &
1599 openpmd_unit_dimension=openpmd_unit_dimension_wavefunction, &
1600 openpmd_unit_si=openpmd_unit_si_wavefunction, &
1601 sim_time=qs_env%sim_time)
1602 WRITE (title, *)
"WAVEFUNCTION ", index_mo,
" spin ", ispin,
" i.e. LUMO + ", ifirst + ivector - 2
1603 CALL mo_section%write_pw(wf_r, unit_nr, title, particles=particles, &
1604 stride=
section_get_ivals(dft_section, mo_section%concat_to_relative(
"%STRIDE")), &
1605 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%MO_CUBES%MAX_FILE_SIZE_MB"), &
1607 CALL mo_section%print_key_finished_output(unit_nr, logger, input, mo_section%absolute_section_key, mpi_io=mpi_io)
1612 CALL timestop(handle)
1614 END SUBROUTINE qs_scf_post_unocc_cubes
1627 INTEGER,
INTENT(IN) :: output_unit
1629 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_moments'
1631 CHARACTER(LEN=default_path_length) :: filename
1632 INTEGER :: handle, max_nmo, maxmom, reference, &
1634 LOGICAL :: com_nl, do_kg, do_kpoints, magnetic, &
1635 periodic, second_ref_point, vel_reprs
1636 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ref_point
1639 CALL timeset(routinen, handle)
1642 subsection_name=
"DFT%PRINT%MOMENTS")
1647 keyword_name=
"DFT%PRINT%MOMENTS%MAX_MOMENT")
1649 keyword_name=
"DFT%PRINT%MOMENTS%PERIODIC")
1651 keyword_name=
"DFT%PRINT%MOMENTS%REFERENCE")
1653 keyword_name=
"DFT%PRINT%MOMENTS%MAGNETIC")
1655 keyword_name=
"DFT%PRINT%MOMENTS%VEL_REPRS")
1657 keyword_name=
"DFT%PRINT%MOMENTS%COM_NL")
1659 keyword_name=
"DFT%PRINT%MOMENTS%SECOND_REFERENCE_POINT")
1661 keyword_name=
"DFT%PRINT%MOMENTS%KG")
1663 keyword_name=
"DFT%PRINT%MOMENTS%MAX_NMO")
1668 print_key_path=
"DFT%PRINT%MOMENTS", extension=
".dat", &
1669 middle_name=
"moments", log_filename=.false.)
1671 IF (output_unit > 0)
THEN
1672 IF (unit_nr /= output_unit)
THEN
1673 INQUIRE (unit=unit_nr, name=filename)
1674 WRITE (unit=output_unit, fmt=
"(/,T2,A,2(/,T3,A),/)") &
1675 "MOMENTS",
"The electric/magnetic moments are written to file:", &
1678 WRITE (unit=output_unit, fmt=
"(/,T2,A)")
"ELECTRIC/MAGNETIC MOMENTS"
1682 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
1684 IF (do_kpoints)
THEN
1690 CALL qs_moment_locop(qs_env, magnetic, maxmom, reference, ref_point, unit_nr, vel_reprs, com_nl)
1698 basis_section=input, print_key_path=
"DFT%PRINT%MOMENTS")
1700 IF (second_ref_point)
THEN
1702 keyword_name=
"DFT%PRINT%MOMENTS%REFERENCE_2")
1707 print_key_path=
"DFT%PRINT%MOMENTS", extension=
".dat", &
1708 middle_name=
"moments_refpoint_2", log_filename=.false.)
1710 IF (output_unit > 0)
THEN
1711 IF (unit_nr /= output_unit)
THEN
1712 INQUIRE (unit=unit_nr, name=filename)
1713 WRITE (unit=output_unit, fmt=
"(/,T2,A,2(/,T3,A),/)") &
1714 "MOMENTS",
"The electric/magnetic moments for the second reference point are written to file:", &
1717 WRITE (unit=output_unit, fmt=
"(/,T2,A)")
"ELECTRIC/MAGNETIC MOMENTS"
1720 IF (do_kpoints)
THEN
1726 CALL qs_moment_locop(qs_env, magnetic, maxmom, reference, ref_point, unit_nr, vel_reprs, com_nl)
1730 basis_section=input, print_key_path=
"DFT%PRINT%MOMENTS")
1735 CALL timestop(handle)
1747 SUBROUTINE qs_scf_post_xray(input, dft_section, logger, qs_env, output_unit)
1752 INTEGER,
INTENT(IN) :: output_unit
1754 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_scf_post_xray'
1756 CHARACTER(LEN=default_path_length) :: filename
1757 INTEGER :: handle, unit_nr
1758 REAL(kind=
dp) :: q_max
1761 CALL timeset(routinen, handle)
1764 subsection_name=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM")
1768 keyword_name=
"PRINT%XRAY_DIFFRACTION_SPECTRUM%Q_MAX")
1770 basis_section=input, &
1771 print_key_path=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM", &
1773 middle_name=
"xrd", &
1774 log_filename=.false.)
1775 IF (output_unit > 0)
THEN
1776 INQUIRE (unit=unit_nr, name=filename)
1777 WRITE (unit=output_unit, fmt=
"(/,/,T2,A)") &
1778 "X-RAY DIFFRACTION SPECTRUM"
1779 IF (unit_nr /= output_unit)
THEN
1780 WRITE (unit=output_unit, fmt=
"(/,T3,A,/,/,T3,A,/)") &
1781 "The coherent X-ray diffraction spectrum is written to the file:", &
1786 unit_number=unit_nr, &
1790 basis_section=input, &
1791 print_key_path=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM")
1794 CALL timestop(handle)
1796 END SUBROUTINE qs_scf_post_xray
1804 SUBROUTINE qs_scf_post_efg(input, logger, qs_env)
1809 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_efg'
1814 CALL timeset(routinen, handle)
1817 subsection_name=
"DFT%PRINT%ELECTRIC_FIELD_GRADIENT")
1823 CALL timestop(handle)
1825 END SUBROUTINE qs_scf_post_efg
1833 SUBROUTINE qs_scf_post_et(input, qs_env, dft_control)
1838 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_et'
1840 INTEGER :: handle, ispin
1842 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: my_mos
1845 CALL timeset(routinen, handle)
1851 IF (qs_env%et_coupling%first_run)
THEN
1853 ALLOCATE (my_mos(dft_control%nspins))
1854 ALLOCATE (qs_env%et_coupling%et_mo_coeff(dft_control%nspins))
1855 DO ispin = 1, dft_control%nspins
1857 matrix_struct=qs_env%mos(ispin)%mo_coeff%matrix_struct, &
1858 name=
"FIRST_RUN_COEFF"//trim(adjustl(
cp_to_string(ispin)))//
"MATRIX")
1867 CALL timestop(handle)
1869 END SUBROUTINE qs_scf_post_et
1880 SUBROUTINE qs_scf_post_elf(input, logger, qs_env)
1885 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_elf'
1887 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
1889 INTEGER :: handle, ispin, output_unit, unit_nr
1890 LOGICAL :: append_cube, gapw, mpi_io
1891 REAL(
dp) :: rho_cutoff
1892 TYPE(cp_section_key) :: elf_section_key
1902 CALL timeset(routinen, handle)
1905 elf_section_key = cube_or_openpmd(input, str_elf_cubes, str_elf_openpmd, logger)
1908 IF (elf_section_key%do_output)
THEN
1910 NULLIFY (dft_control, pw_env, auxbas_pw_pool, pw_pools, particles, subsys)
1911 CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env, subsys=subsys)
1914 gapw = dft_control%qs_control%gapw
1915 IF (.NOT. gapw)
THEN
1917 ALLOCATE (elf_r(dft_control%nspins))
1918 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
1920 DO ispin = 1, dft_control%nspins
1921 CALL auxbas_pw_pool%create_pw(elf_r(ispin))
1925 IF (output_unit > 0)
THEN
1926 WRITE (unit=output_unit, fmt=
"(/,T15,A,/)") &
1927 " ----- ELF is computed on the real space grid -----"
1935 IF (elf_section_key%grid_output == grid_output_cubes)
THEN
1938 my_pos_cube =
"REWIND"
1939 IF (append_cube)
THEN
1940 my_pos_cube =
"APPEND"
1943 DO ispin = 1, dft_control%nspins
1944 WRITE (filename,
'(a5,I1.1)')
"ELF_S", ispin
1945 WRITE (title, *)
"ELF spin ", ispin
1947 unit_nr = elf_section_key%print_key_unit_nr( &
1950 elf_section_key%absolute_section_key, &
1951 extension=
".cube", &
1952 middle_name=trim(filename), &
1953 file_position=my_pos_cube, &
1954 log_filename=.false., &
1956 fout=mpi_filename, &
1957 openpmd_basename=
"dft-elf", &
1958 openpmd_unit_dimension=openpmd_unit_dimension_dimensionless, &
1959 openpmd_unit_si=openpmd_unit_si_dimensionless, &
1960 sim_time=qs_env%sim_time)
1961 IF (output_unit > 0)
THEN
1962 IF (.NOT. mpi_io)
THEN
1963 INQUIRE (unit=unit_nr, name=filename)
1965 filename = mpi_filename
1967 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
1968 "ELF is written in "//elf_section_key%format_name//
" file format to the file:", &
1972 CALL elf_section_key%write_pw(elf_r(ispin), unit_nr, title, particles=particles, &
1974 CALL elf_section_key%print_key_finished_output( &
1978 elf_section_key%absolute_section_key, &
1981 CALL auxbas_pw_pool%give_back_pw(elf_r(ispin))
1989 cpwarn(
"ELF not implemented for GAPW calculations!")
1994 CALL timestop(handle)
1996 END SUBROUTINE qs_scf_post_elf
2008 SUBROUTINE qs_scf_post_molopt(input, logger, qs_env)
2013 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_molopt'
2015 INTEGER :: handle, nao, unit_nr
2016 REAL(kind=
dp) :: s_cond_number
2017 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
2026 CALL timeset(routinen, handle)
2029 subsection_name=
"DFT%PRINT%BASIS_MOLOPT_QUANTITIES")
2033 CALL get_qs_env(qs_env, energy=energy, matrix_s=matrix_s, mos=mos)
2036 CALL get_mo_set(mo_set=mos(1), mo_coeff=mo_coeff, nao=nao)
2038 nrow_global=nao, ncol_global=nao, &
2039 template_fmstruct=mo_coeff%matrix_struct)
2040 CALL cp_fm_create(fm_s, matrix_struct=ao_ao_fmstruct, &
2042 CALL cp_fm_create(fm_work, matrix_struct=ao_ao_fmstruct, &
2045 ALLOCATE (eigenvalues(nao))
2053 s_cond_number = maxval(abs(eigenvalues))/max(minval(abs(eigenvalues)), epsilon(0.0_dp))
2056 extension=
".molopt")
2058 IF (unit_nr > 0)
THEN
2061 WRITE (unit_nr,
'(T2,A28,2A25)')
"",
"Tot. Ener.",
"S Cond. Numb."
2062 WRITE (unit_nr,
'(T2,A28,2E25.17)')
"BASIS_MOLOPT_QUANTITIES", energy%total, s_cond_number
2066 "DFT%PRINT%BASIS_MOLOPT_QUANTITIES")
2070 CALL timestop(handle)
2072 END SUBROUTINE qs_scf_post_molopt
2080 SUBROUTINE qs_scf_post_epr(input, logger, qs_env)
2085 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_epr'
2090 CALL timeset(routinen, handle)
2093 subsection_name=
"DFT%PRINT%HYPERFINE_COUPLING_TENSOR")
2099 CALL timestop(handle)
2101 END SUBROUTINE qs_scf_post_epr
2110 SUBROUTINE write_available_results(qs_env, scf_env)
2114 CHARACTER(len=*),
PARAMETER :: routinen =
'write_available_results'
2118 CALL timeset(routinen, handle)
2126 CALL timestop(handle)
2128 END SUBROUTINE write_available_results
2141 CHARACTER(len=*),
PARAMETER :: routinen =
'write_mo_dependent_results'
2143 INTEGER :: handle, homo, ispin, nlumo_dos, &
2144 nlumo_molden, nlumo_required, nlumos, &
2146 LOGICAL :: all_equal, defer_molden, do_dos, &
2147 do_kpoints, do_pdos, do_pdos_raw, &
2148 do_projected_dos, explicit
2149 REAL(kind=
dp) :: maxocc, s_square, s_square_ideal, &
2150 total_abs_spin_dens, total_spin_dens
2151 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, occupation_numbers
2156 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: unoccupied_orbs
2159 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_s
2173 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2178 dos_section, input, sprint_section, &
2183 CALL timeset(routinen, handle)
2185 NULLIFY (cell, dft_control, pw_env, auxbas_pw_pool, pw_pools, mo_coeff, &
2186 mo_coeff_deriv, mo_eigenvalues, mos, atomic_kind_set, qs_kind_set, &
2187 particle_set, rho, ks_rmpv, matrix_s, scf_control, dft_section, &
2188 molecule_set, input, particles, subsys, rho_r, unoccupied_orbs, &
2189 unoccupied_evals, casino_section, dos_section)
2194 cpassert(
ASSOCIATED(qs_env))
2196 dft_control=dft_control, &
2197 molecule_set=molecule_set, &
2198 atomic_kind_set=atomic_kind_set, &
2199 particle_set=particle_set, &
2200 qs_kind_set=qs_kind_set, &
2201 admm_env=admm_env, &
2202 scf_control=scf_control, &
2211 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
2215 IF (.NOT. qs_env%run_rtp)
THEN
2228 defer_molden = .false.
2229 IF (.NOT. do_kpoints)
THEN
2230 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv)
2234 IF (nlumo_molden /= 0 .AND.
PRESENT(scf_env))
THEN
2235 IF (scf_env%method ==
ot_method_nr) defer_molden = .true.
2237 IF (.NOT. defer_molden)
THEN
2238 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell, &
2239 qs_env=qs_env, calc_energies=.true.)
2248 cpwarn(
"Molden format output is not possible for k-point calculations.")
2252 cpwarn(
"Chargemol .wfx format output is not possible for k-point calculations.")
2259 IF (do_kpoints)
THEN
2263 cpwarn(
"MO_KP is only available for k-point calculations, ignored for Gamma-only")
2274 IF (.NOT. do_kpoints .AND.
PRESENT(scf_env))
THEN
2278 IF (nlumo_dos == -1)
THEN
2280 ELSEIF (nlumo_required /= -1)
THEN
2281 nlumo_required = max(nlumo_required, nlumo_dos)
2285 IF (defer_molden)
THEN
2286 IF (nlumo_molden == -1)
THEN
2288 ELSEIF (nlumo_required /= -1)
THEN
2289 nlumo_required = max(nlumo_required, nlumo_molden)
2292 IF (nlumo_required /= 0)
THEN
2293 ALLOCATE (unoccupied_orbs(dft_control%nspins))
2294 ALLOCATE (unoccupied_evals(dft_control%nspins))
2295 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, &
2296 nlumo_required, nlumos)
2299 IF (do_dos .OR. do_projected_dos)
THEN
2300 DO ispin = 1, dft_control%nspins
2303 IF (dft_control%do_admm)
THEN
2306 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
2307 eigenvalues=mo_eigenvalues)
2308 IF (
ASSOCIATED(qs_env%mo_derivs))
THEN
2309 mo_coeff_deriv => qs_env%mo_derivs(ispin)%matrix
2311 mo_coeff_deriv => null()
2314 do_rotation=.true., &
2315 co_rotate_dbcsr=mo_coeff_deriv)
2317 IF (dft_control%do_admm)
THEN
2325 IF (defer_molden)
THEN
2326 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2327 IF (output_unit > 0)
THEN
2328 WRITE (output_unit,
'(/,T2,A,I6,A)') &
2329 "MO_MOLDEN| Writing ", nlumos,
" unoccupied orbitals to molden file"
2331 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell, &
2332 unoccupied_orbs=unoccupied_orbs, &
2333 unoccupied_evals=unoccupied_evals, &
2334 qs_env=qs_env, calc_energies=.true.)
2340 IF (do_kpoints)
THEN
2344 IF (
ASSOCIATED(unoccupied_evals))
THEN
2345 CALL calculate_dos(mos, dft_section, unoccupied_evals=unoccupied_evals, &
2346 smearing_enabled=dft_control%smear)
2348 CALL calculate_dos(mos, dft_section, smearing_enabled=dft_control%smear)
2354 IF (do_projected_dos)
THEN
2355 IF (do_kpoints)
THEN
2357 write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
2362 DO ispin = 1, dft_control%nspins
2363 IF (dft_control%nspins == 2)
THEN
2364 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2366 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin, &
2367 unoccupied_orbs=unoccupied_orbs(ispin), &
2368 unoccupied_evals=unoccupied_evals(ispin), &
2369 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
2372 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin, &
2373 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
2376 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2378 qs_kind_set, particle_set, qs_env, dft_section, &
2379 unoccupied_orbs=unoccupied_orbs(ispin), &
2380 unoccupied_evals=unoccupied_evals(ispin), &
2381 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
2384 qs_kind_set, particle_set, qs_env, dft_section, &
2385 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
2391 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2392 DO ispin = 1, dft_control%nspins
2393 DEALLOCATE (unoccupied_evals(ispin)%array)
2396 DEALLOCATE (unoccupied_evals)
2397 DEALLOCATE (unoccupied_orbs)
2402 IF (dft_control%nspins == 2)
THEN
2403 total_spin_dens = 0.0_dp
2404 total_abs_spin_dens = 0.0_dp
2405 IF (dft_control%qs_control%gapw)
THEN
2406 CALL get_qs_env(qs_env, qs_charges=qs_charges)
2407 total_spin_dens = qs_charges%total_rho_hard_spin - &
2408 qs_charges%total_rho_soft_spin
2409 total_abs_spin_dens = qs_charges%total_rho_hard_abs_spin - &
2410 qs_charges%total_rho_soft_abs_spin
2413 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
2414 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
2416 CALL auxbas_pw_pool%create_pw(wf_r)
2418 CALL pw_axpy(rho_r(2), wf_r, alpha=-1._dp)
2420 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'(/,(T3,A,T61,F20.10))') &
2421 "Integrated spin density: ", total_spin_dens
2423 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'((T3,A,T61,F20.10))') &
2424 "Integrated absolute spin density: ", total_abs_spin_dens
2425 CALL auxbas_pw_pool%give_back_pw(wf_r)
2431 IF (.NOT. do_kpoints)
THEN
2433 DO ispin = 1, dft_control%nspins
2435 occupation_numbers=occupation_numbers, &
2440 all_equal = all_equal .AND. &
2441 (all(occupation_numbers(1:homo) == maxocc) .AND. &
2442 all(occupation_numbers(homo + 1:nmo) == 0.0_dp))
2447 matrix_s=matrix_s, &
2450 s_square_ideal=s_square_ideal)
2451 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'(T3,A,T51,2F15.6)') &
2452 "Ideal and single determinant S**2 : ", s_square_ideal, s_square
2453 energy%s_square = s_square
2458 CALL timestop(handle)
2470 CHARACTER(len=*),
PARAMETER :: routinen =
'write_mo_free_results'
2471 CHARACTER(len=1),
DIMENSION(3),
PARAMETER :: cdir = [
"x",
"y",
"z"]
2473 CHARACTER(LEN=2) :: element_symbol
2474 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
2476 CHARACTER(LEN=default_string_length) :: name, print_density
2477 INTEGER :: after, handle, i, iat, iatom, id, ikind, img, iso, ispin, iw, l, n_rep_hf, nat, &
2478 natom, nd(3), ngto, niso, nkind, np, nr, output_unit, print_level, should_print_bqb, &
2479 should_print_voro, unit_nr, unit_nr_voro
2480 LOGICAL :: append_cube, append_voro, do_hfx, do_kpoints, mpi_io, omit_headers, print_it, &
2481 rho_r_valid, voro_print_txt, write_ks, write_xc, xrd_interface
2483 rho_total, rho_total_rspace, udvol, &
2485 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
2486 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: bfun
2487 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: aedens, ccdens, ppdens
2488 REAL(kind=
dp),
DIMENSION(3) :: dr
2489 REAL(kind=
dp),
DIMENSION(:),
POINTER :: my_q0
2494 TYPE(cp_section_key) :: e_density_section
2496 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: ks_rmpv, matrix_vxc, rho_ao
2504 TYPE(
pw_c1d_gs_type),
POINTER :: rho0_s_gs, rho_core, rhoz_cneo_s_gs
2511 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2519 print_key, print_key_bqb, &
2520 print_key_voro, xc_section
2522 CALL timeset(routinen, handle)
2523 NULLIFY (cell, dft_control, pw_env, auxbas_pw_pool, pw_pools, hfx_section, &
2524 atomic_kind_set, qs_kind_set, particle_set, rho, ks_rmpv, rho_ao, rho_r, &
2525 dft_section, xc_section, input, particles, subsys, matrix_vxc, v_hartree_rspace, &
2531 cpassert(
ASSOCIATED(qs_env))
2533 atomic_kind_set=atomic_kind_set, &
2534 qs_kind_set=qs_kind_set, &
2535 particle_set=particle_set, &
2537 para_env=para_env, &
2538 dft_control=dft_control, &
2540 do_kpoints=do_kpoints, &
2548 CALL get_qs_env(qs_env, nkind=nkind, natom=natom)
2549 ALLOCATE (zcharge(natom))
2554 iat = atomic_kind_set(ikind)%atom_list(iatom)
2561 "DFT%PRINT%TOT_DENSITY_CUBE"),
cp_p_file))
THEN
2562 NULLIFY (rho_core, rho0_s_gs, rhoz_cneo_s_gs)
2564 my_pos_cube =
"REWIND"
2565 IF (append_cube)
THEN
2566 my_pos_cube =
"APPEND"
2569 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, rho_core=rho_core, &
2570 rho0_s_gs=rho0_s_gs, rhoz_cneo_s_gs=rhoz_cneo_s_gs)
2571 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
2573 CALL auxbas_pw_pool%create_pw(wf_r)
2574 IF (dft_control%qs_control%gapw)
THEN
2575 IF (dft_control%qs_control%gapw_control%nopaw_as_gpw)
THEN
2576 CALL pw_axpy(rho_core, rho0_s_gs)
2577 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2578 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs)
2581 CALL pw_axpy(rho_core, rho0_s_gs, -1.0_dp)
2582 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2583 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs, -1.0_dp)
2586 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2587 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs)
2590 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2591 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs, -1.0_dp)
2597 DO ispin = 1, dft_control%nspins
2598 CALL pw_axpy(rho_r(ispin), wf_r)
2600 filename =
"TOTAL_DENSITY"
2603 extension=
".cube", middle_name=trim(filename), file_position=my_pos_cube, &
2604 log_filename=.false., mpi_io=mpi_io)
2606 particles=particles, zeff=zcharge, &
2608 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%TOT_DENSITY_CUBE%MAX_FILE_SIZE_MB"), &
2611 "DFT%PRINT%TOT_DENSITY_CUBE", mpi_io=mpi_io)
2612 CALL auxbas_pw_pool%give_back_pw(wf_r)
2615 e_density_section = cube_or_openpmd(input, str_e_density_cubes, str_e_density_openpmd, logger)
2618 IF (e_density_section%do_output)
THEN
2620 keyword_name=e_density_section%concat_to_relative(
"%DENSITY_INCLUDE"), &
2621 c_val=print_density)
2622 print_density = trim(print_density)
2624 IF (e_density_section%grid_output == grid_output_cubes)
THEN
2625 append_cube =
section_get_lval(input, e_density_section%concat_to_absolute(
"%APPEND"))
2627 my_pos_cube =
"REWIND"
2628 IF (append_cube)
THEN
2629 my_pos_cube =
"APPEND"
2633 IF (e_density_section%grid_output == grid_output_cubes)
THEN
2634 xrd_interface =
section_get_lval(input, e_density_section%concat_to_absolute(
"%XRD_INTERFACE"))
2637 xrd_interface = .false.
2640 IF (xrd_interface)
THEN
2642 IF (dft_control%qs_control%gapw) print_density =
"SOFT_DENSITY"
2644 filename =
"ELECTRON_DENSITY"
2646 extension=
".xrd", middle_name=trim(filename), &
2647 file_position=my_pos_cube, log_filename=.false.)
2648 ngto =
section_get_ival(input, e_density_section%concat_to_absolute(
"%NGAUSS"))
2649 IF (output_unit > 0)
THEN
2650 INQUIRE (unit=unit_nr, name=filename)
2651 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
2652 "The electron density (atomic part) is written to the file:", &
2657 nkind =
SIZE(atomic_kind_set)
2658 IF (unit_nr > 0)
THEN
2659 WRITE (unit_nr, *)
"Atomic (core) densities"
2660 WRITE (unit_nr, *)
"Unit cell"
2661 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(1, 1), cell%hmat(1, 2), cell%hmat(1, 3)
2662 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(2, 1), cell%hmat(2, 2), cell%hmat(2, 3)
2663 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(3, 1), cell%hmat(3, 2), cell%hmat(3, 3)
2664 WRITE (unit_nr, *)
"Atomic types"
2665 WRITE (unit_nr, *) nkind
2668 ALLOCATE (ppdens(ngto, 2, nkind), aedens(ngto, 2, nkind), ccdens(ngto, 2, nkind))
2670 atomic_kind => atomic_kind_set(ikind)
2671 qs_kind => qs_kind_set(ikind)
2672 CALL get_atomic_kind(atomic_kind, name=name, element_symbol=element_symbol)
2674 iunit=output_unit, confine=.true.)
2676 iunit=output_unit, allelectron=.true., confine=.true.)
2677 ccdens(:, 1, ikind) = aedens(:, 1, ikind)
2678 ccdens(:, 2, ikind) = 0._dp
2679 CALL project_function_a(ccdens(1:ngto, 2, ikind), ccdens(1:ngto, 1, ikind), &
2680 ppdens(1:ngto, 2, ikind), ppdens(1:ngto, 1, ikind), 0)
2681 ccdens(:, 2, ikind) = aedens(:, 2, ikind) - ccdens(:, 2, ikind)
2682 IF (unit_nr > 0)
THEN
2683 WRITE (unit_nr, fmt=
"(I6,A10,A20)") ikind, trim(element_symbol), trim(name)
2684 WRITE (unit_nr, fmt=
"(I6)") ngto
2685 WRITE (unit_nr, *)
" Total density"
2686 WRITE (unit_nr, fmt=
"(2G24.12)") (aedens(i, 1, ikind), aedens(i, 2, ikind), i=1, ngto)
2687 WRITE (unit_nr, *)
" Core density"
2688 WRITE (unit_nr, fmt=
"(2G24.12)") (ccdens(i, 1, ikind), ccdens(i, 2, ikind), i=1, ngto)
2690 NULLIFY (atomic_kind)
2693 IF (dft_control%qs_control%gapw)
THEN
2694 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom_set)
2696 IF (unit_nr > 0)
THEN
2697 WRITE (unit_nr, *)
"Coordinates and GAPW density"
2699 np = particles%n_els
2701 CALL get_atomic_kind(particles%els(iat)%atomic_kind, kind_number=ikind)
2702 CALL get_qs_kind(qs_kind_set(ikind), grid_atom=grid_atom)
2703 rho_atom => rho_atom_set(iat)
2704 IF (
ASSOCIATED(rho_atom%rho_rad_h(1)%r_coef))
THEN
2705 nr =
SIZE(rho_atom%rho_rad_h(1)%r_coef, 1)
2706 niso =
SIZE(rho_atom%rho_rad_h(1)%r_coef, 2)
2711 CALL para_env%sum(nr)
2712 CALL para_env%sum(niso)
2714 ALLOCATE (bfun(nr, niso))
2716 DO ispin = 1, dft_control%nspins
2717 IF (
ASSOCIATED(rho_atom%rho_rad_h(1)%r_coef))
THEN
2718 bfun(:, :) = bfun + rho_atom%rho_rad_h(ispin)%r_coef - rho_atom%rho_rad_s(ispin)%r_coef
2721 CALL para_env%sum(bfun)
2722 ccdens(:, 1, ikind) = ppdens(:, 1, ikind)
2723 ccdens(:, 2, ikind) = 0._dp
2724 IF (unit_nr > 0)
THEN
2725 WRITE (unit_nr,
'(I10,I5,3f12.6)') iat, ikind, particles%els(iat)%r
2729 CALL project_function_b(ccdens(:, 2, ikind), ccdens(:, 1, ikind), bfun(:, iso), grid_atom, l)
2730 IF (unit_nr > 0)
THEN
2731 WRITE (unit_nr, fmt=
"(3I6)") iso, l, ngto
2732 WRITE (unit_nr, fmt=
"(2G24.12)") (ccdens(i, 1, ikind), ccdens(i, 2, ikind), i=1, ngto)
2738 IF (unit_nr > 0)
THEN
2739 WRITE (unit_nr, *)
"Coordinates"
2740 np = particles%n_els
2742 CALL get_atomic_kind(particles%els(iat)%atomic_kind, kind_number=ikind)
2743 WRITE (unit_nr,
'(I10,I5,3f12.6)') iat, ikind, particles%els(iat)%r
2748 DEALLOCATE (ppdens, aedens, ccdens)
2751 e_density_section%absolute_section_key)
2754 IF (dft_control%qs_control%gapw .AND. print_density ==
"TOTAL_DENSITY")
THEN
2756 cpassert(.NOT. do_kpoints)
2761 auxbas_pw_pool=auxbas_pw_pool, &
2763 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
2765 CALL auxbas_pw_pool%create_pw(pw=rho_elec_gspace)
2770 q_max = sqrt(sum((
pi/dr(:))**2))
2772 auxbas_pw_pool=auxbas_pw_pool, &
2773 rhotot_elec_gspace=rho_elec_gspace, &
2775 rho_hard=rho_hard, &
2777 rho_total = rho_hard + rho_soft
2782 CALL pw_scale(rho_elec_gspace, 1.0_dp/volume)
2784 CALL pw_transfer(rho_elec_gspace, rho_elec_rspace)
2786 filename =
"TOTAL_ELECTRON_DENSITY"
2788 unit_nr = e_density_section%print_key_unit_nr( &
2791 e_density_section%absolute_section_key, &
2792 extension=
".cube", &
2793 middle_name=trim(filename), &
2794 file_position=my_pos_cube, &
2795 log_filename=.false., &
2797 fout=mpi_filename, &
2798 openpmd_basename=
"dft-total-electron-density", &
2799 openpmd_unit_dimension=openpmd_unit_dimension_density, &
2800 openpmd_unit_si=openpmd_unit_si_density, &
2801 sim_time=qs_env%sim_time)
2802 IF (output_unit > 0)
THEN
2803 IF (.NOT. mpi_io)
THEN
2804 INQUIRE (unit=unit_nr, name=filename)
2806 filename = mpi_filename
2808 CALL print_density_output_message(output_unit,
"The total electron density", &
2809 e_density_section, filename)
2810 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
2811 "q(max) [1/Angstrom] :", q_max/
angstrom, &
2812 "Soft electronic charge (G-space) :", rho_soft, &
2813 "Hard electronic charge (G-space) :", rho_hard, &
2814 "Total electronic charge (G-space):", rho_total, &
2815 "Total electronic charge (R-space):", rho_total_rspace
2817 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"TOTAL ELECTRON DENSITY", &
2818 particles=particles, zeff=zcharge, &
2819 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2820 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2821 e_density_section%absolute_section_key, mpi_io=mpi_io)
2823 IF (dft_control%nspins > 1)
THEN
2827 auxbas_pw_pool=auxbas_pw_pool, &
2828 rhotot_elec_gspace=rho_elec_gspace, &
2830 rho_hard=rho_hard, &
2831 rho_soft=rho_soft, &
2833 rho_total = rho_hard + rho_soft
2837 CALL pw_scale(rho_elec_gspace, 1.0_dp/volume)
2839 CALL pw_transfer(rho_elec_gspace, rho_elec_rspace)
2841 filename =
"TOTAL_SPIN_DENSITY"
2843 unit_nr = e_density_section%print_key_unit_nr( &
2846 e_density_section%absolute_section_key, &
2847 extension=
".cube", &
2848 middle_name=trim(filename), &
2849 file_position=my_pos_cube, &
2850 log_filename=.false., &
2852 fout=mpi_filename, &
2853 openpmd_basename=
"dft-total-spin-density", &
2854 openpmd_unit_dimension=openpmd_unit_dimension_density, &
2855 openpmd_unit_si=openpmd_unit_si_density, &
2856 sim_time=qs_env%sim_time)
2857 IF (output_unit > 0)
THEN
2858 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2859 INQUIRE (unit=unit_nr, name=filename)
2861 filename = mpi_filename
2863 CALL print_density_output_message(output_unit,
"The total spin density", &
2864 e_density_section, filename)
2865 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
2866 "q(max) [1/Angstrom] :", q_max/
angstrom, &
2867 "Soft part of the spin density (G-space):", rho_soft, &
2868 "Hard part of the spin density (G-space):", rho_hard, &
2869 "Total spin density (G-space) :", rho_total, &
2870 "Total spin density (R-space) :", rho_total_rspace
2872 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"TOTAL 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_gspace)
2879 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
2881 ELSE IF (print_density ==
"SOFT_DENSITY" .OR. .NOT. dft_control%qs_control%gapw)
THEN
2882 IF (dft_control%nspins > 1)
THEN
2886 auxbas_pw_pool=auxbas_pw_pool, &
2888 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
2889 CALL pw_copy(rho_r(1), rho_elec_rspace)
2890 CALL pw_axpy(rho_r(2), rho_elec_rspace)
2891 filename =
"ELECTRON_DENSITY"
2893 unit_nr = e_density_section%print_key_unit_nr( &
2896 e_density_section%absolute_section_key, &
2897 extension=
".cube", &
2898 middle_name=trim(filename), &
2899 file_position=my_pos_cube, &
2900 log_filename=.false., &
2902 fout=mpi_filename, &
2903 openpmd_basename=
"dft-electron-density", &
2904 openpmd_unit_dimension=openpmd_unit_dimension_density, &
2905 openpmd_unit_si=openpmd_unit_si_density, &
2906 sim_time=qs_env%sim_time)
2907 IF (output_unit > 0)
THEN
2908 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2909 INQUIRE (unit=unit_nr, name=filename)
2911 filename = mpi_filename
2913 CALL print_density_output_message(output_unit,
"The sum of alpha and beta density", &
2914 e_density_section, filename)
2916 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SUM OF ALPHA AND BETA DENSITY", &
2917 particles=particles, zeff=zcharge, stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), &
2919 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2920 e_density_section%absolute_section_key, mpi_io=mpi_io)
2921 CALL pw_copy(rho_r(1), rho_elec_rspace)
2922 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
2923 filename =
"SPIN_DENSITY"
2925 unit_nr = e_density_section%print_key_unit_nr( &
2928 e_density_section%absolute_section_key, &
2929 extension=
".cube", &
2930 middle_name=trim(filename), &
2931 file_position=my_pos_cube, &
2932 log_filename=.false., &
2934 fout=mpi_filename, &
2935 openpmd_basename=
"dft-spin-density", &
2936 openpmd_unit_dimension=openpmd_unit_dimension_density, &
2937 openpmd_unit_si=openpmd_unit_si_density, &
2938 sim_time=qs_env%sim_time)
2939 IF (output_unit > 0)
THEN
2940 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2941 INQUIRE (unit=unit_nr, name=filename)
2943 filename = mpi_filename
2945 CALL print_density_output_message(output_unit,
"The spin density", &
2946 e_density_section, filename)
2948 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SPIN DENSITY", &
2949 particles=particles, zeff=zcharge, &
2950 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2951 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2952 e_density_section%absolute_section_key, mpi_io=mpi_io)
2953 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
2955 filename =
"ELECTRON_DENSITY"
2957 unit_nr = e_density_section%print_key_unit_nr( &
2960 e_density_section%absolute_section_key, &
2961 extension=
".cube", &
2962 middle_name=trim(filename), &
2963 file_position=my_pos_cube, &
2964 log_filename=.false., &
2966 fout=mpi_filename, &
2967 openpmd_basename=
"dft-electron-density", &
2968 openpmd_unit_dimension=openpmd_unit_dimension_density, &
2969 openpmd_unit_si=openpmd_unit_si_density, &
2970 sim_time=qs_env%sim_time)
2971 IF (output_unit > 0)
THEN
2972 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2973 INQUIRE (unit=unit_nr, name=filename)
2975 filename = mpi_filename
2977 CALL print_density_output_message(output_unit,
"The electron density", &
2978 e_density_section, filename)
2980 CALL e_density_section%write_pw(rho_r(1), unit_nr,
"ELECTRON DENSITY", &
2981 particles=particles, zeff=zcharge, &
2982 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2983 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2984 e_density_section%absolute_section_key, mpi_io=mpi_io)
2987 ELSE IF (dft_control%qs_control%gapw .AND. print_density ==
"TOTAL_HARD_APPROX")
THEN
2988 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, rho0_mpole=rho0_mpole, natom=natom)
2989 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
2990 CALL auxbas_pw_pool%create_pw(rho_elec_rspace)
2993 ALLOCATE (my_q0(natom))
3001 my_q0(iat) = sum(rho0_mpole%mp_rho(iat)%Q0(1:dft_control%nspins))*
norm_factor
3005 CALL calculate_rho_resp_all(rho_elec_rspace, coeff=my_q0, natom=natom, eta=rho0_mpole%zet0_h, qs_env=qs_env)
3009 DO ispin = 1, dft_control%nspins
3010 CALL pw_axpy(rho_r(ispin), rho_elec_rspace)
3014 rho_total_rspace = rho_soft + rho_hard
3016 filename =
"ELECTRON_DENSITY"
3018 unit_nr = e_density_section%print_key_unit_nr( &
3021 e_density_section%absolute_section_key, &
3022 extension=
".cube", &
3023 middle_name=trim(filename), &
3024 file_position=my_pos_cube, &
3025 log_filename=.false., &
3027 fout=mpi_filename, &
3028 openpmd_basename=
"dft-electron-density", &
3029 openpmd_unit_dimension=openpmd_unit_dimension_density, &
3030 openpmd_unit_si=openpmd_unit_si_density, &
3031 sim_time=qs_env%sim_time)
3032 IF (output_unit > 0)
THEN
3033 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
3034 INQUIRE (unit=unit_nr, name=filename)
3036 filename = mpi_filename
3038 CALL print_density_output_message(output_unit,
"The electron density", &
3039 e_density_section, filename)
3040 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
3041 "Soft electronic charge (R-space) :", rho_soft, &
3042 "Hard electronic charge (R-space) :", rho_hard, &
3043 "Total electronic charge (R-space):", rho_total_rspace
3045 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"ELECTRON DENSITY", &
3046 particles=particles, zeff=zcharge, stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), &
3048 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3049 e_density_section%absolute_section_key, mpi_io=mpi_io)
3052 IF (dft_control%nspins > 1)
THEN
3054 my_q0(iat) = (rho0_mpole%mp_rho(iat)%Q0(1) - rho0_mpole%mp_rho(iat)%Q0(2))*
norm_factor
3057 CALL calculate_rho_resp_all(rho_elec_rspace, coeff=my_q0, natom=natom, eta=rho0_mpole%zet0_h, qs_env=qs_env)
3060 CALL pw_axpy(rho_r(1), rho_elec_rspace)
3061 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
3065 rho_total_rspace = rho_soft + rho_hard
3067 filename =
"SPIN_DENSITY"
3069 unit_nr = e_density_section%print_key_unit_nr( &
3072 e_density_section%absolute_section_key, &
3073 extension=
".cube", &
3074 middle_name=trim(filename), &
3075 file_position=my_pos_cube, &
3076 log_filename=.false., &
3078 fout=mpi_filename, &
3079 openpmd_basename=
"dft-spin-density", &
3080 openpmd_unit_dimension=openpmd_unit_dimension_density, &
3081 openpmd_unit_si=openpmd_unit_si_density, &
3082 sim_time=qs_env%sim_time)
3083 IF (output_unit > 0)
THEN
3084 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
3085 INQUIRE (unit=unit_nr, name=filename)
3087 filename = mpi_filename
3089 CALL print_density_output_message(output_unit,
"The spin density", &
3090 e_density_section, filename)
3091 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
3092 "Soft part of the spin density :", rho_soft, &
3093 "Hard part of the spin density :", rho_hard, &
3094 "Total spin density (R-space) :", rho_total_rspace
3096 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SPIN DENSITY", &
3097 particles=particles, zeff=zcharge, &
3098 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
3099 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3100 e_density_section%absolute_section_key, mpi_io=mpi_io)
3102 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
3108 dft_section,
"PRINT%ENERGY_WINDOWS"),
cp_p_file) .AND. .NOT. do_kpoints)
THEN
3114 "DFT%PRINT%V_HARTREE_CUBE"),
cp_p_file))
THEN
3118 v_hartree_rspace=v_hartree_rspace)
3119 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3120 CALL auxbas_pw_pool%create_pw(aux_r)
3123 my_pos_cube =
"REWIND"
3124 IF (append_cube)
THEN
3125 my_pos_cube =
"APPEND"
3128 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
3131 extension=
".cube", middle_name=
"v_hartree", file_position=my_pos_cube, mpi_io=mpi_io)
3132 udvol = 1.0_dp/v_hartree_rspace%pw_grid%dvol
3134 CALL pw_copy(v_hartree_rspace, aux_r)
3137 CALL cp_pw_to_cube(aux_r, unit_nr,
"HARTREE POTENTIAL", particles=particles, zeff=zcharge, &
3139 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%V_HARTREE_CUBE%MAX_FILE_SIZE_MB"), &
3142 "DFT%PRINT%V_HARTREE_CUBE", mpi_io=mpi_io)
3144 CALL auxbas_pw_pool%give_back_pw(aux_r)
3149 "DFT%PRINT%EXTERNAL_POTENTIAL_CUBE"),
cp_p_file))
THEN
3150 IF (dft_control%apply_external_potential)
THEN
3151 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, vee=vee)
3152 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3153 CALL auxbas_pw_pool%create_pw(aux_r)
3155 append_cube =
section_get_lval(input,
"DFT%PRINT%EXTERNAL_POTENTIAL_CUBE%APPEND")
3156 my_pos_cube =
"REWIND"
3157 IF (append_cube)
THEN
3158 my_pos_cube =
"APPEND"
3163 extension=
".cube", middle_name=
"ext_pot", file_position=my_pos_cube, mpi_io=mpi_io)
3167 CALL cp_pw_to_cube(aux_r, unit_nr,
"EXTERNAL POTENTIAL", particles=particles, zeff=zcharge, &
3168 stride=
section_get_ivals(dft_section,
"PRINT%EXTERNAL_POTENTIAL_CUBE%STRIDE"), &
3169 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%EXTERNAL_POTENTIAL_CUBE%MAX_FILE_SIZE_MB"), &
3172 "DFT%PRINT%EXTERNAL_POTENTIAL_CUBE", mpi_io=mpi_io)
3174 CALL auxbas_pw_pool%give_back_pw(aux_r)
3180 "DFT%PRINT%EFIELD_CUBE"),
cp_p_file))
THEN
3182 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
3183 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3184 CALL auxbas_pw_pool%create_pw(aux_r)
3185 CALL auxbas_pw_pool%create_pw(aux_g)
3188 my_pos_cube =
"REWIND"
3189 IF (append_cube)
THEN
3190 my_pos_cube =
"APPEND"
3192 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, &
3193 v_hartree_rspace=v_hartree_rspace)
3195 udvol = 1.0_dp/v_hartree_rspace%pw_grid%dvol
3199 extension=
".cube", middle_name=
"efield_"//cdir(id), file_position=my_pos_cube, &
3209 CALL cp_pw_to_cube(aux_r, unit_nr,
"ELECTRIC FIELD", particles=particles, zeff=zcharge, &
3211 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%EFIELD_CUBE%MAX_FILE_SIZE_MB"), &
3214 "DFT%PRINT%EFIELD_CUBE", mpi_io=mpi_io)
3217 CALL auxbas_pw_pool%give_back_pw(aux_r)
3218 CALL auxbas_pw_pool%give_back_pw(aux_g)
3222 CALL qs_scf_post_local_energy(input, logger, qs_env)
3225 CALL qs_scf_post_local_stress(input, logger, qs_env)
3228 CALL qs_scf_post_ps_implicit(input, logger, qs_env)
3239 "DFT%PRINT%AO_MATRICES/DENSITY"),
cp_p_file))
THEN
3244 after = min(max(after, 1), 16)
3245 DO ispin = 1, dft_control%nspins
3246 DO img = 1, dft_control%nimages
3248 para_env, output_unit=iw, omit_headers=omit_headers)
3252 "DFT%PRINT%AO_MATRICES/DENSITY")
3257 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX"),
cp_p_file)
3259 "DFT%PRINT%AO_MATRICES/MATRIX_VXC"),
cp_p_file)
3261 IF (write_ks .OR. write_xc)
THEN
3262 IF (write_xc) qs_env%requires_matrix_vxc = .true.
3265 just_energy=.false.)
3266 IF (write_xc) qs_env%requires_matrix_vxc = .false.
3273 CALL get_qs_env(qs_env=qs_env, matrix_ks_kp=ks_rmpv)
3275 after = min(max(after, 1), 16)
3276 DO ispin = 1, dft_control%nspins
3277 DO img = 1, dft_control%nimages
3279 para_env, output_unit=iw, omit_headers=omit_headers)
3283 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX")
3288 IF (.NOT. dft_control%qs_control%pao)
THEN
3296 CALL write_adjacency_matrix(qs_env, input)
3300 CALL get_qs_env(qs_env=qs_env, matrix_vxc_kp=matrix_vxc)
3301 cpassert(
ASSOCIATED(matrix_vxc))
3305 after = min(max(after, 1), 16)
3306 DO ispin = 1, dft_control%nspins
3307 DO img = 1, dft_control%nimages
3309 para_env, output_unit=iw, omit_headers=omit_headers)
3313 "DFT%PRINT%AO_MATRICES/MATRIX_VXC")
3318 "DFT%PRINT%AO_MATRICES/COMMUTATOR_HR"),
cp_p_file))
THEN
3324 after = min(max(after, 1), 16)
3327 para_env, output_unit=iw, omit_headers=omit_headers)
3331 "DFT%PRINT%AO_MATRICES/COMMUTATOR_HR")
3337 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MULLIKEN", extension=
".mulliken", log_filename=.false.)
3340 IF (print_it) print_level = 2
3342 IF (print_it) print_level = 3
3353 CALL qs_rho_get(rho, rho_r_valid=rho_r_valid)
3354 IF (rho_r_valid)
THEN
3355 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%HIRSHFELD", extension=
".hirshfeld", log_filename=.false.)
3356 CALL hirshfeld_charges(qs_env, print_key, unit_nr)
3364 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%EEQ_CHARGES", extension=
".eeq", log_filename=.false.)
3366 CALL eeq_print(qs_env, unit_nr, print_level, ext=.false.)
3374 should_print_voro = 1
3376 should_print_voro = 0
3379 should_print_bqb = 1
3381 should_print_bqb = 0
3383 IF ((should_print_voro /= 0) .OR. (should_print_bqb /= 0))
THEN
3388 CALL qs_rho_get(rho, rho_r_valid=rho_r_valid)
3389 IF (rho_r_valid)
THEN
3391 IF (dft_control%nspins > 1)
THEN
3395 auxbas_pw_pool=auxbas_pw_pool, &
3399 CALL auxbas_pw_pool%create_pw(pw=mb_rho)
3400 CALL pw_copy(rho_r(1), mb_rho)
3401 CALL pw_axpy(rho_r(2), mb_rho)
3408 IF (should_print_voro /= 0)
THEN
3410 IF (voro_print_txt)
THEN
3412 my_pos_voro =
"REWIND"
3413 IF (append_voro)
THEN
3414 my_pos_voro =
"APPEND"
3416 unit_nr_voro =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%VORONOI", extension=
".voronoi", &
3417 file_position=my_pos_voro, log_filename=.false.)
3425 CALL entry_voronoi_or_bqb(should_print_voro, should_print_bqb, print_key_voro, print_key_bqb, &
3426 unit_nr_voro, qs_env, mb_rho)
3428 IF (dft_control%nspins > 1)
THEN
3429 CALL auxbas_pw_pool%give_back_pw(mb_rho)
3433 IF (unit_nr_voro > 0)
THEN
3443 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MAO_ANALYSIS", extension=
".mao", log_filename=.false.)
3451 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MINBAS_ANALYSIS", extension=
".mao", log_filename=.false.)
3459 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IAO_ANALYSIS", extension=
".iao", log_filename=.false.)
3461 IF (particle_set(1)%fragment_index /= 0) iao_env%do_fragments = .true.
3462 IF (iao_env%do_iao)
THEN
3472 extension=
".mao", log_filename=.false.)
3483 IF (qs_env%x_data(i, 1)%do_hfx_ri)
CALL print_ri_hfx(qs_env%x_data(i, 1)%ri_data, qs_env)
3487 DEALLOCATE (zcharge)
3489 CALL timestop(handle)
3499 SUBROUTINE hirshfeld_charges(qs_env, input_section, unit_nr)
3502 INTEGER,
INTENT(IN) :: unit_nr
3504 INTEGER :: i, iat, ikind, natom, nkind, nspin, &
3505 radius_type, refc, shapef
3506 INTEGER,
DIMENSION(:),
POINTER :: atom_list
3507 LOGICAL :: do_radius, do_sc, paw_atom
3508 REAL(kind=
dp) :: zeff
3509 REAL(kind=
dp),
DIMENSION(:),
POINTER :: radii
3510 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: charges
3513 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
3519 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3523 NULLIFY (hirshfeld_env)
3527 CALL get_qs_env(qs_env, nkind=nkind, natom=natom)
3528 ALLOCATE (hirshfeld_env%charges(natom))
3537 IF (.NOT.
SIZE(radii) == nkind) &
3538 CALL cp_abort(__location__, &
3539 "Length of keyword HIRSHFELD\ATOMIC_RADII does not "// &
3540 "match number of atomic kinds in the input coordinate file.")
3545 iterative=do_sc, ref_charge=refc, &
3546 radius_type=radius_type)
3548 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set)
3554 nspin =
SIZE(matrix_p, 1)
3555 ALLOCATE (charges(natom, nspin))
3560 atomic_kind => atomic_kind_set(ikind)
3562 DO iat = 1,
SIZE(atom_list)
3564 hirshfeld_env%charges(i) = zeff
3568 CALL get_qs_env(qs_env, matrix_s_kp=matrix_s, para_env=para_env)
3571 hirshfeld_env%charges(iat) = sum(charges(iat, :))
3574 cpabort(
"Unknown type of reference charge for Hirshfeld partitioning.")
3578 IF (hirshfeld_env%iterative)
THEN
3585 CALL get_qs_env(qs_env, particle_set=particle_set, dft_control=dft_control)
3586 IF (dft_control%qs_control%gapw)
THEN
3588 CALL get_qs_env(qs_env, rho0_mpole=rho0_mpole)
3591 atomic_kind => particle_set(iat)%atomic_kind
3593 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
3595 charges(iat, 1:nspin) = charges(iat, 1:nspin) + mp_rho(iat)%q0(1:nspin)
3600 IF (unit_nr > 0)
THEN
3602 qs_kind_set, unit_nr)
3608 DEALLOCATE (charges)
3610 END SUBROUTINE hirshfeld_charges
3620 SUBROUTINE project_function_a(ca, a, cb, b, l)
3622 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: ca
3623 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: a, cb, b
3624 INTEGER,
INTENT(IN) :: l
3627 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ipiv
3628 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat, tmat, v
3631 ALLOCATE (smat(n, n), tmat(n, n), v(n, 1), ipiv(n))
3635 v(:, 1) = matmul(tmat, cb)
3636 CALL dgesv(n, 1, smat, n, ipiv, v, n, info)
3640 DEALLOCATE (smat, tmat, v, ipiv)
3642 END SUBROUTINE project_function_a
3652 SUBROUTINE project_function_b(ca, a, bfun, grid_atom, l)
3654 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: ca
3655 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: a, bfun
3657 INTEGER,
INTENT(IN) :: l
3659 INTEGER :: i, info, n, nr
3660 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ipiv
3661 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: afun
3662 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat, v
3666 ALLOCATE (smat(n, n), v(n, 1), ipiv(n), afun(nr))
3670 afun(:) = grid_atom%rad(:)**l*exp(-a(i)*grid_atom%rad2(:))
3671 v(i, 1) = sum(afun(:)*bfun(:)*grid_atom%wr(:))
3673 CALL dgesv(n, 1, smat, n, ipiv, v, n, info)
3677 DEALLOCATE (smat, v, ipiv, afun)
3679 END SUBROUTINE project_function_b
3690 SUBROUTINE qs_scf_post_local_energy(input, logger, qs_env)
3695 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_local_energy'
3697 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3698 INTEGER :: handle, io_unit, natom, unit_nr
3699 LOGICAL :: append_cube, gapw, gapw_xc, mpi_io
3708 CALL timeset(routinen, handle)
3711 "DFT%PRINT%LOCAL_ENERGY_CUBE"),
cp_p_file))
THEN
3713 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, natom=natom)
3714 gapw = dft_control%qs_control%gapw
3715 gapw_xc = dft_control%qs_control%gapw_xc
3716 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3718 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3719 CALL auxbas_pw_pool%create_pw(eden)
3723 append_cube =
section_get_lval(input,
"DFT%PRINT%LOCAL_ENERGY_CUBE%APPEND")
3724 IF (append_cube)
THEN
3725 my_pos_cube =
"APPEND"
3727 my_pos_cube =
"REWIND"
3731 extension=
".cube", middle_name=
"local_energy", &
3732 file_position=my_pos_cube, mpi_io=mpi_io)
3733 CALL cp_pw_to_cube(eden, unit_nr,
"LOCAL ENERGY", particles=particles, &
3735 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%LOCAL_ENERGY_CUBE%MAX_FILE_SIZE_MB"), &
3737 IF (io_unit > 0)
THEN
3738 INQUIRE (unit=unit_nr, name=filename)
3739 IF (gapw .OR. gapw_xc)
THEN
3740 WRITE (unit=io_unit, fmt=
"(/,T3,A,A)") &
3741 "The soft part of the local energy is written to the file: ", trim(adjustl(filename))
3743 WRITE (unit=io_unit, fmt=
"(/,T3,A,A)") &
3744 "The local energy is written to the file: ", trim(adjustl(filename))
3748 "DFT%PRINT%LOCAL_ENERGY_CUBE", mpi_io=mpi_io)
3750 CALL auxbas_pw_pool%give_back_pw(eden)
3752 CALL timestop(handle)
3754 END SUBROUTINE qs_scf_post_local_energy
3765 SUBROUTINE qs_scf_post_local_stress(input, logger, qs_env)
3770 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_local_stress'
3772 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3773 INTEGER :: handle, io_unit, natom, unit_nr
3774 LOGICAL :: append_cube, gapw, gapw_xc, mpi_io
3775 REAL(kind=
dp) :: beta
3784 CALL timeset(routinen, handle)
3787 "DFT%PRINT%LOCAL_STRESS_CUBE"),
cp_p_file))
THEN
3788 CALL cp_warn(__location__, &
3789 "LOCAL_STRESS_CUBE uses the existing experimental local stress implementation")
3791 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, natom=natom)
3792 gapw = dft_control%qs_control%gapw
3793 gapw_xc = dft_control%qs_control%gapw_xc
3794 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3796 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3797 CALL auxbas_pw_pool%create_pw(stress)
3803 append_cube =
section_get_lval(input,
"DFT%PRINT%LOCAL_STRESS_CUBE%APPEND")
3804 IF (append_cube)
THEN
3805 my_pos_cube =
"APPEND"
3807 my_pos_cube =
"REWIND"
3811 extension=
".cube", middle_name=
"local_stress", &
3812 file_position=my_pos_cube, mpi_io=mpi_io)
3813 CALL cp_pw_to_cube(stress, unit_nr,
"LOCAL STRESS", particles=particles, &
3815 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%LOCAL_STRESS_CUBE%MAX_FILE_SIZE_MB"), &
3817 IF (io_unit > 0)
THEN
3818 INQUIRE (unit=unit_nr, name=filename)
3819 WRITE (unit=io_unit, fmt=
"(/,T3,A)")
"Write 1/3*Tr(sigma) to cube file"
3820 IF (gapw .OR. gapw_xc)
THEN
3821 WRITE (unit=io_unit, fmt=
"(T3,A,A)") &
3822 "The soft part of the local stress is written to the file: ", trim(adjustl(filename))
3824 WRITE (unit=io_unit, fmt=
"(T3,A,A)") &
3825 "The local stress is written to the file: ", trim(adjustl(filename))
3829 "DFT%PRINT%LOCAL_STRESS_CUBE", mpi_io=mpi_io)
3831 CALL auxbas_pw_pool%give_back_pw(stress)
3834 CALL timestop(handle)
3836 END SUBROUTINE qs_scf_post_local_stress
3847 SUBROUTINE qs_scf_post_ps_implicit(input, logger, qs_env)
3852 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_ps_implicit'
3854 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3855 INTEGER :: boundary_condition, handle, i, j, &
3856 n_cstr, n_tiles, unit_nr
3857 LOGICAL :: append_cube, do_cstr_charge_cube, do_dielectric_cube, do_dirichlet_bc_cube, &
3858 has_dirichlet_bc, has_implicit_ps, mpi_io, tile_cubes
3868 CALL timeset(routinen, handle)
3870 NULLIFY (pw_env, auxbas_pw_pool, dft_section, particles)
3873 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3875 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3877 has_implicit_ps = .false.
3878 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
3883 "DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE"),
cp_p_file)
3884 IF (has_implicit_ps .AND. do_dielectric_cube)
THEN
3885 append_cube =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%APPEND")
3886 my_pos_cube =
"REWIND"
3887 IF (append_cube)
THEN
3888 my_pos_cube =
"APPEND"
3892 extension=
".cube", middle_name=
"DIELECTRIC_CONSTANT", file_position=my_pos_cube, &
3894 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
3895 CALL auxbas_pw_pool%create_pw(aux_r)
3897 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3898 SELECT CASE (boundary_condition)
3900 CALL pw_copy(poisson_env%implicit_env%dielectric%eps, aux_r)
3902 CALL pw_shrink(pw_env%poisson_env%parameters%ps_implicit_params%neumann_directions, &
3903 pw_env%poisson_env%implicit_env%dct_env%dests_shrink, &
3904 pw_env%poisson_env%implicit_env%dct_env%srcs_shrink, &
3905 pw_env%poisson_env%implicit_env%dct_env%bounds_local_shftd, &
3906 poisson_env%implicit_env%dielectric%eps, aux_r)
3909 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIELECTRIC CONSTANT", particles=particles, &
3910 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%STRIDE"), &
3911 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%MAX_FILE_SIZE_MB"), &
3914 "DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE", mpi_io=mpi_io)
3916 CALL auxbas_pw_pool%give_back_pw(aux_r)
3921 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE"),
cp_p_file)
3923 has_dirichlet_bc = .false.
3924 IF (has_implicit_ps)
THEN
3925 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3927 has_dirichlet_bc = .true.
3931 IF (has_implicit_ps .AND. do_cstr_charge_cube .AND. has_dirichlet_bc)
THEN
3933 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%APPEND")
3934 my_pos_cube =
"REWIND"
3935 IF (append_cube)
THEN
3936 my_pos_cube =
"APPEND"
3940 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE", &
3941 extension=
".cube", middle_name=
"dirichlet_cstr_charge", file_position=my_pos_cube, &
3943 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
3944 CALL auxbas_pw_pool%create_pw(aux_r)
3946 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3947 SELECT CASE (boundary_condition)
3949 CALL pw_copy(poisson_env%implicit_env%cstr_charge, aux_r)
3951 CALL pw_shrink(pw_env%poisson_env%parameters%ps_implicit_params%neumann_directions, &
3952 pw_env%poisson_env%implicit_env%dct_env%dests_shrink, &
3953 pw_env%poisson_env%implicit_env%dct_env%srcs_shrink, &
3954 pw_env%poisson_env%implicit_env%dct_env%bounds_local_shftd, &
3955 poisson_env%implicit_env%cstr_charge, aux_r)
3958 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET CONSTRAINT CHARGE", particles=particles, &
3959 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%STRIDE"), &
3960 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%MAX_FILE_SIZE_MB"), &
3963 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE", mpi_io=mpi_io)
3965 CALL auxbas_pw_pool%give_back_pw(aux_r)
3970 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE"),
cp_p_file)
3971 has_dirichlet_bc = .false.
3972 IF (has_implicit_ps)
THEN
3973 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
3975 has_dirichlet_bc = .true.
3979 IF (has_implicit_ps .AND. has_dirichlet_bc .AND. do_dirichlet_bc_cube)
THEN
3980 append_cube =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%APPEND")
3981 my_pos_cube =
"REWIND"
3982 IF (append_cube)
THEN
3983 my_pos_cube =
"APPEND"
3985 tile_cubes =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%TILE_CUBES")
3987 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
3988 CALL auxbas_pw_pool%create_pw(aux_r)
3991 IF (tile_cubes)
THEN
3993 n_cstr =
SIZE(poisson_env%implicit_env%contacts)
3995 n_tiles = poisson_env%implicit_env%contacts(j)%dirichlet_bc%n_tiles
3997 filename =
"dirichlet_cstr_"//trim(adjustl(
cp_to_string(j)))// &
4000 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", &
4001 extension=
".cube", middle_name=filename, file_position=my_pos_cube, &
4004 CALL pw_copy(poisson_env%implicit_env%contacts(j)%dirichlet_bc%tiles(i)%tile%tile_pw, aux_r)
4006 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET TYPE CONSTRAINT", particles=particles, &
4007 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%STRIDE"), &
4008 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%MAX_FILE_SIZE_MB"), &
4011 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", mpi_io=mpi_io)
4016 NULLIFY (dirichlet_tile)
4017 ALLOCATE (dirichlet_tile)
4018 CALL auxbas_pw_pool%create_pw(dirichlet_tile)
4021 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", &
4022 extension=
".cube", middle_name=
"DIRICHLET_CSTR", file_position=my_pos_cube, &
4025 n_cstr =
SIZE(poisson_env%implicit_env%contacts)
4027 n_tiles = poisson_env%implicit_env%contacts(j)%dirichlet_bc%n_tiles
4029 CALL pw_copy(poisson_env%implicit_env%contacts(j)%dirichlet_bc%tiles(i)%tile%tile_pw, dirichlet_tile)
4030 CALL pw_axpy(dirichlet_tile, aux_r)
4034 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET TYPE CONSTRAINT", particles=particles, &
4035 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%STRIDE"), &
4036 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%MAX_FILE_SIZE_MB"), &
4039 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", mpi_io=mpi_io)
4040 CALL auxbas_pw_pool%give_back_pw(dirichlet_tile)
4041 DEALLOCATE (dirichlet_tile)
4044 CALL auxbas_pw_pool%give_back_pw(aux_r)
4047 CALL timestop(handle)
4049 END SUBROUTINE qs_scf_post_ps_implicit
4057 SUBROUTINE write_adjacency_matrix(qs_env, input)
4061 CHARACTER(len=*),
PARAMETER :: routinen =
'write_adjacency_matrix'
4063 INTEGER :: adjm_size, colind, handle, iatom, ikind, &
4064 ind, jatom, jkind, k, natom, nkind, &
4065 output_unit, rowind, unit_nr
4066 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: interact_adjm
4067 LOGICAL :: do_adjm_write, do_symmetric
4073 DIMENSION(:),
POINTER :: nl_iterator
4076 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
4079 CALL timeset(routinen, handle)
4081 NULLIFY (dft_section)
4090 IF (do_adjm_write)
THEN
4091 NULLIFY (qs_kind_set, nl_iterator)
4092 NULLIFY (basis_set_list_a, basis_set_list_b, basis_set_a, basis_set_b)
4094 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, sab_orb=nl, natom=natom, para_env=para_env)
4096 nkind =
SIZE(qs_kind_set)
4097 cpassert(
SIZE(nl) > 0)
4099 cpassert(do_symmetric)
4100 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
4104 adjm_size = ((natom + 1)*natom)/2
4105 ALLOCATE (interact_adjm(4*adjm_size))
4108 NULLIFY (nl_iterator)
4112 ikind=ikind, jkind=jkind, &
4113 iatom=iatom, jatom=jatom)
4115 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
4116 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
4117 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
4118 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
4121 IF (iatom <= jatom)
THEN
4128 ikind = ikind + jkind
4129 jkind = ikind - jkind
4130 ikind = ikind - jkind
4134 ind = adjm_size - (natom - rowind + 1)*((natom - rowind + 1) + 1)/2 + colind - rowind + 1
4137 interact_adjm((ind - 1)*4 + 1) = rowind
4138 interact_adjm((ind - 1)*4 + 2) = colind
4139 interact_adjm((ind - 1)*4 + 3) = ikind
4140 interact_adjm((ind - 1)*4 + 4) = jkind
4143 CALL para_env%sum(interact_adjm)
4146 extension=
".adjmat", file_form=
"FORMATTED", &
4147 file_status=
"REPLACE")
4148 IF (unit_nr > 0)
THEN
4149 WRITE (unit_nr,
"(1A,2X,1A,5X,1A,4X,A5,3X,A5)")
"#",
"iatom",
"jatom",
"ikind",
"jkind"
4150 DO k = 1, 4*adjm_size, 4
4152 IF (interact_adjm(k) > 0 .AND. interact_adjm(k + 1) > 0)
THEN
4153 WRITE (unit_nr,
"(I8,2X,I8,3X,I6,2X,I6)") interact_adjm(k:k + 3)
4161 DEALLOCATE (basis_set_list_a, basis_set_list_b)
4164 CALL timestop(handle)
4166 END SUBROUTINE write_adjacency_matrix
4174 SUBROUTINE update_hartree_with_mp2(rho, qs_env)
4178 LOGICAL :: use_virial
4188 NULLIFY (auxbas_pw_pool, pw_env, poisson_env, energy, rho_core, v_hartree_rspace, virial)
4189 CALL get_qs_env(qs_env, pw_env=pw_env, energy=energy, &
4190 rho_core=rho_core, virial=virial, &
4191 v_hartree_rspace=v_hartree_rspace)
4193 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
4195 IF (.NOT. use_virial)
THEN
4197 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
4198 poisson_env=poisson_env)
4199 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
4200 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
4204 v_hartree_gspace, rho_core=rho_core)
4206 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
4207 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
4209 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
4210 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
4213 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.
Writer for CASINO gwfn.data files.
subroutine, public write_casino(qs_env, casino_section)
Write a CASINO gwfn.data file from the converged GPW/GAPW wavefunction.
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, cartesian_basis)
...
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, 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, openpmd_unit_dimension, openpmd_unit_si, sim_time)
...
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 ...
Routines for the calculation of moments from Wannier functions.
subroutine, public calculate_kg_moments(qs_env, unit_nr, max_moment, magnetic, vel_reprs, com_nl)
Calculates multipole moments per molecule from the Kim-Gordon AO density matrix.
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, qs_env, calc_energies)
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 a_bohr
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)
...
container for information about total charges on the grids
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.
Utilities for broadened DOS and PDOS output.
subroutine, public get_dos_pdos_flags(dos_section, do_dos_output, do_projected_dos, do_pdos, do_pdos_raw)
Resolve projected-DOS requests from a DOS print section.
Calculation and writing of density of states.
subroutine, public calculate_dos(mos, dft_section, unoccupied_evals, smearing_enabled)
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...
Finite-volume Kubo-Greenwood transport from converged Quickstep matrices.
subroutine, public qs_scf_post_kubo_transport(qs_env)
Compute and print the finite-volume Kubo-Greenwood conductivity tensor.
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_kp(qs_env, dft_section, pdos_print_key, write_pdos, write_pdos_raw)
Compute and write broadened projected density of states for k-point calculations.
subroutine, public calculate_projected_dos(mo_set, atomic_kind_set, qs_kind_set, particle_set, qs_env, dft_section, ispin, xas_mittle, external_matrix_shalf, unoccupied_orbs, unoccupied_evals, pdos_print_key, write_pdos, write_pdos_raw)
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 their eigenvalues for all spin channels.
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 ...
Container for information about total charges on the grids.
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.