84#include "./base/base_uses.f90"
90 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_output'
110 INTEGER,
INTENT(IN) :: output_unit
113 INTEGER :: nelectron_total
114 LOGICAL :: gapw, gapw_xc, qmmm
121 NULLIFY (rho, energy, dft_control, scf_env, qs_charges)
122 CALL get_qs_env(qs_env=qs_env, rho=rho, energy=energy, dft_control=dft_control, &
123 scf_env=scf_env, qs_charges=qs_charges)
125 gapw = dft_control%qs_control%gapw
126 gapw_xc = dft_control%qs_control%gapw_xc
128 nelectron_total = scf_env%nelectron
130 CALL qs_scf_print_scf_summary(output_unit, rho, qs_charges, energy, nelectron_total, &
131 dft_control, qmmm, qs_env, gapw, gapw_xc)
143 INTEGER :: output_unit
146 INTEGER,
INTENT(IN) :: ndep
148 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_scf_initial_info'
150 INTEGER :: handle, homo, ispin, nao, &
153 CALL timeset(routinen, handle)
155 IF (output_unit > 0)
THEN
156 DO ispin = 1, dft_control%nspins
159 nelectron=nelectron_spin, &
162 IF (dft_control%nspins > 1)
THEN
163 WRITE (unit=output_unit, fmt=
"(/,T2,A,I2)")
"Spin", ispin
165 WRITE (unit=output_unit, fmt=
"(/,(T2,A,T71,I10))") &
166 "Number of electrons:", nelectron_spin, &
167 "Number of occupied orbitals:", homo, &
168 "Number of molecular orbitals:", nmo
170 WRITE (unit=output_unit, fmt=
"(/,(T2,A,T71,I10))") &
171 "Number of orbital functions:", nao, &
172 "Number of independent orbital functions:", nao - ndep
175 CALL timestop(handle)
190 LOGICAL,
INTENT(IN) :: final_mos
192 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_scf_write_mos'
194 CHARACTER(LEN=2) :: solver_method
195 CHARACTER(LEN=3*default_string_length) :: message
196 CHARACTER(LEN=5) :: spin
197 CHARACTER(LEN=default_string_length), &
198 DIMENSION(:),
POINTER :: tmpstringlist
199 INTEGER :: handle, homo, ikp, ispin, iw, kpoint, &
200 nao, nelectron, nkp, nmo, nspin, numo
201 INTEGER,
DIMENSION(2) :: nmos_occ
202 INTEGER,
DIMENSION(:),
POINTER :: mo_index_range
203 LOGICAL :: do_kpoints, do_printout, print_eigvals, &
204 print_eigvecs, print_mo_info, &
205 print_occup, print_occup_stats
206 REAL(kind=
dp) :: flexible_electron_count, maxocc, n_el_f, &
207 occup_stats_occ_threshold
208 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, umo_eigenvalues
212 TYPE(
cp_fm_type),
POINTER :: mo_coeff, umo_coeff
215 TYPE(
dbcsr_type),
POINTER :: matrix_ks, matrix_s, mo_coeff_deriv
223 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
227 CALL timeset(routinen, handle)
229 cpassert(
ASSOCIATED(qs_env))
233 blacs_env=blacs_env, &
234 dft_control=dft_control, &
235 do_kpoints=do_kpoints, &
237 qs_kind_set=qs_kind_set, &
239 particle_set=particle_set, &
240 scf_control=scf_control)
247 CALL section_vals_val_get(dft_section,
"PRINT%MO%OCCUPATION_NUMBERS_STATS", c_vals=tmpstringlist)
249 print_occup_stats = .false.
250 occup_stats_occ_threshold = 1e-6_dp
251 IF (
SIZE(tmpstringlist) > 0)
THEN
252 print_occup_stats = .true.
253 IF (len_trim(tmpstringlist(1)) > 0) &
254 READ (tmpstringlist(1), *) print_occup_stats
256 IF (
SIZE(tmpstringlist) > 1) &
257 READ (tmpstringlist(2), *) occup_stats_occ_threshold
262 IF ((.NOT. print_mo_info) .OR. (.NOT. (print_eigvals .OR. print_eigvecs .OR. print_occup .OR. print_occup_stats)))
THEN
263 CALL timestop(handle)
267 NULLIFY (fm_struct_tmp)
269 NULLIFY (mo_coeff_deriv)
270 NULLIFY (mo_eigenvalues)
273 NULLIFY (umo_eigenvalues)
277 nspin = dft_control%nspins
283 nkp =
SIZE(kpoints%kp_env)
285 CALL get_qs_env(qs_env, matrix_ks=ks, matrix_s=s)
286 cpassert(
ASSOCIATED(ks))
287 cpassert(
ASSOCIATED(s))
291 kp_loop:
DO ikp = 1, nkp
294 mos => kpoints%kp_env(ikp)%kpoint_env%mos(1, :)
297 CALL get_qs_env(qs_env, matrix_ks=ks, mos=mos)
300 cpassert(
ASSOCIATED(mos))
311 cpabort(
"The OT method is not implemented for k points")
316 matrix_ks => ks(ispin)%matrix
317 matrix_s => s(1)%matrix
320 IF (dft_control%do_admm)
THEN
328 eigenvalues=mo_eigenvalues, &
331 nelectron=nelectron, &
335 flexible_electron_count=flexible_electron_count)
337 IF (
ASSOCIATED(qs_env%mo_derivs))
THEN
338 mo_coeff_deriv => qs_env%mo_derivs(ispin)%matrix
340 mo_coeff_deriv => null()
345 ks_matrix=matrix_ks, &
346 evals_arg=mo_eigenvalues, &
347 co_rotate_dbcsr=mo_coeff_deriv)
352 cpassert(
ASSOCIATED(mo_index_range))
353 IF (mo_index_range(2) < 0)
THEN
356 numo = min(mo_index_range(2) - homo, nao - homo)
375 flexible_electron_count=flexible_electron_count)
377 fm_struct=fm_struct_tmp, &
378 name=
"Temporary MO set (unoccupied MOs only) for printout")
381 mo_coeff=umo_coeff, &
382 eigenvalues=umo_eigenvalues)
388 NULLIFY (local_preconditioner)
389 IF (
ASSOCIATED(scf_env%ot_preconditioner))
THEN
390 local_preconditioner => scf_env%ot_preconditioner(1)%preconditioner
392 NULLIFY (local_preconditioner)
399 matrix_c_fm=umo_coeff, &
400 matrix_orthogonal_space_fm=mo_coeff, &
401 eps_gradient=scf_control%eps_lumos, &
403 iter_max=scf_control%max_iter_lumos, &
404 size_ortho_space=nmo)
407 ks_matrix=matrix_ks, &
408 evals_arg=umo_eigenvalues)
414 IF (dft_control%do_admm)
THEN
420 message =
"The MO information is only calculated after SCF convergence "// &
421 "is achieved when the orbital transformation (OT) method is used"
422 cpwarn(trim(message))
423 do_printout = .false.
444 cpabort(
"Invalid spin")
446 IF (
ASSOCIATED(umo_set))
THEN
448 final_mos=final_mos, spin=trim(spin), solver_method=solver_method, &
452 final_mos=final_mos, spin=trim(spin), solver_method=solver_method)
455 IF (
ASSOCIATED(umo_set))
THEN
457 final_mos=final_mos, solver_method=solver_method, &
461 final_mos=final_mos, solver_method=solver_method)
465 nmos_occ(ispin) = max(nmos_occ(ispin), count(mo_set%occupation_numbers > occup_stats_occ_threshold))
469 IF (
ASSOCIATED(umo_set))
THEN
482 IF (do_printout .AND. print_mo_info .AND. print_occup_stats)
THEN
484 ignore_should_output=print_mo_info, &
487 IF (
SIZE(mos) > 1)
THEN
488 WRITE (unit=iw, fmt=
"(A,I4)")
" MO| Total occupied (ALPHA):", nmos_occ(1)
489 WRITE (unit=iw, fmt=
"(A,I4)")
" MO| Total occupied (BETA): ", nmos_occ(2)
491 WRITE (unit=iw, fmt=
"(A,I4)")
" MO| Total occupied: ", nmos_occ(1)
493 WRITE (unit=iw, fmt=
"(A)")
""
496 ignore_should_output=print_mo_info)
499 CALL timestop(handle)
514 energy, total_steps, should_stop, outer_loop_converged)
515 INTEGER :: output_unit
519 INTEGER :: total_steps
520 LOGICAL,
INTENT(IN) :: should_stop, outer_loop_converged
522 REAL(kind=
dp) :: outer_loop_eps
524 outer_loop_eps = sqrt(maxval(scf_env%outer_scf%gradient(:, scf_env%outer_scf%iter_count)**2))
525 IF (output_unit > 0)
WRITE (output_unit,
'(/,T3,A,I4,A,E10.2,A,F22.10)') &
526 "outer SCF iter = ", scf_env%outer_scf%iter_count, &
527 " RMS gradient = ", outer_loop_eps,
" energy =", energy%total
529 IF (outer_loop_converged)
THEN
530 IF (output_unit > 0)
WRITE (output_unit,
'(T3,A,I4,A,I4,A,/)') &
531 "outer SCF loop converged in", scf_env%outer_scf%iter_count, &
532 " iterations or ", total_steps,
" steps"
533 ELSE IF (scf_env%outer_scf%iter_count > scf_control%outer_scf%max_scf &
534 .OR. should_stop)
THEN
535 IF (output_unit > 0)
WRITE (output_unit,
'(T3,A,I4,A,I4,A,/)') &
536 "outer SCF loop FAILED to converge after ", &
537 scf_env%outer_scf%iter_count,
" iterations or ", total_steps,
" steps"
554 INTEGER :: output_unit
555 LOGICAL :: just_energy
556 REAL(kind=
dp) :: t1, t2
559 IF ((output_unit > 0) .AND. scf_env%print_iter_line)
THEN
560 IF (just_energy)
THEN
561 WRITE (unit=output_unit, &
562 fmt=
"(T2,A,1X,A,T20,E8.2,1X,F6.1,16X,F20.10)") &
563 " -", trim(scf_env%iter_method), scf_env%iter_param, t2 - t1, energy%total
565 IF ((abs(scf_env%iter_delta) < 1.0e-8_dp) .OR. &
566 (abs(scf_env%iter_delta) >= 1.0e5_dp))
THEN
567 WRITE (unit=output_unit, &
568 fmt=
"(T2,I5,1X,A,T20,E8.2,1X,F6.1,1X,ES14.4,1X,F20.10,1X,ES9.2)") &
569 scf_env%iter_count, trim(scf_env%iter_method), scf_env%iter_param, &
570 t2 - t1, scf_env%iter_delta, energy%total, energy%total - energy%tot_old
572 WRITE (unit=output_unit, &
573 fmt=
"(T2,I5,1X,A,T20,E8.2,1X,F6.1,1X,F14.8,1X,F20.10,1X,ES9.2)") &
574 scf_env%iter_count, trim(scf_env%iter_method), scf_env%iter_param, &
575 t2 - t1, scf_env%iter_delta, energy%total, energy%total - energy%tot_old
600 SUBROUTINE qs_scf_print_scf_summary(output_unit, rho, qs_charges, energy, nelectron_total, &
601 dft_control, qmmm, qs_env, gapw, gapw_xc)
602 INTEGER,
INTENT(IN) :: output_unit
606 INTEGER,
INTENT(IN) :: nelectron_total
608 LOGICAL,
INTENT(IN) :: qmmm
610 LOGICAL,
INTENT(IN) :: gapw, gapw_xc
612 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_scf_print_scf_summary'
614 INTEGER :: bc, handle, ispin, psolver
615 REAL(kind=
dp) :: e_extrapolated, exc1_energy, exc_energy, &
616 implicit_ps_ehartree, tot1_h, tot1_s
617 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_r
621 NULLIFY (tot_rho_r, pw_env)
622 CALL timeset(routinen, handle)
624 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, scf_control=scf_control)
625 psolver = pw_env%poisson_env%parameters%solver
627 IF (output_unit > 0)
THEN
629 IF (.NOT. (dft_control%qs_control%semi_empirical .OR. &
630 dft_control%qs_control%xtb .OR. &
631 dft_control%qs_control%dftb))
THEN
632 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T41,2F20.10))") &
633 "Electronic density on regular grids: ", &
636 "Core density on regular grids:", &
637 qs_charges%total_rho_core_rspace, &
638 qs_charges%total_rho_core_rspace + &
639 qs_charges%total_rho1_hard_nuc - &
640 REAL(nelectron_total + dft_control%charge,
dp)
642 IF (dft_control%correct_surf_dip)
THEN
643 WRITE (unit=output_unit, fmt=
"((T3,A,/,T3,A,T41,F20.10))") &
644 "Total dipole moment perpendicular to ", &
645 "the slab [electrons-Angstroem]: ", &
646 qs_env%surface_dipole_moment
650 tot1_h = qs_charges%total_rho1_hard(1)
651 tot1_s = qs_charges%total_rho1_soft(1)
652 DO ispin = 2, dft_control%nspins
653 tot1_h = tot1_h + qs_charges%total_rho1_hard(ispin)
654 tot1_s = tot1_s + qs_charges%total_rho1_soft(ispin)
656 WRITE (unit=output_unit, fmt=
"((T3,A,T41,2F20.10))") &
657 "Hard and soft densities (Lebedev):", &
659 WRITE (unit=output_unit, fmt=
"(T3,A,T41,F20.10)") &
660 "Total Rho_soft + Rho1_hard - Rho1_soft (r-space): ", &
662 "Total charge density (r-space): ", &
664 + qs_charges%total_rho_core_rspace &
665 + qs_charges%total_rho1_hard_nuc
666 IF (qs_charges%total_rho1_hard_nuc /= 0.0_dp)
THEN
667 WRITE (unit=output_unit, fmt=
"(T3,A,T41,F20.10)") &
668 "Total CNEO nuc. char. den. (Lebedev): ", &
669 qs_charges%total_rho1_hard_nuc, &
670 "Total CNEO soft char. den. (Lebedev): ", &
671 qs_charges%total_rho1_soft_nuc_lebedev, &
672 "Total CNEO soft char. den. (r-space): ", &
673 qs_charges%total_rho1_soft_nuc_rspace, &
674 "Total soft Rho_e+n+0 (g-space):", &
675 qs_charges%total_rho_gspace
677 WRITE (unit=output_unit, fmt=
"(T3,A,T41,F20.10)") &
678 "Total Rho_soft + Rho0_soft (g-space):", &
679 qs_charges%total_rho_gspace
683 WRITE (unit=output_unit, fmt=
"(T3,A,T41,F20.10)") &
684 "Total charge density on r-space grids: ", &
686 qs_charges%total_rho_core_rspace, &
687 "Total charge density g-space grids: ", &
688 qs_charges%total_rho_gspace
691 IF (dft_control%qs_control%semi_empirical)
THEN
692 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
693 "Core-core repulsion energy [eV]: ", energy%core_overlap*
evolt, &
694 "Core Hamiltonian energy [eV]: ", energy%core*
evolt, &
695 "Two-electron integral energy [eV]: ", energy%hartree*
evolt, &
696 "Electronic energy [eV]: ", &
697 (energy%core + 0.5_dp*energy%hartree)*
evolt
698 IF (energy%dispersion /= 0.0_dp) &
699 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
700 "Dispersion energy [eV]: ", energy%dispersion*
evolt
701 ELSEIF (dft_control%qs_control%dftb)
THEN
702 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
703 "Core Hamiltonian energy: ", energy%core, &
704 "Repulsive potential energy: ", energy%repulsive, &
705 "Electronic energy: ", energy%hartree, &
706 "Dispersion energy: ", energy%dispersion
707 IF (energy%dftb3 /= 0.0_dp) &
708 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
709 "DFTB3 3rd order energy: ", energy%dftb3
710 IF (energy%efield /= 0.0_dp) &
711 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
712 "Electric field interaction energy: ", energy%efield
713 ELSEIF (dft_control%qs_control%xtb)
THEN
714 IF (dft_control%qs_control%xtb_control%do_tblite)
THEN
715 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
716 "Core Hamiltonian energy: ", energy%core, &
717 "Repulsive potential energy: ", energy%repulsive, &
718 "Electrostatic energy: ", energy%el_stat, &
719 "Self-consistent dispersion energy: ", energy%dispersion_sc, &
720 "Non-self consistent dispersion energy: ", energy%dispersion, &
721 "Correction for halogen bonding: ", energy%xtb_xb_inter
723 IF (dft_control%qs_control%xtb_control%gfn_type == 0)
THEN
724 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
725 "Core Hamiltonian energy: ", energy%core, &
726 "Repulsive potential energy: ", energy%repulsive, &
727 "SRB Correction energy: ", energy%srb, &
728 "Charge equilibration energy: ", energy%eeq, &
729 "Dispersion energy: ", energy%dispersion
730 ELSEIF (dft_control%qs_control%xtb_control%gfn_type == 1)
THEN
731 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
732 "Core Hamiltonian energy: ", energy%core, &
733 "Repulsive potential energy: ", energy%repulsive, &
734 "Electronic energy: ", energy%hartree, &
735 "DFTB3 3rd order energy: ", energy%dftb3, &
736 "Dispersion energy: ", energy%dispersion
737 IF (dft_control%qs_control%xtb_control%xb_interaction) &
738 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
739 "Correction for halogen bonding: ", energy%xtb_xb_inter
740 ELSEIF (dft_control%qs_control%xtb_control%gfn_type == 2)
THEN
741 cpabort(
"gfn_typ 2 NYA")
743 cpabort(
"invalid gfn_typ")
746 IF (dft_control%qs_control%xtb_control%do_nonbonded) &
747 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
748 "Correction for nonbonded interactions: ", energy%xtb_nonbonded
749 IF (energy%efield /= 0.0_dp) &
750 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
751 "Electric field interaction energy: ", energy%efield
753 IF (dft_control%do_admm)
THEN
754 exc_energy = energy%exc + energy%exc_aux_fit
755 IF (gapw .OR. gapw_xc) exc1_energy = energy%exc1 + energy%exc1_aux_fit
757 exc_energy = energy%exc
758 IF (gapw .OR. gapw_xc) exc1_energy = energy%exc1
762 implicit_ps_ehartree = pw_env%poisson_env%implicit_env%ehartree
763 bc = pw_env%poisson_env%parameters%ps_implicit_params%boundary_condition
766 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
767 "Overlap energy of the core charge distribution:", energy%core_overlap, &
768 "Self energy of the core charge distribution: ", energy%core_self, &
769 "Core Hamiltonian energy: ", energy%core, &
770 "Hartree energy: ", implicit_ps_ehartree, &
771 "Electric enthalpy: ", energy%hartree, &
772 "Exchange-correlation energy: ", exc_energy
774 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
775 "Overlap energy of the core charge distribution:", energy%core_overlap, &
776 "Self energy of the core charge distribution: ", energy%core_self, &
777 "Core Hamiltonian energy: ", energy%core, &
778 "Hartree energy: ", energy%hartree, &
779 "Exchange-correlation energy: ", exc_energy
782 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
783 "Overlap energy of the core charge distribution:", energy%core_overlap, &
784 "Self energy of the core charge distribution: ", energy%core_self, &
785 "Core Hamiltonian energy: ", energy%core, &
786 "Hartree energy: ", energy%hartree, &
787 "Exchange-correlation energy: ", exc_energy
789 IF (energy%e_hartree /= 0.0_dp) &
790 WRITE (unit=output_unit, fmt=
"(T3,A,/,T3,A,T56,F25.14)") &
791 "Coulomb Electron-Electron Interaction Energy ", &
792 "- Already included in the total Hartree term ", energy%e_hartree
793 IF (energy%ex /= 0.0_dp) &
794 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
795 "Hartree-Fock Exchange energy: ", energy%ex
796 IF (energy%dispersion /= 0.0_dp) &
797 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
798 "Dispersion energy: ", energy%dispersion
799 IF (energy%gcp /= 0.0_dp) &
800 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
801 "gCP energy: ", energy%gcp
802 IF (energy%efield /= 0.0_dp) &
803 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
804 "Electric field interaction energy: ", energy%efield
806 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
807 "GAPW| Exc from hard and soft atomic rho1: ", exc1_energy, &
808 "GAPW| local Eh = 1 center integrals: ", energy%hartree_1c
811 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
812 "GAPW_XC| Exc from hard and soft atomic rho1: ", exc1_energy
814 IF (energy%core_cneo /= 0.0_dp)
THEN
815 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
816 "CNEO| quantum nuclear core energy: ", energy%core_cneo
819 IF (dft_control%hairy_probes .EQV. .true.)
THEN
820 WRITE (unit=output_unit, fmt=
"((T3,A,T56,F25.14))") &
821 "Electronic entropic energy:", energy%kTS
822 WRITE (unit=output_unit, fmt=
"((T3,A,T56,F25.14))") &
823 "Fermi energy:", energy%efermi
825 IF (dft_control%smear)
THEN
826 SELECT CASE (scf_control%smear%method)
829 WRITE (unit=output_unit, fmt=
"((T3,A,T56,F25.14))") &
830 "Smearing free energy correction:", energy%kTS
832 WRITE (unit=output_unit, fmt=
"((T3,A,T56,F25.14))") &
833 "Electronic entropic energy:", energy%kTS
835 WRITE (unit=output_unit, fmt=
"((T3,A,T56,F25.14))") &
836 "Fermi energy:", energy%efermi
838 IF (dft_control%dft_plus_u)
THEN
839 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
840 "DFT+U energy:", energy%dft_plus_u
842 IF (dft_control%do_sccs)
THEN
843 WRITE (unit=output_unit, fmt=
"(A)")
""
847 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
848 "QM/MM Electrostatic energy: ", energy%qmmm_el
849 IF (qs_env%qmmm_env_qm%image_charge)
THEN
850 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
851 "QM/MM image charge energy: ", energy%image_charge
854 IF (dft_control%qs_control%mulliken_restraint)
THEN
855 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.14)") &
856 "Mulliken restraint energy: ", energy%mulliken
858 IF (dft_control%qs_control%semi_empirical)
THEN
859 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
860 "Total energy [eV]: ", energy%total*
evolt
861 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
862 "Atomic reference energy [eV]: ", energy%core_self*
evolt, &
863 "Heat of formation [kcal/mol]: ", &
864 (energy%total + energy%core_self)*
kcalmol
866 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T56,F25.14))") &
867 "Total energy: ", energy%total
868 IF (dft_control%smear)
THEN
869 SELECT CASE (scf_control%smear%method)
871 e_extrapolated = energy%total - 0.5_dp*energy%kTS
872 WRITE (unit=output_unit, fmt=
"((T3,A,T56,F25.14))") &
873 "Total energy (extrapolated to T->0): ", e_extrapolated
875 e_extrapolated = energy%total - 0.5_dp*energy%kTS
876 WRITE (unit=output_unit, fmt=
"((T3,A,T56,F25.14))") &
877 "Total energy (extrapolated to sigma->0): ", e_extrapolated
884 IF (qs_env%qmmm_env_qm%image_charge)
THEN
891 CALL timestop(handle)
893 END SUBROUTINE qs_scf_print_scf_summary
908 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_scf_loop_print'
910 INTEGER :: after, handle, ic, ispin, iw
911 LOGICAL :: do_kpoints, omit_headers
912 REAL(kind=
dp) :: mo_mag_max, mo_mag_min, orthonormality
914 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_p, matrix_s
921 CALL timeset(routinen, handle)
923 CALL get_qs_env(qs_env=qs_env, input=input, dft_control=dft_control, &
924 do_kpoints=do_kpoints)
930 DO ispin = 1, dft_control%nspins
933 dft_section,
"PRINT%AO_MATRICES/DENSITY"),
cp_p_file))
THEN
939 after = min(max(after, 1), 16)
940 DO ic = 1,
SIZE(matrix_p, 2)
942 output_unit=iw, omit_headers=omit_headers)
945 "PRINT%AO_MATRICES/DENSITY")
949 dft_section,
"PRINT%AO_MATRICES/KOHN_SHAM_MATRIX"),
cp_p_file))
THEN
953 after = min(max(after, 1), 16)
954 CALL get_qs_env(qs_env=qs_env, matrix_ks_kp=matrix_ks)
955 DO ic = 1,
SIZE(matrix_ks, 2)
956 IF (dft_control%qs_control%semi_empirical)
THEN
958 scale=
evolt, output_unit=iw, omit_headers=omit_headers)
961 output_unit=iw, omit_headers=omit_headers)
965 "PRINT%AO_MATRICES/KOHN_SHAM_MATRIX")
971 scf_section,
"PRINT%MO_ORTHONORMALITY"),
cp_p_file))
THEN
976 WRITE (iw,
'(T8,A)') &
977 " K-points: Maximum deviation from MO S-orthonormality not determined"
980 "PRINT%MO_ORTHONORMALITY")
986 CALL get_qs_env(qs_env=qs_env, matrix_s_kp=matrix_s)
992 WRITE (iw,
'(T8,A,T61,E20.4)') &
993 " Maximum deviation from MO S-orthonormality", orthonormality
996 "PRINT%MO_ORTHONORMALITY")
1000 scf_section,
"PRINT%MO_MAGNITUDE"),
cp_p_file))
THEN
1001 IF (do_kpoints)
THEN
1003 extension=
".scfLog")
1005 WRITE (iw,
'(T8,A)') &
1006 " K-points: Minimum/Maximum MO magnitude not determined"
1009 "PRINT%MO_MAGNITUDE")
1014 extension=
".scfLog")
1016 WRITE (iw,
'(T8,A,T41,2E20.4)') &
1017 " Minimum/Maximum MO magnitude ", mo_mag_min, mo_mag_max
1020 "PRINT%MO_MAGNITUDE")
1024 CALL timestop(handle)
1043 energy, total_steps, should_stop, outer_loop_converged, &
1045 INTEGER :: output_unit
1050 INTEGER :: total_steps
1051 LOGICAL,
INTENT(IN) :: should_stop, outer_loop_converged, &
1054 REAL(kind=
dp) :: outer_loop_eps
1057 outer_loop_eps = sqrt(maxval(scf_env%outer_scf%gradient(:, scf_env%outer_scf%iter_count)**2))
1058 IF (output_unit > 0)
WRITE (output_unit,
'(/,T3,A,I4,A,E10.2,A,F22.10)') &
1059 "CDFT SCF iter = ", scf_env%outer_scf%iter_count, &
1060 " RMS gradient = ", outer_loop_eps,
" energy =", energy%total
1061 IF (outer_loop_converged)
THEN
1062 IF (output_unit > 0)
WRITE (output_unit,
'(T3,A,I4,A,I4,A,/)') &
1063 "CDFT SCF loop converged in", scf_env%outer_scf%iter_count, &
1064 " iterations or ", total_steps,
" steps"
1066 IF ((scf_env%outer_scf%iter_count > scf_control%outer_scf%max_scf .OR. should_stop) &
1067 .AND. .NOT. outer_loop_converged)
THEN
1068 IF (output_unit > 0)
WRITE (output_unit,
'(T3,A,I4,A,I4,A,/)') &
1069 "CDFT SCF loop FAILED to converge after ", &
1070 scf_env%outer_scf%iter_count,
" iterations or ", total_steps,
" steps"
1085 INTEGER :: output_unit
1088 IF (output_unit > 0)
THEN
1089 WRITE (output_unit,
'(/,A)') &
1090 " ---------------------------------- CDFT --------------------------------------"
1091 WRITE (output_unit,
'(A)') &
1092 " Optimizing a density constraint in an external SCF loop "
1093 WRITE (output_unit,
'(A)')
" "
1094 SELECT CASE (cdft_control%type)
1096 WRITE (output_unit,
'(A)')
" Type of constraint: Hirshfeld"
1098 WRITE (output_unit,
'(A)')
" Type of constraint: Becke"
1100 WRITE (output_unit,
'(A,I8)')
" Number of constraints: ",
SIZE(cdft_control%group)
1101 WRITE (output_unit,
'(A,L8)')
" Using fragment densities:", cdft_control%fragment_density
1102 WRITE (output_unit,
'(A)')
" "
1103 IF (cdft_control%atomic_charges)
WRITE (output_unit,
'(A,/)')
" Calculating atomic CDFT charges"
1104 SELECT CASE (cdft_control%constraint_control%optimizer)
1106 WRITE (output_unit,
'(A)') &
1107 " Minimizer : SD : steepest descent"
1109 WRITE (output_unit,
'(A)') &
1110 " Minimizer : DIIS : direct inversion"
1111 WRITE (output_unit,
'(A)') &
1112 " in the iterative subspace"
1113 WRITE (output_unit,
'(A,I3,A)') &
1115 cdft_control%constraint_control%diis_buffer_length,
" DIIS vectors"
1117 WRITE (output_unit,
'(A)') &
1118 " Minimizer : BISECT : gradient bisection"
1119 WRITE (output_unit,
'(A,I3)') &
1120 " using a trust count of", &
1121 cdft_control%constraint_control%bisect_trust_count
1125 cdft_control%constraint_control%optimizer, output_unit)
1127 WRITE (output_unit,
'(A)')
" Minimizer : Secant"
1131 WRITE (output_unit,
'(/,A,L7)') &
1132 " Reusing OT preconditioner: ", cdft_control%reuse_precond
1133 IF (cdft_control%reuse_precond)
THEN
1134 WRITE (output_unit,
'(A,I3,A,I3,A)') &
1135 " using old preconditioner for up to ", &
1136 cdft_control%max_reuse,
" subsequent CDFT SCF"
1137 WRITE (output_unit,
'(A,I3,A,I3,A)') &
1138 " iterations if the relevant loop converged in less than ", &
1139 cdft_control%precond_freq,
" steps"
1141 SELECT CASE (cdft_control%type)
1143 WRITE (output_unit,
'(/,A)')
" Hirshfeld constraint settings"
1144 WRITE (output_unit,
'(A)')
" "
1145 SELECT CASE (cdft_control%hirshfeld_control%shape_function)
1147 WRITE (output_unit,
'(A, A8)') &
1148 " Shape function type: ",
"Gaussian"
1149 WRITE (output_unit,
'(A)', advance=
'NO') &
1150 " Type of Gaussian: "
1151 SELECT CASE (cdft_control%hirshfeld_control%gaussian_shape)
1153 WRITE (output_unit,
'(A13)')
"Default"
1155 WRITE (output_unit,
'(A13)')
"Covalent"
1157 WRITE (output_unit,
'(A13)')
"Fixed radius"
1159 WRITE (output_unit,
'(A13)')
"Van der Waals"
1161 WRITE (output_unit,
'(A13)')
"User-defined"
1165 WRITE (output_unit,
'(A, A8)') &
1166 " Shape function type: ",
"Density"
1169 WRITE (output_unit,
'(/, A)')
" Becke constraint settings"
1170 WRITE (output_unit,
'(A)')
" "
1171 SELECT CASE (cdft_control%becke_control%cutoff_type)
1173 WRITE (output_unit,
'(A,F8.3,A)') &
1174 " Cutoff for partitioning :",
cp_unit_from_cp2k(cdft_control%becke_control%rglobal, &
1175 "angstrom"),
" angstrom"
1177 WRITE (output_unit,
'(A)') &
1178 " Using element specific cutoffs for partitioning"
1180 WRITE (output_unit,
'(A,L7)') &
1181 " Skipping distant gpoints: ", cdft_control%becke_control%should_skip
1182 WRITE (output_unit,
'(A,L7)') &
1183 " Precompute gradients : ", cdft_control%becke_control%in_memory
1184 WRITE (output_unit,
'(A)')
" "
1185 IF (cdft_control%becke_control%adjust) &
1186 WRITE (output_unit,
'(A)') &
1187 " Using atomic radii to generate a heteronuclear charge partitioning"
1188 WRITE (output_unit,
'(A)')
" "
1189 IF (.NOT. cdft_control%becke_control%cavity_confine)
THEN
1190 WRITE (output_unit,
'(A)') &
1191 " No confinement is active"
1193 WRITE (output_unit,
'(A)')
" Confinement using a Gaussian shaped cavity is active"
1194 SELECT CASE (cdft_control%becke_control%cavity_shape)
1196 WRITE (output_unit,
'(A,F8.4, A)') &
1197 " Type of Gaussian : Fixed radius: ", &
1200 WRITE (output_unit,
'(A)') &
1201 " Type of Gaussian : Covalent radius "
1203 WRITE (output_unit,
'(A)') &
1204 " Type of Gaussian : vdW radius "
1206 WRITE (output_unit,
'(A)') &
1207 " Type of Gaussian : User radius "
1209 WRITE (output_unit,
'(A,ES12.4)') &
1210 " Cavity threshold : ", cdft_control%becke_control%eps_cavity
1213 WRITE (output_unit,
'(/,A)') &
1214 " ---------------------------------- CDFT --------------------------------------"
1227 INTEGER :: output_unit
1232 IF (output_unit > 0)
THEN
1233 SELECT CASE (cdft_control%type)
1235 WRITE (output_unit,
'(/,T3,A,T60)') &
1236 '------------------- Hirshfeld constraint information -------------------'
1238 WRITE (output_unit,
'(/,T3,A,T60)') &
1239 '--------------------- Becke constraint information ---------------------'
1241 cpabort(
"Unknown CDFT constraint.")
1243 DO igroup = 1,
SIZE(cdft_control%target)
1244 IF (igroup > 1)
WRITE (output_unit,
'(T3,A)')
' '
1245 WRITE (output_unit,
'(T3,A,T54,(3X,I18))') &
1246 'Atomic group :', igroup
1247 SELECT CASE (cdft_control%group(igroup)%constraint_type)
1249 IF (cdft_control%group(igroup)%is_fragment_constraint)
THEN
1250 WRITE (output_unit,
'(T3,A,T42,A)') &
1251 'Type of constraint :', adjustr(
'Charge density constraint (frag.)')
1253 WRITE (output_unit,
'(T3,A,T50,A)') &
1254 'Type of constraint :', adjustr(
'Charge density constraint')
1257 IF (cdft_control%group(igroup)%is_fragment_constraint)
THEN
1258 WRITE (output_unit,
'(T3,A,T35,A)') &
1259 'Type of constraint :', adjustr(
'Magnetization density constraint (frag.)')
1261 WRITE (output_unit,
'(T3,A,T43,A)') &
1262 'Type of constraint :', adjustr(
'Magnetization density constraint')
1265 IF (cdft_control%group(igroup)%is_fragment_constraint)
THEN
1266 WRITE (output_unit,
'(T3,A,T38,A)') &
1267 'Type of constraint :', adjustr(
'Alpha spin density constraint (frag.)')
1269 WRITE (output_unit,
'(T3,A,T46,A)') &
1270 'Type of constraint :', adjustr(
'Alpha spin density constraint')
1273 IF (cdft_control%group(igroup)%is_fragment_constraint)
THEN
1274 WRITE (output_unit,
'(T3,A,T39,A)') &
1275 'Type of constraint :', adjustr(
'Beta spin density constraint (frag.)')
1277 WRITE (output_unit,
'(T3,A,T47,A)') &
1278 'Type of constraint :', adjustr(
'Beta spin density constraint')
1281 cpabort(
"Unknown constraint type.")
1283 WRITE (output_unit,
'(T3,A,T54,(3X,F18.12))') &
1284 'Target value of constraint :', cdft_control%target(igroup)
1285 WRITE (output_unit,
'(T3,A,T54,(3X,F18.12))') &
1286 'Current value of constraint :', cdft_control%value(igroup)
1287 WRITE (output_unit,
'(T3,A,T59,(3X,ES13.3))') &
1288 'Deviation from target :', cdft_control%value(igroup) - cdft_control%target(igroup)
1289 WRITE (output_unit,
'(T3,A,T54,(3X,F18.12))') &
1290 'Strength of constraint :', cdft_control%strength(igroup)
1292 WRITE (output_unit,
'(T3,A)') &
1293 '------------------------------------------------------------------------'
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)
...
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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)
...
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_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 ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
sums arrays of real/complex numbers with much reduced round-off as compared to a naive implementation...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Types and basic routines needed for a kpoint calculation.
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Interface to the message passing library MPI.
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public kcalmol
real(kind=dp), parameter, public evolt
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
functions related to the poisson solver on regular grids
integer, parameter, public pw_poisson_implicit
Routines for image charge calculation within QM/MM.
subroutine, public print_image_coefficients(image_coeff, qs_env)
Print image coefficients.
Control parameters for optimizers that work with CDFT constraints.
subroutine, public cdft_opt_type_write(cdft_opt_control, optimizer, output_unit)
writes information about the CDFT optimizer object
Defines CDFT control structures.
container for information about total charges on the grids
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Definition and initialisation of the mo data type.
subroutine, public write_mo_set_to_output_unit(mo_set, qs_kind_set, particle_set, dft_section, before, kpoint, final_mos, spin, solver_method, rtp, cpart, sim_step, umo_set)
Write MO information to output file (eigenvalues, occupation numbers, coefficients)
collects routines that perform operations directly related to MOs
subroutine, public calculate_magnitude(mo_array, mo_mag_min, mo_mag_max)
...
subroutine, public calculate_orthonormality(orthonormality, mo_array, matrix_s)
...
Set occupation of molecular orbitals.
Definition and initialisation of the mo data type.
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
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)
...
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...
Self-consistent continuum solvation (SCCS) model implementation.
subroutine, public print_sccs_results(energy, sccs_control, output_unit)
Print SCCS results.
subroutine, public qs_scf_print_summary(output_unit, qs_env)
writes a summary of information after scf
subroutine, public qs_scf_cdft_constraint_info(output_unit, cdft_control)
writes CDFT constraint information
subroutine, public qs_scf_loop_print(qs_env, scf_env, para_env)
collects the 'heavy duty' printing tasks out of the SCF loop
subroutine, public qs_scf_outer_loop_info(output_unit, scf_control, scf_env, energy, total_steps, should_stop, outer_loop_converged)
writes basic information obtained in a scf outer loop step
subroutine, public qs_scf_initial_info(output_unit, mos, dft_control, ndep)
writes basic information at the beginning of an scf run
subroutine, public qs_scf_write_mos(qs_env, scf_env, final_mos)
Write the MO eigenvector, eigenvalues, and occupation numbers to the output unit.
subroutine, public qs_scf_loop_info(scf_env, output_unit, just_energy, t1, t2, energy)
writes basic information obtained in a scf step
subroutine, public qs_scf_cdft_info(output_unit, scf_control, scf_env, cdft_control, energy, total_steps, should_stop, outer_loop_converged, cdft_loop)
writes CDFT constraint information and optionally CDFT scf loop info
subroutine, public qs_scf_cdft_initial_info(output_unit, cdft_control)
writes information about the CDFT env
module that contains the definitions of the scf types
integer, parameter, public ot_method_nr
integer, parameter, public special_diag_method_nr
parameters that control an scf iteration
stores some data used in wavefunction fitting
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 information about kpoints.
stores all the informations relevant to an mpi environment
contained for different pw related things
Container for information about total charges on the grids.
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.