38 dbcsr_type_antisymmetric
233#include "./base/base_uses.f90"
239 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_post_gpw'
246 CHARACTER(len=*),
PARAMETER :: &
247 str_mo_cubes =
"PRINT%MO_CUBES", &
248 str_mo_openpmd =
"PRINT%MO_OPENPMD", &
249 str_elf_cubes =
"PRINT%ELF_CUBE", &
250 str_elf_openpmd =
"PRINT%ELF_OPENPMD", &
251 str_e_density_cubes =
"PRINT%E_DENSITY_CUBE", &
252 str_e_density_openpmd =
"PRINT%E_DENSITY_OPENPMD"
254 INTEGER,
PARAMETER :: grid_output_cubes = 1, grid_output_openpmd = 2
256 REAL(kind=
dp),
DIMENSION(7),
PARAMETER :: openpmd_unit_dimension_density = &
257 [-3, 0, 0, 0, 0, 0, 0]
258 REAL(kind=
dp),
DIMENSION(7),
PARAMETER :: openpmd_unit_dimension_dimensionless = &
259 [0, 0, 0, 0, 0, 0, 0]
260 REAL(kind=
dp),
DIMENSION(7),
PARAMETER :: openpmd_unit_dimension_wavefunction = &
261 [-1.5_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp]
262 REAL(kind=
dp),
PARAMETER :: openpmd_unit_si_density =
a_bohr**(-3)
263 REAL(kind=
dp),
PARAMETER :: openpmd_unit_si_dimensionless = 1.0_dp
264 REAL(kind=
dp),
PARAMETER :: openpmd_unit_si_wavefunction =
a_bohr**(-1.5_dp)
270 CHARACTER(len=default_string_length) :: relative_section_key =
""
271 CHARACTER(len=default_string_length) :: absolute_section_key =
""
272 CHARACTER(len=7) :: format_name =
""
273 INTEGER :: grid_output = -1
274 LOGICAL :: do_output = .false.
277 PROCEDURE,
PUBLIC :: print_key_unit_nr => cp_forward_print_key_unit_nr
279 PROCEDURE,
PUBLIC :: write_pw => cp_forward_write_pw
281 PROCEDURE,
PUBLIC :: print_key_finished_output => cp_forward_print_key_finished_output
283 PROCEDURE,
PUBLIC :: do_openpmd => cp_section_key_do_openpmd
284 PROCEDURE,
PUBLIC :: do_cubes => cp_section_key_do_cubes
285 PROCEDURE,
PUBLIC :: concat_to_relative => cp_section_key_concat_to_relative
286 PROCEDURE,
PUBLIC :: concat_to_absolute => cp_section_key_concat_to_absolute
287 END TYPE cp_section_key
298 REAL(KIND=
dp),
ALLOCATABLE,
DIMENSION(:), &
299 INTENT(OUT) :: zcharge
301 INTEGER :: iat, iatom, ikind, nat, natom, nkind
302 REAL(KIND=
dp) :: zeff
304 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
306 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
307 nkind=nkind, natom=natom)
308 ALLOCATE (zcharge(natom))
313 iat = atomic_kind_set(ikind)%atom_list(iatom)
325 FUNCTION cp_section_key_concat_to_absolute(self, extend_by)
RESULT(res)
326 CLASS(cp_section_key),
INTENT(IN) :: self
327 CHARACTER(*),
INTENT(IN) :: extend_by
328 CHARACTER(len=default_string_length) :: res
330 IF (len(trim(extend_by)) > 0 .AND. extend_by(1:1) ==
"%")
THEN
331 res = trim(self%absolute_section_key)//trim(extend_by)
333 res = trim(self%absolute_section_key)//
"%"//trim(extend_by)
335 END FUNCTION cp_section_key_concat_to_absolute
343 FUNCTION cp_section_key_concat_to_relative(self, extend_by)
RESULT(res)
344 CLASS(cp_section_key),
INTENT(IN) :: self
345 CHARACTER(*),
INTENT(IN) :: extend_by
346 CHARACTER(len=default_string_length) :: res
348 IF (len(trim(extend_by)) > 0 .AND. extend_by(1:1) ==
"%")
THEN
349 res = trim(self%relative_section_key)//trim(extend_by)
351 res = trim(self%relative_section_key)//
"%"//trim(extend_by)
353 END FUNCTION cp_section_key_concat_to_relative
360 FUNCTION cp_section_key_do_cubes(self)
RESULT(res)
361 CLASS(cp_section_key) :: self
364 res = self%do_output .AND. self%grid_output == grid_output_cubes
365 END FUNCTION cp_section_key_do_cubes
372 FUNCTION cp_section_key_do_openpmd(self)
RESULT(res)
373 CLASS(cp_section_key) :: self
376 res = self%do_output .AND. self%grid_output == grid_output_openpmd
377 END FUNCTION cp_section_key_do_openpmd
407 FUNCTION cp_forward_print_key_unit_nr( &
416 ignore_should_output, &
427 openpmd_unit_dimension, &
429 sim_time)
RESULT(res)
431 CLASS(cp_section_key),
INTENT(IN) :: self
434 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: print_key_path
435 CHARACTER(len=*),
INTENT(IN) :: extension
436 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: middle_name
437 LOGICAL,
INTENT(IN),
OPTIONAL :: local, log_filename, ignore_should_output
438 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: file_form, file_position, file_action, &
440 LOGICAL,
INTENT(IN),
OPTIONAL :: do_backup, on_file
441 LOGICAL,
INTENT(OUT),
OPTIONAL :: is_new_file
442 LOGICAL,
INTENT(INOUT),
OPTIONAL :: mpi_io
443 CHARACTER(len=default_path_length),
INTENT(OUT), &
445 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: openpmd_basename
446 REAL(kind=
dp),
DIMENSION(7),
OPTIONAL,
INTENT(IN) :: openpmd_unit_dimension
447 REAL(kind=
dp),
OPTIONAL,
INTENT(IN) :: openpmd_unit_si
448 REAL(kind=
dp),
OPTIONAL,
INTENT(IN) :: sim_time
451 IF (self%grid_output == grid_output_cubes)
THEN
453 logger, basis_section, print_key_path, extension=extension, &
454 middle_name=middle_name, local=local, log_filename=log_filename, &
455 ignore_should_output=ignore_should_output, file_form=file_form, &
456 file_position=file_position, file_action=file_action, &
457 file_status=file_status, do_backup=do_backup, on_file=on_file, &
458 is_new_file=is_new_file, mpi_io=mpi_io, fout=fout)
464 middle_name=middle_name, &
465 ignore_should_output=ignore_should_output, &
468 openpmd_basename=openpmd_basename, &
469 openpmd_unit_dimension=openpmd_unit_dimension, &
470 openpmd_unit_si=openpmd_unit_si, &
473 END FUNCTION cp_forward_print_key_unit_nr
491 SUBROUTINE cp_forward_write_pw( &
504 CLASS(cp_section_key),
INTENT(IN) :: self
506 INTEGER,
INTENT(IN) :: unit_nr
507 CHARACTER(*),
INTENT(IN),
OPTIONAL :: title
509 INTEGER,
DIMENSION(:),
OPTIONAL,
POINTER :: stride
510 REAL(KIND=
dp),
INTENT(IN),
OPTIONAL :: max_file_size_mb
511 LOGICAL,
INTENT(IN),
OPTIONAL :: zero_tails, silent, mpi_io
512 REAL(KIND=
dp),
DIMENSION(:),
OPTIONAL :: zeff
514 IF (self%grid_output == grid_output_cubes)
THEN
515 CALL cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
517 CALL cp_pw_to_openpmd(pw, unit_nr, title, particles, zeff, stride, zero_tails, silent, mpi_io)
519 END SUBROUTINE cp_forward_write_pw
535 SUBROUTINE cp_forward_print_key_finished_output(self, unit_nr, logger, basis_section, &
536 print_key_path, local, ignore_should_output, on_file, &
538 CLASS(cp_section_key),
INTENT(IN) :: self
539 INTEGER,
INTENT(INOUT) :: unit_nr
542 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: print_key_path
543 LOGICAL,
INTENT(IN),
OPTIONAL :: local, ignore_should_output, on_file, &
546 IF (self%grid_output == grid_output_cubes)
THEN
551 END SUBROUTINE cp_forward_print_key_finished_output
571 FUNCTION cube_or_openpmd(input, str_cubes, str_openpmd, logger)
RESULT(res)
573 CHARACTER(len=*),
INTENT(IN) :: str_cubes, str_openpmd
575 TYPE(cp_section_key) :: res
577 LOGICAL :: do_cubes, do_openpmd
580 logger%iter_info, input, &
581 "DFT%"//trim(adjustl(str_cubes))),
cp_p_file)
583 logger%iter_info, input, &
584 "DFT%"//trim(adjustl(str_openpmd))),
cp_p_file)
588 cpassert(.NOT. (do_cubes .AND. do_openpmd))
589 res%do_output = do_cubes .OR. do_openpmd
591 res%grid_output = grid_output_openpmd
592 res%relative_section_key = trim(adjustl(str_openpmd))
593 res%format_name =
"openPMD"
595 res%grid_output = grid_output_cubes
596 res%relative_section_key = trim(adjustl(str_cubes))
597 res%format_name =
"Cube"
599 res%absolute_section_key =
"DFT%"//trim(adjustl(res%relative_section_key))
600 END FUNCTION cube_or_openpmd
608 FUNCTION section_key_do_write(grid_output)
RESULT(res)
609 INTEGER,
INTENT(IN) :: grid_output
610 CHARACTER(len=32) :: res
612 IF (grid_output == grid_output_cubes)
THEN
614 ELSE IF (grid_output == grid_output_openpmd)
THEN
615 res =
"%WRITE_OPENPMD"
617 END FUNCTION section_key_do_write
626 SUBROUTINE print_density_output_message(output_unit, prefix, e_density_section, filename)
627 INTEGER,
INTENT(IN) :: output_unit
628 CHARACTER(len=*),
INTENT(IN) :: prefix
629 TYPE(cp_section_key),
INTENT(IN) :: e_density_section
630 CHARACTER(len=*),
INTENT(IN) :: filename
632 IF (e_density_section%grid_output == grid_output_openpmd)
THEN
633 WRITE (unit=output_unit, fmt=
"(/,T2,A)") &
634 trim(prefix)//
" is written in " &
635 //e_density_section%format_name &
636 //
" file format to the file / file pattern:", &
639 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
640 trim(prefix)//
" is written in " &
641 //e_density_section%format_name &
642 //
" file format to the file:", &
645 END SUBROUTINE print_density_output_message
668 CHARACTER(6),
OPTIONAL :: wf_type
669 LOGICAL,
OPTIONAL :: do_mp2
671 CHARACTER(len=*),
PARAMETER :: routinen =
'scf_post_calculation_gpw', &
672 warning_cube_kpoint =
"Print MO cubes not implemented for k-point calculations", &
673 warning_openpmd_kpoint =
"Writing to openPMD not implemented for k-point calculations"
675 INTEGER :: handle, homo, ispin, min_lumos, n_rep, &
676 nchk_nmoloc, nhomo, nlumo, nlumo_stm, &
677 nlumos, nmo, nspins, output_unit, &
679 INTEGER,
DIMENSION(:, :, :),
POINTER :: marked_states
680 LOGICAL :: check_write, compute_lumos, do_homo, do_kpoints,
do_mixed, do_stm, &
681 do_wannier_cubes, has_homo, has_lumo, loc_explicit, loc_print_explicit, my_do_mp2, &
682 my_localized_wfn, p_loc, p_loc_homo, p_loc_lumo, p_loc_mixed
684 REAL(kind=
dp) :: gap, homo_lumo(2, 2), total_zeff_corr
685 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
688 TYPE(
cp_1d_r_p_type),
DIMENSION(:),
POINTER :: mixed_evals, occupied_evals, &
689 unoccupied_evals, unoccupied_evals_stm
690 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: mixed_orbs, occupied_orbs
691 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:), &
692 TARGET :: homo_localized, lumo_localized, &
694 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: lumo_ptr, mo_loc_history, &
695 unoccupied_orbs, unoccupied_orbs_stm
698 TYPE(cp_section_key) :: mo_section
699 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_p_mp2, matrix_s, &
701 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: kinetic_m, rho_ao
713 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
722 localize_section, print_key, &
725 CALL timeset(routinen, handle)
732 IF (
PRESENT(do_mp2)) my_do_mp2 = do_mp2
733 IF (
PRESENT(wf_type))
THEN
734 IF (output_unit > 0)
THEN
735 WRITE (unit=output_unit, fmt=
'(/,(T1,A))') repeat(
"-", 40)
736 WRITE (unit=output_unit, fmt=
'(/,(T3,A,T19,A,T25,A))')
"Properties from ", wf_type,
" density"
737 WRITE (unit=output_unit, fmt=
'(/,(T1,A))') repeat(
"-", 40)
744 my_localized_wfn = .false.
745 NULLIFY (admm_env, dft_control, pw_env, auxbas_pw_pool, pw_pools, mos, rho, &
746 mo_coeff, ks_rmpv, matrix_s, qs_loc_env_homo, qs_loc_env_lumo, scf_control, &
747 unoccupied_orbs, mo_eigenvalues, unoccupied_evals, &
748 unoccupied_evals_stm, molecule_set, mo_derivs, &
749 subsys, particles, input, print_key, kinetic_m, marked_states, &
750 mixed_evals, qs_loc_env_mixed)
751 NULLIFY (lumo_ptr, rho_ao)
758 p_loc_mixed = .false.
760 cpassert(
ASSOCIATED(scf_env))
761 cpassert(
ASSOCIATED(qs_env))
764 dft_control=dft_control, &
765 molecule_set=molecule_set, &
766 scf_control=scf_control, &
767 do_kpoints=do_kpoints, &
772 particle_set=particle_set, &
773 atomic_kind_set=atomic_kind_set, &
774 qs_kind_set=qs_kind_set)
775 rtp_control => dft_control%rtp_control
782 CALL get_qs_env(qs_env, matrix_p_mp2=matrix_p_mp2)
783 DO ispin = 1, dft_control%nspins
784 CALL dbcsr_add(rho_ao(ispin, 1)%matrix, matrix_p_mp2(ispin)%matrix, 1.0_dp, 1.0_dp)
789 CALL update_hartree_with_mp2(rho, qs_env)
792 CALL write_available_results(qs_env, scf_env)
796 "DFT%PRINT%KINETIC_ENERGY") /= 0)
THEN
798 cpassert(
ASSOCIATED(kinetic_m))
799 cpassert(
ASSOCIATED(kinetic_m(1, 1)%matrix))
803 IF (unit_nr > 0)
THEN
804 WRITE (unit_nr,
'(T3,A,T55,F25.14)')
"Electronic kinetic energy:", e_kin
807 "DFT%PRINT%KINETIC_ENERGY")
811 CALL qs_scf_post_charges(input, logger, qs_env)
826 IF (loc_print_explicit)
THEN
848 IF (loc_explicit)
THEN
858 p_loc_mixed = .false.
862 IF (n_rep == 0 .AND. p_loc_lumo)
THEN
863 CALL cp_abort(__location__,
"No LIST_UNOCCUPIED was specified, "// &
864 "therefore localization of unoccupied states will be skipped!")
875 mo_section = cube_or_openpmd(input, str_mo_cubes, str_mo_openpmd, logger)
877 IF (loc_print_explicit)
THEN
881 do_wannier_cubes = .false.
883 nlumo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NLUMO"))
884 nhomo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NHOMO"))
887 IF (((mo_section%do_output .OR. do_wannier_cubes) .AND. (nlumo /= 0 .OR. nhomo /= 0)) .OR. p_loc)
THEN
888 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
890 CALL auxbas_pw_pool%create_pw(wf_r)
891 CALL auxbas_pw_pool%create_pw(wf_g)
894 IF (dft_control%restricted)
THEN
898 nspins = dft_control%nspins
901 IF (dft_control%restricted .AND. (mo_section%do_output .OR. p_loc_homo))
THEN
902 CALL cp_abort(__location__,
"Unclear how we define MOs / localization in the restricted case ... ")
907 cpwarn_if(mo_section%do_cubes(), warning_cube_kpoint)
908 cpwarn_if(mo_section%do_openpmd(), warning_openpmd_kpoint)
913 IF ((mo_section%do_output .AND. nhomo /= 0) .OR. do_stm)
THEN
915 IF (dft_control%do_admm)
THEN
917 CALL make_mo_eig(mos, nspins, ks_rmpv, scf_control, mo_derivs, admm_env=admm_env)
919 IF (dft_control%hairy_probes)
THEN
920 scf_control%smear%do_smear = .false.
921 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs, &
923 probe=dft_control%probe)
925 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
928 DO ispin = 1, dft_control%nspins
929 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=homo)
930 homo_lumo(ispin, 1) = mo_eigenvalues(homo)
934 IF (mo_section%do_output .AND. nhomo /= 0)
THEN
937 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
938 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
939 CALL qs_scf_post_occ_cubes(input, dft_section, dft_control, logger, qs_env, &
940 mo_coeff, wf_g, wf_r, particles, homo, ispin, mo_section)
951 cpwarn(
"Localization not implemented for k-point calculations!")
952 ELSE IF (dft_control%restricted &
955 cpabort(
"ROKS works only with LOCALIZE METHOD NONE or JACOBI")
957 ALLOCATE (occupied_orbs(dft_control%nspins))
958 ALLOCATE (occupied_evals(dft_control%nspins))
959 ALLOCATE (homo_localized(dft_control%nspins))
960 DO ispin = 1, dft_control%nspins
961 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
962 eigenvalues=mo_eigenvalues)
963 occupied_orbs(ispin) = mo_coeff
964 occupied_evals(ispin)%array => mo_eigenvalues
965 CALL cp_fm_create(homo_localized(ispin), occupied_orbs(ispin)%matrix_struct)
966 CALL cp_fm_to_fm(occupied_orbs(ispin), homo_localized(ispin))
969 CALL get_qs_env(qs_env, mo_loc_history=mo_loc_history)
972 ALLOCATE (qs_loc_env_homo)
975 CALL qs_loc_init(qs_env, qs_loc_env_homo, localize_section, homo_localized, do_homo, &
976 mo_section%do_output, mo_loc_history=mo_loc_history)
978 wf_r, wf_g, particles, occupied_orbs, occupied_evals, marked_states)
981 IF (qs_loc_env_homo%localized_wfn_control%use_history)
THEN
983 CALL set_qs_env(qs_env, mo_loc_history=mo_loc_history)
988 homo_localized, do_homo)
990 DEALLOCATE (occupied_orbs)
991 DEALLOCATE (occupied_evals)
993 IF (qs_loc_env_homo%do_localize)
THEN
994 CALL loc_dipole(input, dft_control, qs_loc_env_homo, logger, qs_env)
1000 IF (do_kpoints)
THEN
1001 IF (mo_section%do_output .OR. p_loc_lumo)
THEN
1003 cpwarn(
"Localization and MO related output not implemented for k-point calculations!")
1006 compute_lumos = mo_section%do_output .AND. nlumo /= 0
1007 compute_lumos = compute_lumos .OR. p_loc_lumo
1009 DO ispin = 1, dft_control%nspins
1010 CALL get_mo_set(mo_set=mos(ispin), homo=homo, nmo=nmo)
1011 compute_lumos = compute_lumos .AND. homo == nmo
1014 IF (mo_section%do_output .AND. .NOT. compute_lumos)
THEN
1016 nlumo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NLUMO"))
1017 DO ispin = 1, dft_control%nspins
1019 CALL get_mo_set(mo_set=mos(ispin), homo=homo, nmo=nmo, eigenvalues=mo_eigenvalues)
1020 IF (nlumo > nmo - homo)
THEN
1023 IF (nlumo == -1)
THEN
1026 IF (output_unit > 0)
WRITE (output_unit, *)
" "
1027 IF (output_unit > 0)
WRITE (output_unit, *)
" Lowest eigenvalues of the unoccupied subspace spin ", ispin
1028 IF (output_unit > 0)
WRITE (output_unit, *)
"---------------------------------------------"
1029 IF (output_unit > 0)
WRITE (output_unit,
'(4(1X,1F16.8))') mo_eigenvalues(homo + 1:homo + nlumo)
1032 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1033 CALL qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
1034 mo_coeff, wf_g, wf_r, particles, nlumo, homo, ispin, lumo=homo + 1, mo_section=mo_section)
1040 IF (compute_lumos)
THEN
1041 check_write = .true.
1043 IF (nlumo == 0) check_write = .false.
1044 IF (p_loc_lumo)
THEN
1046 ALLOCATE (qs_loc_env_lumo)
1049 min_lumos = max(maxval(qs_loc_env_lumo%localized_wfn_control%loc_states(:, :)), nlumo)
1052 ALLOCATE (unoccupied_orbs(dft_control%nspins))
1053 ALLOCATE (unoccupied_evals(dft_control%nspins))
1054 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, min_lumos, nlumos)
1055 lumo_ptr => unoccupied_orbs
1056 DO ispin = 1, dft_control%nspins
1058 homo_lumo(ispin, 2) = unoccupied_evals(ispin)%array(1)
1059 CALL get_mo_set(mo_set=mos(ispin), homo=homo)
1060 IF (check_write)
THEN
1061 IF (p_loc_lumo .AND. nlumo /= -1) nlumos = min(nlumo, nlumos)
1063 CALL qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
1064 unoccupied_orbs(ispin), wf_g, wf_r, particles, nlumos, homo, ispin, mo_section=mo_section)
1068 IF (p_loc_lumo)
THEN
1069 ALLOCATE (lumo_localized(dft_control%nspins))
1070 DO ispin = 1, dft_control%nspins
1071 CALL cp_fm_create(lumo_localized(ispin), unoccupied_orbs(ispin)%matrix_struct)
1072 CALL cp_fm_to_fm(unoccupied_orbs(ispin), lumo_localized(ispin))
1074 CALL qs_loc_init(qs_env, qs_loc_env_lumo, localize_section, lumo_localized, do_homo, mo_section%do_output, &
1075 evals=unoccupied_evals)
1076 CALL qs_loc_env_init(qs_loc_env_lumo, qs_loc_env_lumo%localized_wfn_control, qs_env, &
1077 loc_coeff=unoccupied_orbs)
1079 lumo_localized, wf_r, wf_g, particles, &
1080 unoccupied_orbs, unoccupied_evals, marked_states)
1081 CALL loc_write_restart(qs_loc_env_lumo, loc_print_section, mos, homo_localized, do_homo, &
1082 evals=unoccupied_evals)
1083 lumo_ptr => lumo_localized
1087 IF (has_homo .AND. has_lumo)
THEN
1088 IF (output_unit > 0)
WRITE (output_unit, *)
" "
1089 DO ispin = 1, dft_control%nspins
1090 IF (.NOT. scf_control%smear%do_smear)
THEN
1091 gap = homo_lumo(ispin, 2) - homo_lumo(ispin, 1)
1092 IF (output_unit > 0)
WRITE (output_unit,
'(T2,A,F12.6)') &
1093 "HOMO - LUMO gap [eV] :", gap*
evolt
1099 IF (p_loc_mixed)
THEN
1100 IF (do_kpoints)
THEN
1101 cpwarn(
"Localization not implemented for k-point calculations!")
1102 ELSE IF (dft_control%restricted)
THEN
1103 IF (output_unit > 0)
WRITE (output_unit, *) &
1104 " Unclear how we define MOs / localization in the restricted case... skipping"
1107 ALLOCATE (mixed_orbs(dft_control%nspins))
1108 ALLOCATE (mixed_evals(dft_control%nspins))
1109 ALLOCATE (mixed_localized(dft_control%nspins))
1110 DO ispin = 1, dft_control%nspins
1111 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1112 eigenvalues=mo_eigenvalues)
1113 mixed_orbs(ispin) = mo_coeff
1114 mixed_evals(ispin)%array => mo_eigenvalues
1115 CALL cp_fm_create(mixed_localized(ispin), mixed_orbs(ispin)%matrix_struct)
1116 CALL cp_fm_to_fm(mixed_orbs(ispin), mixed_localized(ispin))
1119 CALL get_qs_env(qs_env, mo_loc_history=mo_loc_history)
1122 total_zeff_corr = scf_env%sum_zeff_corr
1123 ALLOCATE (qs_loc_env_mixed)
1126 CALL qs_loc_init(qs_env, qs_loc_env_mixed, localize_section, mixed_localized, do_homo, &
1127 mo_section%do_output, mo_loc_history=mo_loc_history, tot_zeff_corr=total_zeff_corr, &
1130 DO ispin = 1, dft_control%nspins
1131 CALL cp_fm_get_info(mixed_localized(ispin), ncol_global=nchk_nmoloc)
1135 wf_r, wf_g, particles, mixed_orbs, mixed_evals, marked_states)
1138 IF (qs_loc_env_mixed%localized_wfn_control%use_history)
THEN
1140 CALL set_qs_env(qs_env, mo_loc_history=mo_loc_history)
1147 DEALLOCATE (mixed_orbs)
1148 DEALLOCATE (mixed_evals)
1153 IF (((mo_section%do_output .OR. do_wannier_cubes) .AND. (nlumo /= 0 .OR. nhomo /= 0)) .OR. p_loc)
THEN
1154 CALL auxbas_pw_pool%give_back_pw(wf_r)
1155 CALL auxbas_pw_pool%give_back_pw(wf_g)
1159 IF (.NOT. do_kpoints)
THEN
1160 IF (p_loc_homo)
THEN
1162 DEALLOCATE (qs_loc_env_homo)
1164 IF (p_loc_lumo)
THEN
1166 DEALLOCATE (qs_loc_env_lumo)
1168 IF (p_loc_mixed)
THEN
1170 DEALLOCATE (qs_loc_env_mixed)
1175 IF (do_kpoints)
THEN
1178 CALL get_qs_env(qs_env, matrix_s=matrix_s, para_env=para_env)
1179 CALL wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, &
1180 output_unit, unoccupied_orbs=lumo_ptr, scf_env=scf_env, &
1181 matrix_s=matrix_s, marked_states=marked_states)
1185 IF (
ASSOCIATED(marked_states))
THEN
1186 DEALLOCATE (marked_states)
1190 IF (.NOT. do_kpoints)
THEN
1191 IF (compute_lumos)
THEN
1192 DO ispin = 1, dft_control%nspins
1193 DEALLOCATE (unoccupied_evals(ispin)%array)
1196 DEALLOCATE (unoccupied_evals)
1197 DEALLOCATE (unoccupied_orbs)
1203 IF (do_kpoints)
THEN
1204 cpwarn(
"STM not implemented for k-point calculations!")
1206 NULLIFY (unoccupied_orbs_stm, unoccupied_evals_stm)
1207 IF (nlumo_stm > 0)
THEN
1208 ALLOCATE (unoccupied_orbs_stm(dft_control%nspins))
1209 ALLOCATE (unoccupied_evals_stm(dft_control%nspins))
1210 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs_stm, unoccupied_evals_stm, &
1214 CALL th_stm_image(qs_env, stm_section, particles, unoccupied_orbs_stm, &
1215 unoccupied_evals_stm)
1217 IF (nlumo_stm > 0)
THEN
1218 DO ispin = 1, dft_control%nspins
1219 DEALLOCATE (unoccupied_evals_stm(ispin)%array)
1221 DEALLOCATE (unoccupied_evals_stm)
1228 CALL qs_scf_post_xray(input, dft_section, logger, qs_env, output_unit)
1231 CALL qs_scf_post_efg(input, logger, qs_env)
1234 CALL qs_scf_post_et(input, qs_env, dft_control)
1237 CALL qs_scf_post_epr(input, logger, qs_env)
1240 CALL qs_scf_post_molopt(input, logger, qs_env)
1243 CALL qs_scf_post_elf(input, logger, qs_env)
1250 DO ispin = 1, dft_control%nspins
1251 CALL dbcsr_add(rho_ao(ispin, 1)%matrix, matrix_p_mp2(ispin)%matrix, 1.0_dp, -1.0_dp)
1259 CALL timestop(handle)
1272 SUBROUTINE make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
1276 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: unoccupied_orbs
1278 INTEGER,
INTENT(IN) :: nlumo
1279 INTEGER,
INTENT(OUT) :: nlumos
1281 CHARACTER(len=*),
PARAMETER :: routinen =
'make_lumo_gpw'
1283 INTEGER :: handle, homo, ispin, n, nao, nmo, &
1290 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_s
1297 CALL timeset(routinen, handle)
1299 NULLIFY (ks_rmpv, matrix_s, scf_control, dft_control, admm_env, para_env, blacs_env, mos)
1301 matrix_ks=ks_rmpv, &
1302 matrix_s=matrix_s, &
1303 scf_control=scf_control, &
1304 dft_control=dft_control, &
1305 admm_env=admm_env, &
1306 para_env=para_env, &
1307 blacs_env=blacs_env, &
1313 DO ispin = 1, dft_control%nspins
1314 NULLIFY (unoccupied_evals(ispin)%array)
1315 IF (output_unit > 0)
WRITE (output_unit, *)
" "
1316 IF (output_unit > 0)
WRITE (output_unit, *) &
1317 " Using OT eigensolver for additional unoccupied orbitals spin ", ispin
1318 IF (output_unit > 0)
WRITE (output_unit, *) &
1319 " Lowest Eigenvalues of the unoccupied subspace spin ", ispin
1320 IF (output_unit > 0)
WRITE (output_unit, fmt=
'(1X,A)')
"-----------------------------------------------------"
1321 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=homo, nao=nao, nmo=nmo)
1323 nlumos = max(1, min(nlumo, nao - nmo))
1324 IF (nlumo == -1) nlumos = nao - nmo
1325 ALLOCATE (unoccupied_evals(ispin)%array(nlumos))
1327 nrow_global=n, ncol_global=nlumos)
1328 CALL cp_fm_create(unoccupied_orbs(ispin), fm_struct_tmp, name=
"lumos")
1333 NULLIFY (local_preconditioner)
1334 IF (
ASSOCIATED(scf_env))
THEN
1335 IF (
ASSOCIATED(scf_env%ot_preconditioner))
THEN
1336 local_preconditioner => scf_env%ot_preconditioner(1)%preconditioner
1339 NULLIFY (local_preconditioner)
1345 IF (dft_control%do_admm)
THEN
1349 CALL ot_eigensolver(matrix_h=ks_rmpv(ispin)%matrix, matrix_s=matrix_s(1)%matrix, &
1350 matrix_c_fm=unoccupied_orbs(ispin), &
1351 matrix_orthogonal_space_fm=mo_coeff, &
1352 eps_gradient=scf_control%eps_lumos, &
1354 iter_max=scf_control%max_iter_lumos, &
1355 size_ortho_space=nmo)
1358 unoccupied_evals(ispin)%array, scr=output_unit, &
1359 ionode=output_unit > 0)
1362 IF (dft_control%do_admm)
THEN
1368 CALL timestop(handle)
1378 SUBROUTINE qs_scf_post_charges(input, logger, qs_env)
1383 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_charges'
1385 INTEGER :: handle, print_level, unit_nr
1386 LOGICAL :: do_kpoints, print_it
1389 CALL timeset(routinen, handle)
1391 CALL get_qs_env(qs_env=qs_env, do_kpoints=do_kpoints)
1399 log_filename=.false.)
1402 IF (print_it) print_level = 2
1404 IF (print_it) print_level = 3
1415 unit_nr =
cp_print_key_unit_nr(logger, input,
"PROPERTIES%FIT_CHARGE", extension=
".Fitcharge", &
1416 log_filename=.false.)
1418 CALL get_ddapc(qs_env, .false., density_fit_section, iwc=unit_nr)
1422 CALL timestop(handle)
1424 END SUBROUTINE qs_scf_post_charges
1441 SUBROUTINE qs_scf_post_occ_cubes(input, dft_section, dft_control, logger, qs_env, &
1442 mo_coeff, wf_g, wf_r, particles, homo, ispin, mo_section)
1451 INTEGER,
INTENT(IN) :: homo, ispin
1452 TYPE(cp_section_key) :: mo_section
1454 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_occ_cubes'
1456 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1457 INTEGER :: handle, i, ir, ivector, n_rep, nhomo, &
1459 INTEGER,
DIMENSION(:),
POINTER ::
list, list_index
1460 LOGICAL :: append_cube, mpi_io
1461 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
1466 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1468 CALL timeset(routinen, handle)
1473 cpassert(mo_section%grid_output /= grid_output_openpmd)
1476 NULLIFY (list_index)
1479 ,
cp_p_file) .AND.
section_get_lval(dft_section, mo_section%concat_to_relative(section_key_do_write(mo_section%grid_output))))
THEN
1481 nhomo =
section_get_ival(dft_section, mo_section%concat_to_relative(
"%NHOMO"))
1483 IF (mo_section%grid_output == grid_output_cubes)
THEN
1484 append_cube =
section_get_lval(dft_section, mo_section%concat_to_relative(
"%APPEND"))
1486 my_pos_cube =
"REWIND"
1487 IF (append_cube)
THEN
1488 my_pos_cube =
"APPEND"
1490 CALL section_vals_val_get(dft_section, mo_section%concat_to_relative(
"%HOMO_LIST"), n_rep_val=n_rep)
1495 CALL section_vals_val_get(dft_section, mo_section%concat_to_relative(
"%HOMO_LIST"), i_rep_val=ir, &
1497 IF (
ASSOCIATED(
list))
THEN
1499 DO i = 1,
SIZE(
list)
1500 list_index(i + nlist) =
list(i)
1502 nlist = nlist +
SIZE(
list)
1507 IF (nhomo == -1) nhomo = homo
1508 nlist = homo - max(1, homo - nhomo + 1) + 1
1509 ALLOCATE (list_index(nlist))
1511 list_index(i) = max(1, homo - nhomo + 1) + i - 1
1515 ivector = list_index(i)
1517 atomic_kind_set=atomic_kind_set, &
1518 qs_kind_set=qs_kind_set, &
1520 particle_set=particle_set, &
1523 cell, dft_control, particle_set, pw_env)
1524 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", ivector,
"_", ispin
1527 unit_nr = mo_section%print_key_unit_nr( &
1530 mo_section%absolute_section_key, &
1531 extension=
".cube", &
1532 middle_name=trim(filename), &
1533 file_position=my_pos_cube, &
1534 log_filename=.false., &
1536 openpmd_basename=
"dft-mo", &
1537 openpmd_unit_dimension=openpmd_unit_dimension_wavefunction, &
1538 openpmd_unit_si=openpmd_unit_si_wavefunction, &
1539 sim_time=qs_env%sim_time)
1540 WRITE (title, *)
"WAVEFUNCTION ", ivector,
" spin ", ispin,
" i.e. HOMO - ", ivector - homo
1541 CALL mo_section%write_pw(wf_r, unit_nr, title, particles=particles, zeff=zcharge, &
1542 stride=
section_get_ivals(dft_section, mo_section%concat_to_relative(
"%STRIDE")), &
1543 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%MO_CUBES%MAX_FILE_SIZE_MB"), &
1545 CALL mo_section%print_key_finished_output(unit_nr, logger, input, mo_section%absolute_section_key, mpi_io=mpi_io)
1547 IF (
ASSOCIATED(list_index))
DEALLOCATE (list_index)
1548 DEALLOCATE (zcharge)
1551 CALL timestop(handle)
1553 END SUBROUTINE qs_scf_post_occ_cubes
1572 SUBROUTINE qs_scf_post_unocc_cubes(input, dft_section, dft_control, logger, qs_env, &
1573 unoccupied_orbs, wf_g, wf_r, particles, nlumos, homo, ispin, lumo, mo_section)
1579 TYPE(
cp_fm_type),
INTENT(IN) :: unoccupied_orbs
1583 INTEGER,
INTENT(IN) :: nlumos, homo, ispin
1584 INTEGER,
INTENT(IN),
OPTIONAL :: lumo
1585 TYPE(cp_section_key) :: mo_section
1587 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_unocc_cubes'
1589 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1590 INTEGER :: handle, ifirst, index_mo, ivector, &
1592 LOGICAL :: append_cube, mpi_io
1593 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
1598 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1600 CALL timeset(routinen, handle)
1605 cpassert(mo_section%grid_output /= grid_output_openpmd)
1609 .AND.
section_get_lval(dft_section, mo_section%concat_to_relative(section_key_do_write(mo_section%grid_output))))
THEN
1611 NULLIFY (qs_kind_set, particle_set, pw_env, cell)
1613 IF (mo_section%grid_output == grid_output_cubes)
THEN
1614 append_cube =
section_get_lval(dft_section, mo_section%concat_to_relative(
"%APPEND"))
1616 my_pos_cube =
"REWIND"
1617 IF (append_cube)
THEN
1618 my_pos_cube =
"APPEND"
1621 IF (
PRESENT(lumo)) ifirst = lumo
1622 DO ivector = ifirst, ifirst + nlumos - 1
1624 atomic_kind_set=atomic_kind_set, &
1625 qs_kind_set=qs_kind_set, &
1627 particle_set=particle_set, &
1630 qs_kind_set, cell, dft_control, particle_set, pw_env)
1632 IF (ifirst == 1)
THEN
1633 index_mo = homo + ivector
1637 WRITE (filename,
'(a4,I5.5,a1,I1.1)')
"WFN_", index_mo,
"_", ispin
1640 unit_nr = mo_section%print_key_unit_nr( &
1643 mo_section%absolute_section_key, &
1644 extension=
".cube", &
1645 middle_name=trim(filename), &
1646 file_position=my_pos_cube, &
1647 log_filename=.false., &
1649 openpmd_basename=
"dft-mo", &
1650 openpmd_unit_dimension=openpmd_unit_dimension_wavefunction, &
1651 openpmd_unit_si=openpmd_unit_si_wavefunction, &
1652 sim_time=qs_env%sim_time)
1653 WRITE (title, *)
"WAVEFUNCTION ", index_mo,
" spin ", ispin,
" i.e. LUMO + ", ifirst + ivector - 2
1654 CALL mo_section%write_pw(wf_r, unit_nr, title, particles=particles, zeff=zcharge, &
1655 stride=
section_get_ivals(dft_section, mo_section%concat_to_relative(
"%STRIDE")), &
1656 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%MO_CUBES%MAX_FILE_SIZE_MB"), &
1658 CALL mo_section%print_key_finished_output(unit_nr, logger, input, mo_section%absolute_section_key, mpi_io=mpi_io)
1661 DEALLOCATE (zcharge)
1664 CALL timestop(handle)
1666 END SUBROUTINE qs_scf_post_unocc_cubes
1679 INTEGER,
INTENT(IN) :: output_unit
1681 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_moments'
1683 CHARACTER(LEN=default_path_length) :: filename
1684 INTEGER :: handle, max_nmo, maxmom, moments_format, &
1685 moments_unit_nr, reference, unit_nr
1686 LOGICAL :: com_nl, do_kg, do_kpoints, magnetic, &
1687 new_file, periodic, second_ref_point, &
1689 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ref_point
1692 CALL timeset(routinen, handle)
1695 subsection_name=
"DFT%PRINT%MOMENTS")
1700 keyword_name=
"DFT%PRINT%MOMENTS%MAX_MOMENT")
1702 keyword_name=
"DFT%PRINT%MOMENTS%FORMAT")
1704 keyword_name=
"DFT%PRINT%MOMENTS%PERIODIC")
1706 keyword_name=
"DFT%PRINT%MOMENTS%REFERENCE")
1708 keyword_name=
"DFT%PRINT%MOMENTS%MAGNETIC")
1710 keyword_name=
"DFT%PRINT%MOMENTS%VEL_REPRS")
1712 keyword_name=
"DFT%PRINT%MOMENTS%COM_NL")
1714 keyword_name=
"DFT%PRINT%MOMENTS%SECOND_REFERENCE_POINT")
1716 keyword_name=
"DFT%PRINT%MOMENTS%KG")
1718 keyword_name=
"DFT%PRINT%MOMENTS%MAX_NMO")
1723 print_key_path=
"DFT%PRINT%MOMENTS", extension=
".dat", &
1724 middle_name=
"moments", log_filename=.false., &
1725 is_new_file=new_file)
1727 IF (output_unit > 0)
THEN
1728 IF (unit_nr /= output_unit)
THEN
1729 INQUIRE (unit=unit_nr, name=filename)
1730 WRITE (unit=output_unit, fmt=
"(/,T2,A,2(/,T3,A),/)") &
1731 "MOMENTS",
"The electric/magnetic moments are written to file:", &
1734 WRITE (unit=output_unit, fmt=
"(/,T2,A)")
"ELECTRIC/MAGNETIC MOMENTS"
1738 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
1741 IF (do_kpoints)
THEN
1742 cpabort(
"MOMENTS FORMAT TRAJECTORY is not available for k-point calculations.")
1744 IF (maxmom /= 1) cpabort(
"MOMENTS FORMAT TRAJECTORY requires MAX_MOMENT 1.")
1745 IF (magnetic) cpabort(
"MOMENTS FORMAT TRAJECTORY does not support MAGNETIC moments.")
1746 IF (vel_reprs) cpabort(
"MOMENTS FORMAT TRAJECTORY does not support VEL_REPRS.")
1747 IF (do_kg) cpabort(
"MOMENTS FORMAT TRAJECTORY does not support KG moments.")
1748 moments_unit_nr = -1
1750 moments_unit_nr = unit_nr
1753 IF (do_kpoints)
THEN
1754 CALL qs_moment_kpoints(qs_env, maxmom, reference, ref_point, max_nmo, moments_unit_nr)
1759 CALL qs_moment_locop(qs_env, magnetic, maxmom, reference, ref_point, moments_unit_nr, vel_reprs, com_nl)
1766 CALL write_moments_trajectory(unit_nr, logger, qs_env, periodic, new_file,
"MOMENTS|")
1770 basis_section=input, print_key_path=
"DFT%PRINT%MOMENTS")
1772 IF (second_ref_point)
THEN
1774 keyword_name=
"DFT%PRINT%MOMENTS%REFERENCE_2")
1779 print_key_path=
"DFT%PRINT%MOMENTS", extension=
".dat", &
1780 middle_name=
"moments_refpoint_2", log_filename=.false., &
1781 is_new_file=new_file)
1783 IF (output_unit > 0)
THEN
1784 IF (unit_nr /= output_unit)
THEN
1785 INQUIRE (unit=unit_nr, name=filename)
1786 WRITE (unit=output_unit, fmt=
"(/,T2,A,2(/,T3,A),/)") &
1787 "MOMENTS",
"The electric/magnetic moments for the second reference point are written to file:", &
1790 WRITE (unit=output_unit, fmt=
"(/,T2,A)")
"ELECTRIC/MAGNETIC MOMENTS"
1794 IF (do_kpoints)
THEN
1795 CALL qs_moment_kpoints(qs_env, maxmom, reference, ref_point, max_nmo, moments_unit_nr)
1800 CALL qs_moment_locop(qs_env, magnetic, maxmom, reference, ref_point, &
1801 moments_unit_nr, vel_reprs, com_nl)
1805 CALL write_moments_trajectory(unit_nr, logger, qs_env, periodic, new_file,
"MOMENTS_REF2|")
1808 basis_section=input, print_key_path=
"DFT%PRINT%MOMENTS")
1813 CALL timestop(handle)
1826 SUBROUTINE write_moments_trajectory(unit_nr, logger, qs_env, periodic, new_file, label)
1827 INTEGER,
INTENT(IN) :: unit_nr
1830 LOGICAL,
INTENT(IN) :: periodic, new_file
1831 CHARACTER(LEN=*),
INTENT(IN) :: label
1833 CHARACTER(LEN=default_string_length) :: description, iter
1834 REAL(kind=
dp),
DIMENSION(3) :: dipole
1838 IF (unit_nr <= 0)
RETURN
1840 NULLIFY (cell, results)
1841 CALL get_qs_env(qs_env, cell=cell, results=results)
1842 description =
"[DIPOLE]"
1843 CALL get_results(results=results, description=description, values=dipole)
1847 WRITE (unit_nr,
"(A)")
"# "//trim(label)// &
1848 " iter_level dipole_x dipole_y dipole_z dipole_norm cell_xx cell_xy cell_xz"// &
1849 " cell_yx cell_yy cell_yz cell_zx cell_zy cell_zz [Debye]"
1851 WRITE (unit_nr,
"(A)")
"# "//trim(label)// &
1852 " iter_level dipole_x dipole_y dipole_z dipole_norm [Debye]"
1858 WRITE (unit_nr,
"(1X,A,1X,A15,13(1X,ES18.10))") trim(label), iter(1:15), &
1862 WRITE (unit_nr,
"(1X,A,1X,A15,4(1X,ES18.10))") trim(label), iter(1:15), &
1866 END SUBROUTINE write_moments_trajectory
1876 SUBROUTINE qs_scf_post_xray(input, dft_section, logger, qs_env, output_unit)
1881 INTEGER,
INTENT(IN) :: output_unit
1883 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_scf_post_xray'
1885 CHARACTER(LEN=default_path_length) :: filename
1886 INTEGER :: handle, unit_nr
1887 REAL(kind=
dp) :: q_max
1890 CALL timeset(routinen, handle)
1893 subsection_name=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM")
1897 keyword_name=
"PRINT%XRAY_DIFFRACTION_SPECTRUM%Q_MAX")
1899 basis_section=input, &
1900 print_key_path=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM", &
1902 middle_name=
"xrd", &
1903 log_filename=.false.)
1904 IF (output_unit > 0)
THEN
1905 INQUIRE (unit=unit_nr, name=filename)
1906 WRITE (unit=output_unit, fmt=
"(/,/,T2,A)") &
1907 "X-RAY DIFFRACTION SPECTRUM"
1908 IF (unit_nr /= output_unit)
THEN
1909 WRITE (unit=output_unit, fmt=
"(/,T3,A,/,/,T3,A,/)") &
1910 "The coherent X-ray diffraction spectrum is written to the file:", &
1915 unit_number=unit_nr, &
1919 basis_section=input, &
1920 print_key_path=
"DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM")
1923 CALL timestop(handle)
1925 END SUBROUTINE qs_scf_post_xray
1933 SUBROUTINE qs_scf_post_efg(input, logger, qs_env)
1938 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_efg'
1943 CALL timeset(routinen, handle)
1946 subsection_name=
"DFT%PRINT%ELECTRIC_FIELD_GRADIENT")
1952 CALL timestop(handle)
1954 END SUBROUTINE qs_scf_post_efg
1962 SUBROUTINE qs_scf_post_et(input, qs_env, dft_control)
1967 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_et'
1969 INTEGER :: handle, ispin
1971 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: my_mos
1974 CALL timeset(routinen, handle)
1980 IF (qs_env%et_coupling%first_run)
THEN
1982 ALLOCATE (my_mos(dft_control%nspins))
1983 ALLOCATE (qs_env%et_coupling%et_mo_coeff(dft_control%nspins))
1984 DO ispin = 1, dft_control%nspins
1986 matrix_struct=qs_env%mos(ispin)%mo_coeff%matrix_struct, &
1987 name=
"FIRST_RUN_COEFF"//trim(adjustl(
cp_to_string(ispin)))//
"MATRIX")
1996 CALL timestop(handle)
1998 END SUBROUTINE qs_scf_post_et
2009 SUBROUTINE qs_scf_post_elf(input, logger, qs_env)
2014 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_elf'
2016 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
2018 INTEGER :: handle, ispin, output_unit, unit_nr
2019 LOGICAL :: append_cube, gapw, mpi_io
2020 REAL(
dp) :: rho_cutoff
2021 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
2022 TYPE(cp_section_key) :: elf_section_key
2032 CALL timeset(routinen, handle)
2035 elf_section_key = cube_or_openpmd(input, str_elf_cubes, str_elf_openpmd, logger)
2038 IF (elf_section_key%do_output)
THEN
2040 NULLIFY (dft_control, pw_env, auxbas_pw_pool, pw_pools, particles, subsys)
2041 CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env, subsys=subsys)
2044 gapw = dft_control%qs_control%gapw
2045 IF (.NOT. gapw)
THEN
2047 ALLOCATE (elf_r(dft_control%nspins))
2048 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
2050 DO ispin = 1, dft_control%nspins
2051 CALL auxbas_pw_pool%create_pw(elf_r(ispin))
2055 IF (output_unit > 0)
THEN
2056 WRITE (unit=output_unit, fmt=
"(/,T15,A,/)") &
2057 " ----- ELF is computed on the real space grid -----"
2066 IF (elf_section_key%grid_output == grid_output_cubes)
THEN
2069 my_pos_cube =
"REWIND"
2070 IF (append_cube)
THEN
2071 my_pos_cube =
"APPEND"
2074 DO ispin = 1, dft_control%nspins
2075 WRITE (filename,
'(a5,I1.1)')
"ELF_S", ispin
2076 WRITE (title, *)
"ELF spin ", ispin
2078 unit_nr = elf_section_key%print_key_unit_nr( &
2081 elf_section_key%absolute_section_key, &
2082 extension=
".cube", &
2083 middle_name=trim(filename), &
2084 file_position=my_pos_cube, &
2085 log_filename=.false., &
2087 fout=mpi_filename, &
2088 openpmd_basename=
"dft-elf", &
2089 openpmd_unit_dimension=openpmd_unit_dimension_dimensionless, &
2090 openpmd_unit_si=openpmd_unit_si_dimensionless, &
2091 sim_time=qs_env%sim_time)
2092 IF (output_unit > 0)
THEN
2093 IF (.NOT. mpi_io)
THEN
2094 INQUIRE (unit=unit_nr, name=filename)
2096 filename = mpi_filename
2098 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
2099 "ELF is written in "//elf_section_key%format_name//
" file format to the file:", &
2103 CALL elf_section_key%write_pw(elf_r(ispin), unit_nr, title, particles=particles, zeff=zcharge, &
2105 CALL elf_section_key%print_key_finished_output( &
2109 elf_section_key%absolute_section_key, &
2112 CALL auxbas_pw_pool%give_back_pw(elf_r(ispin))
2116 DEALLOCATE (elf_r, zcharge)
2120 cpwarn(
"ELF not implemented for GAPW calculations!")
2125 CALL timestop(handle)
2127 END SUBROUTINE qs_scf_post_elf
2139 SUBROUTINE qs_scf_post_molopt(input, logger, qs_env)
2144 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_molopt'
2146 INTEGER :: handle, nao, unit_nr
2147 REAL(kind=
dp) :: s_cond_number
2148 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
2157 CALL timeset(routinen, handle)
2160 subsection_name=
"DFT%PRINT%BASIS_MOLOPT_QUANTITIES")
2164 CALL get_qs_env(qs_env, energy=energy, matrix_s=matrix_s, mos=mos)
2167 CALL get_mo_set(mo_set=mos(1), mo_coeff=mo_coeff, nao=nao)
2169 nrow_global=nao, ncol_global=nao, &
2170 template_fmstruct=mo_coeff%matrix_struct)
2171 CALL cp_fm_create(fm_s, matrix_struct=ao_ao_fmstruct, &
2173 CALL cp_fm_create(fm_work, matrix_struct=ao_ao_fmstruct, &
2176 ALLOCATE (eigenvalues(nao))
2184 s_cond_number = maxval(abs(eigenvalues))/max(minval(abs(eigenvalues)), epsilon(0.0_dp))
2187 extension=
".molopt")
2189 IF (unit_nr > 0)
THEN
2192 WRITE (unit_nr,
'(T2,A28,2A25)')
"",
"Tot. Ener.",
"S Cond. Numb."
2193 WRITE (unit_nr,
'(T2,A28,2E25.17)')
"BASIS_MOLOPT_QUANTITIES", energy%total, s_cond_number
2197 "DFT%PRINT%BASIS_MOLOPT_QUANTITIES")
2201 CALL timestop(handle)
2203 END SUBROUTINE qs_scf_post_molopt
2211 SUBROUTINE qs_scf_post_epr(input, logger, qs_env)
2216 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_epr'
2221 CALL timeset(routinen, handle)
2224 subsection_name=
"DFT%PRINT%HYPERFINE_COUPLING_TENSOR")
2230 CALL timestop(handle)
2232 END SUBROUTINE qs_scf_post_epr
2241 SUBROUTINE write_available_results(qs_env, scf_env)
2245 CHARACTER(len=*),
PARAMETER :: routinen =
'write_available_results'
2249 CALL timeset(routinen, handle)
2257 CALL timestop(handle)
2259 END SUBROUTINE write_available_results
2272 CHARACTER(len=*),
PARAMETER :: routinen =
'write_mo_dependent_results'
2274 INTEGER :: handle, homo, ispin, nlumo_dos, &
2275 nlumo_molden, nlumo_required, nlumos, &
2277 LOGICAL :: all_equal, defer_molden, do_curve, &
2278 do_dos, do_kpoints, do_pdos, &
2279 do_projected_dos, explicit
2280 REAL(kind=
dp) :: maxocc, s_square, s_square_ideal, &
2281 total_abs_spin_dens, total_spin_dens
2282 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, occupation_numbers
2287 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: unoccupied_orbs
2290 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_rmpv, matrix_s
2304 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2309 dos_section, input, sprint_section, &
2314 CALL timeset(routinen, handle)
2316 NULLIFY (cell, dft_control, pw_env, auxbas_pw_pool, pw_pools, mo_coeff, &
2317 mo_coeff_deriv, mo_eigenvalues, mos, atomic_kind_set, qs_kind_set, &
2318 particle_set, rho, ks_rmpv, matrix_s, scf_control, dft_section, &
2319 molecule_set, input, particles, subsys, rho_r, unoccupied_orbs, &
2320 unoccupied_evals, casino_section, dos_section)
2325 cpassert(
ASSOCIATED(qs_env))
2327 dft_control=dft_control, &
2328 molecule_set=molecule_set, &
2329 atomic_kind_set=atomic_kind_set, &
2330 particle_set=particle_set, &
2331 qs_kind_set=qs_kind_set, &
2332 admm_env=admm_env, &
2333 scf_control=scf_control, &
2342 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
2346 IF (.NOT. qs_env%run_rtp)
THEN
2359 defer_molden = .false.
2360 IF (.NOT. do_kpoints)
THEN
2361 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv)
2365 IF (nlumo_molden /= 0 .AND.
PRESENT(scf_env))
THEN
2366 IF (scf_env%method ==
ot_method_nr) defer_molden = .true.
2368 IF (.NOT. defer_molden)
THEN
2369 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell, &
2370 qs_env=qs_env, calc_energies=.true.)
2379 cpwarn(
"Molden format output is not possible for k-point calculations.")
2383 cpwarn(
"Chargemol .wfx format output is not possible for k-point calculations.")
2390 IF (do_kpoints)
THEN
2394 cpwarn(
"MO_KP is only available for k-point calculations, ignored for Gamma-only")
2405 IF (.NOT. do_kpoints .AND.
PRESENT(scf_env))
THEN
2409 IF (nlumo_dos == -1)
THEN
2411 ELSE IF (nlumo_required /= -1)
THEN
2412 nlumo_required = max(nlumo_required, nlumo_dos)
2416 IF (defer_molden)
THEN
2417 IF (nlumo_molden == -1)
THEN
2419 ELSE IF (nlumo_required /= -1)
THEN
2420 nlumo_required = max(nlumo_required, nlumo_molden)
2423 IF (nlumo_required /= 0)
THEN
2424 ALLOCATE (unoccupied_orbs(dft_control%nspins))
2425 ALLOCATE (unoccupied_evals(dft_control%nspins))
2426 CALL make_lumo_gpw(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, &
2427 nlumo_required, nlumos)
2430 IF (do_dos .OR. do_projected_dos)
THEN
2431 DO ispin = 1, dft_control%nspins
2434 IF (dft_control%do_admm)
THEN
2437 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
2438 eigenvalues=mo_eigenvalues)
2439 IF (
ASSOCIATED(qs_env%mo_derivs))
THEN
2440 mo_coeff_deriv => qs_env%mo_derivs(ispin)%matrix
2442 mo_coeff_deriv => null()
2445 do_rotation=.true., &
2446 co_rotate_dbcsr=mo_coeff_deriv)
2448 IF (dft_control%do_admm)
THEN
2456 IF (defer_molden)
THEN
2457 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2458 IF (output_unit > 0)
THEN
2459 WRITE (output_unit,
'(/,T2,A,I6,A)') &
2460 "MO_MOLDEN| Writing ", nlumos,
" unoccupied orbitals to molden file"
2462 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell, &
2463 unoccupied_orbs=unoccupied_orbs, &
2464 unoccupied_evals=unoccupied_evals, &
2465 qs_env=qs_env, calc_energies=.true.)
2471 IF (do_kpoints)
THEN
2473 IF (do_curve)
CALL calculate_dos_kp(qs_env, dft_section, write_curve_output=.true.)
2476 IF (
ASSOCIATED(unoccupied_evals))
THEN
2477 CALL calculate_dos(mos, dft_section, unoccupied_evals=unoccupied_evals, &
2478 smearing_enabled=dft_control%smear)
2479 IF (do_curve)
CALL calculate_dos(mos, dft_section, unoccupied_evals=unoccupied_evals, &
2480 smearing_enabled=dft_control%smear, write_curve_output=.true.)
2482 CALL calculate_dos(mos, dft_section, smearing_enabled=dft_control%smear)
2483 IF (do_curve)
CALL calculate_dos(mos, dft_section, smearing_enabled=dft_control%smear, &
2484 write_curve_output=.true.)
2490 IF (do_projected_dos)
THEN
2491 IF (do_kpoints)
THEN
2493 write_pdos=do_pdos, write_pdos_curve=do_curve)
2498 DO ispin = 1, dft_control%nspins
2499 IF (dft_control%nspins == 2)
THEN
2500 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2502 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin, &
2503 unoccupied_orbs=unoccupied_orbs(ispin), &
2504 unoccupied_evals=unoccupied_evals(ispin), &
2505 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_curve=do_curve)
2508 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin, &
2509 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_curve=do_curve)
2512 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2514 qs_kind_set, particle_set, qs_env, dft_section, &
2515 unoccupied_orbs=unoccupied_orbs(ispin), &
2516 unoccupied_evals=unoccupied_evals(ispin), &
2517 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_curve=do_curve)
2520 qs_kind_set, particle_set, qs_env, dft_section, &
2521 pdos_print_key=
"PRINT%DOS", write_pdos=do_pdos, write_pdos_curve=do_curve)
2527 IF (
ASSOCIATED(unoccupied_orbs))
THEN
2528 DO ispin = 1, dft_control%nspins
2529 DEALLOCATE (unoccupied_evals(ispin)%array)
2532 DEALLOCATE (unoccupied_evals)
2533 DEALLOCATE (unoccupied_orbs)
2538 IF (dft_control%nspins == 2)
THEN
2539 total_spin_dens = 0.0_dp
2540 total_abs_spin_dens = 0.0_dp
2541 IF (dft_control%qs_control%gapw)
THEN
2542 CALL get_qs_env(qs_env, qs_charges=qs_charges)
2543 total_spin_dens = qs_charges%total_rho_hard_spin - &
2544 qs_charges%total_rho_soft_spin
2545 total_abs_spin_dens = qs_charges%total_rho_hard_abs_spin - &
2546 qs_charges%total_rho_soft_abs_spin
2549 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
2550 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
2552 CALL auxbas_pw_pool%create_pw(wf_r)
2554 CALL pw_axpy(rho_r(2), wf_r, alpha=-1._dp)
2556 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'(/,(T3,A,T61,F20.10))') &
2557 "Integrated spin density: ", total_spin_dens
2559 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'((T3,A,T61,F20.10))') &
2560 "Integrated absolute spin density: ", total_abs_spin_dens
2561 CALL auxbas_pw_pool%give_back_pw(wf_r)
2567 IF (.NOT. do_kpoints)
THEN
2569 DO ispin = 1, dft_control%nspins
2571 occupation_numbers=occupation_numbers, &
2576 all_equal = all_equal .AND. &
2577 (all(occupation_numbers(1:homo) == maxocc) .AND. &
2578 all(occupation_numbers(homo + 1:nmo) == 0.0_dp))
2583 matrix_s=matrix_s, &
2586 s_square_ideal=s_square_ideal)
2587 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
'(T3,A,T51,2F15.6)') &
2588 "Ideal and single determinant S**2 : ", s_square_ideal, s_square
2589 energy%s_square = s_square
2594 CALL timestop(handle)
2606 CHARACTER(len=*),
PARAMETER :: routinen =
'write_mo_free_results'
2607 CHARACTER(len=1),
DIMENSION(3),
PARAMETER :: cdir = [
"x",
"y",
"z"]
2609 CHARACTER(LEN=2) :: element_symbol
2610 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
2612 CHARACTER(LEN=default_string_length) :: name, print_density
2613 INTEGER :: after, handle, i, iat, id, ikind, img, iso, ispin, iw, l, n_rep_hf, natom, nd(3), &
2614 ngto, niso, nkind, np, nr, output_unit, print_level, should_print_bqb, should_print_voro, &
2615 unit_nr, unit_nr_voro
2616 LOGICAL :: append_cube, append_voro, do_hfx, do_kpoints, mpi_io, omit_headers, print_it, &
2617 rho_r_valid, voro_print_txt, write_ks, write_xc, xrd_interface
2619 rho_total, rho_total_rspace, udvol, &
2621 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
2622 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: bfun
2623 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: aedens, ccdens, ppdens
2624 REAL(kind=
dp),
DIMENSION(3) :: checksum_hr, dr
2625 REAL(kind=
dp),
DIMENSION(:),
POINTER :: my_q0
2630 TYPE(cp_section_key) :: e_density_section
2632 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: ks_rmpv, matrix_s, matrix_vxc, rho_ao
2638 POINTER :: sab_orb, sap_ppnl
2642 TYPE(
pw_c1d_gs_type),
POINTER :: rho0_s_gs, rho_core, rhoz_cneo_s_gs
2649 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2657 print_key, print_key_bqb, &
2658 print_key_voro, xc_section
2660 CALL timeset(routinen, handle)
2661 NULLIFY (cell, dft_control, pw_env, auxbas_pw_pool, pw_pools, hfx_section, &
2662 atomic_kind_set, qs_kind_set, particle_set, rho, ks_rmpv, rho_ao, rho_r, &
2663 dft_section, xc_section, input, particles, subsys, matrix_vxc, v_hartree_rspace, &
2664 vee, matrix_hr, matrix_s, sab_orb, sap_ppnl)
2669 cpassert(
ASSOCIATED(qs_env))
2671 atomic_kind_set=atomic_kind_set, &
2672 qs_kind_set=qs_kind_set, &
2675 particle_set=particle_set, &
2677 para_env=para_env, &
2678 dft_control=dft_control, &
2680 do_kpoints=do_kpoints, &
2682 matrix_s_kp=matrix_s, &
2695 "DFT%PRINT%TOT_DENSITY_CUBE"),
cp_p_file))
THEN
2696 NULLIFY (rho_core, rho0_s_gs, rhoz_cneo_s_gs)
2698 my_pos_cube =
"REWIND"
2699 IF (append_cube)
THEN
2700 my_pos_cube =
"APPEND"
2703 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, rho_core=rho_core, &
2704 rho0_s_gs=rho0_s_gs, rhoz_cneo_s_gs=rhoz_cneo_s_gs)
2705 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
2707 CALL auxbas_pw_pool%create_pw(wf_r)
2708 IF (dft_control%qs_control%gapw)
THEN
2709 IF (dft_control%qs_control%gapw_control%nopaw_as_gpw)
THEN
2710 CALL pw_axpy(rho_core, rho0_s_gs)
2711 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2712 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs)
2715 CALL pw_axpy(rho_core, rho0_s_gs, -1.0_dp)
2716 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2717 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs, -1.0_dp)
2720 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2721 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs)
2724 IF (
ASSOCIATED(rhoz_cneo_s_gs))
THEN
2725 CALL pw_axpy(rhoz_cneo_s_gs, rho0_s_gs, -1.0_dp)
2731 DO ispin = 1, dft_control%nspins
2732 CALL pw_axpy(rho_r(ispin), wf_r)
2734 filename =
"TOTAL_DENSITY"
2737 extension=
".cube", middle_name=trim(filename), file_position=my_pos_cube, &
2738 log_filename=.false., mpi_io=mpi_io)
2740 particles=particles, zeff=zcharge, &
2742 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%TOT_DENSITY_CUBE%MAX_FILE_SIZE_MB"), &
2745 "DFT%PRINT%TOT_DENSITY_CUBE", mpi_io=mpi_io)
2746 CALL auxbas_pw_pool%give_back_pw(wf_r)
2749 e_density_section = cube_or_openpmd(input, str_e_density_cubes, str_e_density_openpmd, logger)
2752 IF (e_density_section%do_output)
THEN
2754 keyword_name=e_density_section%concat_to_relative(
"%DENSITY_INCLUDE"), &
2755 c_val=print_density)
2756 print_density = trim(print_density)
2758 IF (e_density_section%grid_output == grid_output_cubes)
THEN
2759 append_cube =
section_get_lval(input, e_density_section%concat_to_absolute(
"%APPEND"))
2761 my_pos_cube =
"REWIND"
2762 IF (append_cube)
THEN
2763 my_pos_cube =
"APPEND"
2767 IF (e_density_section%grid_output == grid_output_cubes)
THEN
2768 xrd_interface =
section_get_lval(input, e_density_section%concat_to_absolute(
"%XRD_INTERFACE"))
2771 xrd_interface = .false.
2774 IF (xrd_interface)
THEN
2776 IF (dft_control%qs_control%gapw) print_density =
"SOFT_DENSITY"
2778 filename =
"ELECTRON_DENSITY"
2780 extension=
".xrd", middle_name=trim(filename), &
2781 file_position=my_pos_cube, log_filename=.false.)
2782 ngto =
section_get_ival(input, e_density_section%concat_to_absolute(
"%NGAUSS"))
2783 IF (output_unit > 0)
THEN
2784 INQUIRE (unit=unit_nr, name=filename)
2785 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,/,T2,A)") &
2786 "The electron density (atomic part) is written to the file:", &
2791 nkind =
SIZE(atomic_kind_set)
2792 IF (unit_nr > 0)
THEN
2793 WRITE (unit_nr, *)
"Atomic (core) densities"
2794 WRITE (unit_nr, *)
"Unit cell"
2795 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(1, 1), cell%hmat(1, 2), cell%hmat(1, 3)
2796 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(2, 1), cell%hmat(2, 2), cell%hmat(2, 3)
2797 WRITE (unit_nr, fmt=
"(3F20.12)") cell%hmat(3, 1), cell%hmat(3, 2), cell%hmat(3, 3)
2798 WRITE (unit_nr, *)
"Atomic types"
2799 WRITE (unit_nr, *) nkind
2802 ALLOCATE (ppdens(ngto, 2, nkind), aedens(ngto, 2, nkind), ccdens(ngto, 2, nkind))
2804 atomic_kind => atomic_kind_set(ikind)
2805 qs_kind => qs_kind_set(ikind)
2806 CALL get_atomic_kind(atomic_kind, name=name, element_symbol=element_symbol)
2808 iunit=output_unit, confine=.true.)
2810 iunit=output_unit, allelectron=.true., confine=.true.)
2811 ccdens(:, 1, ikind) = aedens(:, 1, ikind)
2812 ccdens(:, 2, ikind) = 0._dp
2813 CALL project_function_a(ccdens(1:ngto, 2, ikind), ccdens(1:ngto, 1, ikind), &
2814 ppdens(1:ngto, 2, ikind), ppdens(1:ngto, 1, ikind), 0)
2815 ccdens(:, 2, ikind) = aedens(:, 2, ikind) - ccdens(:, 2, ikind)
2816 IF (unit_nr > 0)
THEN
2817 WRITE (unit_nr, fmt=
"(I6,A10,A20)") ikind, trim(element_symbol), trim(name)
2818 WRITE (unit_nr, fmt=
"(I6)") ngto
2819 WRITE (unit_nr, *)
" Total density"
2820 WRITE (unit_nr, fmt=
"(2G24.12)") (aedens(i, 1, ikind), aedens(i, 2, ikind), i=1, ngto)
2821 WRITE (unit_nr, *)
" Core density"
2822 WRITE (unit_nr, fmt=
"(2G24.12)") (ccdens(i, 1, ikind), ccdens(i, 2, ikind), i=1, ngto)
2824 NULLIFY (atomic_kind)
2827 IF (dft_control%qs_control%gapw)
THEN
2828 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom_set)
2830 IF (unit_nr > 0)
THEN
2831 WRITE (unit_nr, *)
"Coordinates and GAPW density"
2833 np = particles%n_els
2835 CALL get_atomic_kind(particles%els(iat)%atomic_kind, kind_number=ikind)
2836 CALL get_qs_kind(qs_kind_set(ikind), grid_atom=grid_atom)
2837 rho_atom => rho_atom_set(iat)
2838 IF (
ASSOCIATED(rho_atom%rho_rad_h(1)%r_coef))
THEN
2839 nr =
SIZE(rho_atom%rho_rad_h(1)%r_coef, 1)
2840 niso =
SIZE(rho_atom%rho_rad_h(1)%r_coef, 2)
2845 CALL para_env%sum(nr)
2846 CALL para_env%sum(niso)
2848 ALLOCATE (bfun(nr, niso))
2850 DO ispin = 1, dft_control%nspins
2851 IF (
ASSOCIATED(rho_atom%rho_rad_h(1)%r_coef))
THEN
2852 bfun(:, :) = bfun + rho_atom%rho_rad_h(ispin)%r_coef - rho_atom%rho_rad_s(ispin)%r_coef
2855 CALL para_env%sum(bfun)
2856 ccdens(:, 1, ikind) = ppdens(:, 1, ikind)
2857 ccdens(:, 2, ikind) = 0._dp
2858 IF (unit_nr > 0)
THEN
2859 WRITE (unit_nr,
'(I10,I5,3f12.6)') iat, ikind, particles%els(iat)%r
2863 CALL project_function_b(ccdens(:, 2, ikind), ccdens(:, 1, ikind), bfun(:, iso), grid_atom, l)
2864 IF (unit_nr > 0)
THEN
2865 WRITE (unit_nr, fmt=
"(3I6)") iso, l, ngto
2866 WRITE (unit_nr, fmt=
"(2G24.12)") (ccdens(i, 1, ikind), ccdens(i, 2, ikind), i=1, ngto)
2872 IF (unit_nr > 0)
THEN
2873 WRITE (unit_nr, *)
"Coordinates"
2874 np = particles%n_els
2876 CALL get_atomic_kind(particles%els(iat)%atomic_kind, kind_number=ikind)
2877 WRITE (unit_nr,
'(I10,I5,3f12.6)') iat, ikind, particles%els(iat)%r
2882 DEALLOCATE (ppdens, aedens, ccdens)
2885 e_density_section%absolute_section_key)
2888 IF (dft_control%qs_control%gapw .AND. print_density ==
"TOTAL_DENSITY")
THEN
2890 cpassert(.NOT. do_kpoints)
2895 auxbas_pw_pool=auxbas_pw_pool, &
2897 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
2899 CALL auxbas_pw_pool%create_pw(pw=rho_elec_gspace)
2904 q_max = sqrt(sum((
pi/dr(:))**2))
2906 auxbas_pw_pool=auxbas_pw_pool, &
2907 rhotot_elec_gspace=rho_elec_gspace, &
2909 rho_hard=rho_hard, &
2911 rho_total = rho_hard + rho_soft
2916 CALL pw_scale(rho_elec_gspace, 1.0_dp/volume)
2918 CALL pw_transfer(rho_elec_gspace, rho_elec_rspace)
2920 filename =
"TOTAL_ELECTRON_DENSITY"
2922 unit_nr = e_density_section%print_key_unit_nr( &
2925 e_density_section%absolute_section_key, &
2926 extension=
".cube", &
2927 middle_name=trim(filename), &
2928 file_position=my_pos_cube, &
2929 log_filename=.false., &
2931 fout=mpi_filename, &
2932 openpmd_basename=
"dft-total-electron-density", &
2933 openpmd_unit_dimension=openpmd_unit_dimension_density, &
2934 openpmd_unit_si=openpmd_unit_si_density, &
2935 sim_time=qs_env%sim_time)
2936 IF (output_unit > 0)
THEN
2937 IF (.NOT. mpi_io)
THEN
2938 INQUIRE (unit=unit_nr, name=filename)
2940 filename = mpi_filename
2942 CALL print_density_output_message(output_unit,
"The total electron density", &
2943 e_density_section, filename)
2944 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
2945 "q(max) [1/Angstrom] :", q_max/
angstrom, &
2946 "Soft electronic charge (G-space) :", rho_soft, &
2947 "Hard electronic charge (G-space) :", rho_hard, &
2948 "Total electronic charge (G-space):", rho_total, &
2949 "Total electronic charge (R-space):", rho_total_rspace
2951 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"TOTAL ELECTRON DENSITY", &
2952 particles=particles, zeff=zcharge, &
2953 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
2954 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
2955 e_density_section%absolute_section_key, mpi_io=mpi_io)
2957 IF (dft_control%nspins > 1)
THEN
2961 auxbas_pw_pool=auxbas_pw_pool, &
2962 rhotot_elec_gspace=rho_elec_gspace, &
2964 rho_hard=rho_hard, &
2965 rho_soft=rho_soft, &
2967 rho_total = rho_hard + rho_soft
2971 CALL pw_scale(rho_elec_gspace, 1.0_dp/volume)
2973 CALL pw_transfer(rho_elec_gspace, rho_elec_rspace)
2975 filename =
"TOTAL_SPIN_DENSITY"
2977 unit_nr = e_density_section%print_key_unit_nr( &
2980 e_density_section%absolute_section_key, &
2981 extension=
".cube", &
2982 middle_name=trim(filename), &
2983 file_position=my_pos_cube, &
2984 log_filename=.false., &
2986 fout=mpi_filename, &
2987 openpmd_basename=
"dft-total-spin-density", &
2988 openpmd_unit_dimension=openpmd_unit_dimension_density, &
2989 openpmd_unit_si=openpmd_unit_si_density, &
2990 sim_time=qs_env%sim_time)
2991 IF (output_unit > 0)
THEN
2992 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
2993 INQUIRE (unit=unit_nr, name=filename)
2995 filename = mpi_filename
2997 CALL print_density_output_message(output_unit,
"The total spin density", &
2998 e_density_section, filename)
2999 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
3000 "q(max) [1/Angstrom] :", q_max/
angstrom, &
3001 "Soft part of the spin density (G-space):", rho_soft, &
3002 "Hard part of the spin density (G-space):", rho_hard, &
3003 "Total spin density (G-space) :", rho_total, &
3004 "Total spin density (R-space) :", rho_total_rspace
3006 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"TOTAL SPIN DENSITY", &
3007 particles=particles, zeff=zcharge, &
3008 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
3009 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3010 e_density_section%absolute_section_key, mpi_io=mpi_io)
3012 CALL auxbas_pw_pool%give_back_pw(rho_elec_gspace)
3013 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
3015 ELSE IF (print_density ==
"SOFT_DENSITY" .OR. .NOT. dft_control%qs_control%gapw)
THEN
3016 IF (dft_control%nspins > 1)
THEN
3020 auxbas_pw_pool=auxbas_pw_pool, &
3022 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
3023 CALL pw_copy(rho_r(1), rho_elec_rspace)
3024 CALL pw_axpy(rho_r(2), rho_elec_rspace)
3025 filename =
"ELECTRON_DENSITY"
3027 unit_nr = e_density_section%print_key_unit_nr( &
3030 e_density_section%absolute_section_key, &
3031 extension=
".cube", &
3032 middle_name=trim(filename), &
3033 file_position=my_pos_cube, &
3034 log_filename=.false., &
3036 fout=mpi_filename, &
3037 openpmd_basename=
"dft-electron-density", &
3038 openpmd_unit_dimension=openpmd_unit_dimension_density, &
3039 openpmd_unit_si=openpmd_unit_si_density, &
3040 sim_time=qs_env%sim_time)
3041 IF (output_unit > 0)
THEN
3042 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
3043 INQUIRE (unit=unit_nr, name=filename)
3045 filename = mpi_filename
3047 CALL print_density_output_message(output_unit,
"The sum of alpha and beta density", &
3048 e_density_section, filename)
3050 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SUM OF ALPHA AND BETA DENSITY", &
3051 particles=particles, zeff=zcharge, stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), &
3053 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3054 e_density_section%absolute_section_key, mpi_io=mpi_io)
3055 CALL pw_copy(rho_r(1), rho_elec_rspace)
3056 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
3057 filename =
"SPIN_DENSITY"
3059 unit_nr = e_density_section%print_key_unit_nr( &
3062 e_density_section%absolute_section_key, &
3063 extension=
".cube", &
3064 middle_name=trim(filename), &
3065 file_position=my_pos_cube, &
3066 log_filename=.false., &
3068 fout=mpi_filename, &
3069 openpmd_basename=
"dft-spin-density", &
3070 openpmd_unit_dimension=openpmd_unit_dimension_density, &
3071 openpmd_unit_si=openpmd_unit_si_density, &
3072 sim_time=qs_env%sim_time)
3073 IF (output_unit > 0)
THEN
3074 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
3075 INQUIRE (unit=unit_nr, name=filename)
3077 filename = mpi_filename
3079 CALL print_density_output_message(output_unit,
"The spin density", &
3080 e_density_section, filename)
3082 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SPIN DENSITY", &
3083 particles=particles, zeff=zcharge, &
3084 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
3085 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3086 e_density_section%absolute_section_key, mpi_io=mpi_io)
3087 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
3089 filename =
"ELECTRON_DENSITY"
3091 unit_nr = e_density_section%print_key_unit_nr( &
3094 e_density_section%absolute_section_key, &
3095 extension=
".cube", &
3096 middle_name=trim(filename), &
3097 file_position=my_pos_cube, &
3098 log_filename=.false., &
3100 fout=mpi_filename, &
3101 openpmd_basename=
"dft-electron-density", &
3102 openpmd_unit_dimension=openpmd_unit_dimension_density, &
3103 openpmd_unit_si=openpmd_unit_si_density, &
3104 sim_time=qs_env%sim_time)
3105 IF (output_unit > 0)
THEN
3106 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
3107 INQUIRE (unit=unit_nr, name=filename)
3109 filename = mpi_filename
3111 CALL print_density_output_message(output_unit,
"The electron density", &
3112 e_density_section, filename)
3114 CALL e_density_section%write_pw(rho_r(1), unit_nr,
"ELECTRON DENSITY", &
3115 particles=particles, zeff=zcharge, &
3116 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
3117 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3118 e_density_section%absolute_section_key, mpi_io=mpi_io)
3121 ELSE IF (dft_control%qs_control%gapw .AND. print_density ==
"TOTAL_HARD_APPROX")
THEN
3122 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, rho0_mpole=rho0_mpole, natom=natom)
3123 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
3124 CALL auxbas_pw_pool%create_pw(rho_elec_rspace)
3127 ALLOCATE (my_q0(natom))
3135 my_q0(iat) = sum(rho0_mpole%mp_rho(iat)%Q0(1:dft_control%nspins))*
norm_factor
3139 CALL calculate_rho_resp_all(rho_elec_rspace, coeff=my_q0, natom=natom, eta=rho0_mpole%zet0_h, qs_env=qs_env)
3143 DO ispin = 1, dft_control%nspins
3144 CALL pw_axpy(rho_r(ispin), rho_elec_rspace)
3148 rho_total_rspace = rho_soft + rho_hard
3150 filename =
"ELECTRON_DENSITY"
3152 unit_nr = e_density_section%print_key_unit_nr( &
3155 e_density_section%absolute_section_key, &
3156 extension=
".cube", &
3157 middle_name=trim(filename), &
3158 file_position=my_pos_cube, &
3159 log_filename=.false., &
3161 fout=mpi_filename, &
3162 openpmd_basename=
"dft-electron-density", &
3163 openpmd_unit_dimension=openpmd_unit_dimension_density, &
3164 openpmd_unit_si=openpmd_unit_si_density, &
3165 sim_time=qs_env%sim_time)
3166 IF (output_unit > 0)
THEN
3167 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
3168 INQUIRE (unit=unit_nr, name=filename)
3170 filename = mpi_filename
3172 CALL print_density_output_message(output_unit,
"The electron density", &
3173 e_density_section, filename)
3174 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
3175 "Soft electronic charge (R-space) :", rho_soft, &
3176 "Hard electronic charge (R-space) :", rho_hard, &
3177 "Total electronic charge (R-space):", rho_total_rspace
3179 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"ELECTRON DENSITY", &
3180 particles=particles, zeff=zcharge, stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), &
3182 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3183 e_density_section%absolute_section_key, mpi_io=mpi_io)
3186 IF (dft_control%nspins > 1)
THEN
3188 my_q0(iat) = (rho0_mpole%mp_rho(iat)%Q0(1) - rho0_mpole%mp_rho(iat)%Q0(2))*
norm_factor
3191 CALL calculate_rho_resp_all(rho_elec_rspace, coeff=my_q0, natom=natom, eta=rho0_mpole%zet0_h, qs_env=qs_env)
3194 CALL pw_axpy(rho_r(1), rho_elec_rspace)
3195 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
3199 rho_total_rspace = rho_soft + rho_hard
3201 filename =
"SPIN_DENSITY"
3203 unit_nr = e_density_section%print_key_unit_nr( &
3206 e_density_section%absolute_section_key, &
3207 extension=
".cube", &
3208 middle_name=trim(filename), &
3209 file_position=my_pos_cube, &
3210 log_filename=.false., &
3212 fout=mpi_filename, &
3213 openpmd_basename=
"dft-spin-density", &
3214 openpmd_unit_dimension=openpmd_unit_dimension_density, &
3215 openpmd_unit_si=openpmd_unit_si_density, &
3216 sim_time=qs_env%sim_time)
3217 IF (output_unit > 0)
THEN
3218 IF (.NOT. mpi_io .AND. e_density_section%grid_output == grid_output_cubes)
THEN
3219 INQUIRE (unit=unit_nr, name=filename)
3221 filename = mpi_filename
3223 CALL print_density_output_message(output_unit,
"The spin density", &
3224 e_density_section, filename)
3225 WRITE (unit=output_unit, fmt=
"(/,(T2,A,F20.10))") &
3226 "Soft part of the spin density :", rho_soft, &
3227 "Hard part of the spin density :", rho_hard, &
3228 "Total spin density (R-space) :", rho_total_rspace
3230 CALL e_density_section%write_pw(rho_elec_rspace, unit_nr,
"SPIN DENSITY", &
3231 particles=particles, zeff=zcharge, &
3232 stride=
section_get_ivals(dft_section, e_density_section%concat_to_relative(
"%STRIDE")), mpi_io=mpi_io)
3233 CALL e_density_section%print_key_finished_output(unit_nr, logger, input, &
3234 e_density_section%absolute_section_key, mpi_io=mpi_io)
3236 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
3242 dft_section,
"PRINT%ENERGY_WINDOWS"),
cp_p_file) .AND. .NOT. do_kpoints)
THEN
3248 "DFT%PRINT%V_HARTREE_CUBE"),
cp_p_file))
THEN
3252 v_hartree_rspace=v_hartree_rspace)
3253 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3254 CALL auxbas_pw_pool%create_pw(aux_r)
3257 my_pos_cube =
"REWIND"
3258 IF (append_cube)
THEN
3259 my_pos_cube =
"APPEND"
3262 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
3265 extension=
".cube", middle_name=
"v_hartree", file_position=my_pos_cube, mpi_io=mpi_io)
3266 udvol = 1.0_dp/v_hartree_rspace%pw_grid%dvol
3268 CALL pw_copy(v_hartree_rspace, aux_r)
3271 CALL cp_pw_to_cube(aux_r, unit_nr,
"HARTREE POTENTIAL", particles=particles, zeff=zcharge, &
3273 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%V_HARTREE_CUBE%MAX_FILE_SIZE_MB"), &
3276 "DFT%PRINT%V_HARTREE_CUBE", mpi_io=mpi_io)
3278 CALL auxbas_pw_pool%give_back_pw(aux_r)
3283 "DFT%PRINT%EXTERNAL_POTENTIAL_CUBE"),
cp_p_file))
THEN
3284 IF (dft_control%apply_external_potential)
THEN
3285 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, vee=vee)
3286 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3287 CALL auxbas_pw_pool%create_pw(aux_r)
3289 append_cube =
section_get_lval(input,
"DFT%PRINT%EXTERNAL_POTENTIAL_CUBE%APPEND")
3290 my_pos_cube =
"REWIND"
3291 IF (append_cube)
THEN
3292 my_pos_cube =
"APPEND"
3297 extension=
".cube", middle_name=
"ext_pot", file_position=my_pos_cube, mpi_io=mpi_io)
3301 CALL cp_pw_to_cube(aux_r, unit_nr,
"EXTERNAL POTENTIAL", particles=particles, zeff=zcharge, &
3302 stride=
section_get_ivals(dft_section,
"PRINT%EXTERNAL_POTENTIAL_CUBE%STRIDE"), &
3303 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%EXTERNAL_POTENTIAL_CUBE%MAX_FILE_SIZE_MB"), &
3306 "DFT%PRINT%EXTERNAL_POTENTIAL_CUBE", mpi_io=mpi_io)
3308 CALL auxbas_pw_pool%give_back_pw(aux_r)
3314 "DFT%PRINT%EFIELD_CUBE"),
cp_p_file))
THEN
3316 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
3317 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3318 CALL auxbas_pw_pool%create_pw(aux_r)
3319 CALL auxbas_pw_pool%create_pw(aux_g)
3322 my_pos_cube =
"REWIND"
3323 IF (append_cube)
THEN
3324 my_pos_cube =
"APPEND"
3326 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, &
3327 v_hartree_rspace=v_hartree_rspace)
3329 udvol = 1.0_dp/v_hartree_rspace%pw_grid%dvol
3333 extension=
".cube", middle_name=
"efield_"//cdir(id), file_position=my_pos_cube, &
3343 CALL cp_pw_to_cube(aux_r, unit_nr,
"ELECTRIC FIELD", particles=particles, zeff=zcharge, &
3345 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%EFIELD_CUBE%MAX_FILE_SIZE_MB"), &
3348 "DFT%PRINT%EFIELD_CUBE", mpi_io=mpi_io)
3351 CALL auxbas_pw_pool%give_back_pw(aux_r)
3352 CALL auxbas_pw_pool%give_back_pw(aux_g)
3356 CALL qs_scf_post_local_energy(input, logger, qs_env)
3359 CALL qs_scf_post_local_stress(input, logger, qs_env)
3362 CALL qs_scf_post_ps_implicit(input, logger, qs_env)
3376 "DFT%PRINT%AO_MATRICES/DENSITY"),
cp_p_file))
THEN
3381 after = min(max(after, 1), 16)
3382 DO ispin = 1, dft_control%nspins
3383 DO img = 1, dft_control%nimages
3385 para_env, output_unit=iw, omit_headers=omit_headers)
3389 "DFT%PRINT%AO_MATRICES/DENSITY")
3394 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX"),
cp_p_file)
3396 "DFT%PRINT%AO_MATRICES/MATRIX_VXC"),
cp_p_file)
3398 IF (write_ks .OR. write_xc)
THEN
3399 IF (write_xc) qs_env%requires_matrix_vxc = .true.
3402 just_energy=.false.)
3403 IF (write_xc) qs_env%requires_matrix_vxc = .false.
3410 CALL get_qs_env(qs_env=qs_env, matrix_ks_kp=ks_rmpv)
3412 after = min(max(after, 1), 16)
3413 DO ispin = 1, dft_control%nspins
3414 DO img = 1, dft_control%nimages
3416 para_env, output_unit=iw, omit_headers=omit_headers)
3420 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX")
3425 IF (.NOT. dft_control%qs_control%pao)
THEN
3433 CALL write_adjacency_matrix(qs_env, input)
3437 CALL get_qs_env(qs_env=qs_env, matrix_vxc_kp=matrix_vxc)
3438 cpassert(
ASSOCIATED(matrix_vxc))
3442 after = min(max(after, 1), 16)
3443 DO ispin = 1, dft_control%nspins
3444 DO img = 1, dft_control%nimages
3446 para_env, output_unit=iw, omit_headers=omit_headers)
3450 "DFT%PRINT%AO_MATRICES/MATRIX_VXC")
3455 "DFT%PRINT%AO_MATRICES/COMMUTATOR_HR"),
cp_p_file))
THEN
3462 ALLOCATE (matrix_hr(img)%matrix)
3463 CALL dbcsr_create(matrix_hr(img)%matrix, template=matrix_s(1, 1)%matrix, &
3464 name=
"COMMUTATOR", matrix_type=dbcsr_type_antisymmetric)
3466 CALL dbcsr_set(matrix_hr(img)%matrix, 0._dp)
3469 CALL build_com_mom_nl(qs_kind_set, sab_orb, sap_ppnl, dft_control%qs_control%eps_ppnl, &
3470 particle_set, cell, matrix_rv=matrix_hr)
3473 CALL dbcsr_scale(matrix_hr(img)%matrix, alpha_scalar=-1._dp)
3476 IF (output_unit > 0)
THEN
3477 WRITE (output_unit,
'(T2,A,E23.16)')
'COMMUTATOR_HR| CheckSum X =', checksum_hr(1)
3478 WRITE (output_unit,
'(T2,A,E23.16)')
'COMMUTATOR_HR| CheckSum Y =', checksum_hr(2)
3479 WRITE (output_unit,
'(T2,A,E23.16)')
'COMMUTATOR_HR| CheckSum Z =', checksum_hr(3)
3481 after = min(max(after, 1), 16)
3484 para_env, output_unit=iw, omit_headers=omit_headers)
3488 "DFT%PRINT%AO_MATRICES/COMMUTATOR_HR")
3494 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MULLIKEN", extension=
".mulliken", log_filename=.false.)
3497 IF (print_it) print_level = 2
3499 IF (print_it) print_level = 3
3510 CALL qs_rho_get(rho, rho_r_valid=rho_r_valid)
3511 IF (rho_r_valid)
THEN
3512 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%HIRSHFELD", extension=
".hirshfeld", log_filename=.false.)
3513 CALL hirshfeld_charges(qs_env, print_key, unit_nr)
3521 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%EEQ_CHARGES", extension=
".eeq", log_filename=.false.)
3523 CALL eeq_print(qs_env, unit_nr, print_level, ext=.false.)
3531 should_print_voro = 1
3533 should_print_voro = 0
3536 should_print_bqb = 1
3538 should_print_bqb = 0
3540 IF ((should_print_voro /= 0) .OR. (should_print_bqb /= 0))
THEN
3545 CALL qs_rho_get(rho, rho_r_valid=rho_r_valid)
3546 IF (rho_r_valid)
THEN
3548 IF (dft_control%nspins > 1)
THEN
3552 auxbas_pw_pool=auxbas_pw_pool, &
3556 CALL auxbas_pw_pool%create_pw(pw=mb_rho)
3557 CALL pw_copy(rho_r(1), mb_rho)
3558 CALL pw_axpy(rho_r(2), mb_rho)
3565 IF (should_print_voro /= 0)
THEN
3567 IF (voro_print_txt)
THEN
3569 my_pos_voro =
"REWIND"
3570 IF (append_voro)
THEN
3571 my_pos_voro =
"APPEND"
3573 unit_nr_voro =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%VORONOI", extension=
".voronoi", &
3574 file_position=my_pos_voro, log_filename=.false.)
3582 CALL entry_voronoi_or_bqb(should_print_voro, should_print_bqb, print_key_voro, print_key_bqb, &
3583 unit_nr_voro, qs_env, mb_rho)
3585 IF (dft_control%nspins > 1)
THEN
3586 CALL auxbas_pw_pool%give_back_pw(mb_rho)
3590 IF (unit_nr_voro > 0)
THEN
3600 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MAO_ANALYSIS", extension=
".mao", log_filename=.false.)
3608 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%MINBAS_ANALYSIS", extension=
".mao", log_filename=.false.)
3616 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IAO_ANALYSIS", extension=
".iao", log_filename=.false.)
3618 IF (particle_set(1)%fragment_index /= 0) iao_env%do_fragments = .true.
3619 IF (iao_env%do_iao)
THEN
3629 extension=
".mao", log_filename=.false.)
3640 IF (qs_env%x_data(i, 1)%do_hfx_ri)
CALL print_ri_hfx(qs_env%x_data(i, 1)%ri_data, qs_env)
3644 DEALLOCATE (zcharge)
3646 CALL timestop(handle)
3656 SUBROUTINE hirshfeld_charges(qs_env, input_section, unit_nr)
3659 INTEGER,
INTENT(IN) :: unit_nr
3661 INTEGER :: i, iat, ikind, natom, nkind, nspin, &
3662 radius_type, refc, shapef
3663 INTEGER,
DIMENSION(:),
POINTER :: atom_list
3664 LOGICAL :: do_radius, do_sc, paw_atom
3665 REAL(kind=
dp) :: zeff
3666 REAL(kind=
dp),
DIMENSION(:),
POINTER :: radii
3667 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: charges
3670 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
3676 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3680 NULLIFY (hirshfeld_env)
3684 CALL get_qs_env(qs_env, nkind=nkind, natom=natom)
3685 ALLOCATE (hirshfeld_env%charges(natom))
3694 IF (.NOT.
SIZE(radii) == nkind)
THEN
3695 CALL cp_abort(__location__, &
3696 "Length of keyword HIRSHFELD\ATOMIC_RADII does not "// &
3697 "match number of atomic kinds in the input coordinate file.")
3703 iterative=do_sc, ref_charge=refc, &
3704 radius_type=radius_type)
3706 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set)
3712 nspin =
SIZE(matrix_p, 1)
3713 ALLOCATE (charges(natom, nspin))
3718 atomic_kind => atomic_kind_set(ikind)
3720 DO iat = 1,
SIZE(atom_list)
3722 hirshfeld_env%charges(i) = zeff
3726 CALL get_qs_env(qs_env, matrix_s_kp=matrix_s, para_env=para_env)
3729 hirshfeld_env%charges(iat) = sum(charges(iat, :))
3732 cpabort(
"Unknown type of reference charge for Hirshfeld partitioning.")
3736 IF (hirshfeld_env%iterative)
THEN
3743 CALL get_qs_env(qs_env, particle_set=particle_set, dft_control=dft_control)
3744 IF (dft_control%qs_control%gapw)
THEN
3746 CALL get_qs_env(qs_env, rho0_mpole=rho0_mpole)
3749 atomic_kind => particle_set(iat)%atomic_kind
3751 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
3753 charges(iat, 1:nspin) = charges(iat, 1:nspin) + mp_rho(iat)%q0(1:nspin)
3758 IF (unit_nr > 0)
THEN
3760 qs_kind_set, unit_nr)
3766 DEALLOCATE (charges)
3768 END SUBROUTINE hirshfeld_charges
3778 SUBROUTINE project_function_a(ca, a, cb, b, l)
3780 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: ca
3781 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: a, cb, b
3782 INTEGER,
INTENT(IN) :: l
3785 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ipiv
3786 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat, tmat, v
3789 ALLOCATE (smat(n, n), tmat(n, n), v(n, 1), ipiv(n))
3793 v(:, 1) = matmul(tmat, cb)
3794 CALL dgesv(n, 1, smat, n, ipiv, v, n, info)
3798 DEALLOCATE (smat, tmat, v, ipiv)
3800 END SUBROUTINE project_function_a
3810 SUBROUTINE project_function_b(ca, a, bfun, grid_atom, l)
3812 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: ca
3813 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: a, bfun
3815 INTEGER,
INTENT(IN) :: l
3817 INTEGER :: i, info, n, nr
3818 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ipiv
3819 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: afun
3820 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smat, v
3824 ALLOCATE (smat(n, n), v(n, 1), ipiv(n), afun(nr))
3828 afun(:) = grid_atom%rad(:)**l*exp(-a(i)*grid_atom%rad2(:))
3829 v(i, 1) = sum(afun(:)*bfun(:)*grid_atom%wr(:))
3831 CALL dgesv(n, 1, smat, n, ipiv, v, n, info)
3835 DEALLOCATE (smat, v, ipiv, afun)
3837 END SUBROUTINE project_function_b
3848 SUBROUTINE qs_scf_post_local_energy(input, logger, qs_env)
3853 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_local_energy'
3855 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3856 INTEGER :: handle, io_unit, natom, unit_nr
3857 LOGICAL :: append_cube, gapw, gapw_xc, mpi_io
3858 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
3867 CALL timeset(routinen, handle)
3870 "DFT%PRINT%LOCAL_ENERGY_CUBE"),
cp_p_file))
THEN
3872 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, natom=natom)
3873 gapw = dft_control%qs_control%gapw
3874 gapw_xc = dft_control%qs_control%gapw_xc
3875 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3877 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3878 CALL auxbas_pw_pool%create_pw(eden)
3883 append_cube =
section_get_lval(input,
"DFT%PRINT%LOCAL_ENERGY_CUBE%APPEND")
3884 IF (append_cube)
THEN
3885 my_pos_cube =
"APPEND"
3887 my_pos_cube =
"REWIND"
3891 extension=
".cube", middle_name=
"local_energy", &
3892 file_position=my_pos_cube, mpi_io=mpi_io)
3893 CALL cp_pw_to_cube(eden, unit_nr,
"LOCAL ENERGY", particles=particles, zeff=zcharge, &
3895 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%LOCAL_ENERGY_CUBE%MAX_FILE_SIZE_MB"), &
3897 IF (io_unit > 0)
THEN
3898 INQUIRE (unit=unit_nr, name=filename)
3899 IF (gapw .OR. gapw_xc)
THEN
3900 WRITE (unit=io_unit, fmt=
"(/,T3,A,A)") &
3901 "The soft part of the local energy is written to the file: ", trim(adjustl(filename))
3903 WRITE (unit=io_unit, fmt=
"(/,T3,A,A)") &
3904 "The local energy is written to the file: ", trim(adjustl(filename))
3908 "DFT%PRINT%LOCAL_ENERGY_CUBE", mpi_io=mpi_io)
3910 CALL auxbas_pw_pool%give_back_pw(eden)
3911 DEALLOCATE (zcharge)
3913 CALL timestop(handle)
3915 END SUBROUTINE qs_scf_post_local_energy
3926 SUBROUTINE qs_scf_post_local_stress(input, logger, qs_env)
3931 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_local_stress'
3933 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
3934 INTEGER :: handle, io_unit, natom, unit_nr
3935 LOGICAL :: append_cube, gapw, gapw_xc, mpi_io
3936 REAL(kind=
dp) :: beta
3937 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
3946 CALL timeset(routinen, handle)
3949 "DFT%PRINT%LOCAL_STRESS_CUBE"),
cp_p_file))
THEN
3950 CALL cp_warn(__location__, &
3951 "LOCAL_STRESS_CUBE uses the existing experimental local stress implementation")
3953 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, natom=natom)
3954 gapw = dft_control%qs_control%gapw
3955 gapw_xc = dft_control%qs_control%gapw_xc
3956 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
3958 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
3959 CALL auxbas_pw_pool%create_pw(stress)
3966 append_cube =
section_get_lval(input,
"DFT%PRINT%LOCAL_STRESS_CUBE%APPEND")
3967 IF (append_cube)
THEN
3968 my_pos_cube =
"APPEND"
3970 my_pos_cube =
"REWIND"
3974 extension=
".cube", middle_name=
"local_stress", &
3975 file_position=my_pos_cube, mpi_io=mpi_io)
3976 CALL cp_pw_to_cube(stress, unit_nr,
"LOCAL STRESS", particles=particles, zeff=zcharge, &
3978 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%LOCAL_STRESS_CUBE%MAX_FILE_SIZE_MB"), &
3980 IF (io_unit > 0)
THEN
3981 INQUIRE (unit=unit_nr, name=filename)
3982 WRITE (unit=io_unit, fmt=
"(/,T3,A)")
"Write 1/3*Tr(sigma) to cube file"
3983 IF (gapw .OR. gapw_xc)
THEN
3984 WRITE (unit=io_unit, fmt=
"(T3,A,A)") &
3985 "The soft part of the local stress is written to the file: ", trim(adjustl(filename))
3987 WRITE (unit=io_unit, fmt=
"(T3,A,A)") &
3988 "The local stress is written to the file: ", trim(adjustl(filename))
3992 "DFT%PRINT%LOCAL_STRESS_CUBE", mpi_io=mpi_io)
3994 CALL auxbas_pw_pool%give_back_pw(stress)
3995 DEALLOCATE (zcharge)
3998 CALL timestop(handle)
4000 END SUBROUTINE qs_scf_post_local_stress
4011 SUBROUTINE qs_scf_post_ps_implicit(input, logger, qs_env)
4016 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_ps_implicit'
4018 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube
4019 INTEGER :: boundary_condition, handle, i, j, &
4020 n_cstr, n_tiles, unit_nr
4021 LOGICAL :: append_cube, do_cstr_charge_cube, do_dielectric_cube, do_dirichlet_bc_cube, &
4022 has_dirichlet_bc, has_implicit_ps, mpi_io, tile_cubes
4023 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zcharge
4033 CALL timeset(routinen, handle)
4035 NULLIFY (pw_env, auxbas_pw_pool, dft_section, particles)
4038 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, subsys=subsys)
4040 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
4042 has_implicit_ps = .false.
4043 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
4048 "DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE"),
cp_p_file)
4049 IF (has_implicit_ps .AND. do_dielectric_cube)
THEN
4051 append_cube =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%APPEND")
4052 my_pos_cube =
"REWIND"
4053 IF (append_cube)
THEN
4054 my_pos_cube =
"APPEND"
4058 extension=
".cube", middle_name=
"DIELECTRIC_CONSTANT", file_position=my_pos_cube, &
4060 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
4061 CALL auxbas_pw_pool%create_pw(aux_r)
4063 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
4064 SELECT CASE (boundary_condition)
4066 CALL pw_copy(poisson_env%implicit_env%dielectric%eps, aux_r)
4068 CALL pw_shrink(pw_env%poisson_env%parameters%ps_implicit_params%neumann_directions, &
4069 pw_env%poisson_env%implicit_env%dct_env%dests_shrink, &
4070 pw_env%poisson_env%implicit_env%dct_env%srcs_shrink, &
4071 pw_env%poisson_env%implicit_env%dct_env%bounds_local_shftd, &
4072 poisson_env%implicit_env%dielectric%eps, aux_r)
4075 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIELECTRIC CONSTANT", particles=particles, zeff=zcharge, &
4076 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%STRIDE"), &
4077 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE%MAX_FILE_SIZE_MB"), &
4080 "DFT%PRINT%IMPLICIT_PSOLVER%DIELECTRIC_CUBE", mpi_io=mpi_io)
4082 CALL auxbas_pw_pool%give_back_pw(aux_r)
4087 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE"),
cp_p_file)
4089 has_dirichlet_bc = .false.
4090 IF (has_implicit_ps)
THEN
4091 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
4093 has_dirichlet_bc = .true.
4097 IF (has_implicit_ps .AND. do_cstr_charge_cube .AND. has_dirichlet_bc)
THEN
4100 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%APPEND")
4101 my_pos_cube =
"REWIND"
4102 IF (append_cube)
THEN
4103 my_pos_cube =
"APPEND"
4107 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE", &
4108 extension=
".cube", middle_name=
"dirichlet_cstr_charge", file_position=my_pos_cube, &
4110 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
4111 CALL auxbas_pw_pool%create_pw(aux_r)
4113 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
4114 SELECT CASE (boundary_condition)
4116 CALL pw_copy(poisson_env%implicit_env%cstr_charge, aux_r)
4118 CALL pw_shrink(pw_env%poisson_env%parameters%ps_implicit_params%neumann_directions, &
4119 pw_env%poisson_env%implicit_env%dct_env%dests_shrink, &
4120 pw_env%poisson_env%implicit_env%dct_env%srcs_shrink, &
4121 pw_env%poisson_env%implicit_env%dct_env%bounds_local_shftd, &
4122 poisson_env%implicit_env%cstr_charge, aux_r)
4125 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET CONSTRAINT CHARGE", particles=particles, zeff=zcharge, &
4126 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%STRIDE"), &
4127 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE%MAX_FILE_SIZE_MB"), &
4130 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_CSTR_CHARGE_CUBE", mpi_io=mpi_io)
4132 CALL auxbas_pw_pool%give_back_pw(aux_r)
4137 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE"),
cp_p_file)
4138 has_dirichlet_bc = .false.
4139 IF (has_implicit_ps)
THEN
4140 boundary_condition = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
4142 has_dirichlet_bc = .true.
4146 IF (has_implicit_ps .AND. has_dirichlet_bc .AND. do_dirichlet_bc_cube)
THEN
4148 append_cube =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%APPEND")
4149 my_pos_cube =
"REWIND"
4150 IF (append_cube)
THEN
4151 my_pos_cube =
"APPEND"
4153 tile_cubes =
section_get_lval(input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%TILE_CUBES")
4155 CALL pw_env_get(pw_env, poisson_env=poisson_env, auxbas_pw_pool=auxbas_pw_pool)
4156 CALL auxbas_pw_pool%create_pw(aux_r)
4159 IF (tile_cubes)
THEN
4161 n_cstr =
SIZE(poisson_env%implicit_env%contacts)
4163 n_tiles = poisson_env%implicit_env%contacts(j)%dirichlet_bc%n_tiles
4165 filename =
"dirichlet_cstr_"//trim(adjustl(
cp_to_string(j)))// &
4168 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", &
4169 extension=
".cube", middle_name=filename, file_position=my_pos_cube, &
4172 CALL pw_copy(poisson_env%implicit_env%contacts(j)%dirichlet_bc%tiles(i)%tile%tile_pw, aux_r)
4174 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET TYPE CONSTRAINT", particles=particles, zeff=zcharge, &
4175 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%STRIDE"), &
4176 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%MAX_FILE_SIZE_MB"), &
4179 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", mpi_io=mpi_io)
4184 NULLIFY (dirichlet_tile)
4185 ALLOCATE (dirichlet_tile)
4186 CALL auxbas_pw_pool%create_pw(dirichlet_tile)
4189 unit_nr =
cp_print_key_unit_nr(logger, input,
"DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", &
4190 extension=
".cube", middle_name=
"DIRICHLET_CSTR", file_position=my_pos_cube, &
4193 n_cstr =
SIZE(poisson_env%implicit_env%contacts)
4195 n_tiles = poisson_env%implicit_env%contacts(j)%dirichlet_bc%n_tiles
4197 CALL pw_copy(poisson_env%implicit_env%contacts(j)%dirichlet_bc%tiles(i)%tile%tile_pw, dirichlet_tile)
4198 CALL pw_axpy(dirichlet_tile, aux_r)
4202 CALL cp_pw_to_cube(aux_r, unit_nr,
"DIRICHLET TYPE CONSTRAINT", particles=particles, zeff=zcharge, &
4203 stride=
section_get_ivals(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%STRIDE"), &
4204 max_file_size_mb=
section_get_rval(dft_section,
"PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE%MAX_FILE_SIZE_MB"), &
4207 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE", mpi_io=mpi_io)
4208 CALL auxbas_pw_pool%give_back_pw(dirichlet_tile)
4209 DEALLOCATE (dirichlet_tile)
4212 CALL auxbas_pw_pool%give_back_pw(aux_r)
4215 CALL timestop(handle)
4217 END SUBROUTINE qs_scf_post_ps_implicit
4225 SUBROUTINE write_adjacency_matrix(qs_env, input)
4229 CHARACTER(len=*),
PARAMETER :: routinen =
'write_adjacency_matrix'
4231 INTEGER :: adjm_size, colind, handle, iatom, ikind, &
4232 ind, jatom, jkind, k, natom, nkind, &
4233 output_unit, rowind, unit_nr
4234 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: interact_adjm
4235 LOGICAL :: do_adjm_write, do_symmetric
4241 DIMENSION(:),
POINTER :: nl_iterator
4244 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
4247 CALL timeset(routinen, handle)
4249 NULLIFY (dft_section)
4258 IF (do_adjm_write)
THEN
4259 NULLIFY (qs_kind_set, nl_iterator)
4260 NULLIFY (basis_set_list_a, basis_set_list_b, basis_set_a, basis_set_b)
4262 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, sab_orb=nl, natom=natom, para_env=para_env)
4264 nkind =
SIZE(qs_kind_set)
4265 cpassert(
SIZE(nl) > 0)
4267 cpassert(do_symmetric)
4268 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
4272 adjm_size = ((natom + 1)*natom)/2
4273 ALLOCATE (interact_adjm(4*adjm_size))
4276 NULLIFY (nl_iterator)
4280 ikind=ikind, jkind=jkind, &
4281 iatom=iatom, jatom=jatom)
4283 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
4284 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
4285 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
4286 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
4289 IF (iatom <= jatom)
THEN
4296 ikind = ikind + jkind
4297 jkind = ikind - jkind
4298 ikind = ikind - jkind
4302 ind = adjm_size - (natom - rowind + 1)*((natom - rowind + 1) + 1)/2 + colind - rowind + 1
4305 interact_adjm((ind - 1)*4 + 1) = rowind
4306 interact_adjm((ind - 1)*4 + 2) = colind
4307 interact_adjm((ind - 1)*4 + 3) = ikind
4308 interact_adjm((ind - 1)*4 + 4) = jkind
4311 CALL para_env%sum(interact_adjm)
4314 extension=
".adjmat", file_form=
"FORMATTED", &
4315 file_status=
"REPLACE")
4316 IF (unit_nr > 0)
THEN
4317 WRITE (unit_nr,
"(1A,2X,1A,5X,1A,4X,A5,3X,A5)")
"#",
"iatom",
"jatom",
"ikind",
"jkind"
4318 DO k = 1, 4*adjm_size, 4
4320 IF (interact_adjm(k) > 0 .AND. interact_adjm(k + 1) > 0)
THEN
4321 WRITE (unit_nr,
"(I8,2X,I8,3X,I6,2X,I6)") interact_adjm(k:k + 3)
4329 DEALLOCATE (basis_set_list_a, basis_set_list_b)
4332 CALL timestop(handle)
4334 END SUBROUTINE write_adjacency_matrix
4342 SUBROUTINE update_hartree_with_mp2(rho, qs_env)
4346 LOGICAL :: use_virial
4356 NULLIFY (auxbas_pw_pool, pw_env, poisson_env, energy, rho_core, v_hartree_rspace, virial)
4357 CALL get_qs_env(qs_env, pw_env=pw_env, energy=energy, &
4358 rho_core=rho_core, virial=virial, &
4359 v_hartree_rspace=v_hartree_rspace)
4361 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
4363 IF (.NOT. use_virial)
THEN
4365 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
4366 poisson_env=poisson_env)
4367 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
4368 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
4372 v_hartree_gspace, rho_core=rho_core)
4374 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
4375 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
4377 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
4378 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
4381 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.
Calculation of the non-local pseudopotential contribution to the core Hamiltonian <a|V(non-local)|b> ...
subroutine, public build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_set, cell, matrix_rv, matrix_rxrv, matrix_rrv, matrix_rvr, matrix_rrv_vrr, matrix_r_rxvr, matrix_rxvr_r, matrix_r_doublecom, pseudoatom, ref_point)
Calculate [r,Vnl] (matrix_rv), r x [r,Vnl] (matrix_rxrv) or [rr,Vnl] (matrix_rrv) in AO basis....
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_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
real(kind=dp) function, public dbcsr_checksum(matrix, pos)
Calculates the checksum of a DBCSR matrix.
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
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...
character(len=default_string_length) function, public cp_iter_string(iter_info, print_key, for_file)
returns the iteration string, a string that is useful to create unique filenames (once you trim it)
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)
...
set of type/routines to handle the storage of results in force_envs
set of type/routines to handle the storage of results in force_envs
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)
...
GAPW reciprocal-space reconstruction and its discrete adjoint.
subroutine, public calculate_rhotot_elec_gspace(qs_env, auxbas_pw_pool, rhotot_elec_gspace, q_max, rho_hard, rho_soft, fsign, compute_tau, rho_source, allow_nonorthorhombic)
The total electronic density in reciprocal space (g-space) is calculated.
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
real(kind=dp), parameter, public debye
Provide various population analyses and print the requested output information.
subroutine, public lowdin_population_analysis(qs_env, output_unit, print_level)
Perform a Lowdin population analysis based on a symmetric orthogonalisation of the density matrix usi...
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 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_curve)
Resolve projected-DOS requests from a DOS print section.
Calculation and writing of density of states.
subroutine, public calculate_dos_kp(qs_env, dft_section, write_curve_output)
Compute and write density of states (kpoints).
subroutine, public calculate_dos(mos, dft_section, unoccupied_evals, smearing_enabled, write_curve_output)
Compute and write density of states.
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, matrix_vhxc, 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)
...
Fractional occupation number weighted density (Grimme and Hansen).
subroutine, public qs_scf_post_fod(input, logger, qs_env, output_unit)
Print the orbital FOD sum and, optionally, its real-space density.
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, hund_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, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, 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, cmo_coeff)
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)
...
subroutine, public build_lin_mom_matrix(qs_env, matrix, minimum_image)
Calculation of the linear momentum matrix <mu|∂|nu> over Cartesian Gaussian functions.
an eigen-space solver for the generalised symmetric eigenvalue problem for sparse matrices,...
subroutine, public ot_eigensolver(matrix_h, matrix_s, matrix_orthogonal_space_fm, matrix_c_fm, preconditioner, eps_gradient, iter_max, size_ortho_space, silent, ot_settings)
...
Calculation and writing of projected density of states The DOS is computed per angular momentum and p...
subroutine, public calculate_projected_dos_kp(qs_env, dft_section, pdos_print_key, write_pdos, write_pdos_curve)
Compute and write broadened projected density of states for k-point calculations.
subroutine, public calculate_projected_dos(mo_set, atomic_kind_set, qs_kind_set, particle_set, qs_env, dft_section, ispin, xas_mittle, external_matrix_shalf, unoccupied_orbs, unoccupied_evals, pdos_print_key, write_pdos, write_pdos_curve)
Compute and write projected density of states.
Finite or periodic quadratic pseudospectrum analysis after SCF.
subroutine, public qs_scf_post_quadratic(qs_env)
Evaluate scans of quadratic gaps and localized joint approximate eigenstates.
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 get_effective_core_charges(qs_env, zcharge)
Collects the effective core charge for every atom in a QS environment.
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.
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
Post-SCF finite-system spectral localizers and analytic AO position export.
subroutine, public qs_scf_post_localizer(qs_env)
Export finite AO positions and optionally evaluate localizers after SCF.
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...
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...
contains arbitrary information which need to be stored
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.