LCOV - code coverage report
Current view: top level - src - qs_tddfpt2_soc_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1be8651) Lines: 98.4 % 63 62
Test Date: 2026-11-24 01:22:08 Functions: 44.4 % 9 4

            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              : MODULE qs_tddfpt2_soc_types
       8              :    USE cp_array_utils,                  ONLY: cp_2d_r_p_type
       9              :    USE cp_dbcsr_api,                    ONLY: dbcsr_p_type,&
      10              :                                               dbcsr_release
      11              :    USE cp_dbcsr_operations,             ONLY: dbcsr_deallocate_matrix_set
      12              :    USE cp_fm_types,                     ONLY: cp_fm_release,&
      13              :                                               cp_fm_type
      14              :    USE kinds,                           ONLY: dp
      15              :    USE qs_grid_atom,                    ONLY: deallocate_grid_atom,&
      16              :                                               grid_atom_type
      17              :    USE qs_harmonics_atom,               ONLY: deallocate_harmonics_atom,&
      18              :                                               harmonics_atom_type
      19              : 
      20              :    IMPLICIT NONE
      21              : 
      22              :    PUBLIC  :: soc_env_type, soc_env_create, &
      23              :               soc_env_release, soc_atom_env_type, &
      24              :               soc_atom_create, soc_atom_release
      25              : 
      26              :    PRIVATE
      27              : 
      28              :    !! Helper copied from xas_tdp_types
      29              :    TYPE grid_atom_p_type
      30              :       TYPE(grid_atom_type), POINTER                   :: grid_atom => Null()
      31              :    END TYPE grid_atom_p_type
      32              : 
      33              :    TYPE harmonics_atom_p_type
      34              :       TYPE(harmonics_atom_type), POINTER              :: harmonics_atom => Null()
      35              :    END TYPE harmonics_atom_p_type
      36              : 
      37              : !*************************************************************************************************
      38              : ! \brief: This structure contains the static matrices for the soc-correction
      39              : ! \param dbcsr_soc: the ZORA-operator within the ao-basis
      40              : ! \param dipmat: the dipole-operator within the ao-basis
      41              : ! \paramn evals_a: spin-conservin/singlet excitation energies
      42              : ! \param evals_b: spin-filp/triplet exciation energies
      43              : ! \param a_coeff: spin-conservin/singlet excitation vector
      44              : ! \param b_coeff: spin-filp/triplet exciation vectors
      45              : ! \param soc_evals: SOC-Corrected eigenvalues
      46              : ! \param soc_osc: ozillatorstrength of soc-corrected excitations
      47              : !*************************************************************************************************
      48              :    TYPE soc_env_type
      49              :       !! a :: singlet or spin-conserving b :: triplet or spin flip
      50              :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER       :: orb_soc => Null()
      51              :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER       :: dipmat_ao => Null()
      52              :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER       :: dipmat => Null()
      53              :       REAL(dp), POINTER, DIMENSION(:)                 :: evals_a => Null(), &
      54              :                                                          evals_b => Null()
      55              :       TYPE(cp_fm_type), DIMENSION(:, :), ALLOCATABLE   :: CdS
      56              :       TYPE(cp_fm_type), DIMENSION(:), ALLOCATABLE     :: SC, ediff
      57              :       TYPE(cp_fm_type)                                :: a_coeff = cp_fm_type(), &
      58              :                                                          b_coeff = cp_fm_type()
      59              :       REAL(dp), ALLOCATABLE, DIMENSION(:)             :: soc_evals, &
      60              :                                                          soc_osc
      61              :    END TYPE soc_env_type
      62              : 
      63              : ! ************************************************************************************************
      64              : ! \bief: an environment type analog to the xas_atom_env in xas_tdp_types:343
      65              : !        All unused parameters have been droped
      66              : ! \param nspins: number of spins
      67              : ! \param grid_atom_set:
      68              : ! \param harmonics_atom_set:
      69              : ! \param orb_sphi_so contains the coefficient for direct contraction from so to sgf, for the orb basis
      70              : !*************************************************************************************************
      71              :    TYPE soc_atom_env_type
      72              :       INTEGER                                            :: nspins = -1
      73              :       TYPE(grid_atom_p_type), DIMENSION(:), POINTER      :: grid_atom_set => Null()
      74              :       TYPE(harmonics_atom_p_type), DIMENSION(:), POINTER :: harmonics_atom_set => Null()
      75              :       TYPE(cp_2d_r_p_type), DIMENSION(:), POINTER        :: orb_sphi_so => Null()
      76              :       TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER       :: soc_pp => Null()
      77              :    END TYPE soc_atom_env_type
      78              : 
      79              : CONTAINS
      80              : 
      81              : ! **************************************************************************************************
      82              : !> \brief ...
      83              : !> \param soc_env ...
      84              : ! **************************************************************************************************
      85           10 :    SUBROUTINE soc_env_create(soc_env)
      86              :       TYPE(soc_env_type), TARGET                         :: soc_env
      87              : 
      88           10 :       NULLIFY (soc_env%orb_soc)
      89           10 :       NULLIFY (soc_env%evals_a)
      90           10 :       NULLIFY (soc_env%evals_b)
      91           10 :       NULLIFY (soc_env%dipmat, soc_env%dipmat_ao)
      92              : 
      93           10 :    END SUBROUTINE soc_env_create
      94              : 
      95              : ! **************************************************************************************************
      96              : !> \brief ...
      97              : !> \param soc_env ...
      98              : ! **************************************************************************************************
      99           10 :    SUBROUTINE soc_env_release(soc_env)
     100              :       TYPE(soc_env_type), TARGET                         :: soc_env
     101              : 
     102              :       INTEGER                                            :: i, j
     103              : 
     104           10 :       IF (ASSOCIATED(soc_env%orb_soc)) THEN
     105           40 :          DO i = 1, SIZE(soc_env%orb_soc)
     106           30 :             CALL dbcsr_release(soc_env%orb_soc(i)%matrix)
     107           40 :             DEALLOCATE (soc_env%orb_soc(i)%matrix)
     108              :          END DO
     109           10 :          DEALLOCATE (soc_env%orb_soc)
     110              :       END IF
     111              : 
     112           10 :       CALL cp_fm_release(soc_env%a_coeff)
     113           10 :       CALL cp_fm_release(soc_env%b_coeff)
     114           10 :       IF (ASSOCIATED(soc_env%evals_a)) NULLIFY (soc_env%evals_a)
     115           10 :       IF (ASSOCIATED(soc_env%evals_b)) NULLIFY (soc_env%evals_b)
     116           10 :       IF (ASSOCIATED(soc_env%dipmat)) THEN
     117           32 :          DO i = 1, SIZE(soc_env%dipmat)
     118           24 :             CALL dbcsr_release(soc_env%dipmat(i)%matrix)
     119           32 :             DEALLOCATE (soc_env%dipmat(i)%matrix)
     120              :          END DO
     121            8 :          DEALLOCATE (soc_env%dipmat)
     122              :       END IF
     123           10 :       IF (ASSOCIATED(soc_env%dipmat_ao)) THEN
     124           40 :          DO i = 1, SIZE(soc_env%dipmat_ao)
     125           30 :             CALL dbcsr_release(soc_env%dipmat_ao(i)%matrix)
     126           40 :             DEALLOCATE (soc_env%dipmat_ao(i)%matrix)
     127              :          END DO
     128           10 :          DEALLOCATE (soc_env%dipmat_ao)
     129              :       END IF
     130           10 :       IF (ALLOCATED(soc_env%soc_evals)) DEALLOCATE (soc_env%soc_evals)
     131           10 :       IF (ALLOCATED(soc_env%soc_osc)) DEALLOCATE (soc_env%soc_osc)
     132           10 :       IF (ALLOCATED(soc_env%CdS)) THEN
     133            4 :          DO i = 1, SIZE(soc_env%CdS, 1)
     134           10 :             DO j = 1, SIZE(soc_env%CdS, 2)
     135            8 :                CALL cp_fm_release(soc_env%CdS(i, j))
     136              :             END DO
     137              :          END DO
     138            2 :          DEALLOCATE (soc_env%CdS)
     139              :       END IF
     140           10 :       IF (ALLOCATED(soc_env%SC)) THEN
     141            4 :          DO i = 1, SIZE(soc_env%SC)
     142            2 :             CALL cp_fm_release(soc_env%SC(i))
     143            4 :             CALL cp_fm_release(soc_env%ediff(i))
     144              :          END DO
     145            2 :          DEALLOCATE (soc_env%SC, soc_env%ediff)
     146              :       END IF
     147              : 
     148           10 :    END SUBROUTINE soc_env_release
     149              : 
     150              : ! ************************************************************************************************
     151              : !*************************************************************************************************
     152              : 
     153              : ! **************************************************************************************************
     154              : !> \brief ...
     155              : !> \param soc_atom_env ...
     156              : ! **************************************************************************************************
     157           10 :    SUBROUTINE soc_atom_create(soc_atom_env)
     158              :       TYPE(soc_atom_env_type), POINTER                   :: soc_atom_env
     159              : 
     160           10 :       ALLOCATE (soc_atom_env)
     161              : 
     162           10 :       soc_atom_env%nspins = 1
     163              :       NULLIFY (soc_atom_env%grid_atom_set)
     164              :       NULLIFY (soc_atom_env%harmonics_atom_set)
     165              :       NULLIFY (soc_atom_env%orb_sphi_so)
     166              :       NULLIFY (soc_atom_env%soc_pp)
     167              : 
     168           10 :    END SUBROUTINE soc_atom_create
     169              : 
     170              : ! **************************************************************************************************
     171              : !> \brief ...
     172              : !> \param soc_atom_env ...
     173              : ! **************************************************************************************************
     174           10 :    SUBROUTINE soc_atom_release(soc_atom_env)
     175              :       TYPE(soc_atom_env_type), POINTER                   :: soc_atom_env
     176              : 
     177              :       INTEGER                                            :: i
     178              : 
     179           10 :       IF (ASSOCIATED(soc_atom_env%grid_atom_set)) THEN
     180           20 :          DO i = 1, SIZE(soc_atom_env%grid_atom_set)
     181           20 :             IF (ASSOCIATED(soc_atom_env%grid_atom_set(i)%grid_atom)) THEN
     182           10 :                CALL deallocate_grid_atom(soc_atom_env%grid_atom_set(i)%grid_atom)
     183              :             END IF
     184              :          END DO
     185           10 :          DEALLOCATE (soc_atom_env%grid_atom_set)
     186              :       END IF
     187              : 
     188           10 :       IF (ASSOCIATED(soc_atom_env%harmonics_atom_set)) THEN
     189           20 :          DO i = 1, SIZE(soc_atom_env%harmonics_atom_set)
     190           20 :             IF (ASSOCIATED(soc_atom_env%harmonics_atom_set(i)%harmonics_atom)) THEN
     191           10 :                CALL deallocate_harmonics_atom(soc_atom_env%harmonics_atom_set(i)%harmonics_atom)
     192              :             END IF
     193              :          END DO
     194           10 :          DEALLOCATE (soc_atom_env%harmonics_atom_set)
     195              :       END IF
     196              : 
     197           10 :       IF (ASSOCIATED(soc_atom_env%orb_sphi_so)) THEN
     198           20 :          DO i = 1, SIZE(soc_atom_env%orb_sphi_so)
     199           20 :             IF (ASSOCIATED(soc_atom_env%orb_sphi_so(i)%array)) THEN
     200           10 :                DEALLOCATE (soc_atom_env%orb_sphi_so(i)%array)
     201              :             END IF
     202              :          END DO
     203           10 :          DEALLOCATE (soc_atom_env%orb_sphi_so)
     204              :       END IF
     205              : 
     206           10 :       IF (ASSOCIATED(soc_atom_env%soc_pp)) CALL dbcsr_deallocate_matrix_set(soc_atom_env%soc_pp)
     207              : 
     208           10 :       DEALLOCATE (soc_atom_env)
     209              : 
     210           10 :    END SUBROUTINE soc_atom_release
     211              : 
     212            0 : END MODULE qs_tddfpt2_soc_types
        

Generated by: LCOV version 2.0-1