(git:374b731)
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-2024 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_fm_types, ONLY: cp_fm_type
17 USE dbcsr_api, ONLY: dbcsr_p_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
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, cutoff_type, &
78 confine_bounds(2)
79 LOGICAL :: in_memory, &
80 adjust, cavity_confine, &
81 should_skip, print_cavity, &
82 use_bohr
83 REAL(kind=dp) :: rglobal, &
84 rcavity, eps_cavity
85 REAL(kind=dp), DIMENSION(:), POINTER :: cutoffs, cutoffs_tmp, &
86 radii_tmp, radii
87 REAL(kind=dp), POINTER, &
88 DIMENSION(:, :) :: aij
89 REAL(kind=dp), POINTER, &
90 DIMENSION(:, :, :) :: cavity_mat
91 TYPE(becke_vector_buffer) :: vector_buffer
92 TYPE(hirshfeld_type), POINTER :: cavity_env
93 TYPE(pw_r3d_rs_type) :: cavity
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, shape_function, atoms_memory
112 LOGICAL :: use_bohr, print_density, use_atomic_cutoff
113 REAL(kind=dp) :: radius, eps_cutoff, atomic_cutoff
114 REAL(kind=dp), DIMENSION(:), POINTER :: radii
115 TYPE(hirshfeld_type), POINTER :: hirshfeld_env
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
189 ! Constraint type: charge constraint, magnetization density constraint, or spin channel specific constraint
190 INTEGER :: constraint_type
191 ! Is the constraint fragment based
192 LOGICAL :: is_fragment_constraint
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
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
202 ! Atomic gradients of the weight function at every grid point
203 REAL(kind=dp), POINTER, &
204 DIMENSION(:, :, :, :) :: gradients
205 REAL(kind=dp), POINTER, &
206 DIMENSION(:, :, :, :) :: gradients_x
207 REAL(kind=dp), POINTER, &
208 DIMENSION(:, :, :, :) :: gradients_y
209 REAL(kind=dp), POINTER, &
210 DIMENSION(:, :, :, :) :: gradients_z
211 ! The weight function of this constraint group
212 TYPE(pw_r3d_rs_type), POINTER :: weight
213 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: hw_rho_atomic
214 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: hw_rho_atomic_dr
215 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: hw_rho_atomic_charge
216 TYPE(pw_r3d_rs_type) :: hw_rho_total_constraint
217 TYPE(pw_r3d_rs_type) :: hw_rho_total
218 END TYPE cdft_group_type
219
221 CHARACTER(LEN=default_path_length) :: fragment_a_fname, &
222 fragment_b_fname, &
223 fragment_a_spin_fname, &
224 fragment_b_spin_fname
225 INTEGER :: ref_count, total_steps, TYPE, &
226 precond_freq, nreused, max_reuse, &
227 purge_freq, nbad_conv, purge_offset, &
228 istep, ienergy, natoms
229 INTEGER, POINTER, DIMENSION(:) :: atoms
230 LOGICAL :: need_pot, save_pot, do_et, &
231 reuse_precond, purge_history, &
232 should_purge, calculate_metric, &
233 atomic_charges, fragment_density, &
234 fragments_integrated, flip_fragment(2), &
235 transfer_pot, external_control, &
236 first_iteration, print_weight, in_memory
237 LOGICAL, POINTER, DIMENSION(:) :: is_constraint
238 REAL(kind=dp), DIMENSION(:), POINTER :: strength, TARGET, value
239 REAL(kind=dp), POINTER, &
240 DIMENSION(:, :) :: charges_fragment
241 TYPE(becke_constraint_type), POINTER :: becke_control
242 TYPE(cdft_group_type), POINTER, &
243 DIMENSION(:) :: group
244 TYPE(cp_1d_r_p_type), ALLOCATABLE, &
245 DIMENSION(:) :: occupations
246 TYPE(cp_fm_type), DIMENSION(:), &
247 POINTER :: mo_coeff
248 TYPE(dbcsr_p_type) :: matrix_s
249 TYPE(dbcsr_p_type), DIMENSION(:), &
250 POINTER :: wmat, matrix_p
252 POINTER :: hirshfeld_control
253 TYPE(outer_scf_control_type) :: constraint_control, ot_control
254 TYPE(pw_r3d_rs_type), POINTER, &
255 DIMENSION(:) :: charge
256 TYPE(pw_r3d_rs_type), POINTER, &
257 DIMENSION(:, :) :: fragments
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)) &
319 DEALLOCATE (becke_control%vector_buffer%distances)
320 IF (ALLOCATED(becke_control%vector_buffer%distance_vecs)) &
321 DEALLOCATE (becke_control%vector_buffer%distance_vecs)
322 IF (ALLOCATED(becke_control%vector_buffer%position_vecs)) &
323 DEALLOCATE (becke_control%vector_buffer%position_vecs)
324 IF (ALLOCATED(becke_control%vector_buffer%R12)) &
325 DEALLOCATE (becke_control%vector_buffer%R12)
326 IF (ALLOCATED(becke_control%vector_buffer%pair_dist_vecs)) &
327 DEALLOCATE (becke_control%vector_buffer%pair_dist_vecs)
328 END IF
329 IF (ASSOCIATED(becke_control%cutoffs)) &
330 DEALLOCATE (becke_control%cutoffs)
331 IF (ASSOCIATED(becke_control%cutoffs_tmp)) &
332 DEALLOCATE (becke_control%cutoffs_tmp)
333 IF (ASSOCIATED(becke_control%radii_tmp)) &
334 DEALLOCATE (becke_control%radii_tmp)
335 IF (ASSOCIATED(becke_control%radii)) &
336 DEALLOCATE (becke_control%radii)
337 IF (ASSOCIATED(becke_control%aij)) &
338 DEALLOCATE (becke_control%aij)
339 IF (ASSOCIATED(becke_control%cavity_mat)) &
340 DEALLOCATE (becke_control%cavity_mat)
341 IF (becke_control%cavity_confine) &
342 CALL release_hirshfeld_type(becke_control%cavity_env)
343
344 END SUBROUTINE becke_control_release
345
346! **************************************************************************************************
347!> \brief create the cdft_control_type
348!> \param cdft_control the structure to create
349!> \par History
350!> 12.2015 created [Nico Holmberg]
351! **************************************************************************************************
352 SUBROUTINE cdft_control_create(cdft_control)
353 TYPE(cdft_control_type), INTENT(OUT) :: cdft_control
354
355 cdft_control%total_steps = 0
356 NULLIFY (cdft_control%strength)
357 NULLIFY (cdft_control%target)
358 NULLIFY (cdft_control%value)
359 NULLIFY (cdft_control%atoms)
360 NULLIFY (cdft_control%is_constraint)
361 NULLIFY (cdft_control%charges_fragment)
362 NULLIFY (cdft_control%fragments)
363 NULLIFY (cdft_control%group)
364 NULLIFY (cdft_control%charge)
365 cdft_control%natoms = 0
366 cdft_control%type = outer_scf_none
367 cdft_control%need_pot = .true.
368 cdft_control%save_pot = .false.
369 cdft_control%transfer_pot = .false.
370 cdft_control%atomic_charges = .false.
371 cdft_control%first_iteration = .true.
372 cdft_control%fragment_density = .false.
373 cdft_control%fragments_integrated = .false.
374 cdft_control%flip_fragment = .false.
375 cdft_control%external_control = .false.
376 cdft_control%do_et = .false.
377 cdft_control%reuse_precond = .false.
378 cdft_control%nreused = 0
379 cdft_control%precond_freq = 0
380 cdft_control%max_reuse = 0
381 cdft_control%should_purge = .false.
382 cdft_control%purge_history = .false.
383 cdft_control%calculate_metric = .false.
384 cdft_control%in_memory = .false.
385 cdft_control%purge_freq = 0
386 cdft_control%nbad_conv = 0
387 cdft_control%purge_offset = 0
388 cdft_control%istep = 0
389 cdft_control%ienergy = 0
390 NULLIFY (cdft_control%becke_control)
391 ALLOCATE (cdft_control%becke_control)
392 CALL becke_control_create(cdft_control%becke_control)
393 NULLIFY (cdft_control%hirshfeld_control)
394 ALLOCATE (cdft_control%hirshfeld_control)
395 CALL hirshfeld_control_create(cdft_control%hirshfeld_control)
396 NULLIFY (cdft_control%wmat)
397 NULLIFY (cdft_control%matrix_s%matrix)
398 NULLIFY (cdft_control%mo_coeff)
399 NULLIFY (cdft_control%matrix_p)
400 ! Outer SCF default settings
401 cdft_control%ot_control%have_scf = .false.
402 cdft_control%ot_control%max_scf = 0
403 cdft_control%ot_control%eps_scf = 0.0_dp
404 cdft_control%ot_control%step_size = 0.0_dp
405 cdft_control%ot_control%type = -1
406 cdft_control%ot_control%optimizer = -1
407 cdft_control%ot_control%diis_buffer_length = -1
408 NULLIFY (cdft_control%ot_control%cdft_opt_control)
409 cdft_control%constraint_control%have_scf = .false.
410 cdft_control%constraint_control%max_scf = 0
411 cdft_control%constraint_control%eps_scf = 0.0_dp
412 cdft_control%constraint_control%step_size = 0.0_dp
413 cdft_control%constraint_control%type = -1
414 cdft_control%constraint_control%optimizer = -1
415 cdft_control%constraint_control%diis_buffer_length = -1
416 NULLIFY (cdft_control%constraint_control%cdft_opt_control)
417 cdft_control%constraint%iter_count = 0
418 NULLIFY (cdft_control%constraint%variables)
419 NULLIFY (cdft_control%constraint%gradient)
420 NULLIFY (cdft_control%constraint%energy)
421 NULLIFY (cdft_control%constraint%count)
422 NULLIFY (cdft_control%constraint%inv_jacobian)
423 cdft_control%constraint%deallocate_jacobian = .true.
424 END SUBROUTINE cdft_control_create
425
426! **************************************************************************************************
427!> \brief release the cdft_control_type
428!> \param cdft_control the structure to release
429!> \par History
430!> 12.2015 created [Nico Holmberg]
431! **************************************************************************************************
432 SUBROUTINE cdft_control_release(cdft_control)
433 TYPE(cdft_control_type), INTENT(INOUT) :: cdft_control
434
435 INTEGER :: i
436
437 ! Constraint settings
438 IF (ASSOCIATED(cdft_control%atoms)) &
439 DEALLOCATE (cdft_control%atoms)
440 IF (ASSOCIATED(cdft_control%strength)) &
441 DEALLOCATE (cdft_control%strength)
442 IF (ASSOCIATED(cdft_control%target)) &
443 DEALLOCATE (cdft_control%target)
444 IF (ASSOCIATED(cdft_control%value)) &
445 DEALLOCATE (cdft_control%value)
446 IF (ASSOCIATED(cdft_control%charges_fragment)) &
447 DEALLOCATE (cdft_control%charges_fragment)
448 IF (ASSOCIATED(cdft_control%fragments)) &
449 DEALLOCATE (cdft_control%fragments)
450 IF (ASSOCIATED(cdft_control%is_constraint)) &
451 DEALLOCATE (cdft_control%is_constraint)
452 IF (ASSOCIATED(cdft_control%charge)) &
453 DEALLOCATE (cdft_control%charge)
454 ! Constraint atom groups
455 IF (ASSOCIATED(cdft_control%group)) THEN
456 DO i = 1, SIZE(cdft_control%group)
457 IF (ASSOCIATED(cdft_control%group(i)%atoms)) &
458 DEALLOCATE (cdft_control%group(i)%atoms)
459 IF (ASSOCIATED(cdft_control%group(i)%coeff)) &
460 DEALLOCATE (cdft_control%group(i)%coeff)
461 IF (ALLOCATED(cdft_control%group(i)%d_sum_const_dR)) &
462 DEALLOCATE (cdft_control%group(i)%d_sum_const_dR)
463 IF (cdft_control%type == outer_scf_becke_constraint) THEN
464 IF (ASSOCIATED(cdft_control%group(i)%gradients)) &
465 DEALLOCATE (cdft_control%group(i)%gradients)
466 ELSE IF (cdft_control%type == outer_scf_hirshfeld_constraint) THEN
467 IF (ASSOCIATED(cdft_control%group(i)%gradients_x)) &
468 DEALLOCATE (cdft_control%group(i)%gradients_x)
469 IF (ASSOCIATED(cdft_control%group(i)%gradients_y)) &
470 DEALLOCATE (cdft_control%group(i)%gradients_y)
471 IF (ASSOCIATED(cdft_control%group(i)%gradients_z)) &
472 DEALLOCATE (cdft_control%group(i)%gradients_z)
473 END IF
474 IF (ASSOCIATED(cdft_control%group(i)%integrated)) &
475 DEALLOCATE (cdft_control%group(i)%integrated)
476 END DO
477 DEALLOCATE (cdft_control%group)
478 END IF
479 ! Constraint type specific deallocations
480 IF (ASSOCIATED(cdft_control%becke_control)) THEN
481 CALL becke_control_release(cdft_control%becke_control)
482 DEALLOCATE (cdft_control%becke_control)
483 END IF
484 IF (ASSOCIATED(cdft_control%hirshfeld_control)) THEN
485 CALL hirshfeld_control_release(cdft_control%hirshfeld_control)
486 DEALLOCATE (cdft_control%hirshfeld_control)
487 END IF
488 ! Release OUTER_SCF types
489 CALL cdft_opt_type_release(cdft_control%ot_control%cdft_opt_control)
490 CALL cdft_opt_type_release(cdft_control%constraint_control%cdft_opt_control)
491 IF (ASSOCIATED(cdft_control%constraint%variables)) &
492 DEALLOCATE (cdft_control%constraint%variables)
493 IF (ASSOCIATED(cdft_control%constraint%count)) &
494 DEALLOCATE (cdft_control%constraint%count)
495 IF (ASSOCIATED(cdft_control%constraint%gradient)) &
496 DEALLOCATE (cdft_control%constraint%gradient)
497 IF (ASSOCIATED(cdft_control%constraint%energy)) &
498 DEALLOCATE (cdft_control%constraint%energy)
499 IF (ASSOCIATED(cdft_control%constraint%inv_jacobian)) &
500 DEALLOCATE (cdft_control%constraint%inv_jacobian)
501 ! Storage for mixed CDFT calculations
502 IF (ALLOCATED(cdft_control%occupations)) THEN
503 DO i = 1, SIZE(cdft_control%occupations)
504 IF (ASSOCIATED(cdft_control%occupations(i)%array)) &
505 DEALLOCATE (cdft_control%occupations(i)%array)
506 END DO
507 DEALLOCATE (cdft_control%occupations)
508 END IF
509 ! Release control
510 cdft_control%type = outer_scf_none
511
512 END SUBROUTINE cdft_control_release
513
514! **************************************************************************************************
515!> \brief create the hirshfeld_constraint_type
516!> \param hirshfeld_control the structure to create
517!> \par History
518!> 09.2018 created [Nico Holmberg]
519! **************************************************************************************************
520 SUBROUTINE hirshfeld_control_create(hirshfeld_control)
521 TYPE(hirshfeld_constraint_type), INTENT(OUT) :: hirshfeld_control
522
523 hirshfeld_control%use_bohr = .false.
524 hirshfeld_control%print_density = .false.
525 hirshfeld_control%use_atomic_cutoff = .true.
526 hirshfeld_control%radius = 3.0_dp
527 hirshfeld_control%eps_cutoff = 1.0e-12_dp
528 hirshfeld_control%atomic_cutoff = 1.0e-12_dp
529 hirshfeld_control%shape_function = shape_function_gaussian
530 hirshfeld_control%atoms_memory = 80
531 hirshfeld_control%gaussian_shape = radius_single
532 NULLIFY (hirshfeld_control%hirshfeld_env)
533 NULLIFY (hirshfeld_control%radii)
534
535 END SUBROUTINE hirshfeld_control_create
536
537! **************************************************************************************************
538!> \brief release the hirshfeld_constraint_type
539!> \param hirshfeld_control the structure to release
540!> \par History
541!> 09.2018 created [Nico Holmberg]
542! **************************************************************************************************
543 SUBROUTINE hirshfeld_control_release(hirshfeld_control)
544 TYPE(hirshfeld_constraint_type), INTENT(INOUT) :: hirshfeld_control
545
546 IF (ASSOCIATED(hirshfeld_control%radii)) &
547 DEALLOCATE (hirshfeld_control%radii)
548 CALL release_hirshfeld_type(hirshfeld_control%hirshfeld_env)
549
550 END SUBROUTINE hirshfeld_control_release
551
552END 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