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 basis types for the calculation of the perturbation of density theory. 10 : !> \par History 11 : !> 4.2002 created [fawzi] 12 : !> \author Fawzi Mohamed 13 : ! ************************************************************************************************** 14 : MODULE qs_kpp1_env_types 15 : USE cp_dbcsr_api, ONLY: dbcsr_deallocate_matrix,& 16 : dbcsr_p_type 17 : USE xc_derivative_set_types, ONLY: xc_derivative_set_type,& 18 : xc_dset_release 19 : USE xc_rho_set_types, ONLY: xc_rho_set_release,& 20 : xc_rho_set_type 21 : #include "./base/base_uses.f90" 22 : 23 : IMPLICIT NONE 24 : PRIVATE 25 : PUBLIC :: qs_kpp1_env_type 26 : PUBLIC :: kpp1_release 27 : 28 : LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE. 29 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_kpp1_env_types' 30 : 31 : ! ************************************************************************************************** 32 : !> \brief environment that keeps the informations and temporary 33 : !> val to build the kpp1 kernel matrix 34 : !> \param v_ao the potential in the ao basis (used togheter with v_rspace 35 : !> to update only what changed 36 : !> \param deriv_xc (ii,ipot): the second derivative of the xc potential at psi0 37 : !> (qs_env%c), if grad pot is true it should already be divised 38 : !> by the gradient 39 : ! ************************************************************************************************** 40 : TYPE qs_kpp1_env_type 41 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: v_ao => NULL() 42 : TYPE(xc_derivative_set_type), POINTER :: deriv_set => NULL() 43 : TYPE(xc_rho_set_type), POINTER :: rho_set => NULL() 44 : TYPE(xc_derivative_set_type), POINTER :: deriv_set_admm => NULL() 45 : TYPE(xc_rho_set_type), POINTER :: rho_set_admm => NULL() 46 : END TYPE qs_kpp1_env_type 47 : 48 : CONTAINS 49 : 50 : ! ************************************************************************************************** 51 : !> \brief releases a kpp1_env (see doc/ReferenceCounting.html) 52 : !> \param kpp1_env the environment to release 53 : !> \par History 54 : !> 07.2002 created [fawzi] 55 : !> \author Fawzi Mohamed 56 : ! ************************************************************************************************** 57 1646 : SUBROUTINE kpp1_release(kpp1_env) 58 : TYPE(qs_kpp1_env_type) :: kpp1_env 59 : 60 : INTEGER :: ispin 61 : 62 1646 : IF (ASSOCIATED(kpp1_env%v_ao)) THEN 63 2764 : DO ispin = 1, SIZE(kpp1_env%v_ao) 64 2764 : IF (ASSOCIATED(kpp1_env%v_ao(ispin)%matrix)) THEN 65 1486 : CALL dbcsr_deallocate_matrix(kpp1_env%v_ao(ispin)%matrix) 66 : END IF 67 : END DO 68 1278 : DEALLOCATE (kpp1_env%v_ao) 69 : END IF 70 1646 : IF (ASSOCIATED(kpp1_env%deriv_set)) THEN 71 276 : CALL xc_dset_release(kpp1_env%deriv_set) 72 276 : DEALLOCATE (kpp1_env%deriv_set) 73 : NULLIFY (kpp1_env%deriv_set) 74 : END IF 75 1646 : IF (ASSOCIATED(kpp1_env%rho_set)) THEN 76 276 : CALL xc_rho_set_release(kpp1_env%rho_set) 77 276 : DEALLOCATE (kpp1_env%rho_set) 78 : NULLIFY (kpp1_env%rho_set) 79 : END IF 80 1646 : IF (ASSOCIATED(kpp1_env%deriv_set_admm)) THEN 81 194 : CALL xc_dset_release(kpp1_env%deriv_set_admm) 82 194 : DEALLOCATE (kpp1_env%deriv_set_admm) 83 : NULLIFY (kpp1_env%deriv_set_admm) 84 : END IF 85 1646 : IF (ASSOCIATED(kpp1_env%rho_set_admm)) THEN 86 194 : CALL xc_rho_set_release(kpp1_env%rho_set_admm) 87 194 : DEALLOCATE (kpp1_env%rho_set_admm) 88 : NULLIFY (kpp1_env%rho_set_admm) 89 : END IF 90 1646 : END SUBROUTINE kpp1_release 91 : 92 0 : END MODULE qs_kpp1_env_types