(git:71c3ab0)
Loading...
Searching...
No Matches
mixed_cdft_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 mixed CDFT calculations
10!> \par History
11!> Separated CDFT routines from mixed_environment_types
12!> \author Nico Holmberg [01.2017]
13! **************************************************************************************************
18 USE cp_dbcsr_api, ONLY: dbcsr_p_type,&
21 USE cp_fm_types, ONLY: cp_fm_release,&
25 USE kinds, ONLY: dp
26 USE pw_env_types, ONLY: pw_env_release,&
32#include "./base/base_uses.f90"
33
34 IMPLICIT NONE
35 PRIVATE
36
37! **************************************************************************************************
38!> \brief Container for results related to a mixed CDFT calculation
39! **************************************************************************************************
40 TYPE mixed_cdft_result_type
41 ! CDFT electronic couplings calculated with different methods
42 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: lowdin, nonortho, &
43 rotation, wfn
44 ! Energies of the CDFT states
45 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: energy
46 ! Lagrangian multipliers of the CDFT constraints
47 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: strength
48 ! Reliability metric for CDFT electronic couplings
49 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: metric
50 ! The mixed CDFT Hamiltonian matrix
51 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: h
52 ! Overlaps between CDFT states
53 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: s
54 ! S^(-1/2)
55 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: s_minushalf
56 ! Off-diagonal elements of the weight function matrices <Psi_j | w_i(r) | Psi_i>
57 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: wad, wda
58 ! Diagonal elements of the weight function matrices, i.e., the constraint values
59 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: w_diagonal
60 END TYPE mixed_cdft_result_type
61
62! **************************************************************************************************
63!> \brief Container for mixed CDFT matrices
64! **************************************************************************************************
65 TYPE mixed_cdft_work_type
66 ! Matrix representations of the CDFT weight functions
67 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: w_matrix => null()
68 ! AO overlap matrix
69 TYPE(dbcsr_type), POINTER :: mixed_matrix_s => null()
70 ! MO coefficients of each CDFT state
71 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: mixed_mo_coeff => null()
72 ! Density matrices of the CDFT states
73 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: density_matrix => null()
74 END TYPE mixed_cdft_work_type
75
76! **************************************************************************************************
77!> \brief Buffers for load balancing
78!> \param rank indices of the processors the data in this buffer should be sent to
79!> \param tag mpi tags for the messages to send
80!> \param cavity the cavity to send
81!> \param weight the weight to send
82!> \param gradients the gradients to send
83! **************************************************************************************************
84 TYPE buffers
85 INTEGER :: rank(2) = -1, tag(2) = -1
86 REAL(KIND=dp), POINTER, &
87 DIMENSION(:, :, :) :: cavity => null(), weight => null()
88 REAL(KIND=dp), POINTER, &
89 DIMENSION(:, :, :, :) :: gradients => null()
90 END TYPE buffers
91! **************************************************************************************************
92!> \brief To build array of buffers
93!> \param buffs the pointer to the buffers type
94! **************************************************************************************************
95 TYPE p_buffers
96 TYPE(buffers), DIMENSION(:), POINTER :: buffs => null()
97 END TYPE p_buffers
98! **************************************************************************************************
99!> \brief Information about load balancing
100!> \param matrix_info size of the target_list array to receive and grid point bounds of the data
101!> \param target_list the target_list array of the processor that sends me data
102! **************************************************************************************************
103 TYPE repl_info
104 INTEGER, DIMENSION(:), POINTER :: matrix_info => null()
105 INTEGER, DIMENSION(:, :), POINTER :: target_list => null()
106 END TYPE repl_info
107! **************************************************************************************************
108!> \brief Load balancing control for mixed CDFT calculation
109!> \param my_source index of the processor which will send this processor data
110!> \param distributed bounds that determine which grid points this processor will compute after
111!> applying load balancing (is_special = .FALSE.)
112!> \param my_dest_repl the dest_list arrays of all processors which send additional work to this
113!> processor (indices of the processors where the redistributed slices should be
114!> returned)
115!> \param dest_tags_repl tags for the send messages (is_special = .FALSE.)
116!> \param more_work allow heavily overloaded processors to redistribute more_work slices
117!> \param bo bounds of the data that this processor will send to other processors which tells the
118!> receivers how to rearrange the data correctly
119!> \param expected_work a list of the estimated work per processor
120!> \param prediction_error the difference between the estimated and actual work per processor
121!> \param target_list a list of processors to send data and the size of data to send
122!> \param recv_work flag that determines if this processor will receive data from others
123!> \param send_work flag that determines if this processor will send data to others
124!> \param recv_work_repl list of processor indices where this processor will send data during load
125!> balancing
126!> \param load_scale allow underloaded processors to accept load_scale additional work
127!> \param very_overloaded value to determine which processors are heavily overloaded
128!> \param cavity the cavity that this processor builds in addition to its own cavity defined
129!> on the grid points which were redistributed to this processor
130!> \param weight the weight that this processor builds in addition to its own weight
131!> \param gradients the gradients that this processor builds in addition to its own gradients
132!> \param sendbuffer buffer to hold the data this processor will send
133!> \param sendbuffer buffer to hold the data this processor will receive
134!> \param recv_info additional information on the data this processor will receive
135! **************************************************************************************************
136 TYPE mixed_cdft_dlb_type
137 INTEGER :: my_source = -1, distributed(2) = -1, &
138 my_dest_repl(2) = -1, dest_tags_repl(2) = -1, &
139 more_work = -1
140 INTEGER, DIMENSION(:), POINTER :: bo => null(), expected_work => null(), &
141 prediction_error => null()
142 INTEGER, DIMENSION(:, :), POINTER :: target_list => null()
143 LOGICAL :: recv_work = .false., send_work = .false.
144 LOGICAL, DIMENSION(:), POINTER :: recv_work_repl => null()
145 REAL(KIND=dp) :: load_scale = 0.0_dp, very_overloaded = 0.0_dp
146 REAL(KIND=dp), POINTER, &
147 DIMENSION(:, :, :) :: cavity => null(), weight => null()
148 REAL(KIND=dp), POINTER, &
149 DIMENSION(:, :, :, :) :: gradients => null()
150 ! Should convert to TYPE(p_buffers), POINTER
151 TYPE(buffers), DIMENSION(:), POINTER :: sendbuff => null()
152 TYPE(p_buffers), DIMENSION(:), POINTER :: recvbuff => null()
153 TYPE(repl_info), DIMENSION(:), POINTER :: recv_info => null()
154 END TYPE mixed_cdft_dlb_type
155! **************************************************************************************************
156!> \brief Main mixed CDFT control type
157!> \param sim_step counter to keep track of the simulation step for MD
158!> \param multiplicity spin multiplicity
159!> \param nconstraint the number of constraints
160!> \param run_type what type of mixed CDFT simulation to perform
161!> \param source_list a list of processors which will send this processor data
162!> \param dest_list a list of processors which this processor will send data to
163!> \param recv_bo bounds of the data which this processor will receive (is_special = .FALSE.)
164!> \param source_list_save permanent copy of source_list which might get reallocated during
165!> load balancing
166!> \param dest_list_save permanent copy of dest_list which might get reallocated during
167!> load balancing
168!> \param source_list_bo bounds of the data which this processor will receive (is_special = .TRUE.)
169!> \param dest_list_bo bounds of the data this processor will send (is_special = .TRUE.)
170!> \param source_bo_save permanent copy of source_list_bo
171!> \param deset_bo_save permanent copy of dest_list_bo
172!> \param is_pencil flag controlling which scheme to use for constraint replication
173!> \param dlb flag to enable dynamic load balancing
174!> \param is_special another flag controlling which scheme to use for constraint replication
175!> \param first_iteration flag to mark the first iteration e.g. during MD to output information
176!> \param calculate_metric flag which determines if the coupling reliability metric should be computed
177!> \param wnf_ovelap_method flag to enable the wavefunction overlap method for computing the coupling
178!> \param has_unit_metric flag to determine if the basis set has unit metric
179!> \param use_lowdin flag which determines if Lowdin orthogonalization is used to compute the coupling
180!> \param do_ci flag which determines if a CDFT-CI calculation was requested
181!> \param nonortho_coupling flag which determines if the nonorthogonal CDFT interaction energies
182!> should be printed out
183!> \param identical_constraints flag which determines if the constraint definitions are identical
184!> across all CDFT states
185!> \param block_diagonalize flag which determines if the CDFT Hamiltonian should be block
186!> diagonalized
187!> \param constraint_type list of integers which determine what type of constraint should be applied
188!> to each constraint group
189!> \param eps_rho_rspace threshold to determine when the realspace density can be considered zero
190!> \param sim_dt timestep of the MD simulation
191!> \param eps_svd value that controls which matrix inversion method to use
192!> \param weight the constraint weight function
193!> \param cavity the confinement cavity: the weight function is nonzero only within the cavity
194!> \param cdft_control container for cdft_control_type
195!> \param sendbuff buffer that holds the data to be replicated
196!> \param blacs_env the blacs_env needed to redistribute arrays during a coupling calculation
197!> \param results container for mixed CDFT results
198!> \param matrix container for mixed CDFT work matrices
199!> \param dlb_control container for load balancing structures
200!> \param qs_kind_set the qs_kind_set needed to setup a confinement cavity
201!> \param pw_env the pw_env that holds the fully distributed realspace grid
202!> \param occupations occupation numbers in case non-uniform occupation
203! **************************************************************************************************
205 INTEGER :: sim_step = -1, multiplicity = -1, &
206 nconstraint = -1, &
207 run_type = -1
208 INTEGER, DIMENSION(:, :), ALLOCATABLE :: constraint_type
209 INTEGER, POINTER, DIMENSION(:) :: source_list => null(), dest_list => null(), &
210 recv_bo => null(), source_list_save => null(), &
211 dest_list_save => null()
212 INTEGER, POINTER, DIMENSION(:, :) :: source_list_bo => null(), dest_list_bo => null(), &
213 source_bo_save => null(), dest_bo_save => null()
214 LOGICAL :: is_pencil = .false., dlb = .false., &
215 is_special = .false., first_iteration = .false., &
216 calculate_metric = .false., &
217 wfn_overlap_method = .false., &
218 has_unit_metric = .false., &
219 use_lowdin = .false., &
220 do_ci = .false., nonortho_coupling = .false., &
221 identical_constraints = .false., &
222 block_diagonalize = .false.
223 REAL(kind=dp) :: eps_rho_rspace = 0.0_dp, sim_dt = 0.0_dp, &
224 eps_svd = 0.0_dp
225 REAL(kind=dp), POINTER, DIMENSION(:, :, :) :: weight => null(), cavity => null()
226 TYPE(cdft_control_type), POINTER :: cdft_control => null()
227 TYPE(buffers), DIMENSION(:), POINTER :: sendbuff => null()
228 TYPE(cp_1d_r_p_type), ALLOCATABLE, &
229 DIMENSION(:, :) :: occupations
230 TYPE(cp_blacs_env_type), POINTER :: blacs_env => null()
231 TYPE(cp_logger_p_type), DIMENSION(:), POINTER :: sub_logger => null()
232 TYPE(mixed_cdft_result_type) :: results = mixed_cdft_result_type()
233 TYPE(mixed_cdft_work_type) :: matrix = mixed_cdft_work_type()
234 TYPE(mixed_cdft_dlb_type), POINTER :: dlb_control => null()
235 TYPE(pw_env_type), POINTER :: pw_env => null()
236 TYPE(qs_kind_type), DIMENSION(:), &
237 POINTER :: qs_kind_set => null()
238 END TYPE mixed_cdft_type
239
240! **************************************************************************************************
241!> \brief Container for constraint settings to check consistency of force_evals
242! **************************************************************************************************
244 LOGICAL :: is_spherical = .false., &
245 is_odd = .false.
246 LOGICAL, DIMENSION(:, :), POINTER :: sb => null()
247 INTEGER :: ncdft = -1, &
248 max_nkinds = -1
249 INTEGER, DIMENSION(2, 3) :: bo = -1
250 INTEGER, DIMENSION(:), POINTER :: grid_span => null(), &
251 spherical => null(), &
252 odd => null()
253 INTEGER, DIMENSION(:, :), POINTER :: si => null(), &
254 rs_dims => null(), &
255 atoms => null(), &
256 npts => null()
257 REAL(kind=dp) :: radius = 0.0_dp
258 REAL(kind=dp), DIMENSION(:), POINTER :: cutoff => null(), &
259 rel_cutoff => null()
260 REAL(kind=dp), DIMENSION(:, :), POINTER :: sr => null(), &
261 coeffs => null(), &
262 cutoffs => null(), &
263 radii => null()
265
266! *** Public data types ***
267
268 PUBLIC :: mixed_cdft_type, &
270
271! *** Public subroutines ***
272
273 PUBLIC :: mixed_cdft_type_create, &
279
280 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'mixed_cdft_types'
281
282CONTAINS
283
284! **************************************************************************************************
285!> \brief inits the given mixed_cdft_type
286!> \param cdft_control the object to init
287!> \author Nico Holmberg [01.2017]
288! **************************************************************************************************
289 SUBROUTINE mixed_cdft_type_create(cdft_control)
290 TYPE(mixed_cdft_type), POINTER :: cdft_control
291
292 NULLIFY (cdft_control%pw_env, cdft_control%blacs_env, cdft_control%qs_kind_set)
293 NULLIFY (cdft_control%dlb_control, cdft_control%dest_list_bo, cdft_control%dest_list)
294 NULLIFY (cdft_control%dest_bo_save, cdft_control%dest_list_save, cdft_control%source_list)
295 NULLIFY (cdft_control%source_list_save, cdft_control%source_bo_save, cdft_control%source_list_bo)
296 NULLIFY (cdft_control%cavity, cdft_control%weight, cdft_control%sendbuff)
297 NULLIFY (cdft_control%cdft_control, cdft_control%recv_bo)
298 NULLIFY (cdft_control%sub_logger)
299
300 END SUBROUTINE mixed_cdft_type_create
301
302! **************************************************************************************************
303!> \brief releases the given mixed_cdft_type
304!> \param cdft_control the object to release
305!> \author Nico Holmberg [01.2017]
306! **************************************************************************************************
307 SUBROUTINE mixed_cdft_type_release(cdft_control)
308 TYPE(mixed_cdft_type), POINTER :: cdft_control
309
310 INTEGER :: i, j
311
312 CALL pw_env_release(cdft_control%pw_env)
313 IF (ASSOCIATED(cdft_control%dest_list)) THEN
314 DEALLOCATE (cdft_control%dest_list)
315 END IF
316 IF (ASSOCIATED(cdft_control%dest_list_save)) THEN
317 DEALLOCATE (cdft_control%dest_list_save)
318 END IF
319 IF (ASSOCIATED(cdft_control%dest_list_bo)) THEN
320 DEALLOCATE (cdft_control%dest_list_bo)
321 END IF
322 IF (ASSOCIATED(cdft_control%dest_bo_save)) THEN
323 DEALLOCATE (cdft_control%dest_bo_save)
324 END IF
325 IF (ASSOCIATED(cdft_control%source_list)) THEN
326 DEALLOCATE (cdft_control%source_list)
327 END IF
328 IF (ASSOCIATED(cdft_control%source_list_save)) THEN
329 DEALLOCATE (cdft_control%source_list_save)
330 END IF
331 IF (ASSOCIATED(cdft_control%source_list_bo)) THEN
332 DEALLOCATE (cdft_control%source_list_bo)
333 END IF
334 IF (ASSOCIATED(cdft_control%source_bo_save)) THEN
335 DEALLOCATE (cdft_control%source_bo_save)
336 END IF
337 IF (ASSOCIATED(cdft_control%recv_bo)) THEN
338 DEALLOCATE (cdft_control%recv_bo)
339 END IF
340 IF (ASSOCIATED(cdft_control%weight)) THEN
341 DEALLOCATE (cdft_control%weight)
342 END IF
343 IF (ASSOCIATED(cdft_control%cavity)) THEN
344 DEALLOCATE (cdft_control%cavity)
345 END IF
346 IF (ALLOCATED(cdft_control%constraint_type)) THEN
347 DEALLOCATE (cdft_control%constraint_type)
348 END IF
349 IF (ALLOCATED(cdft_control%occupations)) THEN
350 DO i = 1, SIZE(cdft_control%occupations, 1)
351 DO j = 1, SIZE(cdft_control%occupations, 2)
352 IF (ASSOCIATED(cdft_control%occupations(i, j)%array)) THEN
353 DEALLOCATE (cdft_control%occupations(i, j)%array)
354 END IF
355 END DO
356 END DO
357 DEALLOCATE (cdft_control%occupations)
358 END IF
359 IF (ASSOCIATED(cdft_control%dlb_control)) THEN
360 CALL mixed_cdft_dlb_release(cdft_control%dlb_control)
361 END IF
362 IF (ASSOCIATED(cdft_control%sendbuff)) THEN
363 DO i = 1, SIZE(cdft_control%sendbuff)
364 CALL mixed_cdft_buffers_release(cdft_control%sendbuff(i))
365 END DO
366 DEALLOCATE (cdft_control%sendbuff)
367 END IF
368 IF (ASSOCIATED(cdft_control%cdft_control)) THEN
369 CALL cdft_control_release(cdft_control%cdft_control)
370 DEALLOCATE (cdft_control%cdft_control)
371 END IF
372 IF (ASSOCIATED(cdft_control%blacs_env)) THEN
373 CALL cp_blacs_env_release(cdft_control%blacs_env)
374 END IF
375 IF (ASSOCIATED(cdft_control%qs_kind_set)) THEN
376 CALL deallocate_qs_kind_set(cdft_control%qs_kind_set)
377 END IF
378 IF (ASSOCIATED(cdft_control%sub_logger)) THEN
379 DO i = 1, SIZE(cdft_control%sub_logger)
380 CALL cp_logger_release(cdft_control%sub_logger(i)%p)
381 END DO
382 DEALLOCATE (cdft_control%sub_logger)
383 END IF
384 CALL mixed_cdft_result_type_release(cdft_control%results)
385 CALL mixed_cdft_work_type_release(cdft_control%matrix)
386 DEALLOCATE (cdft_control)
387
388 END SUBROUTINE mixed_cdft_type_release
389
390! **************************************************************************************************
391!> \brief releases the given load balancing control
392!> \param dlb_control the object to release
393!> \author Nico Holmberg [01.2017]
394! **************************************************************************************************
395 SUBROUTINE mixed_cdft_dlb_release(dlb_control)
396 TYPE(mixed_cdft_dlb_type), POINTER :: dlb_control
397
398 INTEGER :: i
399
400 IF (ASSOCIATED(dlb_control%recv_work_repl)) THEN
401 DEALLOCATE (dlb_control%recv_work_repl)
402 END IF
403 IF (ASSOCIATED(dlb_control%sendbuff)) THEN
404 DO i = 1, SIZE(dlb_control%sendbuff)
405 CALL mixed_cdft_buffers_release(dlb_control%sendbuff(i))
406 END DO
407 DEALLOCATE (dlb_control%sendbuff)
408 END IF
409 IF (ASSOCIATED(dlb_control%recvbuff)) THEN
410 DO i = 1, SIZE(dlb_control%recvbuff)
411 CALL mixed_cdft_p_buffers_release(dlb_control%recvbuff(i))
412 END DO
413 DEALLOCATE (dlb_control%recvbuff)
414 END IF
415 IF (ASSOCIATED(dlb_control%recv_info)) THEN
416 DO i = 1, SIZE(dlb_control%recv_info)
417 IF (ASSOCIATED(dlb_control%recv_info(i)%matrix_info)) THEN
418 DEALLOCATE (dlb_control%recv_info(i)%matrix_info)
419 END IF
420 IF (ASSOCIATED(dlb_control%recv_info(i)%target_list)) THEN
421 DEALLOCATE (dlb_control%recv_info(i)%target_list)
422 END IF
423 END DO
424 DEALLOCATE (dlb_control%recv_info)
425 END IF
426 IF (ASSOCIATED(dlb_control%bo)) THEN
427 DEALLOCATE (dlb_control%bo)
428 END IF
429 IF (ASSOCIATED(dlb_control%expected_work)) THEN
430 DEALLOCATE (dlb_control%expected_work)
431 END IF
432 IF (ASSOCIATED(dlb_control%prediction_error)) THEN
433 DEALLOCATE (dlb_control%prediction_error)
434 END IF
435 IF (ASSOCIATED(dlb_control%target_list)) THEN
436 DEALLOCATE (dlb_control%target_list)
437 END IF
438 IF (ASSOCIATED(dlb_control%cavity)) THEN
439 DEALLOCATE (dlb_control%cavity)
440 END IF
441 IF (ASSOCIATED(dlb_control%weight)) THEN
442 DEALLOCATE (dlb_control%weight)
443 END IF
444 IF (ASSOCIATED(dlb_control%gradients)) THEN
445 DEALLOCATE (dlb_control%gradients)
446 END IF
447 DEALLOCATE (dlb_control)
448
449 END SUBROUTINE mixed_cdft_dlb_release
450
451! **************************************************************************************************
452!> \brief releases the given buffers
453!> \param buffer the object to release
454!> \author Nico Holmberg [01.2017]
455! **************************************************************************************************
456 SUBROUTINE mixed_cdft_buffers_release(buffer)
457 TYPE(buffers) :: buffer
458
459 IF (ASSOCIATED(buffer%cavity)) THEN
460 DEALLOCATE (buffer%cavity)
461 END IF
462 IF (ASSOCIATED(buffer%weight)) THEN
463 DEALLOCATE (buffer%weight)
464 END IF
465 IF (ASSOCIATED(buffer%gradients)) THEN
466 DEALLOCATE (buffer%gradients)
467 END IF
468
469 END SUBROUTINE mixed_cdft_buffers_release
470
471! **************************************************************************************************
472!> \brief releases the given pointer of buffers
473!> \param p_buffer the object to release
474!> \author Nico Holmberg [01.2017]
475! **************************************************************************************************
476 SUBROUTINE mixed_cdft_p_buffers_release(p_buffer)
477 TYPE(p_buffers) :: p_buffer
478
479 INTEGER :: i
480
481 IF (ASSOCIATED(p_buffer%buffs)) THEN
482 DO i = 1, SIZE(p_buffer%buffs)
483 CALL mixed_cdft_buffers_release(p_buffer%buffs(i))
484 END DO
485 DEALLOCATE (p_buffer%buffs)
486 END IF
487
488 END SUBROUTINE mixed_cdft_p_buffers_release
489
490! **************************************************************************************************
491!> \brief Updates arrays within the mixed CDFT result container
492!> \param results the array container
493!> \param lowdin CDFT electronic couplings from Lowdin orthogonalization
494!> \param wfn CDFT electronic couplings from wavefunction overlap method
495!> \param nonortho CDFT electronic couplings (interaction energies) before orthogonalization
496!> \param metric Reliability metric for CDFT electronic couplings
497!> \param rotation CDFT electronic couplings using the weight function matrix for orthogonalization
498!> \param H The mixed CDFT Hamiltonian
499!> \param S The overlap matrix between CDFT states
500!> \param Wad Integrals of type <Psi_a | w_d(r) | Psi_d>
501!> \param Wda Integrals of type <Psi_d | w_a(r) | Psi_a>
502!> \param W_diagonal Values of the CDFT constraints
503!> \param energy Energies of the CDFT states
504!> \param strength Lagrangian multipliers of the CDFT states
505!> \param S_minushalf S^(-1/2)
506!> \author Nico Holmberg [11.2017]
507! **************************************************************************************************
508 SUBROUTINE mixed_cdft_result_type_set(results, lowdin, wfn, nonortho, metric, rotation, &
509 H, S, Wad, Wda, W_diagonal, energy, strength, S_minushalf)
510 TYPE(mixed_cdft_result_type) :: results
511 REAL(kind=dp), DIMENSION(:), OPTIONAL :: lowdin, wfn, nonortho
512 REAL(kind=dp), DIMENSION(:, :), OPTIONAL :: metric
513 REAL(kind=dp), DIMENSION(:), OPTIONAL :: rotation
514 REAL(kind=dp), DIMENSION(:, :), OPTIONAL :: h, s, wad, wda, w_diagonal
515 REAL(kind=dp), DIMENSION(:), OPTIONAL :: energy
516 REAL(kind=dp), DIMENSION(:, :), OPTIONAL :: strength, s_minushalf
517
518 IF (PRESENT(lowdin)) THEN
519 IF (ALLOCATED(results%lowdin)) DEALLOCATE (results%lowdin)
520 ALLOCATE (results%lowdin(SIZE(lowdin)))
521 results%lowdin(:) = lowdin(:)
522 END IF
523 IF (PRESENT(wfn)) THEN
524 IF (ALLOCATED(results%wfn)) DEALLOCATE (results%wfn)
525 ALLOCATE (results%wfn(SIZE(wfn)))
526 results%wfn(:) = wfn(:)
527 END IF
528 IF (PRESENT(nonortho)) THEN
529 IF (ALLOCATED(results%nonortho)) DEALLOCATE (results%nonortho)
530 ALLOCATE (results%nonortho(SIZE(nonortho)))
531 results%nonortho(:) = nonortho(:)
532 END IF
533 IF (PRESENT(rotation)) THEN
534 IF (ALLOCATED(results%rotation)) DEALLOCATE (results%rotation)
535 ALLOCATE (results%rotation(SIZE(rotation)))
536 results%rotation(:) = rotation(:)
537 END IF
538 IF (PRESENT(energy)) THEN
539 IF (ALLOCATED(results%energy)) DEALLOCATE (results%energy)
540 ALLOCATE (results%energy(SIZE(energy)))
541 results%energy(:) = energy(:)
542 END IF
543 IF (PRESENT(strength)) THEN
544 IF (ALLOCATED(results%strength)) DEALLOCATE (results%strength)
545 ALLOCATE (results%strength(SIZE(strength, 1), SIZE(strength, 2)))
546 results%strength(:, :) = strength(:, :)
547 END IF
548 IF (PRESENT(metric)) THEN
549 IF (ALLOCATED(results%metric)) DEALLOCATE (results%metric)
550 ALLOCATE (results%metric(SIZE(metric, 1), SIZE(metric, 2)))
551 results%metric(:, :) = metric(:, :)
552 END IF
553 IF (PRESENT(h)) THEN
554 IF (ALLOCATED(results%H)) DEALLOCATE (results%H)
555 ALLOCATE (results%H(SIZE(h, 1), SIZE(h, 2)))
556 results%H(:, :) = h(:, :)
557 END IF
558 IF (PRESENT(s)) THEN
559 IF (ALLOCATED(results%S)) DEALLOCATE (results%S)
560 ALLOCATE (results%S(SIZE(s, 1), SIZE(s, 2)))
561 results%S(:, :) = s(:, :)
562 END IF
563 IF (PRESENT(s_minushalf)) THEN
564 IF (ALLOCATED(results%S_minushalf)) DEALLOCATE (results%S_minushalf)
565 ALLOCATE (results%S_minushalf(SIZE(s_minushalf, 1), SIZE(s_minushalf, 2)))
566 results%S_minushalf(:, :) = s_minushalf(:, :)
567 END IF
568 IF (PRESENT(wad)) THEN
569 IF (ALLOCATED(results%Wad)) DEALLOCATE (results%Wad)
570 ALLOCATE (results%Wad(SIZE(wad, 1), SIZE(wad, 2)))
571 results%Wad(:, :) = wad(:, :)
572 END IF
573 IF (PRESENT(wda)) THEN
574 IF (ALLOCATED(results%Wda)) DEALLOCATE (results%Wda)
575 ALLOCATE (results%Wda(SIZE(wda, 1), SIZE(wda, 2)))
576 results%Wda(:, :) = wda(:, :)
577 END IF
578 IF (PRESENT(w_diagonal)) THEN
579 IF (ALLOCATED(results%W_diagonal)) DEALLOCATE (results%W_diagonal)
580 ALLOCATE (results%W_diagonal(SIZE(w_diagonal, 1), SIZE(w_diagonal, 2)))
581 results%W_diagonal(:, :) = w_diagonal(:, :)
582 END IF
583
584 END SUBROUTINE mixed_cdft_result_type_set
585
586! **************************************************************************************************
587!> \brief Releases all arrays within the mixed CDFT result container
588!> \param results the container
589!> \author Nico Holmberg [11.2017]
590! **************************************************************************************************
592 TYPE(mixed_cdft_result_type) :: results
593
594 IF (ALLOCATED(results%lowdin)) DEALLOCATE (results%lowdin)
595 IF (ALLOCATED(results%wfn)) DEALLOCATE (results%wfn)
596 IF (ALLOCATED(results%metric)) DEALLOCATE (results%metric)
597 IF (ALLOCATED(results%nonortho)) DEALLOCATE (results%nonortho)
598 IF (ALLOCATED(results%rotation)) DEALLOCATE (results%rotation)
599 IF (ALLOCATED(results%H)) DEALLOCATE (results%H)
600 IF (ALLOCATED(results%S)) DEALLOCATE (results%S)
601 IF (ALLOCATED(results%S_minushalf)) DEALLOCATE (results%S_minushalf)
602 IF (ALLOCATED(results%Wad)) DEALLOCATE (results%Wad)
603 IF (ALLOCATED(results%Wda)) DEALLOCATE (results%Wda)
604 IF (ALLOCATED(results%W_diagonal)) DEALLOCATE (results%W_diagonal)
605 IF (ALLOCATED(results%energy)) DEALLOCATE (results%energy)
606 IF (ALLOCATED(results%strength)) DEALLOCATE (results%strength)
607
608 END SUBROUTINE mixed_cdft_result_type_release
609
610! **************************************************************************************************
611!> \brief Initializes the mixed_cdft_work_type
612!> \param matrix the type to initialize
613!> \author Nico Holmberg [01.2017]
614! **************************************************************************************************
615 SUBROUTINE mixed_cdft_work_type_init(matrix)
616 TYPE(mixed_cdft_work_type) :: matrix
617
618 NULLIFY (matrix%w_matrix)
619 NULLIFY (matrix%mixed_matrix_s)
620 NULLIFY (matrix%mixed_mo_coeff)
621 NULLIFY (matrix%density_matrix)
622
623 END SUBROUTINE mixed_cdft_work_type_init
624
625! **************************************************************************************************
626!> \brief Releases arrays within the mixed CDFT work matrix container
627!> \param matrix the container
628!> \author Nico Holmberg [01.2017]
629! **************************************************************************************************
631 TYPE(mixed_cdft_work_type) :: matrix
632
633 INTEGER :: i, j
634
635 IF (ASSOCIATED(matrix%w_matrix)) THEN
636 DO i = 1, SIZE(matrix%w_matrix, 2)
637 DO j = 1, SIZE(matrix%w_matrix, 1)
638 CALL dbcsr_release_p(matrix%w_matrix(j, i)%matrix)
639 END DO
640 END DO
641 DEALLOCATE (matrix%w_matrix)
642 END IF
643 IF (ASSOCIATED(matrix%mixed_matrix_s)) THEN
644 CALL dbcsr_release_p(matrix%mixed_matrix_s)
645 END IF
646 IF (ASSOCIATED(matrix%mixed_mo_coeff)) THEN
647 DO i = 1, SIZE(matrix%mixed_mo_coeff, 2)
648 DO j = 1, SIZE(matrix%mixed_mo_coeff, 1)
649 CALL cp_fm_release(matrix%mixed_mo_coeff(j, i))
650 END DO
651 END DO
652 DEALLOCATE (matrix%mixed_mo_coeff)
653 END IF
654 IF (ASSOCIATED(matrix%density_matrix)) THEN
655 DO i = 1, SIZE(matrix%density_matrix, 2)
656 DO j = 1, SIZE(matrix%density_matrix, 1)
657 CALL dbcsr_release_p(matrix%density_matrix(j, i)%matrix)
658 END DO
659 END DO
660 DEALLOCATE (matrix%density_matrix)
661 END IF
662
663 END SUBROUTINE mixed_cdft_work_type_release
664
665END MODULE mixed_cdft_types
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
subroutine, public dbcsr_release_p(matrix)
...
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
various routines to log and control the output. The idea is that decisions about where to log should ...
subroutine, public cp_logger_release(logger)
releases this logger
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Types for mixed CDFT calculations.
subroutine, public mixed_cdft_type_release(cdft_control)
releases the given mixed_cdft_type
subroutine, public mixed_cdft_result_type_set(results, lowdin, wfn, nonortho, metric, rotation, h, s, wad, wda, w_diagonal, energy, strength, s_minushalf)
Updates arrays within the mixed CDFT result container.
subroutine, public mixed_cdft_result_type_release(results)
Releases all arrays within the mixed CDFT result container.
subroutine, public mixed_cdft_work_type_init(matrix)
Initializes the mixed_cdft_work_type.
subroutine, public mixed_cdft_type_create(cdft_control)
inits the given mixed_cdft_type
subroutine, public mixed_cdft_work_type_release(matrix)
Releases arrays within the mixed CDFT work matrix container.
container for various plainwaves related things
subroutine, public pw_env_release(pw_env, para_env)
releases the given pw_env (see doc/ReferenceCounting.html)
Defines CDFT control structures.
subroutine, public cdft_control_release(cdft_control)
release the cdft_control_type
Define the quickstep kind type and their sub types.
subroutine, public deallocate_qs_kind_set(qs_kind_set)
Destructor routine for a set of qs kinds.
represent a pointer to a 1d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
represent a full matrix
Container for constraint settings to check consistency of force_evals.
Main mixed CDFT control type.
contained for different pw related things
Provides all information about a quickstep kind.