LCOV - code coverage report
Current view: top level - src - qs_tddfpt_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 25 26 96.2 %
Date: 2024-11-21 06:45:46 Functions: 2 3 66.7 %

          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             : MODULE qs_tddfpt_types
      10             :    USE cp_blacs_env,                    ONLY: cp_blacs_env_type
      11             :    USE cp_control_types,                ONLY: dft_control_type
      12             :    USE cp_fm_pool_types,                ONLY: cp_fm_pool_p_type,&
      13             :                                               fm_pool_create_fm,&
      14             :                                               fm_pool_give_back_fm
      15             :    USE cp_fm_struct,                    ONLY: cp_fm_struct_create,&
      16             :                                               cp_fm_struct_release,&
      17             :                                               cp_fm_struct_type
      18             :    USE cp_fm_types,                     ONLY: cp_fm_create,&
      19             :                                               cp_fm_release,&
      20             :                                               cp_fm_type
      21             :    USE kinds,                           ONLY: dp
      22             :    USE message_passing,                 ONLY: mp_para_env_type
      23             :    USE qs_environment_types,            ONLY: get_qs_env,&
      24             :                                               qs_environment_type
      25             :    USE qs_matrix_pools,                 ONLY: mpools_get
      26             :    USE qs_p_env_types,                  ONLY: qs_p_env_type
      27             : #include "./base/base_uses.f90"
      28             : 
      29             :    IMPLICIT NONE
      30             : 
      31             : ! **************************************************************************************************
      32             :    TYPE tddfpt_env_type
      33             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: evals => NULL() ! eigenvalues
      34             :       TYPE(cp_fm_type), DIMENSION(:, :), &
      35             :          POINTER                                       :: evecs => NULL() ! eigenvectors
      36             :       TYPE(cp_fm_type), DIMENSION(:), POINTER          :: invS => NULL() ! the inverse of the metric
      37             :       TYPE(cp_fm_pool_p_type), DIMENSION(:), &
      38             :          POINTER                                       :: ao_mo_fm_pools => NULL()
      39             :    END TYPE tddfpt_env_type
      40             : 
      41             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_tddfpt_types'
      42             : 
      43             :    PRIVATE
      44             : 
      45             :    PUBLIC :: tddfpt_env_type
      46             : 
      47             :    PUBLIC :: tddfpt_env_allocate, &
      48             :              tddfpt_env_deallocate
      49             : 
      50             : CONTAINS
      51             : 
      52             : ! **************************************************************************************************
      53             : !> \brief ...
      54             : !> \param t_env ...
      55             : !> \param p_env ...
      56             : !> \param qs_env ...
      57             : ! **************************************************************************************************
      58          12 :    SUBROUTINE tddfpt_env_allocate(t_env, p_env, qs_env)
      59             : 
      60             :       TYPE(tddfpt_env_type)                              :: t_env
      61             :       TYPE(qs_p_env_type)                                :: p_env
      62             :       TYPE(qs_environment_type), POINTER                 :: qs_env
      63             : 
      64             :       CHARACTER(len=*), PARAMETER :: routineN = 'tddfpt_env_allocate', &
      65             :          routineP = moduleN//':'//routineN
      66             : 
      67             :       INTEGER                                            :: i, n_ev, n_spins, spin
      68             :       TYPE(cp_blacs_env_type), POINTER                   :: blacs_env
      69             :       TYPE(cp_fm_struct_type), POINTER                   :: fm_struct
      70             :       TYPE(dft_control_type), POINTER                    :: dft_control
      71             :       TYPE(mp_para_env_type), POINTER                    :: para_env
      72             : 
      73          12 :       NULLIFY (dft_control, para_env, blacs_env)
      74             : 
      75             :       CALL get_qs_env(qs_env, &
      76             :                       dft_control=dft_control, &
      77             :                       para_env=para_env, &
      78          12 :                       blacs_env=blacs_env)
      79             : 
      80          12 :       n_ev = dft_control%tddfpt_control%n_ev
      81          12 :       n_spins = dft_control%nspins
      82          12 :       CALL mpools_get(qs_env%mpools, ao_mo_fm_pools=t_env%ao_mo_fm_pools)
      83             : 
      84          36 :       ALLOCATE (t_env%evals(n_ev))
      85         108 :       ALLOCATE (t_env%evecs(n_ev, n_spins))
      86          28 :       DO spin = 1, n_spins
      87          72 :          DO i = 1, n_ev
      88             :             CALL fm_pool_create_fm(t_env%ao_mo_fm_pools(spin)%pool, &
      89          60 :                                    t_env%evecs(i, spin))
      90             :          END DO
      91             :       END DO
      92             : 
      93             :       !-------------------------------------------------!
      94             :       ! allocate memory for the inverse of the S matrix !
      95             :       !-------------------------------------------------!
      96          52 :       ALLOCATE (t_env%invS(n_spins))
      97          28 :       DO spin = 1, n_spins
      98          16 :          NULLIFY (fm_struct)
      99             :          CALL cp_fm_struct_create(fm_struct, para_env, blacs_env, &
     100          16 :                                   p_env%n_ao(spin), p_env%n_ao(spin))
     101          16 :          CALL cp_fm_create(t_env%invS(spin), fm_struct, routineP//"invS")
     102          28 :          CALL cp_fm_struct_release(fm_struct)
     103             :       END DO
     104             : 
     105          12 :    END SUBROUTINE tddfpt_env_allocate
     106             : 
     107             : ! **************************************************************************************************
     108             : !> \brief ...
     109             : !> \param t_env ...
     110             : ! **************************************************************************************************
     111          12 :    SUBROUTINE tddfpt_env_deallocate(t_env)
     112             : 
     113             :       TYPE(tddfpt_env_type), INTENT(inout)               :: t_env
     114             : 
     115             :       INTEGER                                            :: i, spin
     116             : 
     117          28 :       DO spin = 1, SIZE(t_env%evecs, 2)
     118          72 :          DO i = 1, SIZE(t_env%evecs, 1)
     119             :             CALL fm_pool_give_back_fm(t_env%ao_mo_fm_pools(spin)%pool, &
     120          60 :                                       t_env%evecs(i, spin))
     121             :          END DO
     122             :       END DO
     123          12 :       DEALLOCATE (t_env%evecs, t_env%evals)
     124             : 
     125          12 :       CALL cp_fm_release(t_env%invS)
     126             : 
     127          12 :    END SUBROUTINE tddfpt_env_deallocate
     128             : 
     129           0 : END MODULE qs_tddfpt_types

Generated by: LCOV version 1.15