LCOV - code coverage report
Current view: top level - src - qs_nonscf_utils.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 59 66 89.4 %
Date: 2024-12-21 06:28:57 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief Routines for Quickstep NON-SCF run.
      10             : !> \par History
      11             : !>      - initial setup [JGH, 2024]
      12             : !> \author JGH (13.05.2024)
      13             : ! **************************************************************************************************
      14             : MODULE qs_nonscf_utils
      15             :    USE cp_control_types,                ONLY: dft_control_type
      16             :    USE kinds,                           ONLY: dp
      17             :    USE machine,                         ONLY: m_flush
      18             :    USE qs_charges_types,                ONLY: qs_charges_type
      19             :    USE qs_energy_types,                 ONLY: qs_energy_type
      20             :    USE qs_environment_types,            ONLY: get_qs_env,&
      21             :                                               qs_environment_type
      22             :    USE qs_rho_types,                    ONLY: qs_rho_get,&
      23             :                                               qs_rho_type
      24             : #include "./base/base_uses.f90"
      25             : 
      26             :    IMPLICIT NONE
      27             : 
      28             :    PRIVATE
      29             : 
      30             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_nonscf_utils'
      31             : 
      32             :    PUBLIC :: qs_nonscf_print_summary
      33             : 
      34             : CONTAINS
      35             : 
      36             : ! **************************************************************************************************
      37             : !> \brief writes a summary of information after diagonalization
      38             : !> \param qs_env ...
      39             : !> \param tdiag ...
      40             : !> \param nelectron_total ...
      41             : !> \param iounit ...
      42             : ! **************************************************************************************************
      43        2010 :    SUBROUTINE qs_nonscf_print_summary(qs_env, tdiag, nelectron_total, iounit)
      44             :       TYPE(qs_environment_type), POINTER                 :: qs_env
      45             :       REAL(KIND=dp), INTENT(IN)                          :: tdiag
      46             :       INTEGER, INTENT(IN)                                :: nelectron_total, iounit
      47             : 
      48        2010 :       REAL(KIND=dp), DIMENSION(:), POINTER               :: tot_rho_r
      49             :       TYPE(dft_control_type), POINTER                    :: dft_control
      50             :       TYPE(qs_charges_type), POINTER                     :: qs_charges
      51             :       TYPE(qs_energy_type), POINTER                      :: energy
      52             :       TYPE(qs_rho_type), POINTER                         :: rho
      53             : 
      54        2010 :       IF (iounit > 0) THEN
      55        1005 :          CALL get_qs_env(qs_env=qs_env, energy=energy, dft_control=dft_control)
      56        1005 :          IF (qs_env%harris_method) THEN
      57          15 :             CPASSERT(.NOT. dft_control%qs_control%gapw)
      58          15 :             CPASSERT(.NOT. dft_control%qs_control%gapw_xc)
      59             : 
      60          15 :             CALL get_qs_env(qs_env=qs_env, rho=rho, qs_charges=qs_charges)
      61          15 :             CALL qs_rho_get(rho, tot_rho_r=tot_rho_r)
      62             :             WRITE (UNIT=iounit, FMT="(/,(T3,A,T41,2F20.10))") &
      63          15 :                "Electronic density on regular grids: ", &
      64          30 :                SUM(tot_rho_r), &
      65          30 :                SUM(tot_rho_r) + nelectron_total, &
      66          15 :                "Core density on regular grids:", &
      67          15 :                qs_charges%total_rho_core_rspace, &
      68          30 :                qs_charges%total_rho_core_rspace - REAL(nelectron_total + dft_control%charge, dp)
      69             :             WRITE (UNIT=iounit, FMT="(T3,A,T41,F20.10)") &
      70          15 :                "Total charge density on r-space grids:     ", &
      71             :                SUM(tot_rho_r) + &
      72          30 :                qs_charges%total_rho_core_rspace, &
      73          15 :                "Total charge density g-space grids:     ", &
      74          30 :                qs_charges%total_rho_gspace
      75             : 
      76             :             WRITE (UNIT=iounit, FMT="(/,T2,A,T40,A,F10.2,T61,F20.10)") &
      77          15 :                "Diagonalization", "Time:", tdiag, energy%band
      78             : 
      79             :             WRITE (UNIT=iounit, FMT="((T3,A,T56,F25.14))") &
      80          15 :                "Core Hamiltonian energy:                       ", energy%core, &
      81          15 :                "Overlap energy of the core charge distribution:", energy%core_overlap, &
      82          15 :                "Self energy of the core charge distribution:   ", energy%core_self, &
      83          15 :                "Hartree energy:                                ", energy%hartree, &
      84          30 :                "Exchange-correlation energy:                   ", energy%exc
      85          15 :             IF (energy%dispersion /= 0.0_dp) &
      86             :                WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
      87          15 :                "Dispersion energy:                             ", energy%dispersion
      88          15 :             IF (energy%gcp /= 0.0_dp) &
      89             :                WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
      90           0 :                "gCP energy:                                    ", energy%gcp
      91          15 :             IF (energy%efield /= 0.0_dp) &
      92             :                WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
      93           0 :                "Electric field interaction energy:          ", energy%efield
      94             : 
      95         990 :          ELSEIF (dft_control%qs_control%semi_empirical) THEN
      96           0 :             CPABORT("NONSCF not available")
      97         990 :          ELSEIF (dft_control%qs_control%dftb) THEN
      98         288 :             CPASSERT(energy%dftb3 == 0.0_dp)
      99         288 :             energy%total = energy%total + energy%band + energy%qmmm_el
     100             :             WRITE (UNIT=iounit, FMT="(/,T2,A,T40,A,F10.2,T61,F20.10)") &
     101         288 :                "Diagonalization", "Time:", tdiag, energy%total
     102             :             WRITE (UNIT=iounit, FMT="((T3,A,T56,F25.14))") &
     103         288 :                "Core Hamiltonian energy:                       ", energy%core, &
     104         288 :                "Repulsive potential energy:                    ", energy%repulsive, &
     105         576 :                "Dispersion energy:                             ", energy%dispersion
     106         288 :             IF (energy%efield /= 0.0_dp) &
     107             :                WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
     108           0 :                "Electric field interaction energy:          ", energy%efield
     109         702 :          ELSEIF (dft_control%qs_control%xtb) THEN
     110         702 :             energy%total = energy%total + energy%band + energy%qmmm_el
     111             :             WRITE (UNIT=iounit, FMT="(/,T2,A,T40,A,F10.2,T61,F20.10)") &
     112         702 :                "Diagonalization", "Time:", tdiag, energy%total
     113         702 :             CPASSERT(dft_control%qs_control%xtb_control%gfn_type == 0)
     114             :             WRITE (UNIT=iounit, FMT="((T3,A,T56,F25.14))") &
     115         702 :                "Core Hamiltonian energy:                       ", energy%core, &
     116         702 :                "Repulsive potential energy:                    ", energy%repulsive, &
     117         702 :                "SRB Correction energy:                         ", energy%srb, &
     118         702 :                "Charge equilibration energy:                   ", energy%eeq, &
     119        1404 :                "Dispersion energy:                             ", energy%dispersion
     120         702 :             IF (dft_control%qs_control%xtb_control%do_nonbonded) &
     121             :                WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
     122           0 :                "Correction for nonbonded interactions:         ", energy%xtb_nonbonded
     123         702 :             IF (energy%efield /= 0.0_dp) &
     124             :                WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
     125          50 :                "Electric field interaction energy:          ", energy%efield
     126             :          ELSE
     127           0 :             CPABORT("NONSCF not available")
     128             :          END IF
     129        1005 :          IF (dft_control%smear) THEN
     130             :             WRITE (UNIT=iounit, FMT="((T3,A,T56,F25.14))") &
     131         479 :                "Electronic entropic energy:", energy%kTS
     132             :             WRITE (UNIT=iounit, FMT="((T3,A,T56,F25.14))") &
     133         479 :                "Fermi energy:", energy%efermi
     134             :          END IF
     135        1005 :          IF (energy%qmmm_el /= 0.0_dp) THEN
     136             :             WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
     137         167 :                "QM/MM Electrostatic energy:                    ", energy%qmmm_el
     138         167 :             IF (qs_env%qmmm_env_qm%image_charge) THEN
     139             :                WRITE (UNIT=iounit, FMT="(T3,A,T56,F25.14)") &
     140           0 :                   "QM/MM image charge energy:                ", energy%image_charge
     141             :             END IF
     142             :          END IF
     143             : 
     144             :          WRITE (UNIT=iounit, FMT="(/,(T3,A,T56,F25.14))") &
     145        1005 :             "Total energy:                                  ", energy%total
     146             : 
     147        1005 :          CALL m_flush(iounit)
     148             :       END IF
     149             : 
     150        2010 :    END SUBROUTINE qs_nonscf_print_summary
     151             : 
     152             : END MODULE qs_nonscf_utils

Generated by: LCOV version 1.15