(git:374b731)
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-2024 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_fm_types, ONLY: cp_fm_release,&
22 USE dbcsr_api, ONLY: dbcsr_p_type,&
23 dbcsr_release_p,&
24 dbcsr_type
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
68 ! AO overlap matrix
69 TYPE(dbcsr_type), POINTER :: mixed_matrix_s
70 ! MO coefficients of each CDFT state
71 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: mixed_mo_coeff
72 ! Density matrices of the CDFT states
73 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: density_matrix
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), tag(2)
86 REAL(KIND=dp), POINTER, &
87 DIMENSION(:, :, :) :: cavity, weight
88 REAL(KIND=dp), POINTER, &
89 DIMENSION(:, :, :, :) :: gradients
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
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
105 INTEGER, DIMENSION(:, :), POINTER :: target_list
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, distributed(2), &
138 my_dest_repl(2), dest_tags_repl(2), &
139 more_work
140 INTEGER, DIMENSION(:), POINTER :: bo, expected_work, &
141 prediction_error
142 INTEGER, DIMENSION(:, :), POINTER :: target_list
143 LOGICAL :: recv_work, send_work
144 LOGICAL, DIMENSION(:), POINTER :: recv_work_repl
145 REAL(KIND=dp) :: load_scale, very_overloaded
146 REAL(KIND=dp), POINTER, &
147 DIMENSION(:, :, :) :: cavity, weight
148 REAL(KIND=dp), POINTER, &
149 DIMENSION(:, :, :, :) :: gradients
150 ! Should convert to TYPE(p_buffers), POINTER
151 TYPE(buffers), DIMENSION(:), POINTER :: sendbuff
152 TYPE(p_buffers), DIMENSION(:), POINTER :: recvbuff
153 TYPE(repl_info), DIMENSION(:), POINTER :: recv_info
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, multiplicity, &
206 nconstraint, &
207 run_type
208 INTEGER, DIMENSION(:, :), ALLOCATABLE :: constraint_type
209 INTEGER, POINTER, DIMENSION(:) :: source_list, dest_list, &
210 recv_bo, source_list_save, &
211 dest_list_save
212 INTEGER, POINTER, DIMENSION(:, :) :: source_list_bo, dest_list_bo, &
213 source_bo_save, dest_bo_save
214 LOGICAL :: is_pencil, dlb, &
215 is_special, first_iteration, &
216 calculate_metric, &
217 wfn_overlap_method, &
218 has_unit_metric, &
219 use_lowdin, &
220 do_ci, nonortho_coupling, &
221 identical_constraints, &
222 block_diagonalize
223 REAL(kind=dp) :: eps_rho_rspace, sim_dt, &
224 eps_svd
225 REAL(kind=dp), POINTER, DIMENSION(:, :, :) :: weight, cavity
226 TYPE(cdft_control_type), POINTER :: cdft_control
227 TYPE(buffers), DIMENSION(:), POINTER :: sendbuff
228 TYPE(cp_1d_r_p_type), ALLOCATABLE, &
229 DIMENSION(:, :) :: occupations
230 TYPE(cp_blacs_env_type), POINTER :: blacs_env
231 TYPE(cp_logger_p_type), DIMENSION(:), POINTER :: sub_logger
232 TYPE(mixed_cdft_result_type) :: results
233 TYPE(mixed_cdft_work_type) :: matrix
234 TYPE(mixed_cdft_dlb_type), POINTER :: dlb_control
235 TYPE(pw_env_type), POINTER :: pw_env
236 TYPE(qs_kind_type), DIMENSION(:), &
237 POINTER :: qs_kind_set
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, &
245 is_odd
246 LOGICAL, DIMENSION(:, :), POINTER :: sb
247 INTEGER :: ncdft, &
248 max_nkinds
249 INTEGER, DIMENSION(2, 3) :: bo
250 INTEGER, DIMENSION(:), POINTER :: grid_span, &
251 spherical, &
252 odd
253 INTEGER, DIMENSION(:, :), POINTER :: si, &
254 rs_dims, &
255 atoms, &
256 npts
257 REAL(kind=dp) :: radius
258 REAL(kind=dp), DIMENSION(:), POINTER :: cutoff, &
259 rel_cutoff
260 REAL(kind=dp), DIMENSION(:, :), POINTER :: sr, &
261 coeffs, &
262 cutoffs, &
263 radii
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)) &
314 DEALLOCATE (cdft_control%dest_list)
315 IF (ASSOCIATED(cdft_control%dest_list_save)) &
316 DEALLOCATE (cdft_control%dest_list_save)
317 IF (ASSOCIATED(cdft_control%dest_list_bo)) &
318 DEALLOCATE (cdft_control%dest_list_bo)
319 IF (ASSOCIATED(cdft_control%dest_bo_save)) &
320 DEALLOCATE (cdft_control%dest_bo_save)
321 IF (ASSOCIATED(cdft_control%source_list)) &
322 DEALLOCATE (cdft_control%source_list)
323 IF (ASSOCIATED(cdft_control%source_list_save)) &
324 DEALLOCATE (cdft_control%source_list_save)
325 IF (ASSOCIATED(cdft_control%source_list_bo)) &
326 DEALLOCATE (cdft_control%source_list_bo)
327 IF (ASSOCIATED(cdft_control%source_bo_save)) &
328 DEALLOCATE (cdft_control%source_bo_save)
329 IF (ASSOCIATED(cdft_control%recv_bo)) &
330 DEALLOCATE (cdft_control%recv_bo)
331 IF (ASSOCIATED(cdft_control%weight)) &
332 DEALLOCATE (cdft_control%weight)
333 IF (ASSOCIATED(cdft_control%cavity)) &
334 DEALLOCATE (cdft_control%cavity)
335 IF (ALLOCATED(cdft_control%constraint_type)) &
336 DEALLOCATE (cdft_control%constraint_type)
337 IF (ALLOCATED(cdft_control%occupations)) THEN
338 DO i = 1, SIZE(cdft_control%occupations, 1)
339 DO j = 1, SIZE(cdft_control%occupations, 2)
340 IF (ASSOCIATED(cdft_control%occupations(i, j)%array)) &
341 DEALLOCATE (cdft_control%occupations(i, j)%array)
342 END DO
343 END DO
344 DEALLOCATE (cdft_control%occupations)
345 END IF
346 IF (ASSOCIATED(cdft_control%dlb_control)) &
347 CALL mixed_cdft_dlb_release(cdft_control%dlb_control)
348 IF (ASSOCIATED(cdft_control%sendbuff)) THEN
349 DO i = 1, SIZE(cdft_control%sendbuff)
350 CALL mixed_cdft_buffers_release(cdft_control%sendbuff(i))
351 END DO
352 DEALLOCATE (cdft_control%sendbuff)
353 END IF
354 IF (ASSOCIATED(cdft_control%cdft_control)) THEN
355 CALL cdft_control_release(cdft_control%cdft_control)
356 DEALLOCATE (cdft_control%cdft_control)
357 END IF
358 IF (ASSOCIATED(cdft_control%blacs_env)) &
359 CALL cp_blacs_env_release(cdft_control%blacs_env)
360 IF (ASSOCIATED(cdft_control%qs_kind_set)) &
361 CALL deallocate_qs_kind_set(cdft_control%qs_kind_set)
362 IF (ASSOCIATED(cdft_control%sub_logger)) THEN
363 DO i = 1, SIZE(cdft_control%sub_logger)
364 CALL cp_logger_release(cdft_control%sub_logger(i)%p)
365 END DO
366 DEALLOCATE (cdft_control%sub_logger)
367 END IF
368 CALL mixed_cdft_result_type_release(cdft_control%results)
369 CALL mixed_cdft_work_type_release(cdft_control%matrix)
370 DEALLOCATE (cdft_control)
371
372 END SUBROUTINE mixed_cdft_type_release
373
374! **************************************************************************************************
375!> \brief releases the given load balancing control
376!> \param dlb_control the object to release
377!> \author Nico Holmberg [01.2017]
378! **************************************************************************************************
379 SUBROUTINE mixed_cdft_dlb_release(dlb_control)
380 TYPE(mixed_cdft_dlb_type), POINTER :: dlb_control
381
382 INTEGER :: i
383
384 IF (ASSOCIATED(dlb_control%recv_work_repl)) &
385 DEALLOCATE (dlb_control%recv_work_repl)
386 IF (ASSOCIATED(dlb_control%sendbuff)) THEN
387 DO i = 1, SIZE(dlb_control%sendbuff)
388 CALL mixed_cdft_buffers_release(dlb_control%sendbuff(i))
389 END DO
390 DEALLOCATE (dlb_control%sendbuff)
391 END IF
392 IF (ASSOCIATED(dlb_control%recvbuff)) THEN
393 DO i = 1, SIZE(dlb_control%recvbuff)
394 CALL mixed_cdft_p_buffers_release(dlb_control%recvbuff(i))
395 END DO
396 DEALLOCATE (dlb_control%recvbuff)
397 END IF
398 IF (ASSOCIATED(dlb_control%recv_info)) THEN
399 DO i = 1, SIZE(dlb_control%recv_info)
400 IF (ASSOCIATED(dlb_control%recv_info(i)%matrix_info)) &
401 DEALLOCATE (dlb_control%recv_info(i)%matrix_info)
402 IF (ASSOCIATED(dlb_control%recv_info(i)%target_list)) &
403 DEALLOCATE (dlb_control%recv_info(i)%target_list)
404 END DO
405 DEALLOCATE (dlb_control%recv_info)
406 END IF
407 IF (ASSOCIATED(dlb_control%bo)) &
408 DEALLOCATE (dlb_control%bo)
409 IF (ASSOCIATED(dlb_control%expected_work)) &
410 DEALLOCATE (dlb_control%expected_work)
411 IF (ASSOCIATED(dlb_control%prediction_error)) &
412 DEALLOCATE (dlb_control%prediction_error)
413 IF (ASSOCIATED(dlb_control%target_list)) &
414 DEALLOCATE (dlb_control%target_list)
415 IF (ASSOCIATED(dlb_control%cavity)) &
416 DEALLOCATE (dlb_control%cavity)
417 IF (ASSOCIATED(dlb_control%weight)) &
418 DEALLOCATE (dlb_control%weight)
419 IF (ASSOCIATED(dlb_control%gradients)) &
420 DEALLOCATE (dlb_control%gradients)
421 DEALLOCATE (dlb_control)
422
423 END SUBROUTINE mixed_cdft_dlb_release
424
425! **************************************************************************************************
426!> \brief releases the given buffers
427!> \param buffer the object to release
428!> \author Nico Holmberg [01.2017]
429! **************************************************************************************************
430 SUBROUTINE mixed_cdft_buffers_release(buffer)
431 TYPE(buffers) :: buffer
432
433 IF (ASSOCIATED(buffer%cavity)) &
434 DEALLOCATE (buffer%cavity)
435 IF (ASSOCIATED(buffer%weight)) &
436 DEALLOCATE (buffer%weight)
437 IF (ASSOCIATED(buffer%gradients)) &
438 DEALLOCATE (buffer%gradients)
439
440 END SUBROUTINE mixed_cdft_buffers_release
441
442! **************************************************************************************************
443!> \brief releases the given pointer of buffers
444!> \param p_buffer the object to release
445!> \author Nico Holmberg [01.2017]
446! **************************************************************************************************
447 SUBROUTINE mixed_cdft_p_buffers_release(p_buffer)
448 TYPE(p_buffers) :: p_buffer
449
450 INTEGER :: i
451
452 IF (ASSOCIATED(p_buffer%buffs)) THEN
453 DO i = 1, SIZE(p_buffer%buffs)
454 CALL mixed_cdft_buffers_release(p_buffer%buffs(i))
455 END DO
456 DEALLOCATE (p_buffer%buffs)
457 END IF
458
459 END SUBROUTINE mixed_cdft_p_buffers_release
460
461! **************************************************************************************************
462!> \brief Updates arrays within the mixed CDFT result container
463!> \param results the array container
464!> \param lowdin CDFT electronic couplings from Lowdin orthogonalization
465!> \param wfn CDFT electronic couplings from wavefunction overlap method
466!> \param nonortho CDFT electronic couplings (interaction energies) before orthogonalization
467!> \param metric Reliability metric for CDFT electronic couplings
468!> \param rotation CDFT electronic couplings using the weight function matrix for orthogonalization
469!> \param H The mixed CDFT Hamiltonian
470!> \param S The overlap matrix between CDFT states
471!> \param Wad Integrals of type <Psi_a | w_d(r) | Psi_d>
472!> \param Wda Integrals of type <Psi_d | w_a(r) | Psi_a>
473!> \param W_diagonal Values of the CDFT constraints
474!> \param energy Energies of the CDFT states
475!> \param strength Lagrangian multipliers of the CDFT states
476!> \param S_minushalf S^(-1/2)
477!> \author Nico Holmberg [11.2017]
478! **************************************************************************************************
479 SUBROUTINE mixed_cdft_result_type_set(results, lowdin, wfn, nonortho, metric, rotation, &
480 H, S, Wad, Wda, W_diagonal, energy, strength, S_minushalf)
481 TYPE(mixed_cdft_result_type) :: results
482 REAL(kind=dp), DIMENSION(:), OPTIONAL :: lowdin, wfn, nonortho
483 REAL(kind=dp), DIMENSION(:, :), OPTIONAL :: metric
484 REAL(kind=dp), DIMENSION(:), OPTIONAL :: rotation
485 REAL(kind=dp), DIMENSION(:, :), OPTIONAL :: h, s, wad, wda, w_diagonal
486 REAL(kind=dp), DIMENSION(:), OPTIONAL :: energy
487 REAL(kind=dp), DIMENSION(:, :), OPTIONAL :: strength, s_minushalf
488
489 IF (PRESENT(lowdin)) THEN
490 IF (ALLOCATED(results%lowdin)) DEALLOCATE (results%lowdin)
491 ALLOCATE (results%lowdin(SIZE(lowdin)))
492 results%lowdin(:) = lowdin(:)
493 END IF
494 IF (PRESENT(wfn)) THEN
495 IF (ALLOCATED(results%wfn)) DEALLOCATE (results%wfn)
496 ALLOCATE (results%wfn(SIZE(wfn)))
497 results%wfn(:) = wfn(:)
498 END IF
499 IF (PRESENT(nonortho)) THEN
500 IF (ALLOCATED(results%nonortho)) DEALLOCATE (results%nonortho)
501 ALLOCATE (results%nonortho(SIZE(nonortho)))
502 results%nonortho(:) = nonortho(:)
503 END IF
504 IF (PRESENT(rotation)) THEN
505 IF (ALLOCATED(results%rotation)) DEALLOCATE (results%rotation)
506 ALLOCATE (results%rotation(SIZE(rotation)))
507 results%rotation(:) = rotation(:)
508 END IF
509 IF (PRESENT(energy)) THEN
510 IF (ALLOCATED(results%energy)) DEALLOCATE (results%energy)
511 ALLOCATE (results%energy(SIZE(energy)))
512 results%energy(:) = energy(:)
513 END IF
514 IF (PRESENT(strength)) THEN
515 IF (ALLOCATED(results%strength)) DEALLOCATE (results%strength)
516 ALLOCATE (results%strength(SIZE(strength, 1), SIZE(strength, 2)))
517 results%strength(:, :) = strength(:, :)
518 END IF
519 IF (PRESENT(metric)) THEN
520 IF (ALLOCATED(results%metric)) DEALLOCATE (results%metric)
521 ALLOCATE (results%metric(SIZE(metric, 1), SIZE(metric, 2)))
522 results%metric(:, :) = metric(:, :)
523 END IF
524 IF (PRESENT(h)) THEN
525 IF (ALLOCATED(results%H)) DEALLOCATE (results%H)
526 ALLOCATE (results%H(SIZE(h, 1), SIZE(h, 2)))
527 results%H(:, :) = h(:, :)
528 END IF
529 IF (PRESENT(s)) THEN
530 IF (ALLOCATED(results%S)) DEALLOCATE (results%S)
531 ALLOCATE (results%S(SIZE(s, 1), SIZE(s, 2)))
532 results%S(:, :) = s(:, :)
533 END IF
534 IF (PRESENT(s_minushalf)) THEN
535 IF (ALLOCATED(results%S_minushalf)) DEALLOCATE (results%S_minushalf)
536 ALLOCATE (results%S_minushalf(SIZE(s_minushalf, 1), SIZE(s_minushalf, 2)))
537 results%S_minushalf(:, :) = s_minushalf(:, :)
538 END IF
539 IF (PRESENT(wad)) THEN
540 IF (ALLOCATED(results%Wad)) DEALLOCATE (results%Wad)
541 ALLOCATE (results%Wad(SIZE(wad, 1), SIZE(wad, 2)))
542 results%Wad(:, :) = wad(:, :)
543 END IF
544 IF (PRESENT(wda)) THEN
545 IF (ALLOCATED(results%Wda)) DEALLOCATE (results%Wda)
546 ALLOCATE (results%Wda(SIZE(wda, 1), SIZE(wda, 2)))
547 results%Wda(:, :) = wda(:, :)
548 END IF
549 IF (PRESENT(w_diagonal)) THEN
550 IF (ALLOCATED(results%W_diagonal)) DEALLOCATE (results%W_diagonal)
551 ALLOCATE (results%W_diagonal(SIZE(w_diagonal, 1), SIZE(w_diagonal, 2)))
552 results%W_diagonal(:, :) = w_diagonal(:, :)
553 END IF
554
555 END SUBROUTINE mixed_cdft_result_type_set
556
557! **************************************************************************************************
558!> \brief Releases all arrays within the mixed CDFT result container
559!> \param results the container
560!> \author Nico Holmberg [11.2017]
561! **************************************************************************************************
563 TYPE(mixed_cdft_result_type) :: results
564
565 IF (ALLOCATED(results%lowdin)) DEALLOCATE (results%lowdin)
566 IF (ALLOCATED(results%wfn)) DEALLOCATE (results%wfn)
567 IF (ALLOCATED(results%metric)) DEALLOCATE (results%metric)
568 IF (ALLOCATED(results%nonortho)) DEALLOCATE (results%nonortho)
569 IF (ALLOCATED(results%rotation)) DEALLOCATE (results%rotation)
570 IF (ALLOCATED(results%H)) DEALLOCATE (results%H)
571 IF (ALLOCATED(results%S)) DEALLOCATE (results%S)
572 IF (ALLOCATED(results%S_minushalf)) DEALLOCATE (results%S_minushalf)
573 IF (ALLOCATED(results%Wad)) DEALLOCATE (results%Wad)
574 IF (ALLOCATED(results%Wda)) DEALLOCATE (results%Wda)
575 IF (ALLOCATED(results%W_diagonal)) DEALLOCATE (results%W_diagonal)
576 IF (ALLOCATED(results%energy)) DEALLOCATE (results%energy)
577 IF (ALLOCATED(results%strength)) DEALLOCATE (results%strength)
578
579 END SUBROUTINE mixed_cdft_result_type_release
580
581! **************************************************************************************************
582!> \brief Initializes the mixed_cdft_work_type
583!> \param matrix the type to initialize
584!> \author Nico Holmberg [01.2017]
585! **************************************************************************************************
586 SUBROUTINE mixed_cdft_work_type_init(matrix)
587 TYPE(mixed_cdft_work_type) :: matrix
588
589 NULLIFY (matrix%w_matrix)
590 NULLIFY (matrix%mixed_matrix_s)
591 NULLIFY (matrix%mixed_mo_coeff)
592 NULLIFY (matrix%density_matrix)
593
594 END SUBROUTINE mixed_cdft_work_type_init
595
596! **************************************************************************************************
597!> \brief Releases arrays within the mixed CDFT work matrix container
598!> \param matrix the container
599!> \author Nico Holmberg [01.2017]
600! **************************************************************************************************
602 TYPE(mixed_cdft_work_type) :: matrix
603
604 INTEGER :: i, j
605
606 IF (ASSOCIATED(matrix%w_matrix)) THEN
607 DO i = 1, SIZE(matrix%w_matrix, 2)
608 DO j = 1, SIZE(matrix%w_matrix, 1)
609 CALL dbcsr_release_p(matrix%w_matrix(j, i)%matrix)
610 END DO
611 END DO
612 DEALLOCATE (matrix%w_matrix)
613 END IF
614 IF (ASSOCIATED(matrix%mixed_matrix_s)) THEN
615 CALL dbcsr_release_p(matrix%mixed_matrix_s)
616 END IF
617 IF (ASSOCIATED(matrix%mixed_mo_coeff)) THEN
618 DO i = 1, SIZE(matrix%mixed_mo_coeff, 2)
619 DO j = 1, SIZE(matrix%mixed_mo_coeff, 1)
620 CALL cp_fm_release(matrix%mixed_mo_coeff(j, i))
621 END DO
622 END DO
623 DEALLOCATE (matrix%mixed_mo_coeff)
624 END IF
625 IF (ASSOCIATED(matrix%density_matrix)) THEN
626 DO i = 1, SIZE(matrix%density_matrix, 2)
627 DO j = 1, SIZE(matrix%density_matrix, 1)
628 CALL dbcsr_release_p(matrix%density_matrix(j, i)%matrix)
629 END DO
630 END DO
631 DEALLOCATE (matrix%density_matrix)
632 END IF
633
634 END SUBROUTINE mixed_cdft_work_type_release
635
636END 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
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.