LCOV - code coverage report
Current view: top level - src - kg_environment_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:9843133) Lines: 32 35 91.4 %
Date: 2024-05-10 06:53:45 Functions: 1 5 20.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 Types needed for a Kim-Gordon-like partitioning into molecular
      10             : !>        subunits
      11             : !> \par History
      12             : !>       2012.07 created [Martin Haeufel]
      13             : !> \author Martin Haeufel
      14             : ! **************************************************************************************************
      15             : MODULE kg_environment_types
      16             :    USE cp_dbcsr_operations,             ONLY: dbcsr_deallocate_matrix_set
      17             :    USE dbcsr_api,                       ONLY: dbcsr_p_type
      18             :    USE input_section_types,             ONLY: section_vals_type
      19             :    USE integration_grid_types,          ONLY: deallocate_intgrid,&
      20             :                                               integration_grid_type
      21             :    USE kinds,                           ONLY: dp
      22             :    USE lri_environment_types,           ONLY: lri_density_release,&
      23             :                                               lri_density_type,&
      24             :                                               lri_env_release,&
      25             :                                               lri_environment_type
      26             :    USE molecule_types,                  ONLY: molecule_type
      27             :    USE qs_dispersion_types,             ONLY: qs_dispersion_type
      28             :    USE qs_grid_atom,                    ONLY: atom_integration_grid_type,&
      29             :                                               deallocate_atom_int_grid
      30             :    USE qs_neighbor_list_types,          ONLY: neighbor_list_set_p_type,&
      31             :                                               release_neighbor_list_sets
      32             :    USE task_list_types,                 ONLY: deallocate_task_list,&
      33             :                                               task_list_type
      34             : #include "./base/base_uses.f90"
      35             : 
      36             :    IMPLICIT NONE
      37             : 
      38             :    PRIVATE
      39             : 
      40             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'kg_environment_types'
      41             : 
      42             :    PUBLIC :: kg_environment_type, kg_env_release, energy_correction_type
      43             : 
      44             :    TYPE subset_type
      45             :       TYPE(neighbor_list_set_p_type), DIMENSION(:), POINTER :: sab_orb
      46             :       TYPE(task_list_type), POINTER :: task_list
      47             :    END TYPE subset_type
      48             : 
      49             : ! *****************************************************************************
      50             : !> \brief Contains information on the energy correction functional for KG
      51             : !> \par History
      52             : !>       03.2014 created
      53             : !> \author JGH
      54             : ! *****************************************************************************
      55             :    TYPE energy_correction_type
      56             :       CHARACTER(len=20)                                :: ec_name
      57             :       INTEGER                                          :: energy_functional
      58             :       INTEGER                                          :: ks_solver
      59             :       INTEGER                                          :: factorization
      60             :       REAL(KIND=dp)                                    :: eps_default
      61             :       ! basis set
      62             :       CHARACTER(len=20)                                :: basis
      63             :       LOGICAL                                          :: mao
      64             :       INTEGER                                          :: mao_max_iter
      65             :       REAL(KIND=dp)                                    :: mao_eps_grad
      66             :       ! energy components
      67             :       REAL(KIND=dp)                                    :: etotal
      68             :       REAL(KIND=dp)                                    :: eband, exc, ehartree, vhxc
      69             :       REAL(KIND=dp)                                    :: edispersion
      70             :       ! full neighbor lists and corresponding task list
      71             :       TYPE(neighbor_list_set_p_type), &
      72             :          DIMENSION(:), POINTER                         :: sab_orb, sac_ppl, sap_ppnl
      73             :       TYPE(task_list_type), POINTER                    :: task_list
      74             :       ! the XC function to be used for the correction, dispersion info
      75             :       TYPE(section_vals_type), POINTER                 :: xc_section
      76             :       TYPE(qs_dispersion_type), POINTER                :: dispersion_env
      77             :       ! matrices in complete basis
      78             :       ! KS: Kohn-Sham; H: Core; S: overlap; T: kinetic energy;
      79             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_ks
      80             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_h
      81             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_s
      82             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_t
      83             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_p
      84             :       ! reduce basis
      85             :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER     :: mao_coef
      86             :    END TYPE energy_correction_type
      87             : 
      88             : ! **************************************************************************************************
      89             : !> \brief Contains all the info needed for KG runs...
      90             : !> \param xc_section_kg:    XC section with only the KE functional
      91             : !> \param molecule_set:     set of molecular entities as in qs_env
      92             : !> \param sab_orb_full:     full neighborlist (build with molecular=.FALSE.)
      93             : !>                          needed for the coloring
      94             : !> \param subset_of_mol:    ith entry contains the index of the subset, the ith
      95             : !>                          molecule belongs to
      96             : !> \param subset:   task list and neighbor list of each subset of molecules
      97             : !> \param nsubsets: number of subsets
      98             : !> \par History
      99             : !>       2012.07 created [Martin Haeufel]
     100             : !> \author Martin Haeufel
     101             : ! **************************************************************************************************
     102             :    TYPE kg_environment_type
     103             :       INTEGER                                         :: nspins
     104             :       INTEGER                                         :: natom
     105             :       TYPE(section_vals_type), POINTER                :: xc_section_kg
     106             :       INTEGER, ALLOCATABLE, DIMENSION(:)              :: atom_to_molecule
     107             :       TYPE(molecule_type), DIMENSION(:), POINTER      :: molecule_set
     108             :       INTEGER                                         :: tnadd_method
     109             :       TYPE(neighbor_list_set_p_type), &
     110             :          DIMENSION(:), POINTER                        :: sab_orb_full, sac_kin
     111             :       !
     112             :       INTEGER, DIMENSION(:), POINTER                  :: subset_of_mol
     113             :       TYPE(subset_type), DIMENSION(:), POINTER        :: subset
     114             :       INTEGER                                         :: nsubsets
     115             :       INTEGER                                         :: maxdegree
     116             :       INTEGER                                         :: coloring_method
     117             :       !
     118             :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER       :: tnadd_mat
     119             :       ! LRI
     120             :       TYPE(lri_environment_type), POINTER             :: lri_env, lri_env1
     121             :       TYPE(lri_density_type), POINTER                 :: lri_density, lri_rho1
     122             :       ! atomic grid
     123             :       TYPE(atom_integration_grid_type), POINTER       :: int_grid_atom
     124             :       TYPE(integration_grid_type), POINTER            :: int_grid_molecules
     125             :       TYPE(integration_grid_type), POINTER            :: int_grid_full
     126             :    END TYPE kg_environment_type
     127             : 
     128             : CONTAINS
     129             : 
     130             : ! **************************************************************************************************
     131             : !> \brief ...
     132             : !> \param kg_env ...
     133             : ! **************************************************************************************************
     134          66 :    SUBROUTINE kg_env_release(kg_env)
     135             :       TYPE(kg_environment_type), POINTER                 :: kg_env
     136             : 
     137             :       CHARACTER(LEN=*), PARAMETER                        :: routineN = 'kg_env_release'
     138             : 
     139             :       INTEGER                                            :: handle, isub
     140             : 
     141          66 :       CALL timeset(routineN, handle)
     142             : 
     143          66 :       CPASSERT(ASSOCIATED(kg_env))
     144             : 
     145          66 :       CALL release_neighbor_list_sets(kg_env%sab_orb_full)
     146          66 :       CALL release_neighbor_list_sets(kg_env%sac_kin)
     147             : 
     148          66 :       IF (ASSOCIATED(kg_env%tnadd_mat)) THEN
     149          12 :          CALL dbcsr_deallocate_matrix_set(kg_env%tnadd_mat)
     150             :       END IF
     151             : 
     152         172 :       DO isub = 1, kg_env%nsubsets
     153         106 :          CALL release_neighbor_list_sets(kg_env%subset(isub)%sab_orb)
     154         172 :          CALL deallocate_task_list(kg_env%subset(isub)%task_list)
     155             :       END DO
     156             : 
     157          66 :       IF (ASSOCIATED(kg_env%subset_of_mol)) DEALLOCATE (kg_env%subset_of_mol)
     158          66 :       IF (ASSOCIATED(kg_env%subset)) DEALLOCATE (kg_env%subset)
     159             : 
     160          66 :       IF (ALLOCATED(kg_env%atom_to_molecule)) DEALLOCATE (kg_env%atom_to_molecule)
     161             : 
     162             :       ! LRI
     163          66 :       IF (ASSOCIATED(kg_env%lri_env)) THEN
     164           2 :          CALL lri_env_release(kg_env%lri_env)
     165           2 :          DEALLOCATE (kg_env%lri_env)
     166             :       END IF
     167          66 :       IF (ASSOCIATED(kg_env%lri_density)) THEN
     168           2 :          CALL lri_density_release(kg_env%lri_density)
     169           2 :          DEALLOCATE (kg_env%lri_density)
     170             :       END IF
     171          66 :       IF (ASSOCIATED(kg_env%lri_env1)) THEN
     172           2 :          CALL lri_env_release(kg_env%lri_env1)
     173           2 :          DEALLOCATE (kg_env%lri_env1)
     174             :       END IF
     175          66 :       IF (ASSOCIATED(kg_env%lri_rho1)) THEN
     176           0 :          CALL lri_density_release(kg_env%lri_rho1)
     177           0 :          DEALLOCATE (kg_env%lri_rho1)
     178             :       END IF
     179             :       ! atom grids
     180          66 :       IF (ASSOCIATED(kg_env%int_grid_atom)) THEN
     181           2 :          CALL deallocate_atom_int_grid(kg_env%int_grid_atom)
     182             :       END IF
     183          66 :       IF (ASSOCIATED(kg_env%int_grid_molecules)) THEN
     184           2 :          CALL deallocate_intgrid(kg_env%int_grid_molecules)
     185             :       END IF
     186          66 :       IF (ASSOCIATED(kg_env%int_grid_full)) THEN
     187           2 :          CALL deallocate_intgrid(kg_env%int_grid_full)
     188             :       END IF
     189             : 
     190          66 :       DEALLOCATE (kg_env)
     191             : 
     192          66 :       CALL timestop(handle)
     193             : 
     194          66 :    END SUBROUTINE kg_env_release
     195             : 
     196           0 : END MODULE kg_environment_types

Generated by: LCOV version 1.15