LCOV - code coverage report
Current view: top level - src - gw_auto_ri_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:92574dc) Lines: 94.7 % 19 18
Test Date: 2026-09-24 01:27:39 Functions: 33.3 % 3 1

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief Input and persistent data for automatic RI basis optimization.
      10              : !> \par History
      11              : !>      09.2026 created [Jan Wilhelm]
      12              : ! **************************************************************************************************
      13              : MODULE gw_auto_ri_types
      14              :    USE base_hooks,                      ONLY: timeset,&
      15              :                                               timestop
      16              :    USE cp_fm_types,                     ONLY: cp_fm_release,&
      17              :                                               cp_fm_type
      18              :    USE kinds,                           ONLY: dp
      19              : 
      20              :    IMPLICIT NONE
      21              :    PRIVATE
      22              : 
      23              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gw_auto_ri_types'
      24              : 
      25              :    PUBLIC :: auto_ri_release, auto_ri_type
      26              : 
      27              :    TYPE auto_ri_type
      28              : 
      29              :       ! Input parameters.
      30              :       REAL(KIND=dp)                   :: occ_energy_window = -1.0_dp
      31              :       REAL(KIND=dp)                   :: neighbor_radius = -1.0_dp
      32              :       LOGICAL                         :: enabled = .FALSE.
      33              :       REAL(KIND=dp)                   :: ri_ao_ratio = -1.0_dp
      34              : 
      35              :       ! Two-center matrices M_pq and V_pq of optimized RI basis set
      36              :       TYPE(cp_fm_type)                :: V_pq = cp_fm_type()
      37              :       TYPE(cp_fm_type)                :: M_pq_inv = cp_fm_type()
      38              :       LOGICAL                         :: ready = .FALSE.
      39              :       INTEGER, ALLOCATABLE            :: sizes_opt_RI(:)
      40              : 
      41              :       ! U_Pp_AB contains the RI-basis contraction coefficients:
      42              :       ! for A=B: φ_p^A(r)  = Σ_P U_Pp^AA φ_P^A(r)    (φ_P^A(r): large ref. RI basis)
      43              :       ! for A≠B: φ_p^AB(r) = Σ_P U_Pp^AB φ_P^AB^⊥(r) (see forthcoming paper)
      44              :       ! RI basis contains contractions of Gaussians on neighboring atoms!!
      45              :       REAL(KIND=dp), ALLOCATABLE      :: U_Pp_AB(:)
      46              :       INTEGER                         :: AB_block_count = 0
      47              :       INTEGER, ALLOCATABLE            :: AB_atom_A(:), AB_atom_B(:)
      48              :       INTEGER, ALLOCATABLE            :: AB_first_p_A(:), AB_first_p_B(:)
      49              :       INTEGER, ALLOCATABLE            :: AB_size_opt_RI_to_A(:)
      50              :       INTEGER, ALLOCATABLE            :: AB_size_ref_RI(:)
      51              :       INTEGER, ALLOCATABLE            :: AB_size_opt_RI(:)
      52              :       INTEGER, ALLOCATABLE            :: U_Pp_AB_offset(:)
      53              : 
      54              :    END TYPE auto_ri_type
      55              : 
      56              : CONTAINS
      57              : 
      58              : ! **************************************************************************************************
      59              : !> \brief Releases all data owned by an optimized AUTO_RI basis.
      60              : !> \param auto_ri AUTO_RI input and optimized-basis data
      61              : ! **************************************************************************************************
      62          126 :    SUBROUTINE auto_ri_release(auto_ri)
      63              :       TYPE(auto_ri_type), INTENT(INOUT)                  :: auto_ri
      64              : 
      65              :       CHARACTER(LEN=*), PARAMETER                        :: routineN = 'auto_ri_release'
      66              : 
      67              :       INTEGER                                            :: handle
      68              : 
      69          126 :       CALL timeset(routineN, handle)
      70              : 
      71          126 :       IF (ALLOCATED(auto_ri%sizes_opt_RI)) DEALLOCATE (auto_ri%sizes_opt_RI)
      72          126 :       IF (ALLOCATED(auto_ri%AB_atom_A)) DEALLOCATE (auto_ri%AB_atom_A)
      73          126 :       IF (ALLOCATED(auto_ri%AB_atom_B)) DEALLOCATE (auto_ri%AB_atom_B)
      74          126 :       IF (ALLOCATED(auto_ri%AB_first_p_A)) DEALLOCATE (auto_ri%AB_first_p_A)
      75          126 :       IF (ALLOCATED(auto_ri%AB_first_p_B)) DEALLOCATE (auto_ri%AB_first_p_B)
      76          126 :       IF (ALLOCATED(auto_ri%AB_size_opt_RI_to_A)) DEALLOCATE (auto_ri%AB_size_opt_RI_to_A)
      77          126 :       IF (ALLOCATED(auto_ri%AB_size_ref_RI)) DEALLOCATE (auto_ri%AB_size_ref_RI)
      78          126 :       IF (ALLOCATED(auto_ri%AB_size_opt_RI)) DEALLOCATE (auto_ri%AB_size_opt_RI)
      79          126 :       IF (ALLOCATED(auto_ri%U_Pp_AB_offset)) DEALLOCATE (auto_ri%U_Pp_AB_offset)
      80          126 :       IF (ALLOCATED(auto_ri%U_Pp_AB)) DEALLOCATE (auto_ri%U_Pp_AB)
      81          126 :       CALL cp_fm_release(auto_ri%V_pq)
      82          126 :       CALL cp_fm_release(auto_ri%M_pq_inv)
      83          126 :       auto_ri%AB_block_count = 0
      84          126 :       auto_ri%ready = .FALSE.
      85              : 
      86          126 :       CALL timestop(handle)
      87              : 
      88          126 :    END SUBROUTINE auto_ri_release
      89              : 
      90            0 : END MODULE gw_auto_ri_types
        

Generated by: LCOV version 2.0-1