LCOV - code coverage report
Current view: top level - src - kg_environment_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 32 35 91.4 %
Date: 2024-11-21 06:45:46 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_api,                    ONLY: dbcsr_p_type
      17             :    USE cp_dbcsr_operations,             ONLY: dbcsr_deallocate_matrix_set
      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 => NULL()
      46             :       TYPE(task_list_type), POINTER :: task_list => NULL()
      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 = -1
      58             :       INTEGER                                          :: ks_solver = -1
      59             :       INTEGER                                          :: factorization = -1
      60             :       REAL(KIND=dp)                                    :: eps_default = 0.0_dp
      61             :       ! basis set
      62             :       CHARACTER(len=20)                                :: basis = ""
      63             :       LOGICAL                                          :: mao = .FALSE.
      64             :       INTEGER                                          :: mao_max_iter = -1
      65             :       REAL(KIND=dp)                                    :: mao_eps_grad = 0.0_dp
      66             :       ! energy components
      67             :       REAL(KIND=dp)                                    :: etotal = 0.0_dp
      68             :       REAL(KIND=dp)                                    :: eband = 0.0_dp, exc = 0.0_dp, ehartree = 0.0_dp, vhxc = 0.0_dp
      69             :       REAL(KIND=dp)                                    :: edispersion = 0.0_dp
      70             :       ! full neighbor lists and corresponding task list
      71             :       TYPE(neighbor_list_set_p_type), &
      72             :          DIMENSION(:), POINTER                         :: sab_orb => NULL(), sac_ppl => NULL(), sap_ppnl => NULL()
      73             :       TYPE(task_list_type), POINTER                    :: task_list => NULL()
      74             :       ! the XC function to be used for the correction, dispersion info
      75             :       TYPE(section_vals_type), POINTER                 :: xc_section => NULL()
      76             :       TYPE(qs_dispersion_type), POINTER                :: dispersion_env => NULL()
      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 => NULL()
      80             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_h => NULL()
      81             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_s => NULL()
      82             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_t => NULL()
      83             :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER  :: matrix_p => NULL()
      84             :       ! reduce basis
      85             :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER     :: mao_coef => NULL()
      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 = -1
     104             :       INTEGER                                         :: natom = -1
     105             :       TYPE(section_vals_type), POINTER                :: xc_section_kg => NULL()
     106             :       INTEGER, ALLOCATABLE, DIMENSION(:)              :: atom_to_molecule
     107             :       TYPE(molecule_type), DIMENSION(:), POINTER      :: molecule_set => NULL()
     108             :       INTEGER                                         :: tnadd_method = -1
     109             :       TYPE(neighbor_list_set_p_type), &
     110             :          DIMENSION(:), POINTER                        :: sab_orb_full => NULL(), sac_kin => NULL()
     111             :       !
     112             :       INTEGER, DIMENSION(:), POINTER                  :: subset_of_mol => NULL()
     113             :       TYPE(subset_type), DIMENSION(:), POINTER        :: subset => NULL()
     114             :       INTEGER                                         :: nsubsets = -1
     115             :       INTEGER                                         :: maxdegree = -1
     116             :       INTEGER                                         :: coloring_method = -1
     117             :       !
     118             :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER       :: tnadd_mat => NULL()
     119             :       ! LRI
     120             :       TYPE(lri_environment_type), POINTER             :: lri_env => NULL(), lri_env1 => NULL()
     121             :       TYPE(lri_density_type), POINTER                 :: lri_density => NULL(), lri_rho1 => NULL()
     122             :       ! atomic grid
     123             :       TYPE(atom_integration_grid_type), POINTER       :: int_grid_atom => NULL()
     124             :       TYPE(integration_grid_type), POINTER            :: int_grid_molecules => NULL()
     125             :       TYPE(integration_grid_type), POINTER            :: int_grid_full => NULL()
     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