(git:9fc00bd)
Loading...
Searching...
No Matches
kpoint_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 and basic routines needed for a kpoint calculation
10!> \par History
11!> 2014.07 created [JGH]
12!> 2014.11 unified k-point and gamma-point code [Ole Schuett]
13!> \author JGH
14! **************************************************************************************************
18 USE cp_cfm_types, ONLY: cp_cfm_release,&
20 USE cp_fm_types, ONLY: cp_fm_release,&
36 USE kinds, ONLY: default_string_length,&
37 dp
38 USE mathconstants, ONLY: twopi
41 USE physcon, ONLY: angstrom
50#include "./base/base_uses.f90"
51
52 IMPLICIT NONE
53
54 PRIVATE
55
56 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'kpoint_types'
57
58 PUBLIC :: kpoint_type
63 PUBLIC :: kind_rotmat_type
64 PUBLIC :: kpoint_sym_type
65 PUBLIC :: kpoint_sym_create
66
67! **************************************************************************************************
68!> \brief Keeps information about a specific k-point
69!> \param nkpoint the kpoint index
70!> \param wkp weight of this kpoint
71!> \param xkp kpoint coordinates in units of b-vector
72!> \param is_local if this kpoint is calculated on a single thread
73!> \param mos associated MOs (r/i,spin)
74!> \param pmat associated density matrix (r/i,spin)
75!> \param wmat associated energy weighted density matrix (r/i,spin)
76!> \param smat associated overlap matrix (for ADMM) (r/i,spin)
77!> \param amat associated ADMM basis projection matrix (r/i,spin)
78!> \param shalf S(K)^(1/2) DFT+U Lowdin method (real wfn)
79!> \param cshalf S(K)^(1/2) DFT+U Lowdin method (complex wfn)
80!> \author JGH
81! **************************************************************************************************
83 INTEGER :: nkpoint = -1
84 REAL(kind=dp) :: wkp = 0.0_dp
85 REAL(kind=dp), DIMENSION(3) :: xkp = 0.0_dp
86 LOGICAL :: is_local = .false.
87 TYPE(mo_set_type), DIMENSION(:, :), POINTER :: mos => null()
88 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: pmat => null()
89 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: wmat => null()
90 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: smat => null()
91 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: amat => null()
92 TYPE(cp_fm_type) :: shalf
93 TYPE(cp_cfm_type) :: cshalf
94 END TYPE kpoint_env_type
95
97 TYPE(kpoint_env_type), POINTER :: kpoint_env => null()
98 END TYPE kpoint_env_p_type
99
100! **************************************************************************************************
101!> \brief Rotation matrices for basis sets
102!> \param rmat atom basis function rotation matrix
103!> \author JGH
104! **************************************************************************************************
106 REAL(kind=dp), DIMENSION(:, :), POINTER :: rmat => null()
107 END TYPE kind_rotmat_type
108
109! **************************************************************************************************
110!> \brief Keeps symmetry information about a specific k-point
111!> \param apply_symmetry ...
112!> \param nwght kpoint multiplicity
113!> \param xkp kpoint coordinates
114!> \param rot rotation matrices
115!> \param f0 atom permutation
116!> \param fcell atom cell shifts generated by the symmetry operation
117!> \param kgphase atom Bloch gauge from reciprocal-lattice folding of the mapped k-point
118!> \author JGH
119! **************************************************************************************************
121 LOGICAL :: apply_symmetry = .false.
122 INTEGER :: nwght = -1
123 INTEGER :: nwred = -1
124 REAL(kind=dp), DIMENSION(:, :), POINTER :: xkp => null()
125 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: rot => null()
126 INTEGER, DIMENSION(:), POINTER :: rotp => null()
127 INTEGER, DIMENSION(:, :), POINTER :: f0 => null()
128 INTEGER, DIMENSION(:, :, :), POINTER :: fcell => null()
129 REAL(kind=dp), DIMENSION(:, :), POINTER :: kgphase => null()
130 END TYPE kpoint_sym_type
131
132 TYPE kpoint_sym_p_type
133 TYPE(kpoint_sym_type), POINTER :: kpoint_sym => null()
134 END TYPE kpoint_sym_p_type
135
136! **************************************************************************************************
137!> \brief Contains information about kpoints
138!> \par History
139!> 2014.07 created [JGH]
140!> \param kp_scheme [input] Type of kpoint grid
141!> \param nkp_grid [input] Grid points
142!> \param kp_shift [input] Shift of the grid
143!> \param use_real_wfn [input] real/complex wfn
144!> \param symmetry [input] use symmetry (atoms) to reduce kpoints
145!> \param full_grid [input] don't reduce kpoints at all
146!> \param inversion_symmetry_only [input] reduce kpoints only by inversion symmetry
147!> \param symmetry_backend [input] k-point symmetry backend
148!> \param symmetry_reduction_method [input] k-point symmetry reduction method
149!> \param verbose [input] more output information
150!> \param eps_geo [input] accuracy of atom symmetry detection
151!> \param parallel_group_size [input] kpoint group size
152!> \param nkp number of kpoints
153!> \param xkp kpoint coordinates
154!> \param wkp kpoint weights
155!> \param xkp_input explicit GENERAL kpoint coordinates as read from the input
156!> \param wkp_input explicit GENERAL kpoint weights as read from the input
157!> \param para_env 'global' parallel environment
158!> \param para_env_kp parallel environment of the kpoint calculation
159!> \param para_env_inter_kp parallel environment between kpoints
160!> \param iogrp this kpoint group has the IO processor
161!> \param nkp_groups number of kpoint groups
162!> \param kp_dist kpoints distribution on groups
163!> \param kp_range kpoints distribution for local processor
164!> \param blacs_env BLACS env for the kpoint group
165!> \param opmats Operator matrices
166!> \param kp_env Information for each kpoint
167!> \param mpools FM matrix pools for kpoint groups
168!> \author JGH
169! **************************************************************************************************
171 CHARACTER(LEN=default_string_length) :: kp_scheme = ""
172 INTEGER, DIMENSION(3) :: nkp_grid = -1
173 REAL(kind=dp), DIMENSION(3) :: kp_shift = 0.0_dp
174 LOGICAL :: gamma_centered = .false.
175 LOGICAL :: use_real_wfn = .false.
176 LOGICAL :: symmetry = .false.
177 LOGICAL :: full_grid = .false.
178 LOGICAL :: inversion_symmetry_only = .false.
179 INTEGER :: symmetry_backend = use_k290_kpoint_backend
180 INTEGER :: symmetry_reduction_method = use_k290_kpoint_symmetry
181 LOGICAL :: verbose = .false.
182 REAL(kind=dp) :: eps_geo = 0.0_dp
183 INTEGER :: parallel_group_size = -1
184 INTEGER :: nkp = -1
185 REAL(kind=dp), DIMENSION(:, :), POINTER :: xkp => null()
186 REAL(kind=dp), DIMENSION(:), POINTER :: wkp => null()
187 REAL(kind=dp), DIMENSION(:, :), POINTER :: xkp_input => null()
188 REAL(kind=dp), DIMENSION(:), POINTER :: wkp_input => null()
189 ! parallel environment
190 TYPE(mp_para_env_type), POINTER :: para_env => null()
191 TYPE(cp_blacs_env_type), POINTER :: blacs_env_all => null()
192 TYPE(mp_para_env_type), POINTER :: para_env_kp => null(), &
193 para_env_inter_kp => null()
194 LOGICAL :: iogrp = .false.
195 INTEGER :: nkp_groups = -1
196 INTEGER, DIMENSION(:, :), POINTER :: kp_dist => null()
197 INTEGER, DIMENSION(2) :: kp_range = -1
198 TYPE(cp_blacs_env_type), POINTER :: blacs_env => null()
199 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index => null()
200 INTEGER, DIMENSION(:, :), POINTER :: index_to_cell => null()
202 DIMENSION(:), POINTER :: sab_nl => null(), &
203 sab_nl_nosym => null()
204 ! environment
205 TYPE(kpoint_env_p_type), DIMENSION(:), &
206 POINTER :: kp_env => null()
207 TYPE(kpoint_env_p_type), DIMENSION(:), &
208 POINTER :: kp_aux_env => null()
209 ! symmetry
210 TYPE(kpoint_sym_p_type), DIMENSION(:), &
211 POINTER :: kp_sym => null()
212 INTEGER, DIMENSION(:), POINTER :: atype => null()
213 INTEGER, DIMENSION(:), POINTER :: ibrot => null()
214 TYPE(kind_rotmat_type), DIMENSION(:, :), &
215 POINTER :: kind_rotmat => null()
216 ! pools
217 TYPE(qs_matrix_pools_type), POINTER :: mpools => null()
218 TYPE(qs_diis_buffer_type_kp), POINTER :: scf_diis_buffer => null()
219 TYPE(qs_matrix_pools_type), POINTER :: mpools_aux_fit => null()
220 END TYPE kpoint_type
221
222! **************************************************************************************************
223
224CONTAINS
225
226! **************************************************************************************************
227!> \brief Create a kpoint environment
228!> \param kpoint All the kpoint information
229!> \author JGH
230! **************************************************************************************************
231 SUBROUTINE kpoint_create(kpoint)
232 TYPE(kpoint_type), POINTER :: kpoint
233
234 cpassert(.NOT. ASSOCIATED(kpoint))
235
236 ALLOCATE (kpoint)
237
238 kpoint%kp_scheme = ""
239 kpoint%nkp_grid = 0
240 kpoint%kp_shift = 0.0_dp
241 kpoint%gamma_centered = .false.
242 kpoint%symmetry = .false.
243 kpoint%verbose = .false.
244 kpoint%full_grid = .false.
245 kpoint%inversion_symmetry_only = .false.
246 kpoint%symmetry_backend = use_k290_kpoint_backend
247 kpoint%symmetry_reduction_method = use_k290_kpoint_symmetry
248 kpoint%use_real_wfn = .false.
249 kpoint%eps_geo = 1.0e-6_dp
250 kpoint%parallel_group_size = -1
251
252 kpoint%nkp = 0
253
254 NULLIFY (kpoint%xkp, kpoint%wkp)
255 NULLIFY (kpoint%xkp_input, kpoint%wkp_input)
256 NULLIFY (kpoint%kp_dist)
257
258 NULLIFY (kpoint%para_env)
259 NULLIFY (kpoint%blacs_env_all)
260 NULLIFY (kpoint%para_env_kp, kpoint%para_env_inter_kp)
261 NULLIFY (kpoint%blacs_env)
262 kpoint%nkp_groups = 0
263 kpoint%iogrp = .false.
264 kpoint%kp_range = 0
265
266 NULLIFY (kpoint%kp_env)
267 NULLIFY (kpoint%mpools)
268
269 ALLOCATE (kpoint%cell_to_index(0:0, 0:0, 0:0))
270 kpoint%cell_to_index(:, :, :) = 1
271
272 ALLOCATE (kpoint%index_to_cell(0:0, 0:0))
273 kpoint%index_to_cell(:, :) = 0
274
275 END SUBROUTINE kpoint_create
276
277! **************************************************************************************************
278!> \brief Release a kpoint environment, deallocate all data
279!> \param kpoint The kpoint environment
280!> \author JGH
281! **************************************************************************************************
282 SUBROUTINE kpoint_release(kpoint)
283 TYPE(kpoint_type), POINTER :: kpoint
284
285 INTEGER :: i, ik, j
286
287 IF (ASSOCIATED(kpoint)) THEN
288
289 IF (ASSOCIATED(kpoint%xkp)) THEN
290 DEALLOCATE (kpoint%xkp)
291 END IF
292 IF (ASSOCIATED(kpoint%wkp)) THEN
293 DEALLOCATE (kpoint%wkp)
294 END IF
295 IF (ASSOCIATED(kpoint%xkp_input)) THEN
296 DEALLOCATE (kpoint%xkp_input)
297 END IF
298 IF (ASSOCIATED(kpoint%wkp_input)) THEN
299 DEALLOCATE (kpoint%wkp_input)
300 END IF
301 IF (ASSOCIATED(kpoint%kp_dist)) THEN
302 DEALLOCATE (kpoint%kp_dist)
303 END IF
304
305 CALL mpools_release(kpoint%mpools)
306 CALL mpools_release(kpoint%mpools_aux_fit)
307
308 CALL cp_blacs_env_release(kpoint%blacs_env)
309 CALL cp_blacs_env_release(kpoint%blacs_env_all)
310
311 CALL mp_para_env_release(kpoint%para_env)
312 CALL mp_para_env_release(kpoint%para_env_kp)
313 CALL mp_para_env_release(kpoint%para_env_inter_kp)
314
315 IF (ASSOCIATED(kpoint%cell_to_index)) DEALLOCATE (kpoint%cell_to_index)
316 IF (ASSOCIATED(kpoint%index_to_cell)) DEALLOCATE (kpoint%index_to_cell)
317
318 IF (ASSOCIATED(kpoint%kp_env)) THEN
319 DO ik = 1, SIZE(kpoint%kp_env)
320 CALL kpoint_env_release(kpoint%kp_env(ik)%kpoint_env)
321 END DO
322 DEALLOCATE (kpoint%kp_env)
323 END IF
324
325 IF (ASSOCIATED(kpoint%kp_aux_env)) THEN
326 DO ik = 1, SIZE(kpoint%kp_aux_env)
327 CALL kpoint_env_release(kpoint%kp_aux_env(ik)%kpoint_env)
328 END DO
329 DEALLOCATE (kpoint%kp_aux_env)
330 END IF
331
332 IF (ASSOCIATED(kpoint%kp_sym)) THEN
333 DO ik = 1, SIZE(kpoint%kp_sym)
334 CALL kpoint_sym_release(kpoint%kp_sym(ik)%kpoint_sym)
335 END DO
336 DEALLOCATE (kpoint%kp_sym)
337 END IF
338
339 IF (ASSOCIATED(kpoint%atype)) DEALLOCATE (kpoint%atype)
340 IF (ASSOCIATED(kpoint%ibrot)) DEALLOCATE (kpoint%ibrot)
341
342 IF (ASSOCIATED(kpoint%kind_rotmat)) THEN
343 DO i = 1, SIZE(kpoint%kind_rotmat, 1)
344 DO j = 1, SIZE(kpoint%kind_rotmat, 2)
345 IF (ASSOCIATED(kpoint%kind_rotmat(i, j)%rmat)) THEN
346 DEALLOCATE (kpoint%kind_rotmat(i, j)%rmat)
347 END IF
348 END DO
349 END DO
350 DEALLOCATE (kpoint%kind_rotmat)
351 END IF
352
353 IF (ASSOCIATED(kpoint%scf_diis_buffer)) THEN
354 CALL qs_diis_b_release_kp(kpoint%scf_diis_buffer)
355 DEALLOCATE (kpoint%scf_diis_buffer)
356 END IF
357
358 DEALLOCATE (kpoint)
359
360 END IF
361
362 END SUBROUTINE kpoint_release
363
364! **************************************************************************************************
365!> \brief Reset all data derived from a concrete k-point initialization.
366!> Input options such as the scheme, grid, shifts and symmetry settings are kept.
367!> \param kpoint The kpoint environment
368! **************************************************************************************************
370 TYPE(kpoint_type), INTENT(INOUT) :: kpoint
371
372 INTEGER :: i, ik, j
373
374 IF (ASSOCIATED(kpoint%xkp)) THEN
375 DEALLOCATE (kpoint%xkp)
376 NULLIFY (kpoint%xkp)
377 END IF
378 IF (ASSOCIATED(kpoint%wkp)) THEN
379 DEALLOCATE (kpoint%wkp)
380 NULLIFY (kpoint%wkp)
381 END IF
382 IF (kpoint%kp_scheme == "GENERAL" .AND. ASSOCIATED(kpoint%xkp_input) .AND. &
383 ASSOCIATED(kpoint%wkp_input)) THEN
384 kpoint%nkp = SIZE(kpoint%wkp_input)
385 ALLOCATE (kpoint%xkp(3, kpoint%nkp), kpoint%wkp(kpoint%nkp))
386 kpoint%xkp(1:3, 1:kpoint%nkp) = kpoint%xkp_input(1:3, 1:kpoint%nkp)
387 kpoint%wkp(1:kpoint%nkp) = kpoint%wkp_input(1:kpoint%nkp)
388 END IF
389 IF (ASSOCIATED(kpoint%kp_dist)) THEN
390 DEALLOCATE (kpoint%kp_dist)
391 NULLIFY (kpoint%kp_dist)
392 END IF
393
394 CALL mpools_release(kpoint%mpools)
395 CALL mpools_release(kpoint%mpools_aux_fit)
396
397 CALL cp_blacs_env_release(kpoint%blacs_env)
398 CALL cp_blacs_env_release(kpoint%blacs_env_all)
399
400 CALL mp_para_env_release(kpoint%para_env)
401 CALL mp_para_env_release(kpoint%para_env_kp)
402 CALL mp_para_env_release(kpoint%para_env_inter_kp)
403
404 IF (ASSOCIATED(kpoint%cell_to_index)) THEN
405 DEALLOCATE (kpoint%cell_to_index)
406 NULLIFY (kpoint%cell_to_index)
407 END IF
408 IF (ASSOCIATED(kpoint%index_to_cell)) THEN
409 DEALLOCATE (kpoint%index_to_cell)
410 NULLIFY (kpoint%index_to_cell)
411 END IF
412
413 IF (ASSOCIATED(kpoint%kp_env)) THEN
414 DO ik = 1, SIZE(kpoint%kp_env)
415 CALL kpoint_env_release(kpoint%kp_env(ik)%kpoint_env)
416 END DO
417 DEALLOCATE (kpoint%kp_env)
418 NULLIFY (kpoint%kp_env)
419 END IF
420
421 IF (ASSOCIATED(kpoint%kp_aux_env)) THEN
422 DO ik = 1, SIZE(kpoint%kp_aux_env)
423 CALL kpoint_env_release(kpoint%kp_aux_env(ik)%kpoint_env)
424 END DO
425 DEALLOCATE (kpoint%kp_aux_env)
426 NULLIFY (kpoint%kp_aux_env)
427 END IF
428
429 IF (ASSOCIATED(kpoint%kp_sym)) THEN
430 DO ik = 1, SIZE(kpoint%kp_sym)
431 CALL kpoint_sym_release(kpoint%kp_sym(ik)%kpoint_sym)
432 END DO
433 DEALLOCATE (kpoint%kp_sym)
434 NULLIFY (kpoint%kp_sym)
435 END IF
436
437 IF (ASSOCIATED(kpoint%atype)) THEN
438 DEALLOCATE (kpoint%atype)
439 NULLIFY (kpoint%atype)
440 END IF
441 IF (ASSOCIATED(kpoint%ibrot)) THEN
442 DEALLOCATE (kpoint%ibrot)
443 NULLIFY (kpoint%ibrot)
444 END IF
445
446 IF (ASSOCIATED(kpoint%kind_rotmat)) THEN
447 DO i = 1, SIZE(kpoint%kind_rotmat, 1)
448 DO j = 1, SIZE(kpoint%kind_rotmat, 2)
449 IF (ASSOCIATED(kpoint%kind_rotmat(i, j)%rmat)) THEN
450 DEALLOCATE (kpoint%kind_rotmat(i, j)%rmat)
451 NULLIFY (kpoint%kind_rotmat(i, j)%rmat)
452 END IF
453 END DO
454 END DO
455 DEALLOCATE (kpoint%kind_rotmat)
456 NULLIFY (kpoint%kind_rotmat)
457 END IF
458
459 IF (ASSOCIATED(kpoint%scf_diis_buffer)) THEN
460 CALL qs_diis_b_release_kp(kpoint%scf_diis_buffer)
461 DEALLOCATE (kpoint%scf_diis_buffer)
462 NULLIFY (kpoint%scf_diis_buffer)
463 END IF
464
465 NULLIFY (kpoint%sab_nl)
466 NULLIFY (kpoint%sab_nl_nosym)
467
468 ALLOCATE (kpoint%cell_to_index(0:0, 0:0, 0:0))
469 kpoint%cell_to_index(:, :, :) = 1
470
471 ALLOCATE (kpoint%index_to_cell(0:0, 0:0))
472 kpoint%index_to_cell(:, :) = 0
473
474 IF (.NOT. ASSOCIATED(kpoint%wkp)) kpoint%nkp = 0
475 kpoint%nkp_groups = 0
476 kpoint%kp_range = 0
477 kpoint%iogrp = .false.
478
479 END SUBROUTINE kpoint_reset_initialization
480
481! **************************************************************************************************
482!> \brief Retrieve information from a kpoint environment
483!> \param kpoint The kpoint environment
484!> \param kp_scheme Type of kpoint grid
485!> \param nkp_grid Grid points
486!> \param kp_shift Shift of the grid
487!> \param symmetry use symmetry (atoms) to reduce kpoints
488!> \param verbose more output information
489!> \param full_grid don't reduce kpoints at all
490!> \param use_real_wfn real/complex wfn
491!> \param eps_geo accuracy of atom symmetry detection
492!> \param parallel_group_size kpoint group size
493!> \param kp_range kpoints distribution for local processor
494!> \param nkp number of kpoints
495!> \param xkp kpoint coordinates in units of b-vector
496!> \param wkp kpoint weights
497!> \param para_env 'global' parallel environment
498!> \param blacs_env_all BLACS env for the total environment
499!> \param para_env_kp parallel environment of the kpoint calculation
500!> \param para_env_inter_kp parallel environment between kpoints
501!> \param blacs_env BLACS env for the kpoint group
502!> \param kp_env Information for each kpoint
503!> \param kp_aux_env ...
504!> \param mpools FM matrix pools for kpoint groups
505!> \param iogrp this kpoint group has the IO processor
506!> \param nkp_groups number of kpoint groups
507!> \param kp_dist kpoints distribution on groups
508!> \param cell_to_index given a cell triple, returns the real space index
509!> \param index_to_cell ...
510!> \param sab_nl neighbourlist that defines real space matrices
511!> \param sab_nl_nosym neighbourlist that defines real space matrices, non-symmetric
512!> \param inversion_symmetry_only reduce kpoints only by inversion symmetry
513!> \param symmetry_backend k-point symmetry backend
514!> \param symmetry_reduction_method k-point symmetry reduction method
515!> \param gamma_centered ...
516!> \author JGH
517! **************************************************************************************************
518 SUBROUTINE get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, &
519 full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, &
520 para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, &
521 kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, &
522 sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, &
523 symmetry_reduction_method, gamma_centered)
524 TYPE(kpoint_type), INTENT(IN) :: kpoint
525 CHARACTER(LEN=*), OPTIONAL :: kp_scheme
526 INTEGER, DIMENSION(3), OPTIONAL :: nkp_grid
527 REAL(kind=dp), DIMENSION(3), OPTIONAL :: kp_shift
528 LOGICAL, OPTIONAL :: symmetry, verbose, full_grid, &
530 REAL(kind=dp), OPTIONAL :: eps_geo
531 INTEGER, OPTIONAL :: parallel_group_size
532 INTEGER, DIMENSION(2), OPTIONAL :: kp_range
533 INTEGER, OPTIONAL :: nkp
534 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: xkp
535 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: wkp
536 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
537 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env_all
538 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env_kp, para_env_inter_kp
539 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env
540 TYPE(kpoint_env_p_type), DIMENSION(:), OPTIONAL, &
541 POINTER :: kp_env, kp_aux_env
542 TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
543 LOGICAL, OPTIONAL :: iogrp
544 INTEGER, OPTIONAL :: nkp_groups
545 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: kp_dist
546 INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER :: cell_to_index
547 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: index_to_cell
548 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
549 OPTIONAL, POINTER :: sab_nl, sab_nl_nosym
550 LOGICAL, OPTIONAL :: inversion_symmetry_only
551 INTEGER, OPTIONAL :: symmetry_backend, &
552 symmetry_reduction_method
553 LOGICAL, OPTIONAL :: gamma_centered
554
555 IF (PRESENT(kp_scheme)) kp_scheme = kpoint%kp_scheme
556 IF (PRESENT(nkp_grid)) nkp_grid = kpoint%nkp_grid
557 IF (PRESENT(kp_shift)) kp_shift = kpoint%kp_shift
558 IF (PRESENT(gamma_centered)) gamma_centered = kpoint%gamma_centered
559 IF (PRESENT(symmetry)) symmetry = kpoint%symmetry
560 IF (PRESENT(verbose)) verbose = kpoint%verbose
561 IF (PRESENT(full_grid)) full_grid = kpoint%full_grid
562 IF (PRESENT(inversion_symmetry_only)) inversion_symmetry_only = kpoint%inversion_symmetry_only
563 IF (PRESENT(symmetry_backend)) symmetry_backend = kpoint%symmetry_backend
564 IF (PRESENT(symmetry_reduction_method)) &
565 symmetry_reduction_method = kpoint%symmetry_reduction_method
566 IF (PRESENT(use_real_wfn)) use_real_wfn = kpoint%use_real_wfn
567 IF (PRESENT(eps_geo)) eps_geo = kpoint%eps_geo
568 IF (PRESENT(parallel_group_size)) parallel_group_size = kpoint%parallel_group_size
569
570 IF (PRESENT(nkp)) nkp = kpoint%nkp
571 IF (PRESENT(wkp)) wkp => kpoint%wkp
572 IF (PRESENT(xkp)) xkp => kpoint%xkp
573
574 IF (PRESENT(para_env)) para_env => kpoint%para_env
575 IF (PRESENT(para_env_kp)) para_env_kp => kpoint%para_env_kp
576 IF (PRESENT(para_env_inter_kp)) para_env_inter_kp => kpoint%para_env_inter_kp
577 IF (PRESENT(blacs_env_all)) blacs_env_all => kpoint%blacs_env_all
578 IF (PRESENT(blacs_env)) blacs_env => kpoint%blacs_env
579
580 IF (PRESENT(iogrp)) iogrp = kpoint%iogrp
581 IF (PRESENT(kp_range)) kp_range = kpoint%kp_range
582 IF (PRESENT(nkp_groups)) nkp_groups = kpoint%nkp_groups
583 IF (PRESENT(kp_dist)) kp_dist => kpoint%kp_dist
584
585 IF (PRESENT(kp_env)) kp_env => kpoint%kp_env
586 IF (PRESENT(kp_aux_env)) kp_aux_env => kpoint%kp_aux_env
587 IF (PRESENT(mpools)) mpools => kpoint%mpools
588
589 IF (PRESENT(cell_to_index)) cell_to_index => kpoint%cell_to_index
590 IF (PRESENT(index_to_cell)) index_to_cell => kpoint%index_to_cell
591 IF (PRESENT(sab_nl)) sab_nl => kpoint%sab_nl
592 IF (PRESENT(sab_nl_nosym)) sab_nl_nosym => kpoint%sab_nl_nosym
593
594 END SUBROUTINE get_kpoint_info
595
596! **************************************************************************************************
597!> \brief Set information in a kpoint environment
598!> \param kpoint The kpoint environment
599!> \param kp_scheme Type of kpoint grid
600!> \param nkp_grid Grid points
601!> \param kp_shift Shift of the grid
602!> \param symmetry use symmetry (atoms) to reduce kpoints
603!> \param verbose more output information
604!> \param full_grid don't reduce kpoints at all
605!> \param use_real_wfn real/complex wfn
606!> \param eps_geo accuracy of atom symmetry detection
607!> \param parallel_group_size kpoint group size
608!> \param kp_range kpoints distribution for local processor
609!> \param nkp number of kpoints
610!> \param xkp kpoint coordinates
611!> \param wkp kpoint weights
612!> \param para_env 'global' parallel environment
613!> \param blacs_env_all BLACS env for the total environment
614!> \param para_env_kp parallel environment of the kpoint calculation
615!> \param para_env_inter_kp parallel environment between kpoints
616!> \param blacs_env BLACS env for the kpoint group
617!> \param kp_env Information for each kpoint
618!> \param kp_aux_env ...
619!> \param mpools FM matrix pools for kpoint groups
620!> \param iogrp this kpoint group has the IO processor
621!> \param nkp_groups number of kpoint groups
622!> \param kp_dist kpoints distribution on groups
623!> \param cell_to_index given a cell triple, returns the real space index
624!> \param index_to_cell ...
625!> \param sab_nl neighbourlist that defines real space matrices
626!> \param sab_nl_nosym neighbourlist that defines real space matrices
627!> \param inversion_symmetry_only reduce kpoints only by inversion symmetry
628!> \param symmetry_backend k-point symmetry backend
629!> \param symmetry_reduction_method k-point symmetry reduction method
630!> \param gamma_centered ...
631!> \author JGH
632! **************************************************************************************************
633 SUBROUTINE set_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, &
634 full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, &
635 para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, &
636 kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, &
637 sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, &
638 symmetry_reduction_method, gamma_centered)
639 TYPE(kpoint_type), INTENT(INOUT) :: kpoint
640 CHARACTER(LEN=*), OPTIONAL :: kp_scheme
641 INTEGER, DIMENSION(3), OPTIONAL :: nkp_grid
642 REAL(kind=dp), DIMENSION(3), OPTIONAL :: kp_shift
643 LOGICAL, OPTIONAL :: symmetry, verbose, full_grid, &
645 REAL(kind=dp), OPTIONAL :: eps_geo
646 INTEGER, OPTIONAL :: parallel_group_size
647 INTEGER, DIMENSION(2), OPTIONAL :: kp_range
648 INTEGER, OPTIONAL :: nkp
649 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: xkp
650 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: wkp
651 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
652 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env_all
653 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env_kp, para_env_inter_kp
654 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env
655 TYPE(kpoint_env_p_type), DIMENSION(:), OPTIONAL, &
656 POINTER :: kp_env, kp_aux_env
657 TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
658 LOGICAL, OPTIONAL :: iogrp
659 INTEGER, OPTIONAL :: nkp_groups
660 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: kp_dist
661 INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER :: cell_to_index
662 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: index_to_cell
663 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
664 OPTIONAL, POINTER :: sab_nl, sab_nl_nosym
665 LOGICAL, OPTIONAL :: inversion_symmetry_only
666 INTEGER, OPTIONAL :: symmetry_backend, &
667 symmetry_reduction_method
668 LOGICAL, OPTIONAL :: gamma_centered
669
670 IF (PRESENT(kp_scheme)) kpoint%kp_scheme = kp_scheme
671 IF (PRESENT(nkp_grid)) kpoint%nkp_grid = nkp_grid
672 IF (PRESENT(kp_shift)) kpoint%kp_shift = kp_shift
673 IF (PRESENT(gamma_centered)) kpoint%gamma_centered = gamma_centered
674 IF (PRESENT(symmetry)) kpoint%symmetry = symmetry
675 IF (PRESENT(verbose)) kpoint%verbose = verbose
676 IF (PRESENT(full_grid)) kpoint%full_grid = full_grid
677 IF (PRESENT(inversion_symmetry_only)) kpoint%inversion_symmetry_only = inversion_symmetry_only
678 IF (PRESENT(symmetry_backend)) kpoint%symmetry_backend = symmetry_backend
679 IF (PRESENT(symmetry_reduction_method)) &
680 kpoint%symmetry_reduction_method = symmetry_reduction_method
681 IF (PRESENT(use_real_wfn)) kpoint%use_real_wfn = use_real_wfn
682 IF (PRESENT(eps_geo)) kpoint%eps_geo = eps_geo
683 IF (PRESENT(parallel_group_size)) kpoint%parallel_group_size = parallel_group_size
684
685 IF (PRESENT(nkp)) kpoint%nkp = nkp
686 IF (PRESENT(wkp)) kpoint%wkp => wkp
687 IF (PRESENT(xkp)) kpoint%xkp => xkp
688
689 IF (PRESENT(para_env)) kpoint%para_env => para_env
690 IF (PRESENT(para_env_kp)) kpoint%para_env_kp => para_env_kp
691 IF (PRESENT(para_env_inter_kp)) kpoint%para_env_inter_kp => para_env_inter_kp
692 IF (PRESENT(blacs_env_all)) kpoint%blacs_env_all => blacs_env_all
693 IF (PRESENT(blacs_env)) kpoint%blacs_env => blacs_env
694
695 IF (PRESENT(iogrp)) kpoint%iogrp = iogrp
696 IF (PRESENT(kp_range)) kpoint%kp_range = kp_range
697 IF (PRESENT(nkp_groups)) kpoint%nkp_groups = nkp_groups
698 IF (PRESENT(kp_dist)) kpoint%kp_dist => kp_dist
699
700 IF (PRESENT(kp_env)) kpoint%kp_env => kp_env
701 IF (PRESENT(kp_env)) kpoint%kp_aux_env => kp_aux_env
702 IF (PRESENT(mpools)) kpoint%mpools => mpools
703 IF (PRESENT(sab_nl)) kpoint%sab_nl => sab_nl
704 IF (PRESENT(sab_nl_nosym)) kpoint%sab_nl_nosym => sab_nl_nosym
705
706 IF (PRESENT(cell_to_index)) THEN
707 IF (ASSOCIATED(kpoint%cell_to_index)) DEALLOCATE (kpoint%cell_to_index)
708 kpoint%cell_to_index => cell_to_index
709 END IF
710
711 IF (PRESENT(index_to_cell)) THEN
712 IF (ASSOCIATED(kpoint%index_to_cell)) DEALLOCATE (kpoint%index_to_cell)
713 kpoint%index_to_cell => index_to_cell
714 END IF
715
716 END SUBROUTINE set_kpoint_info
717
718! **************************************************************************************************
719!> \brief Read the kpoint input section
720!> \param kpoint The kpoint environment
721!> \param kpoint_section The input section
722!> \param a_vec ...
723!> \author JGH
724! **************************************************************************************************
725 SUBROUTINE read_kpoint_section(kpoint, kpoint_section, a_vec)
726 TYPE(kpoint_type), INTENT(INOUT) :: kpoint
727 TYPE(section_vals_type), POINTER :: kpoint_section
728 REAL(kind=dp), DIMENSION(3, 3), INTENT(IN) :: a_vec
729
730 CHARACTER(LEN=default_string_length) :: ustr
731 CHARACTER(LEN=default_string_length), &
732 DIMENSION(:), POINTER :: tmpstringlist
733 INTEGER :: i, n_rep, nval, wfntype
734 LOGICAL :: available, backend_explicit, &
735 reduction_explicit
736 REAL(kind=dp) :: ff
737 REAL(kind=dp), DIMENSION(:), POINTER :: reallist
738
739 CALL section_vals_get(kpoint_section, explicit=available)
740
741 IF (available) THEN
742 CALL section_vals_val_get(kpoint_section, "SCHEME", c_vals=tmpstringlist)
743 nval = SIZE(tmpstringlist)
744 cpassert(nval >= 1)
745 kpoint%kp_scheme = tmpstringlist(1)
746 CALL uppercase(kpoint%kp_scheme)
747
748 ! SCHEME [None, Gamma, Monkhorst-Pack, MacDonald, General]
749 SELECT CASE (kpoint%kp_scheme)
750 CASE ("NONE")
751 ! do nothing
752 CASE ("GAMMA")
753 ! do nothing
754 CASE ("MONKHORST-PACK")
755 cpassert(nval >= 4)
756 DO i = 2, 4
757 READ (tmpstringlist(i), *) kpoint%nkp_grid(i - 1)
758 END DO
759 CASE ("MACDONALD")
760 cpassert(nval >= 7)
761 DO i = 2, 4
762 READ (tmpstringlist(i), *) kpoint%nkp_grid(i - 1)
763 END DO
764 DO i = 5, 7
765 READ (tmpstringlist(i), *) kpoint%kp_shift(i - 4)
766 END DO
767 CASE ("GENERAL")
768 CALL section_vals_val_get(kpoint_section, "UNITS", c_val=ustr)
769 CALL uppercase(ustr)
770 CALL section_vals_val_get(kpoint_section, "KPOINT", n_rep_val=n_rep)
771 kpoint%nkp = n_rep
772 IF (ASSOCIATED(kpoint%xkp_input)) THEN
773 DEALLOCATE (kpoint%xkp_input)
774 NULLIFY (kpoint%xkp_input)
775 END IF
776 IF (ASSOCIATED(kpoint%wkp_input)) THEN
777 DEALLOCATE (kpoint%wkp_input)
778 NULLIFY (kpoint%wkp_input)
779 END IF
780 ALLOCATE (kpoint%xkp(3, n_rep), kpoint%wkp(n_rep))
781 DO i = 1, n_rep
782 CALL section_vals_val_get(kpoint_section, "KPOINT", i_rep_val=i, &
783 r_vals=reallist)
784 nval = SIZE(reallist)
785 cpassert(nval >= 4)
786 SELECT CASE (ustr)
787 CASE ("B_VECTOR")
788 kpoint%xkp(1:3, i) = reallist(1:3)
789 CASE ("CART_ANGSTROM")
790 kpoint%xkp(1:3, i) = (reallist(1)*a_vec(1, 1:3) + &
791 reallist(2)*a_vec(2, 1:3) + &
792 reallist(3)*a_vec(3, 1:3))/twopi*angstrom
793 CASE ("CART_BOHR")
794 kpoint%xkp(1:3, i) = (reallist(1)*a_vec(1, 1:3) + &
795 reallist(2)*a_vec(2, 1:3) + &
796 reallist(3)*a_vec(3, 1:3))/twopi
797 CASE DEFAULT
798 cpabort("Unknown Unit for kpoint definition")
799 END SELECT
800 kpoint%wkp(i) = reallist(4)
801 END DO
802 ff = 1.0_dp/sum(kpoint%wkp(:))
803 kpoint%wkp(:) = ff*kpoint%wkp(:)
804 ALLOCATE (kpoint%xkp_input(3, n_rep), kpoint%wkp_input(n_rep))
805 kpoint%xkp_input(1:3, 1:n_rep) = kpoint%xkp(1:3, 1:n_rep)
806 kpoint%wkp_input(1:n_rep) = kpoint%wkp(1:n_rep)
807 CASE DEFAULT
808 cpabort("")
809 END SELECT
810
811 CALL section_vals_val_get(kpoint_section, "GAMMA_CENTERED", l_val=kpoint%gamma_centered)
812 IF (kpoint%gamma_centered .AND. kpoint%kp_scheme /= "MONKHORST-PACK" .AND. &
813 kpoint%kp_scheme /= "MACDONALD") THEN
814 CALL cp_abort(__location__, &
815 "KPOINTS%GAMMA_CENTERED is only supported with SCHEME MONKHORST-PACK or MACDONALD")
816 END IF
817
818 CALL section_vals_val_get(kpoint_section, "SYMMETRY", l_val=kpoint%symmetry)
819 CALL section_vals_val_get(kpoint_section, "WAVEFUNCTIONS", i_val=wfntype)
820 CALL section_vals_val_get(kpoint_section, "VERBOSE", l_val=kpoint%verbose)
821 CALL section_vals_val_get(kpoint_section, "FULL_GRID", l_val=kpoint%full_grid)
822 CALL section_vals_val_get(kpoint_section, "INVERSION_SYMMETRY_ONLY", &
823 l_val=kpoint%inversion_symmetry_only)
824 CALL section_vals_val_get(kpoint_section, "SYMMETRY_BACKEND", &
825 i_val=kpoint%symmetry_backend, explicit=backend_explicit)
826 CALL section_vals_val_get(kpoint_section, "SYMMETRY_REDUCTION_METHOD", &
827 i_val=kpoint%symmetry_reduction_method, explicit=reduction_explicit)
828 CALL resolve_kpoint_symmetry_settings(kpoint, backend_explicit, reduction_explicit)
829 CALL section_vals_val_get(kpoint_section, "EPS_SYMMETRY", r_val=kpoint%eps_geo)
830 CALL section_vals_val_get(kpoint_section, "PARALLEL_GROUP_SIZE", &
831 i_val=kpoint%parallel_group_size)
832 SELECT CASE (wfntype)
833 CASE (use_real_wfn)
834 kpoint%use_real_wfn = .true.
835 CASE (use_complex_wfn)
836 kpoint%use_real_wfn = .false.
837 CASE DEFAULT
838 cpabort("")
839 END SELECT
840
841 ELSE
842 kpoint%kp_scheme = "NONE"
843 END IF
844
845 END SUBROUTINE read_kpoint_section
846
847! **************************************************************************************************
848!> \brief Resolve legacy and backend k-point symmetry settings
849!> \param kpoint ...
850!> \param backend_explicit whether SYMMETRY_BACKEND was given
851!> \param reduction_explicit whether SYMMETRY_REDUCTION_METHOD was given
852! **************************************************************************************************
853 SUBROUTINE resolve_kpoint_symmetry_settings(kpoint, backend_explicit, reduction_explicit)
854 TYPE(kpoint_type), INTENT(INOUT) :: kpoint
855 LOGICAL, INTENT(IN) :: backend_explicit, reduction_explicit
856
857 IF (backend_explicit .AND. .NOT. reduction_explicit) THEN
858 SELECT CASE (kpoint%symmetry_backend)
860 kpoint%symmetry_reduction_method = use_k290_kpoint_symmetry
862 kpoint%symmetry_reduction_method = use_spglib_kpoint_symmetry
863 CASE DEFAULT
864 cpabort("Unknown k-point symmetry backend")
865 END SELECT
866 END IF
867
868 IF (kpoint%symmetry_backend == use_spglib_kpoint_backend .AND. &
869 kpoint%symmetry_reduction_method /= use_spglib_kpoint_symmetry) THEN
870 CALL cp_abort(__location__, &
871 "SYMMETRY_BACKEND SPGLIB requires SYMMETRY_REDUCTION_METHOD SPGLIB")
872 END IF
873
874 END SUBROUTINE resolve_kpoint_symmetry_settings
875
876! **************************************************************************************************
877!> \brief Write information on the kpoints to output
878!> \param kpoint The kpoint environment
879!> \param iounit output unit
880!> \param dft_section DFT section information for output unit
881!> \author JGH
882! **************************************************************************************************
883 SUBROUTINE write_kpoint_info(kpoint, iounit, dft_section)
884 TYPE(kpoint_type), INTENT(IN) :: kpoint
885 INTEGER, INTENT(IN), OPTIONAL :: iounit
886 TYPE(section_vals_type), INTENT(IN), OPTIONAL :: dft_section
887
888 INTEGER :: i, punit
889 TYPE(cp_logger_type), POINTER :: logger
890
891 NULLIFY (logger)
892 logger => cp_get_default_logger()
893
894 IF (PRESENT(dft_section)) THEN
895 punit = cp_print_key_unit_nr(logger, dft_section, "PRINT%KPOINTS", extension=".Log")
896 ELSE IF (PRESENT(iounit)) THEN
897 punit = iounit
898 ELSE
899 punit = cp_logger_get_default_unit_nr(logger)
900 END IF
901
902 IF (punit > 0) THEN
903
904 IF (kpoint%kp_scheme /= "NONE") THEN
905 WRITE (punit, '(/," ",79("*"),/,T37,A,/," ",79("*"))') "Kpoints"
906 END IF
907 SELECT CASE (kpoint%kp_scheme)
908 CASE ("NONE")
909 ! be silent
910 CASE ("GAMMA")
911 WRITE (punit, '(A,T57,A)') ' BRILLOUIN|', ' Gamma-point calculation'
912 CASE ("MONKHORST-PACK")
913 WRITE (punit, '(A,T61,A20)') ' BRILLOUIN| K-point scheme ', ' Monkhorst-Pack'
914 WRITE (punit, '(A,T66,3I5)') ' BRILLOUIN| K-Point grid', kpoint%nkp_grid
915 IF (kpoint%gamma_centered) THEN
916 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Gamma-centered k-point mesh', ' ON'
917 END IF
918 WRITE (punit, '(A,T66,G15.6)') &
919 ' BRILLOUIN| K-point symmetry accuracy', kpoint%eps_geo
920 CASE ("MACDONALD")
921 WRITE (punit, '(A,T71,A10)') ' BRILLOUIN| K-point scheme ', ' MacDonald'
922 WRITE (punit, '(A,T66,3I5)') ' BRILLOUIN| K-Point grid', kpoint%nkp_grid
923 WRITE (punit, '(A,T51,3F10.4)') ' BRILLOUIN| K-Point shift', kpoint%kp_shift
924 IF (kpoint%gamma_centered) THEN
925 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Gamma-centered k-point mesh', ' ON'
926 END IF
927 WRITE (punit, '(A,T66,G15.6)') &
928 ' BRILLOUIN| K-point symmetry accuracy', kpoint%eps_geo
929 CASE ("GENERAL")
930 WRITE (punit, '(A,T71,A10)') ' BRILLOUIN| K-point scheme ', ' General'
931 CASE DEFAULT
932 cpabort("")
933 END SELECT
934 IF (kpoint%kp_scheme /= "NONE") THEN
935 IF (kpoint%symmetry) THEN
936 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| K-Point point group symmetrization', ' ON'
937 ELSE
938 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| K-Point point group symmetrization', ' OFF'
939 END IF
940 IF (kpoint%inversion_symmetry_only) THEN
941 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Restrict symmetry to inversion', ' ON'
942 END IF
943 IF (kpoint%symmetry .AND. .NOT. kpoint%full_grid .AND. &
944 .NOT. kpoint%inversion_symmetry_only .AND. &
945 (kpoint%kp_scheme == "MONKHORST-PACK" .OR. kpoint%kp_scheme == "MACDONALD" .OR. &
946 kpoint%kp_scheme == "GENERAL")) THEN
947 SELECT CASE (kpoint%symmetry_backend)
949 WRITE (punit, '(A,T73,A)') ' BRILLOUIN| Symmetry backend', ' K290'
951 WRITE (punit, '(A,T73,A)') ' BRILLOUIN| Symmetry backend', ' SPGLIB'
952 CASE DEFAULT
953 cpabort("Unknown k-point symmetry backend")
954 END SELECT
955 SELECT CASE (kpoint%symmetry_reduction_method)
957 WRITE (punit, '(A,T73,A)') ' BRILLOUIN| Symmetry reduction method', ' K290'
959 WRITE (punit, '(A,T73,A)') ' BRILLOUIN| Symmetry reduction method', ' SPGLIB'
960 CASE DEFAULT
961 cpabort("Unknown k-point symmetry reduction method")
962 END SELECT
963 END IF
964 IF (kpoint%use_real_wfn) THEN
965 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Wavefunction type', ' REAL'
966 ELSE
967 WRITE (punit, '(A,T73,A)') ' BRILLOUIN| Wavefunction type', ' COMPLEX'
968 END IF
969 IF (kpoint%full_grid) THEN
970 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Use full k-point grid '
971 END IF
972 IF (kpoint%kp_scheme /= "GAMMA") THEN
973 WRITE (punit, '(A,T71,I10)') ' BRILLOUIN| List of Kpoints [2 Pi/Bohr]', kpoint%nkp
974 WRITE (punit, '(A,T30,A,T48,A,T63,A,T78,A)') &
975 ' BRILLOUIN| Number ', 'Weight', 'X', 'Y', 'Z'
976 DO i = 1, kpoint%nkp
977 WRITE (punit, '(A,I5,3X,4F15.5)') ' BRILLOUIN| ', i, kpoint%wkp(i), &
978 kpoint%xkp(1, i), kpoint%xkp(2, i), kpoint%xkp(3, i)
979 END DO
980 END IF
981 WRITE (punit, '(" ",79("*"))')
982 END IF
983
984 END IF
985
986 IF (PRESENT(dft_section)) THEN
987 CALL cp_print_key_finished_output(punit, logger, dft_section, "PRINT%KPOINTS")
988 END IF
989
990 END SUBROUTINE write_kpoint_info
991
992! **************************************************************************************************
993!> \brief Create a single kpoint environment
994!> \param kp_env Single kpoint environment
995!> \author JGH
996! **************************************************************************************************
997 SUBROUTINE kpoint_env_create(kp_env)
998 TYPE(kpoint_env_type), POINTER :: kp_env
999
1000 cpassert(.NOT. ASSOCIATED(kp_env))
1001
1002 ALLOCATE (kp_env)
1003
1004 kp_env%nkpoint = 0
1005 kp_env%wkp = 0.0_dp
1006 kp_env%xkp = 0.0_dp
1007 kp_env%is_local = .false.
1008
1009 NULLIFY (kp_env%mos)
1010 NULLIFY (kp_env%pmat)
1011 NULLIFY (kp_env%wmat)
1012 NULLIFY (kp_env%smat)
1013 NULLIFY (kp_env%amat)
1014
1015 END SUBROUTINE kpoint_env_create
1016
1017! **************************************************************************************************
1018!> \brief Release a single kpoint environment
1019!> \param kp_env Single kpoint environment
1020!> \author JGH
1021! **************************************************************************************************
1022 SUBROUTINE kpoint_env_release(kp_env)
1023 TYPE(kpoint_env_type), POINTER :: kp_env
1024
1025 INTEGER :: ic, is
1026
1027 IF (ASSOCIATED(kp_env)) THEN
1028
1029 IF (ASSOCIATED(kp_env%mos)) THEN
1030 DO is = 1, SIZE(kp_env%mos, 2)
1031 DO ic = 1, SIZE(kp_env%mos, 1)
1032 CALL deallocate_mo_set(kp_env%mos(ic, is))
1033 END DO
1034 END DO
1035 DEALLOCATE (kp_env%mos)
1036 END IF
1037
1038 CALL cp_fm_release(kp_env%pmat)
1039 CALL cp_fm_release(kp_env%wmat)
1040 CALL cp_fm_release(kp_env%smat)
1041 CALL cp_fm_release(kp_env%amat)
1042
1043 CALL cp_fm_release(kp_env%shalf)
1044 CALL cp_cfm_release(kp_env%cshalf)
1045
1046 DEALLOCATE (kp_env)
1047
1048 END IF
1049
1050 END SUBROUTINE kpoint_env_release
1051
1052! **************************************************************************************************
1053!> \brief Get information from a single kpoint environment
1054!> \param kpoint_env Single kpoint environment
1055!> \param nkpoint Index of kpoint
1056!> \param wkp Weight of kpoint
1057!> \param xkp Coordinates of kpoint
1058!> \param is_local Is this kpoint local (single cpu group)
1059!> \param mos MOs of this kpoint
1060!> \author JGH
1061! **************************************************************************************************
1062 SUBROUTINE get_kpoint_env(kpoint_env, nkpoint, wkp, xkp, is_local, mos)
1063 TYPE(kpoint_env_type), INTENT(IN) :: kpoint_env
1064 INTEGER, OPTIONAL :: nkpoint
1065 REAL(kind=dp), OPTIONAL :: wkp
1066 REAL(kind=dp), DIMENSION(3), OPTIONAL :: xkp
1067 LOGICAL, OPTIONAL :: is_local
1068 TYPE(mo_set_type), DIMENSION(:, :), OPTIONAL, &
1069 POINTER :: mos
1070
1071 IF (PRESENT(nkpoint)) nkpoint = kpoint_env%nkpoint
1072 IF (PRESENT(wkp)) wkp = kpoint_env%wkp
1073 IF (PRESENT(xkp)) xkp = kpoint_env%xkp
1074 IF (PRESENT(is_local)) is_local = kpoint_env%is_local
1075 IF (PRESENT(mos)) mos => kpoint_env%mos
1076
1077 END SUBROUTINE get_kpoint_env
1078
1079! **************************************************************************************************
1080!> \brief Create a single kpoint symmetry environment
1081!> \param kp_sym ...
1082!> \author JGH
1083! **************************************************************************************************
1084 SUBROUTINE kpoint_sym_create(kp_sym)
1085 TYPE(kpoint_sym_type), POINTER :: kp_sym
1086
1087 cpassert(.NOT. ASSOCIATED(kp_sym))
1088
1089 ALLOCATE (kp_sym)
1090
1091 kp_sym%nwght = 0
1092 kp_sym%nwred = 0
1093 kp_sym%apply_symmetry = .false.
1094
1095 NULLIFY (kp_sym%rot)
1096 NULLIFY (kp_sym%xkp)
1097 NULLIFY (kp_sym%rotp)
1098 NULLIFY (kp_sym%f0)
1099 NULLIFY (kp_sym%fcell)
1100 NULLIFY (kp_sym%kgphase)
1101
1102 END SUBROUTINE kpoint_sym_create
1103
1104! **************************************************************************************************
1105!> \brief Release a single kpoint symmetry environment
1106!> \param kp_sym ...
1107!> \author JGH
1108! **************************************************************************************************
1109 SUBROUTINE kpoint_sym_release(kp_sym)
1110 TYPE(kpoint_sym_type), POINTER :: kp_sym
1111
1112 IF (ASSOCIATED(kp_sym)) THEN
1113
1114 IF (ASSOCIATED(kp_sym%rot)) THEN
1115 DEALLOCATE (kp_sym%rot)
1116 END IF
1117 IF (ASSOCIATED(kp_sym%xkp)) THEN
1118 DEALLOCATE (kp_sym%xkp)
1119 END IF
1120 IF (ASSOCIATED(kp_sym%f0)) THEN
1121 DEALLOCATE (kp_sym%f0)
1122 END IF
1123 IF (ASSOCIATED(kp_sym%fcell)) THEN
1124 DEALLOCATE (kp_sym%fcell)
1125 END IF
1126 IF (ASSOCIATED(kp_sym%kgphase)) THEN
1127 DEALLOCATE (kp_sym%kgphase)
1128 END IF
1129 IF (ASSOCIATED(kp_sym%rotp)) THEN
1130 DEALLOCATE (kp_sym%rotp)
1131 END IF
1132
1133 DEALLOCATE (kp_sym)
1134
1135 END IF
1136
1137 END SUBROUTINE kpoint_sym_release
1138
1139! **************************************************************************************************
1140
1141END MODULE kpoint_types
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full 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 ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
function that build the kpoints section of the input
integer, parameter, public use_spglib_kpoint_symmetry
integer, parameter, public use_k290_kpoint_symmetry
integer, parameter, public use_real_wfn
integer, parameter, public use_spglib_kpoint_backend
integer, parameter, public use_k290_kpoint_backend
integer, parameter, public use_complex_wfn
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Types and basic routines needed for a kpoint calculation.
subroutine, public read_kpoint_section(kpoint, kpoint_section, a_vec)
Read the kpoint input section.
subroutine, public kpoint_sym_create(kp_sym)
Create a single kpoint symmetry environment.
subroutine, public set_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered)
Set information in a kpoint environment.
subroutine, public get_kpoint_env(kpoint_env, nkpoint, wkp, xkp, is_local, mos)
Get information from a single kpoint environment.
subroutine, public kpoint_reset_initialization(kpoint)
Reset all data derived from a concrete k-point initialization. Input options such as the scheme,...
subroutine, public kpoint_env_create(kp_env)
Create a single kpoint environment.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered)
Retrieve information from a kpoint environment.
subroutine, public write_kpoint_info(kpoint, iounit, dft_section)
Write information on the kpoints to output.
subroutine, public kpoint_release(kpoint)
Release a kpoint environment, deallocate all data.
subroutine, public kpoint_create(kpoint)
Create a kpoint environment.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public angstrom
Definition physcon.F:144
buffer for the diis of the scf
subroutine, public qs_diis_b_release_kp(diis_buffer)
releases the given diis KP buffer
wrapper for the pools of matrixes
subroutine, public mpools_release(mpools)
releases the given mpools
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
Define the neighbor list data types and the corresponding functionality.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
Represent a complex full matrix.
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Rotation matrices for basis sets.
Keeps information about a specific k-point.
Keeps symmetry information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
build arrau of pointers to diis buffers in the k-point (complex full matrices) case
container for the pools of matrixes used by qs