(git:71c3ab0)
Loading...
Searching...
No Matches
qs_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 Defines CDFT control structures
10!> \par History
11!> separated from cp_control_types [03.2017]
12!> \author Nico Holmberg [03.2017]
13! **************************************************************************************************
16 USE cp_dbcsr_api, ONLY: dbcsr_p_type
17 USE cp_fm_types, ONLY: cp_fm_type
26 USE kinds, ONLY: default_path_length,&
27 dp
30 USE pw_types, ONLY: pw_r3d_rs_type
32#include "./base/base_uses.f90"
33
34 IMPLICIT NONE
35
36 PRIVATE
37
38! **************************************************************************************************
39!> \brief some parameters useful for becke_constraints
40!> \param aij pairwise parameters used to adjust the Becke cell boundaries built from atomic radii
41!> \param adjust logical which determines if the Becke potential is adjusted with atomic radii
42!> \param cavity the Gaussian confinement cavity: the constraint is nonzero outside this cavity
43!> \param cavity_confine logical which determines if cavity confinement is active
44!> \param cavity_mat a compacted version of cavity
45!> \param cavity_shape the confinement cavity shape id
46!> \param cavity_env the structure used to build the Gaussian cavity
47!> \param confine_bounds grid point indices outside which the constraint vanishes along Z-axis
48!> \param cutoff_type the cutoff type to use for building the constraint
49!> \param cutoffs element specific cutoffs
50!> \param cutoffs_tmp same as cutoffs but a temporary read during parsing of this type
51!> \param eps_cavity threshold used screen small values of the Gaussian cavity density
52!> \param in_memory logical which determines if the gradients of the Becke potential should be
53!> \param print_cavity logical to print the Gaussian confinement cavity
54!> \param radii permanent copy of radii_tmp
55!> \param radii_tmp temporary list of element specific atomic radii used to adjust the Becke cells
56!> \param rcavity an optional global radius parameter used to define the Gaussian confinement cavity
57!> \param rglobal global cutoff to use for building the constraint
58!> computed simultaneously with the potential instead of separately
59!> \param should_skip logical which determines is grid points should be skipped if all constraint
60!> atoms are found to reside beyond the cutoff distance from it
61!> \param use_bohr decides whether to use angstrom or bohr units for the confinement cavity radius
62! **************************************************************************************************
63 ! Utility vector container for building becke constraint
64 TYPE becke_vector_buffer
65 LOGICAL :: store_vectors = .false.
66 REAL(kind=dp), ALLOCATABLE, &
67 DIMENSION(:) :: distances
68 REAL(kind=dp), ALLOCATABLE, &
69 DIMENSION(:, :) :: distance_vecs, &
70 position_vecs, &
71 r12
72 REAL(kind=dp), ALLOCATABLE, &
73 DIMENSION(:, :, :) :: pair_dist_vecs
74 END TYPE becke_vector_buffer
75
77 INTEGER :: cavity_shape = -1, cutoff_type = -1, &
78 confine_bounds(2) = -1
79 LOGICAL :: in_memory = .false., &
80 adjust = .false., cavity_confine = .false., &
81 should_skip = .false., print_cavity = .false., &
82 use_bohr = .false.
83 REAL(kind=dp) :: rglobal = -1.0_dp, &
84 rcavity = -1.0_dp, eps_cavity = -1.0_dp
85 REAL(kind=dp), DIMENSION(:), POINTER :: cutoffs => null(), cutoffs_tmp => null(), &
86 radii_tmp => null(), radii => null()
87 REAL(kind=dp), POINTER, &
88 DIMENSION(:, :) :: aij => null()
89 REAL(kind=dp), POINTER, &
90 DIMENSION(:, :, :) :: cavity_mat => null()
91 TYPE(becke_vector_buffer) :: vector_buffer = becke_vector_buffer()
92 TYPE(hirshfeld_type), POINTER :: cavity_env => null()
93 TYPE(pw_r3d_rs_type) :: cavity = pw_r3d_rs_type()
95
96! **************************************************************************************************
97! \brief control parameters for Hirshfeld constraints
98!> \param gaussian_shape the type of Gaussian to use (shape_function Gaussian)
99!> \param radii list of Gaussian radii for different atomic kinds
100!> \param radius Gaussian radius parameter
101!> \param shape_function the constraint type: atomic density or single Gaussian
102!> \param use_bohr determines whether to use angstrom or bohr units for the radii of Gaussians
103!> \param use_atomic_cutoff Logical to control use of ATOMIC_CUTOFF
104!> \param atomic_cutoff Numerical cutoff for calculation of Hirshfeld densities
105!> \param atoms_memory Number of atomic gradients to store in memory
106!> \param eps_cutoff Numerical cutoff for calculation of weight function
107!> \param print_density Logical to control printing of Hirshfeld densities to .cube file
108!> \param hirshfeld_env auxiliary type storing information about the Gaussians
109! **************************************************************************************************
111 INTEGER :: gaussian_shape = -1, shape_function = -1, atoms_memory = -1
112 LOGICAL :: use_bohr = .false., print_density = .false., use_atomic_cutoff = .false.
113 REAL(kind=dp) :: radius = -1.0_dp, eps_cutoff = -1.0_dp, atomic_cutoff = -1.0_dp
114 REAL(kind=dp), DIMENSION(:), POINTER :: radii => null()
115 TYPE(hirshfeld_type), POINTER :: hirshfeld_env => null()
117
118! **************************************************************************************************
119!> \brief control parameters for CDFT simulations
120!> \param fragment_a_fname filename of cube file holding the total electron density
121!> of isolated fragment a
122!> \param fragment_b_fname filename of cube file holding the total electron density
123!> of isolated fragment b
124!> \param fragment_a_spin_fname filename of cube file holding the spin difference density
125!> of isolated fragment a
126!> \param fragment_b_spin_fname filename of cube file holding the spin difference density
127!> of isolated fragment b
128!> \param ref_count the ref count
129!> \param need_pot logical which determines if the Becke potential needs to be built
130!> \param save_pot logical which determines if the Becke potential should be saved until forces
131!> have been evaluated
132!> \param atomic_charges flag that determines if atomic CDFT charges should be computed
133!> \param total_steps counter to keep track of the total number of SCF steps
134!> \param type the type of CDFT constraint to use
135!> \param precond_freq preconditioner can be used if SCF converged in less than precond_freq steps
136!> \param nreused determines how many times the current OT preconditioner has been reused
137!> \param max_reuse the same preconditioner can be used a maximum of max_reuse times
138!> \param purge_freq determines how large nbad_conv can grow before purging the wfn/constraint history
139!> \param nbad_conv a running counter keeping track of the number of CDFT SCF loops when the first
140!> CDFT SCF iteration required more than 1 outer SCF loop. Reset when convergence is
141!> smooth
142!> \param purge_offset purging is only allowed when more than purge_offset steps have passed since
143!> last purge
144!> \param istep a counter to keep track of how many steps have passed since the last purge
145!> \param ienergy a counter tracking the total number of CDFT energy evaluations
146!> \param natoms the total number of atoms included in constraint/dummy atom groups
147!> \param atoms list of constraint atoms
148!> \param need_pot logical which determines if the constraint potential needs to be built
149!> \param save_pot logical which determines if the constraint potential should be saved until forces
150!> have been evaluated
151!> \param do_et logical which determines if a ET coupling calculation was requested
152!> \param reuse_precond logical which determines if a preconditioner can be reused
153!> \param purge_history logical which determines if the wfn/constraint history can be purged
154!> \param should_purge logical which determines if purging should take place after this CDFT SCF loop
155!> \param calculate_metric logical which determines if the ET coupling reliability metric is computed
156!> \param fragment_density use isolated fragment densities as a reference for the constraint
157!> \param fragments_integrated logical to determine if the fragment densities have been integrated
158!> \param flip_fragment should the spin difference density of the either fragment be flipped
159!> \param transfer_pot logical which determines if constraint should be saved for reuse later
160!> \param external_control logical which determines if the constraint has already been built
161!> in a mixed_env that holds multiple CDFT states
162!> \param first_iteration a flag to mark the first iteration for printing of additional data
163!> \param print_weight logical which determines if CDFT weight functions should be saved to a file
164!> \param in_memory logical which determines if the gradients of the Becke potential should be
165!> \param is_constraint list of logicals which determines if an atom is included in a constraint group
166!> \param strength Lagrangian multipliers of the constraints
167!> \param target target values of the constraints
168!> \param value integrated values of the constraints
169!> \param charges_fragment atomic partial charges computed from the isolated fragment densities
170!> \param becke_control control parameters for Becke constraints
171!> \param group container for atom groups each defining their own constraint
172!> \param occupations occupation numbers in case non-uniform MO occupation (for do_et)
173!> \param mo_coeff save the MO coeffs (for do_et)
174!> \param matrix_s save the overlap matrix (for do_et)
175!> \param wmat matrix representation of the weight function (for do_et)
176!> \param matrix_p save the density matrix (for calculate_metric)
177!> \param hirshfeld_control control parameters for Hirshfeld constraints
178!> \param constraint_control the outer_scf_control_type for the CDFT constraints
179!> \param ot_control the outer_scf_control_type for OT where data is stashed when outside the OT
180!> outer loop
181!> \param charge atomic CDFT real space potentials needed to calculate CDFT charges
182!> \param fragments container for isolated fragment densities read from cube files
183!> \param constraint holds information about the CDFT SCF loop
184! **************************************************************************************************
185 ! To build multiple constraints
187 ! Atoms of this constraint group
188 INTEGER, POINTER, DIMENSION(:) :: atoms => null()
189 ! Constraint type: charge constraint, magnetization density constraint, or spin channel specific constraint
190 INTEGER :: constraint_type = -1
191 ! Is the constraint fragment based
192 LOGICAL :: is_fragment_constraint = .false.
193 ! Temporary array holding a component of the weight function gradient that only includes
194 ! terms defined on constraint atoms
195 REAL(kind=dp), ALLOCATABLE, &
196 DIMENSION(:, :) :: d_sum_const_dr
197 ! Coefficients that determine how to sum up the atoms to form the constraint
198 REAL(kind=dp), POINTER, DIMENSION(:) :: coeff => null()
199 ! Result of integration dw/dR * rho_r dr where dw/dR is the weight function gradient
200 REAL(kind=dp), POINTER, &
201 DIMENSION(:, :) :: integrated => null()
202 ! Atomic gradients of the weight function at every grid point
203 REAL(kind=dp), POINTER, &
204 DIMENSION(:, :, :, :) :: gradients => null()
205 REAL(kind=dp), POINTER, &
206 DIMENSION(:, :, :, :) :: gradients_x => null()
207 REAL(kind=dp), POINTER, &
208 DIMENSION(:, :, :, :) :: gradients_y => null()
209 REAL(kind=dp), POINTER, &
210 DIMENSION(:, :, :, :) :: gradients_z => null()
211 ! The weight function of this constraint group
212 TYPE(pw_r3d_rs_type), POINTER :: weight => null()
213 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: hw_rho_atomic => null()
214 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: hw_rho_atomic_dr => null()
215 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: hw_rho_atomic_charge => null()
216 TYPE(pw_r3d_rs_type) :: hw_rho_total_constraint = pw_r3d_rs_type()
217 END TYPE cdft_group_type
218
220 CHARACTER(LEN=default_path_length) :: fragment_a_fname = "", &
221 fragment_b_fname = "", &
222 fragment_a_spin_fname = "", &
223 fragment_b_spin_fname = ""
224 INTEGER :: ref_count = -1, total_steps = -1, TYPE = -1, &
225 precond_freq = -1, nreused = -1, max_reuse = -1, &
226 purge_freq = -1, nbad_conv = -1, purge_offset = -1, &
227 istep = -1, ienergy = -1, natoms = -1
228 INTEGER, POINTER, DIMENSION(:) :: atoms => null()
229 LOGICAL :: need_pot = .false., save_pot = .false., do_et = .false., &
230 reuse_precond = .false., purge_history = .false., &
231 should_purge = .false., calculate_metric = .false., &
232 atomic_charges = .false., fragment_density = .false., &
233 fragments_integrated = .false., flip_fragment(2) = .false., &
234 transfer_pot = .false., external_control = .false., &
235 first_iteration = .false., print_weight = .false., in_memory = .false.
236 LOGICAL, POINTER, DIMENSION(:) :: is_constraint => null()
237 REAL(kind=dp), DIMENSION(:), POINTER :: strength => null(), TARGET => null(), value => null()
238 REAL(kind=dp), POINTER, &
239 DIMENSION(:, :) :: charges_fragment => null()
240 TYPE(becke_constraint_type), POINTER :: becke_control => null()
241 TYPE(cdft_group_type), POINTER, &
242 DIMENSION(:) :: group => null()
243 TYPE(cp_1d_r_p_type), ALLOCATABLE, &
244 DIMENSION(:) :: occupations
245 TYPE(cp_fm_type), DIMENSION(:), &
246 POINTER :: mo_coeff => null()
247 TYPE(dbcsr_p_type) :: matrix_s
248 TYPE(dbcsr_p_type), DIMENSION(:), &
249 POINTER :: wmat => null(), matrix_p => null()
251 POINTER :: hirshfeld_control => null()
252 TYPE(outer_scf_control_type) :: constraint_control = outer_scf_control_type(), ot_control = outer_scf_control_type()
253 TYPE(pw_r3d_rs_type), POINTER, &
254 DIMENSION(:) :: charge => null()
255 TYPE(pw_r3d_rs_type), POINTER, &
256 DIMENSION(:, :) :: fragments => null()
258 TYPE(pw_r3d_rs_type) :: hw_rho_total = pw_r3d_rs_type()
259 END TYPE cdft_control_type
260
261 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'qs_cdft_types'
262
263 ! Public data types
264
265 PUBLIC :: becke_constraint_type, &
269
270 ! Public subroutines
271
272 PUBLIC :: cdft_control_create, &
274
275CONTAINS
276
277! **************************************************************************************************
278!> \brief create the becke_constraint_type
279!> \param becke_control the structure to create
280!> \par History
281!> 02.2007 created [Florian Schiffmann]
282! **************************************************************************************************
283 SUBROUTINE becke_control_create(becke_control)
284 TYPE(becke_constraint_type), INTENT(OUT) :: becke_control
285
286 becke_control%adjust = .false.
287 becke_control%cutoff_type = becke_cutoff_global
288 becke_control%cavity_confine = .false.
289 becke_control%should_skip = .false.
290 becke_control%print_cavity = .false.
291 becke_control%in_memory = .false.
292 becke_control%use_bohr = .false.
293 becke_control%confine_bounds = 0
294 becke_control%rcavity = 3.0_dp
295 becke_control%rglobal = 6.0_dp
296 becke_control%eps_cavity = 1.0e-6_dp
297 becke_control%cavity_shape = radius_single
298 becke_control%vector_buffer%store_vectors = .true.
299 NULLIFY (becke_control%aij)
300 NULLIFY (becke_control%cavity_mat)
301 NULLIFY (becke_control%cavity_env)
302 NULLIFY (becke_control%cutoffs)
303 NULLIFY (becke_control%cutoffs_tmp)
304 NULLIFY (becke_control%radii)
305 NULLIFY (becke_control%radii_tmp)
306 END SUBROUTINE becke_control_create
307
308! **************************************************************************************************
309!> \brief release the becke_constraint_type
310!> \param becke_control the structure to release
311!> \par History
312!> 02.2007 created [Florian Schiffmann]
313! **************************************************************************************************
314 SUBROUTINE becke_control_release(becke_control)
315 TYPE(becke_constraint_type), INTENT(INOUT) :: becke_control
316
317 IF (becke_control%vector_buffer%store_vectors) THEN
318 IF (ALLOCATED(becke_control%vector_buffer%distances)) THEN
319 DEALLOCATE (becke_control%vector_buffer%distances)
320 END IF
321 IF (ALLOCATED(becke_control%vector_buffer%distance_vecs)) THEN
322 DEALLOCATE (becke_control%vector_buffer%distance_vecs)
323 END IF
324 IF (ALLOCATED(becke_control%vector_buffer%position_vecs)) THEN
325 DEALLOCATE (becke_control%vector_buffer%position_vecs)
326 END IF
327 IF (ALLOCATED(becke_control%vector_buffer%R12)) THEN
328 DEALLOCATE (becke_control%vector_buffer%R12)
329 END IF
330 IF (ALLOCATED(becke_control%vector_buffer%pair_dist_vecs)) THEN
331 DEALLOCATE (becke_control%vector_buffer%pair_dist_vecs)
332 END IF
333 END IF
334 IF (ASSOCIATED(becke_control%cutoffs)) THEN
335 DEALLOCATE (becke_control%cutoffs)
336 END IF
337 IF (ASSOCIATED(becke_control%cutoffs_tmp)) THEN
338 DEALLOCATE (becke_control%cutoffs_tmp)
339 END IF
340 IF (ASSOCIATED(becke_control%radii_tmp)) THEN
341 DEALLOCATE (becke_control%radii_tmp)
342 END IF
343 IF (ASSOCIATED(becke_control%radii)) THEN
344 DEALLOCATE (becke_control%radii)
345 END IF
346 IF (ASSOCIATED(becke_control%aij)) THEN
347 DEALLOCATE (becke_control%aij)
348 END IF
349 IF (ASSOCIATED(becke_control%cavity_mat)) THEN
350 DEALLOCATE (becke_control%cavity_mat)
351 END IF
352 IF (becke_control%cavity_confine) THEN
353 CALL release_hirshfeld_type(becke_control%cavity_env)
354 END IF
355
356 END SUBROUTINE becke_control_release
357
358! **************************************************************************************************
359!> \brief create the cdft_control_type
360!> \param cdft_control the structure to create
361!> \par History
362!> 12.2015 created [Nico Holmberg]
363! **************************************************************************************************
364 SUBROUTINE cdft_control_create(cdft_control)
365 TYPE(cdft_control_type), INTENT(OUT) :: cdft_control
366
367 cdft_control%total_steps = 0
368 NULLIFY (cdft_control%strength)
369 NULLIFY (cdft_control%target)
370 NULLIFY (cdft_control%value)
371 NULLIFY (cdft_control%atoms)
372 NULLIFY (cdft_control%is_constraint)
373 NULLIFY (cdft_control%charges_fragment)
374 NULLIFY (cdft_control%fragments)
375 NULLIFY (cdft_control%group)
376 NULLIFY (cdft_control%charge)
377 cdft_control%natoms = 0
378 cdft_control%type = outer_scf_none
379 cdft_control%need_pot = .true.
380 cdft_control%save_pot = .false.
381 cdft_control%transfer_pot = .false.
382 cdft_control%atomic_charges = .false.
383 cdft_control%first_iteration = .true.
384 cdft_control%fragment_density = .false.
385 cdft_control%fragments_integrated = .false.
386 cdft_control%flip_fragment = .false.
387 cdft_control%external_control = .false.
388 cdft_control%do_et = .false.
389 cdft_control%reuse_precond = .false.
390 cdft_control%nreused = 0
391 cdft_control%precond_freq = 0
392 cdft_control%max_reuse = 0
393 cdft_control%should_purge = .false.
394 cdft_control%purge_history = .false.
395 cdft_control%calculate_metric = .false.
396 cdft_control%in_memory = .false.
397 cdft_control%purge_freq = 0
398 cdft_control%nbad_conv = 0
399 cdft_control%purge_offset = 0
400 cdft_control%istep = 0
401 cdft_control%ienergy = 0
402 NULLIFY (cdft_control%becke_control)
403 ALLOCATE (cdft_control%becke_control)
404 CALL becke_control_create(cdft_control%becke_control)
405 NULLIFY (cdft_control%hirshfeld_control)
406 ALLOCATE (cdft_control%hirshfeld_control)
407 CALL hirshfeld_control_create(cdft_control%hirshfeld_control)
408 NULLIFY (cdft_control%wmat)
409 NULLIFY (cdft_control%matrix_s%matrix)
410 NULLIFY (cdft_control%mo_coeff)
411 NULLIFY (cdft_control%matrix_p)
412 ! Outer SCF default settings
413 cdft_control%ot_control%have_scf = .false.
414 cdft_control%ot_control%max_scf = 0
415 cdft_control%ot_control%eps_scf = 0.0_dp
416 cdft_control%ot_control%step_size = 0.0_dp
417 cdft_control%ot_control%type = -1
418 cdft_control%ot_control%optimizer = -1
419 cdft_control%ot_control%diis_buffer_length = -1
420 NULLIFY (cdft_control%ot_control%cdft_opt_control)
421 cdft_control%constraint_control%have_scf = .false.
422 cdft_control%constraint_control%max_scf = 0
423 cdft_control%constraint_control%eps_scf = 0.0_dp
424 cdft_control%constraint_control%step_size = 0.0_dp
425 cdft_control%constraint_control%type = -1
426 cdft_control%constraint_control%optimizer = -1
427 cdft_control%constraint_control%diis_buffer_length = -1
428 NULLIFY (cdft_control%constraint_control%cdft_opt_control)
429 cdft_control%constraint%iter_count = 0
430 NULLIFY (cdft_control%constraint%variables)
431 NULLIFY (cdft_control%constraint%gradient)
432 NULLIFY (cdft_control%constraint%energy)
433 NULLIFY (cdft_control%constraint%count)
434 NULLIFY (cdft_control%constraint%inv_jacobian)
435 cdft_control%constraint%deallocate_jacobian = .true.
436 END SUBROUTINE cdft_control_create
437
438! **************************************************************************************************
439!> \brief release the cdft_control_type
440!> \param cdft_control the structure to release
441!> \par History
442!> 12.2015 created [Nico Holmberg]
443! **************************************************************************************************
444 SUBROUTINE cdft_control_release(cdft_control)
445 TYPE(cdft_control_type), INTENT(INOUT) :: cdft_control
446
447 INTEGER :: i
448
449 ! Constraint settings
450 IF (ASSOCIATED(cdft_control%atoms)) THEN
451 DEALLOCATE (cdft_control%atoms)
452 END IF
453 IF (ASSOCIATED(cdft_control%strength)) THEN
454 DEALLOCATE (cdft_control%strength)
455 END IF
456 IF (ASSOCIATED(cdft_control%target)) THEN
457 DEALLOCATE (cdft_control%target)
458 END IF
459 IF (ASSOCIATED(cdft_control%value)) THEN
460 DEALLOCATE (cdft_control%value)
461 END IF
462 IF (ASSOCIATED(cdft_control%charges_fragment)) THEN
463 DEALLOCATE (cdft_control%charges_fragment)
464 END IF
465 IF (ASSOCIATED(cdft_control%fragments)) THEN
466 DEALLOCATE (cdft_control%fragments)
467 END IF
468 IF (ASSOCIATED(cdft_control%is_constraint)) THEN
469 DEALLOCATE (cdft_control%is_constraint)
470 END IF
471 IF (ASSOCIATED(cdft_control%charge)) THEN
472 DEALLOCATE (cdft_control%charge)
473 END IF
474 ! Constraint atom groups
475 IF (ASSOCIATED(cdft_control%group)) THEN
476 DO i = 1, SIZE(cdft_control%group)
477 IF (ASSOCIATED(cdft_control%group(i)%atoms)) THEN
478 DEALLOCATE (cdft_control%group(i)%atoms)
479 END IF
480 IF (ASSOCIATED(cdft_control%group(i)%coeff)) THEN
481 DEALLOCATE (cdft_control%group(i)%coeff)
482 END IF
483 IF (ALLOCATED(cdft_control%group(i)%d_sum_const_dR)) THEN
484 DEALLOCATE (cdft_control%group(i)%d_sum_const_dR)
485 END IF
486 IF (cdft_control%type == outer_scf_becke_constraint) THEN
487 IF (ASSOCIATED(cdft_control%group(i)%gradients)) THEN
488 DEALLOCATE (cdft_control%group(i)%gradients)
489 END IF
490 ELSE IF (cdft_control%type == outer_scf_hirshfeld_constraint) THEN
491 IF (ASSOCIATED(cdft_control%group(i)%gradients_x)) THEN
492 DEALLOCATE (cdft_control%group(i)%gradients_x)
493 END IF
494 IF (ASSOCIATED(cdft_control%group(i)%gradients_y)) THEN
495 DEALLOCATE (cdft_control%group(i)%gradients_y)
496 END IF
497 IF (ASSOCIATED(cdft_control%group(i)%gradients_z)) THEN
498 DEALLOCATE (cdft_control%group(i)%gradients_z)
499 END IF
500 END IF
501 IF (ASSOCIATED(cdft_control%group(i)%integrated)) THEN
502 DEALLOCATE (cdft_control%group(i)%integrated)
503 END IF
504 END DO
505 DEALLOCATE (cdft_control%group)
506 END IF
507 ! Constraint type specific deallocations
508 IF (ASSOCIATED(cdft_control%becke_control)) THEN
509 CALL becke_control_release(cdft_control%becke_control)
510 DEALLOCATE (cdft_control%becke_control)
511 END IF
512 IF (ASSOCIATED(cdft_control%hirshfeld_control)) THEN
513 CALL hirshfeld_control_release(cdft_control%hirshfeld_control)
514 DEALLOCATE (cdft_control%hirshfeld_control)
515 END IF
516 ! Release OUTER_SCF types
517 CALL cdft_opt_type_release(cdft_control%ot_control%cdft_opt_control)
518 CALL cdft_opt_type_release(cdft_control%constraint_control%cdft_opt_control)
519 IF (ASSOCIATED(cdft_control%constraint%variables)) THEN
520 DEALLOCATE (cdft_control%constraint%variables)
521 END IF
522 IF (ASSOCIATED(cdft_control%constraint%count)) THEN
523 DEALLOCATE (cdft_control%constraint%count)
524 END IF
525 IF (ASSOCIATED(cdft_control%constraint%gradient)) THEN
526 DEALLOCATE (cdft_control%constraint%gradient)
527 END IF
528 IF (ASSOCIATED(cdft_control%constraint%energy)) THEN
529 DEALLOCATE (cdft_control%constraint%energy)
530 END IF
531 IF (ASSOCIATED(cdft_control%constraint%inv_jacobian)) THEN
532 DEALLOCATE (cdft_control%constraint%inv_jacobian)
533 END IF
534 ! Storage for mixed CDFT calculations
535 IF (ALLOCATED(cdft_control%occupations)) THEN
536 DO i = 1, SIZE(cdft_control%occupations)
537 IF (ASSOCIATED(cdft_control%occupations(i)%array)) THEN
538 DEALLOCATE (cdft_control%occupations(i)%array)
539 END IF
540 END DO
541 DEALLOCATE (cdft_control%occupations)
542 END IF
543 ! Release control
544 cdft_control%type = outer_scf_none
545
546 END SUBROUTINE cdft_control_release
547
548! **************************************************************************************************
549!> \brief create the hirshfeld_constraint_type
550!> \param hirshfeld_control the structure to create
551!> \par History
552!> 09.2018 created [Nico Holmberg]
553! **************************************************************************************************
554 SUBROUTINE hirshfeld_control_create(hirshfeld_control)
555 TYPE(hirshfeld_constraint_type), INTENT(OUT) :: hirshfeld_control
556
557 hirshfeld_control%use_bohr = .false.
558 hirshfeld_control%print_density = .false.
559 hirshfeld_control%use_atomic_cutoff = .true.
560 hirshfeld_control%radius = 3.0_dp
561 hirshfeld_control%eps_cutoff = 1.0e-12_dp
562 hirshfeld_control%atomic_cutoff = 1.0e-12_dp
563 hirshfeld_control%shape_function = shape_function_gaussian
564 hirshfeld_control%atoms_memory = 80
565 hirshfeld_control%gaussian_shape = radius_single
566 NULLIFY (hirshfeld_control%hirshfeld_env)
567 NULLIFY (hirshfeld_control%radii)
568
569 END SUBROUTINE hirshfeld_control_create
570
571! **************************************************************************************************
572!> \brief release the hirshfeld_constraint_type
573!> \param hirshfeld_control the structure to release
574!> \par History
575!> 09.2018 created [Nico Holmberg]
576! **************************************************************************************************
577 SUBROUTINE hirshfeld_control_release(hirshfeld_control)
578 TYPE(hirshfeld_constraint_type), INTENT(INOUT) :: hirshfeld_control
579
580 IF (ASSOCIATED(hirshfeld_control%radii)) THEN
581 DEALLOCATE (hirshfeld_control%radii)
582 END IF
583 CALL release_hirshfeld_type(hirshfeld_control%hirshfeld_env)
584
585 END SUBROUTINE hirshfeld_control_release
586
587END MODULE qs_cdft_types
simple routine to print charges for all atomic charge methods (currently mulliken,...
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
The types needed for the calculation of Hirshfeld charges and related functions.
subroutine, public release_hirshfeld_type(hirshfeld_env)
...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public outer_scf_becke_constraint
integer, parameter, public outer_scf_hirshfeld_constraint
integer, parameter, public shape_function_gaussian
integer, parameter, public radius_single
integer, parameter, public outer_scf_none
integer, parameter, public becke_cutoff_global
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_path_length
Definition kinds.F:58
parameters that control the outer loop of an SCF iteration
Control parameters for optimizers that work with CDFT constraints.
subroutine, public cdft_opt_type_release(cdft_opt_control)
releases the CDFT optimizer control object
Defines CDFT control structures.
subroutine, public cdft_control_release(cdft_control)
release the cdft_control_type
subroutine, public cdft_control_create(cdft_control)
create the cdft_control_type
represent a pointer to a 1d array
represent a full matrix
quantities needed for a Hirshfeld based partitioning of real space
contains the parameters needed by a scf run
control parameters for CDFT simulations