(git:c641773)
Loading...
Searching...
No Matches
qs_diis_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!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief buffer for the diis of the scf
10!> \par History
11!> 02.2003 rewamped [fawzi]
12!> \author Matthias Krack
13! **************************************************************************************************
15 USE cp_cfm_types, ONLY: cp_cfm_release,&
17 USE cp_dbcsr_api, ONLY: dbcsr_p_type,&
20 USE cp_fm_types, ONLY: cp_fm_release,&
22 USE kinds, ONLY: dp
23#include "./base/base_uses.f90"
24
25 IMPLICIT NONE
26 PRIVATE
27
28 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
29 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_diis_types'
30
31 PUBLIC :: qs_diis_buffer_type
32 PUBLIC :: qs_diis_b_release
37
38! **************************************************************************************************
39!> \brief keeps a buffer with the previous values of s,p,k
40!> \par History
41!> 02.2003 rewamped [fawzi]
42!> \author Matthias Krack
43! **************************************************************************************************
45 INTEGER :: nbuffer = -1
46 INTEGER :: ncall = -1
47 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: error => null()
48 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: param => null()
49 REAL(kind=dp), DIMENSION(:, :), POINTER :: b_matrix => null()
50 TYPE(dbcsr_fm_copy_plan_type), ALLOCATABLE :: overlap_copy_plan
51 END TYPE qs_diis_buffer_type
52
53! **************************************************************************************************
54!> \brief build array of pointers to diis buffers for sparse matrix case
55!> \param diis_buffer the diis buffer pointer
56!> \par History
57!> 10.2014 Modified from non-sparse case by Fredy W. Aquino
58!> \author fwaq
59! **************************************************************************************************
61 INTEGER :: nbuffer = -1
62 INTEGER :: ncall = -1
63 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: error => null()
64 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: param => null()
65 REAL(kind=dp), DIMENSION(:, :), POINTER :: b_matrix => null()
67
68! **************************************************************************************************
69!> \brief build arrau of pointers to diis buffers in the k-point (complex full matrices) case
70!> \note we keep the overlap matrix and 1 parameter matrix per k-point, in the corresponding kp subgroup
71!> \par History
72!> 04.2023 created
73!> \author Augustin Bussy
74! **************************************************************************************************
76 INTEGER :: nbuffer = -1
77 INTEGER :: ncall = -1
78 TYPE(cp_cfm_type), DIMENSION(:), POINTER :: smat => null()
79 TYPE(cp_cfm_type), DIMENSION(:, :, :), POINTER :: param => null()
80 TYPE(cp_cfm_type), DIMENSION(:, :, :), POINTER :: error => null()
81 COMPLEX(KIND=dp), DIMENSION(:, :), POINTER :: b_matrix => null()
83
84CONTAINS
85
86! **************************************************************************************************
87!> \brief releases the given diis buffer (see doc/ReferenceCounting.html)
88!> \param diis_buffer the buffer to release
89!> \par History
90!> 02.2003 created [fawzi]
91!> \author fawzi
92! **************************************************************************************************
93 SUBROUTINE qs_diis_b_release(diis_buffer)
94 TYPE(qs_diis_buffer_type), INTENT(INOUT) :: diis_buffer
95
96 IF (ALLOCATED(diis_buffer%overlap_copy_plan)) DEALLOCATE (diis_buffer%overlap_copy_plan)
97 IF (ASSOCIATED(diis_buffer%b_matrix)) THEN
98 DEALLOCATE (diis_buffer%b_matrix)
99 END IF
100 CALL cp_fm_release(diis_buffer%error)
101 CALL cp_fm_release(diis_buffer%param)
102
103 END SUBROUTINE qs_diis_b_release
104
105! **************************************************************************************************
106!> \brief releases the given diis buffer (see doc/ReferenceCounting.html)
107!> \param diis_buffer the buffer to release
108!> \par History
109!> 10-11-14 created [FA] modified from qs_diis_b_release
110!> \author Fredy W. Aquino
111! **************************************************************************************************
112 SUBROUTINE qs_diis_b_release_sparse(diis_buffer)
113
114 TYPE(qs_diis_buffer_type_sparse), INTENT(INOUT) :: diis_buffer
115
116 INTEGER :: i, j
117
118 IF (ASSOCIATED(diis_buffer%b_matrix)) THEN
119 DEALLOCATE (diis_buffer%b_matrix)
120 END IF
121 IF (ASSOCIATED(diis_buffer%error)) THEN
122 DO j = 1, SIZE(diis_buffer%error, 2)
123 DO i = 1, SIZE(diis_buffer%error, 1)
124 CALL dbcsr_release(diis_buffer%error(i, j)%matrix)
125 DEALLOCATE (diis_buffer%error(i, j)%matrix)
126 END DO
127 END DO
128 DEALLOCATE (diis_buffer%error)
129 END IF
130 IF (ASSOCIATED(diis_buffer%param)) THEN
131 DO j = 1, SIZE(diis_buffer%param, 2)
132 DO i = 1, SIZE(diis_buffer%param, 1)
133 CALL dbcsr_release(diis_buffer%param(i, j)%matrix)
134 DEALLOCATE (diis_buffer%param(i, j)%matrix)
135 END DO
136 END DO
137 DEALLOCATE (diis_buffer%param)
138 END IF
139 END SUBROUTINE qs_diis_b_release_sparse
140
141! **************************************************************************************************
142!> \brief releases the given diis KP buffer
143!> \param diis_buffer the buffer to release
144! **************************************************************************************************
145 SUBROUTINE qs_diis_b_release_kp(diis_buffer)
146 TYPE(qs_diis_buffer_type_kp), INTENT(INOUT) :: diis_buffer
147
148 INTEGER :: i, j, k
149
150 IF (ASSOCIATED(diis_buffer%b_matrix)) THEN
151 DEALLOCATE (diis_buffer%b_matrix)
152 END IF
153 IF (ASSOCIATED(diis_buffer%smat)) THEN
154 DO i = 1, SIZE(diis_buffer%smat)
155 CALL cp_cfm_release(diis_buffer%smat(i))
156 END DO
157 DEALLOCATE (diis_buffer%smat)
158 END IF
159 IF (ASSOCIATED(diis_buffer%error)) THEN
160 DO k = 1, SIZE(diis_buffer%error, 3)
161 DO j = 1, SIZE(diis_buffer%error, 2)
162 DO i = 1, SIZE(diis_buffer%error, 1)
163 CALL cp_cfm_release(diis_buffer%error(i, j, k))
164 END DO
165 END DO
166 END DO
167 DEALLOCATE (diis_buffer%error)
168 END IF
169 IF (ASSOCIATED(diis_buffer%param)) THEN
170 DO k = 1, SIZE(diis_buffer%param, 3)
171 DO j = 1, SIZE(diis_buffer%param, 2)
172 DO i = 1, SIZE(diis_buffer%param, 1)
173 CALL cp_cfm_release(diis_buffer%param(i, j, k))
174 END DO
175 END DO
176 END DO
177 DEALLOCATE (diis_buffer%param)
178 END IF
179 END SUBROUTINE qs_diis_b_release_kp
180END MODULE qs_diis_types
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
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
buffer for the diis of the scf
subroutine, public qs_diis_b_release_kp(diis_buffer)
releases the given diis KP buffer
subroutine, public qs_diis_b_release(diis_buffer)
releases the given diis buffer (see doc/ReferenceCounting.html)
subroutine, public qs_diis_b_release_sparse(diis_buffer)
releases the given diis buffer (see doc/ReferenceCounting.html)
Represent a complex full matrix.
represent a full matrix
build arrau of pointers to diis buffers in the k-point (complex full matrices) case
build array of pointers to diis buffers for sparse matrix case
keeps a buffer with the previous values of s,p,k