(git:27c966b)
Loading...
Searching...
No Matches
qs_tddfpt2_soc_types.F
Go to the documentation of this file.
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!--------------------------------------------------------------------------------------------------!
9 USE cp_dbcsr_api, ONLY: dbcsr_p_type,&
12 USE cp_fm_types, ONLY: cp_fm_release,&
14 USE kinds, ONLY: dp
19
20 IMPLICIT NONE
21
22 PUBLIC :: soc_env_type, soc_env_create, &
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!*************************************************************************************************
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!*************************************************************************************************
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
79CONTAINS
80
81! **************************************************************************************************
82!> \brief ...
83!> \param soc_env ...
84! **************************************************************************************************
85 SUBROUTINE soc_env_create(soc_env)
86 TYPE(soc_env_type), TARGET :: soc_env
87
88 NULLIFY (soc_env%orb_soc)
89 NULLIFY (soc_env%evals_a)
90 NULLIFY (soc_env%evals_b)
91 NULLIFY (soc_env%dipmat, soc_env%dipmat_ao)
92
93 END SUBROUTINE soc_env_create
94
95! **************************************************************************************************
96!> \brief ...
97!> \param soc_env ...
98! **************************************************************************************************
99 SUBROUTINE soc_env_release(soc_env)
100 TYPE(soc_env_type), TARGET :: soc_env
101
102 INTEGER :: i, j
103
104 IF (ASSOCIATED(soc_env%orb_soc)) THEN
105 DO i = 1, SIZE(soc_env%orb_soc)
106 CALL dbcsr_release(soc_env%orb_soc(i)%matrix)
107 DEALLOCATE (soc_env%orb_soc(i)%matrix)
108 END DO
109 DEALLOCATE (soc_env%orb_soc)
110 END IF
111
112 CALL cp_fm_release(soc_env%a_coeff)
113 CALL cp_fm_release(soc_env%b_coeff)
114 IF (ASSOCIATED(soc_env%evals_a)) NULLIFY (soc_env%evals_a)
115 IF (ASSOCIATED(soc_env%evals_b)) NULLIFY (soc_env%evals_b)
116 IF (ASSOCIATED(soc_env%dipmat)) THEN
117 DO i = 1, SIZE(soc_env%dipmat)
118 CALL dbcsr_release(soc_env%dipmat(i)%matrix)
119 DEALLOCATE (soc_env%dipmat(i)%matrix)
120 END DO
121 DEALLOCATE (soc_env%dipmat)
122 END IF
123 IF (ASSOCIATED(soc_env%dipmat_ao)) THEN
124 DO i = 1, SIZE(soc_env%dipmat_ao)
125 CALL dbcsr_release(soc_env%dipmat_ao(i)%matrix)
126 DEALLOCATE (soc_env%dipmat_ao(i)%matrix)
127 END DO
128 DEALLOCATE (soc_env%dipmat_ao)
129 END IF
130 IF (ALLOCATED(soc_env%soc_evals)) DEALLOCATE (soc_env%soc_evals)
131 IF (ALLOCATED(soc_env%soc_osc)) DEALLOCATE (soc_env%soc_osc)
132 IF (ALLOCATED(soc_env%CdS)) THEN
133 DO i = 1, SIZE(soc_env%CdS, 1)
134 DO j = 1, SIZE(soc_env%CdS, 2)
135 CALL cp_fm_release(soc_env%CdS(i, j))
136 END DO
137 END DO
138 DEALLOCATE (soc_env%CdS)
139 END IF
140 IF (ALLOCATED(soc_env%SC)) THEN
141 DO i = 1, SIZE(soc_env%SC)
142 CALL cp_fm_release(soc_env%SC(i))
143 CALL cp_fm_release(soc_env%ediff(i))
144 END DO
145 DEALLOCATE (soc_env%SC, soc_env%ediff)
146 END IF
147
148 END SUBROUTINE soc_env_release
149
150! ************************************************************************************************
151!*************************************************************************************************
152
153! **************************************************************************************************
154!> \brief ...
155!> \param soc_atom_env ...
156! **************************************************************************************************
157 SUBROUTINE soc_atom_create(soc_atom_env)
158 TYPE(soc_atom_env_type), POINTER :: soc_atom_env
159
160 ALLOCATE (soc_atom_env)
161
162 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 END SUBROUTINE soc_atom_create
169
170! **************************************************************************************************
171!> \brief ...
172!> \param soc_atom_env ...
173! **************************************************************************************************
174 SUBROUTINE soc_atom_release(soc_atom_env)
175 TYPE(soc_atom_env_type), POINTER :: soc_atom_env
176
177 INTEGER :: i
178
179 IF (ASSOCIATED(soc_atom_env%grid_atom_set)) THEN
180 DO i = 1, SIZE(soc_atom_env%grid_atom_set)
181 IF (ASSOCIATED(soc_atom_env%grid_atom_set(i)%grid_atom)) THEN
182 CALL deallocate_grid_atom(soc_atom_env%grid_atom_set(i)%grid_atom)
183 END IF
184 END DO
185 DEALLOCATE (soc_atom_env%grid_atom_set)
186 END IF
187
188 IF (ASSOCIATED(soc_atom_env%harmonics_atom_set)) THEN
189 DO i = 1, SIZE(soc_atom_env%harmonics_atom_set)
190 IF (ASSOCIATED(soc_atom_env%harmonics_atom_set(i)%harmonics_atom)) THEN
191 CALL deallocate_harmonics_atom(soc_atom_env%harmonics_atom_set(i)%harmonics_atom)
192 END IF
193 END DO
194 DEALLOCATE (soc_atom_env%harmonics_atom_set)
195 END IF
196
197 IF (ASSOCIATED(soc_atom_env%orb_sphi_so)) THEN
198 DO i = 1, SIZE(soc_atom_env%orb_sphi_so)
199 IF (ASSOCIATED(soc_atom_env%orb_sphi_so(i)%array)) THEN
200 DEALLOCATE (soc_atom_env%orb_sphi_so(i)%array)
201 END IF
202 END DO
203 DEALLOCATE (soc_atom_env%orb_sphi_so)
204 END IF
205
206 IF (ASSOCIATED(soc_atom_env%soc_pp)) CALL dbcsr_deallocate_matrix_set(soc_atom_env%soc_pp)
207
208 DEALLOCATE (soc_atom_env)
209
210 END SUBROUTINE soc_atom_release
211
212END MODULE qs_tddfpt2_soc_types
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
subroutine, public dbcsr_release(matrix)
...
DBCSR operations in CP2K.
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
subroutine, public deallocate_grid_atom(grid_atom)
Deallocate a Gaussian-type orbital (GTO) basis set data set.
subroutine, public deallocate_harmonics_atom(harmonics)
Deallocate the spherical harmonics set for the atom grid.
subroutine, public soc_env_create(soc_env)
...
subroutine, public soc_atom_release(soc_atom_env)
...
subroutine, public soc_atom_create(soc_atom_env)
...
subroutine, public soc_env_release(soc_env)
...
represent a pointer to a 2d array
represent a full matrix