(git:98357aa)
Loading...
Searching...
No Matches
ct_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 Types for all cayley transformation methods
10!> \par History
11!> 2011.06 created [Rustam Z Khaliullin]
12!> \author Rustam Z Khaliullin
13! **************************************************************************************************
16 USE cp_dbcsr_api, ONLY: dbcsr_copy,&
21 USE kinds, ONLY: dp
23#include "./base/base_uses.f90"
24
25 IMPLICIT NONE
26
27 PRIVATE
28
29 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ct_types'
30
31 ! Public types
32 PUBLIC :: ct_step_env_type
33
34 ! Public subroutines
36
38
39 ! this type contains options for cayley transformation routines
40
41 ! use orbitals or projectors?
42 LOGICAL :: use_occ_orbs = .false., use_virt_orbs = .false.
43 LOGICAL :: occ_orbs_orthogonal = .false., virt_orbs_orthogonal = .false.
44 ! tensor properties of matrix indeces:
45 ! tensor_up_down, tensor_orthogonal
46 INTEGER :: tensor_type = 0
47 ! neglect the quadratic term in riccati equations?
48 LOGICAL :: neglect_quadratic_term = .false.
49 ! what kind of output do we produce?
50 LOGICAL :: update_p = .false., update_q = .false., calculate_energy_corr = .false.
51 ! variety of conjugate gradient
52 INTEGER :: conjugator = 0
53
54 ! type of preconditioner
55 LOGICAL :: pp_preconditioner_full = .false., &
56 qq_preconditioner_full = .false.
57
58 REAL(kind=dp) :: eps_convergence = 0.0_dp
59 REAL(kind=dp) :: eps_filter = 0.0_dp
60 INTEGER :: max_iter = 0
61 !INTEGER :: nspins
62 LOGICAL :: converged = .false.
63 INTEGER :: order_lanczos = 0
64 REAL(kind=dp) :: eps_lancsoz = 0.0_dp
65 INTEGER :: max_iter_lanczos = 0
66
67 REAL(kind=dp) :: energy_correction = 0.0_dp
68
69 ! metric matrices for covariant to contravariant transformations
70 TYPE(dbcsr_type), POINTER :: p_index_up => null()
71 TYPE(dbcsr_type), POINTER :: p_index_down => null()
72 TYPE(dbcsr_type), POINTER :: q_index_up => null()
73 TYPE(dbcsr_type), POINTER :: q_index_down => null()
74
75 ! kohn-sham, covariant-covariant representation
76 TYPE(dbcsr_type), POINTER :: matrix_ks => null()
77 ! density, contravariant-contravariant representation
78 TYPE(dbcsr_type), POINTER :: matrix_p => null()
79 ! occ orbitals, contravariant-covariant representation
80 TYPE(dbcsr_type), POINTER :: matrix_t => null()
81 ! virt orbitals, contravariant-covariant representation
82 TYPE(dbcsr_type), POINTER :: matrix_v => null()
83
84 ! to avoid building Occ-by-N and Virt-vy-N matrices inside
85 ! the ct routines get them from the external code
86 TYPE(dbcsr_type), POINTER :: matrix_qp_template => null()
87 TYPE(dbcsr_type), POINTER :: matrix_pq_template => null()
88
89 ! guess for single excitation amplitudes
90 ! it is used exclusively as a guess, not modified
91 ! it should be given in the up_down representation
92 TYPE(dbcsr_type), POINTER :: matrix_x_guess => null()
93
94 ! single excitation amplitudes
95 TYPE(dbcsr_type) :: matrix_x
96 ! residuals
97 TYPE(dbcsr_type) :: matrix_res
98
99 TYPE(mp_para_env_type), POINTER :: para_env => null()
100 TYPE(cp_blacs_env_type), POINTER :: blacs_env => null()
101
102 END TYPE ct_step_env_type
103
104CONTAINS
105
106! **************************************************************************************************
107!> \brief ...
108!> \param env ...
109! **************************************************************************************************
110 SUBROUTINE ct_step_env_init(env)
111
112 TYPE(ct_step_env_type) :: env
113
114 env%use_occ_orbs = .true.
115 env%use_virt_orbs = .false.
116 env%occ_orbs_orthogonal = .false.
117 env%virt_orbs_orthogonal = .false.
118 env%tensor_type = tensor_orthogonal
119 env%neglect_quadratic_term = .false.
120 env%calculate_energy_corr = .true.
121 env%update_p = .false.
122 env%update_q = .false.
123 env%pp_preconditioner_full = .true.
124 env%qq_preconditioner_full = .false.
125
126 env%eps_convergence = 1.0e-8_dp
127 env%eps_filter = 1.0e-8_dp
128 env%max_iter = 400
129 env%order_lanczos = 3
130 env%eps_lancsoz = 1.0e-4_dp
131 env%max_iter_lanczos = 40
132 env%converged = .false.
133 env%conjugator = cg_polak_ribiere
134
135 NULLIFY (env%p_index_up)
136 NULLIFY (env%p_index_down)
137 NULLIFY (env%q_index_up)
138 NULLIFY (env%q_index_down)
139
140 NULLIFY (env%matrix_ks)
141 NULLIFY (env%matrix_p)
142 NULLIFY (env%matrix_t)
143 NULLIFY (env%matrix_v)
144 NULLIFY (env%matrix_x_guess)
145 NULLIFY (env%matrix_qp_template)
146 NULLIFY (env%matrix_pq_template)
147
148 !RZK-warning read_parameters_from_input
149
150 END SUBROUTINE ct_step_env_init
151
152! **************************************************************************************************
153!> \brief ...
154!> \param env ...
155!> \param use_occ_orbs ...
156!> \param use_virt_orbs ...
157!> \param tensor_type ...
158!> \param occ_orbs_orthogonal ...
159!> \param virt_orbs_orthogonal ...
160!> \param neglect_quadratic_term ...
161!> \param update_p ...
162!> \param update_q ...
163!> \param eps_convergence ...
164!> \param eps_filter ...
165!> \param max_iter ...
166!> \param p_index_up ...
167!> \param p_index_down ...
168!> \param q_index_up ...
169!> \param q_index_down ...
170!> \param matrix_ks ...
171!> \param matrix_p ...
172!> \param matrix_qp_template ...
173!> \param matrix_pq_template ...
174!> \param matrix_t ...
175!> \param matrix_v ...
176!> \param copy_matrix_x ...
177!> \param energy_correction ...
178!> \param calculate_energy_corr ...
179!> \param converged ...
180!> \param qq_preconditioner_full ...
181!> \param pp_preconditioner_full ...
182! **************************************************************************************************
183 SUBROUTINE ct_step_env_get(env, use_occ_orbs, use_virt_orbs, tensor_type, &
184 occ_orbs_orthogonal, virt_orbs_orthogonal, neglect_quadratic_term, &
185 update_p, update_q, eps_convergence, eps_filter, max_iter, &
186 p_index_up, p_index_down, q_index_up, q_index_down, matrix_ks, matrix_p, &
187 matrix_qp_template, matrix_pq_template, &
188 matrix_t, matrix_v, copy_matrix_x, energy_correction, calculate_energy_corr, &
189 converged, qq_preconditioner_full, pp_preconditioner_full)
190
191 TYPE(ct_step_env_type) :: env
192 LOGICAL, OPTIONAL :: use_occ_orbs, use_virt_orbs
193 INTEGER, OPTIONAL :: tensor_type
194 LOGICAL, OPTIONAL :: occ_orbs_orthogonal, &
195 virt_orbs_orthogonal, &
196 neglect_quadratic_term, update_p, &
197 update_q
198 REAL(kind=dp), OPTIONAL :: eps_convergence, eps_filter
199 INTEGER, OPTIONAL :: max_iter
200 TYPE(dbcsr_type), OPTIONAL, POINTER :: p_index_up, p_index_down, q_index_up, q_index_down, &
201 matrix_ks, matrix_p, matrix_qp_template, matrix_pq_template, matrix_t, matrix_v
202 TYPE(dbcsr_type), OPTIONAL :: copy_matrix_x
203 REAL(kind=dp), OPTIONAL :: energy_correction
204 LOGICAL, OPTIONAL :: calculate_energy_corr, converged, &
205 qq_preconditioner_full, &
206 pp_preconditioner_full
207
208 IF (PRESENT(use_occ_orbs)) use_occ_orbs = env%use_occ_orbs
209 IF (PRESENT(use_virt_orbs)) use_virt_orbs = env%use_virt_orbs
210 IF (PRESENT(occ_orbs_orthogonal)) occ_orbs_orthogonal = &
211 env%occ_orbs_orthogonal
212 IF (PRESENT(virt_orbs_orthogonal)) virt_orbs_orthogonal = &
213 env%virt_orbs_orthogonal
214 IF (PRESENT(tensor_type)) tensor_type = env%tensor_type
215 IF (PRESENT(neglect_quadratic_term)) neglect_quadratic_term = &
216 env%neglect_quadratic_term
217 IF (PRESENT(calculate_energy_corr)) calculate_energy_corr = &
218 env%calculate_energy_corr
219 IF (PRESENT(update_p)) update_p = env%update_p
220 IF (PRESENT(update_q)) update_q = env%update_q
221 IF (PRESENT(pp_preconditioner_full)) pp_preconditioner_full = &
222 env%pp_preconditioner_full
223 IF (PRESENT(qq_preconditioner_full)) qq_preconditioner_full = &
224 env%qq_preconditioner_full
225 IF (PRESENT(eps_convergence)) eps_convergence = env%eps_convergence
226 IF (PRESENT(eps_filter)) eps_filter = env%eps_filter
227 IF (PRESENT(max_iter)) max_iter = env%max_iter
228 IF (PRESENT(matrix_ks)) matrix_ks => env%matrix_ks
229 IF (PRESENT(matrix_p)) matrix_p => env%matrix_p
230 IF (PRESENT(matrix_t)) matrix_t => env%matrix_t
231 IF (PRESENT(matrix_v)) matrix_v => env%matrix_v
232 IF (PRESENT(matrix_qp_template)) matrix_qp_template => &
233 env%matrix_qp_template
234 IF (PRESENT(matrix_pq_template)) matrix_pq_template => &
235 env%matrix_pq_template
236 IF (PRESENT(p_index_up)) p_index_up => env%p_index_up
237 IF (PRESENT(q_index_up)) q_index_up => env%q_index_up
238 IF (PRESENT(p_index_down)) p_index_down => env%p_index_down
239 IF (PRESENT(q_index_down)) q_index_down => env%q_index_down
240 IF (PRESENT(copy_matrix_x)) THEN
241 CALL dbcsr_copy(copy_matrix_x, env%matrix_x)
242 END IF
243 IF (PRESENT(energy_correction)) energy_correction = env%energy_correction
244 IF (PRESENT(converged)) converged = env%converged
245
246 END SUBROUTINE ct_step_env_get
247
248! **************************************************************************************************
249!> \brief ...
250!> \param env ...
251!> \param para_env ...
252!> \param blacs_env ...
253!> \param use_occ_orbs ...
254!> \param use_virt_orbs ...
255!> \param tensor_type ...
256!> \param occ_orbs_orthogonal ...
257!> \param virt_orbs_orthogonal ...
258!> \param neglect_quadratic_term ...
259!> \param update_p ...
260!> \param update_q ...
261!> \param eps_convergence ...
262!> \param eps_filter ...
263!> \param max_iter ...
264!> \param p_index_up ...
265!> \param p_index_down ...
266!> \param q_index_up ...
267!> \param q_index_down ...
268!> \param matrix_ks ...
269!> \param matrix_p ...
270!> \param matrix_qp_template ...
271!> \param matrix_pq_template ...
272!> \param matrix_t ...
273!> \param matrix_v ...
274!> \param matrix_x_guess ...
275!> \param calculate_energy_corr ...
276!> \param conjugator ...
277!> \param qq_preconditioner_full ...
278!> \param pp_preconditioner_full ...
279! **************************************************************************************************
280 SUBROUTINE ct_step_env_set(env, para_env, blacs_env, use_occ_orbs, &
281 use_virt_orbs, tensor_type, &
282 occ_orbs_orthogonal, virt_orbs_orthogonal, neglect_quadratic_term, &
283 update_p, update_q, eps_convergence, eps_filter, max_iter, &
284 p_index_up, p_index_down, q_index_up, q_index_down, matrix_ks, matrix_p, &
285 matrix_qp_template, matrix_pq_template, &
286 matrix_t, matrix_v, matrix_x_guess, calculate_energy_corr, conjugator, &
287 qq_preconditioner_full, pp_preconditioner_full)
288
289 TYPE(ct_step_env_type) :: env
290 TYPE(mp_para_env_type), POINTER :: para_env
291 TYPE(cp_blacs_env_type), POINTER :: blacs_env
292 LOGICAL, OPTIONAL :: use_occ_orbs, use_virt_orbs
293 INTEGER, OPTIONAL :: tensor_type
294 LOGICAL, OPTIONAL :: occ_orbs_orthogonal, &
295 virt_orbs_orthogonal, &
296 neglect_quadratic_term, update_p, &
297 update_q
298 REAL(kind=dp), OPTIONAL :: eps_convergence, eps_filter
299 INTEGER, OPTIONAL :: max_iter
300 TYPE(dbcsr_type), OPTIONAL, TARGET :: p_index_up, p_index_down, q_index_up, q_index_down, &
301 matrix_ks, matrix_p, matrix_qp_template, matrix_pq_template, matrix_t, matrix_v, &
302 matrix_x_guess
303 LOGICAL, OPTIONAL :: calculate_energy_corr
304 INTEGER, OPTIONAL :: conjugator
305 LOGICAL, OPTIONAL :: qq_preconditioner_full, &
306 pp_preconditioner_full
307
308 env%para_env => para_env
309 env%blacs_env => blacs_env
310
311 IF (PRESENT(use_occ_orbs)) env%use_occ_orbs = use_occ_orbs
312 IF (PRESENT(use_virt_orbs)) env%use_virt_orbs = use_virt_orbs
313 IF (PRESENT(occ_orbs_orthogonal)) env%occ_orbs_orthogonal = &
314 occ_orbs_orthogonal
315 IF (PRESENT(virt_orbs_orthogonal)) env%virt_orbs_orthogonal = &
316 virt_orbs_orthogonal
317 IF (PRESENT(tensor_type)) env%tensor_type = tensor_type
318 IF (PRESENT(neglect_quadratic_term)) env%neglect_quadratic_term = &
319 neglect_quadratic_term
320 IF (PRESENT(calculate_energy_corr)) env%calculate_energy_corr = &
321 calculate_energy_corr
322 IF (PRESENT(update_p)) env%update_p = update_p
323 IF (PRESENT(update_q)) env%update_q = update_q
324 IF (PRESENT(pp_preconditioner_full)) env%pp_preconditioner_full = &
325 pp_preconditioner_full
326 IF (PRESENT(qq_preconditioner_full)) env%qq_preconditioner_full = &
327 qq_preconditioner_full
328 IF (PRESENT(eps_convergence)) env%eps_convergence = eps_convergence
329 IF (PRESENT(eps_filter)) env%eps_filter = eps_filter
330 IF (PRESENT(max_iter)) env%max_iter = max_iter
331 IF (PRESENT(conjugator)) env%conjugator = conjugator
332 IF (PRESENT(matrix_ks)) env%matrix_ks => matrix_ks
333 IF (PRESENT(matrix_p)) env%matrix_p => matrix_p
334 IF (PRESENT(matrix_t)) env%matrix_t => matrix_t
335 IF (PRESENT(matrix_v)) env%matrix_v => matrix_v
336 IF (PRESENT(matrix_x_guess)) env%matrix_x_guess => matrix_x_guess
337 IF (PRESENT(matrix_qp_template)) env%matrix_qp_template => &
338 matrix_qp_template
339 IF (PRESENT(matrix_pq_template)) env%matrix_pq_template => &
340 matrix_pq_template
341 IF (PRESENT(p_index_up)) env%p_index_up => p_index_up
342 IF (PRESENT(q_index_up)) env%q_index_up => q_index_up
343 IF (PRESENT(p_index_down)) env%p_index_down => p_index_down
344 IF (PRESENT(q_index_down)) env%q_index_down => q_index_down
345
346 END SUBROUTINE ct_step_env_set
347
348! **************************************************************************************************
349!> \brief ...
350!> \param env ...
351! **************************************************************************************************
352 SUBROUTINE ct_step_env_clean(env)
353
354 TYPE(ct_step_env_type) :: env
355
356 NULLIFY (env%para_env)
357 NULLIFY (env%blacs_env)
358
359 !DO ispin=1,env%nspins
360 CALL dbcsr_release(env%matrix_x)
361 CALL dbcsr_release(env%matrix_res)
362
363 NULLIFY (env%p_index_up)
364 NULLIFY (env%p_index_down)
365 NULLIFY (env%q_index_up)
366 NULLIFY (env%q_index_down)
367
368 NULLIFY (env%matrix_ks)
369 NULLIFY (env%matrix_p)
370 NULLIFY (env%matrix_t)
371 NULLIFY (env%matrix_v)
372 NULLIFY (env%matrix_x_guess)
373 NULLIFY (env%matrix_qp_template)
374 NULLIFY (env%matrix_pq_template)
375
376 END SUBROUTINE ct_step_env_clean
377
378END MODULE ct_types
379
methods related to the blacs parallel environment
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_release(matrix)
...
Types for all cayley transformation methods.
Definition ct_types.F:14
subroutine, public ct_step_env_clean(env)
...
Definition ct_types.F:353
subroutine, public ct_step_env_set(env, para_env, blacs_env, use_occ_orbs, use_virt_orbs, tensor_type, occ_orbs_orthogonal, virt_orbs_orthogonal, neglect_quadratic_term, update_p, update_q, eps_convergence, eps_filter, max_iter, p_index_up, p_index_down, q_index_up, q_index_down, matrix_ks, matrix_p, matrix_qp_template, matrix_pq_template, matrix_t, matrix_v, matrix_x_guess, calculate_energy_corr, conjugator, qq_preconditioner_full, pp_preconditioner_full)
...
Definition ct_types.F:288
subroutine, public ct_step_env_init(env)
...
Definition ct_types.F:111
subroutine, public ct_step_env_get(env, use_occ_orbs, use_virt_orbs, tensor_type, occ_orbs_orthogonal, virt_orbs_orthogonal, neglect_quadratic_term, update_p, update_q, eps_convergence, eps_filter, max_iter, p_index_up, p_index_down, q_index_up, q_index_down, matrix_ks, matrix_p, matrix_qp_template, matrix_pq_template, matrix_t, matrix_v, copy_matrix_x, energy_correction, calculate_energy_corr, converged, qq_preconditioner_full, pp_preconditioner_full)
...
Definition ct_types.F:190
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public tensor_orthogonal
integer, parameter, public cg_polak_ribiere
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
stores all the informations relevant to an mpi environment