(git:9754b87)
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-2025 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_fm_types, ONLY: cp_fm_release,&
29 USE kinds, ONLY: default_string_length,&
30 dp
31 USE mathconstants, ONLY: twopi
34 USE physcon, ONLY: angstrom
43#include "./base/base_uses.f90"
44
45 IMPLICIT NONE
46
47 PRIVATE
48
49 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'kpoint_types'
50
51 PUBLIC :: kpoint_type
56 PUBLIC :: kind_rotmat_type
57 PUBLIC :: kpoint_sym_type
58 PUBLIC :: kpoint_sym_create
59
60! **************************************************************************************************
61!> \brief Keeps information about a specific k-point
62!> \param nkpoint the kpoint index
63!> \param wkp weight of this kpoint
64!> \param xkp kpoint coordinates in units of b-vector
65!> \param is_local if this kpoint is calculated on a single thread
66!> \param mos associated MOs (r/i,spin)
67!> \param pmat associated density matrix (r/i,spin)
68!> \param wmat associated energy weighted density matrix (r/i,spin)
69!> \param smat associated overlap matrix (for ADMM) (r/i,spin)
70!> \param amat associated ADMM basis projection matrix (r/i,spin)
71!> \author JGH
72! **************************************************************************************************
74 INTEGER :: nkpoint = -1
75 REAL(kind=dp) :: wkp = 0.0_dp
76 REAL(kind=dp), DIMENSION(3) :: xkp = 0.0_dp
77 LOGICAL :: is_local = .false.
78 TYPE(mo_set_type), DIMENSION(:, :), POINTER :: mos => null()
79 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: pmat => null()
80 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: wmat => null()
81 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: smat => null()
82 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: amat => null()
83 END TYPE kpoint_env_type
84
86 TYPE(kpoint_env_type), POINTER :: kpoint_env => null()
87 END TYPE kpoint_env_p_type
88
89! **************************************************************************************************
90!> \brief Rotation matrices for basis sets
91!> \param rmat atom basis function rotation matrix
92!> \author JGH
93! **************************************************************************************************
95 REAL(kind=dp), DIMENSION(:, :), POINTER :: rmat => null()
96 END TYPE kind_rotmat_type
97
98! **************************************************************************************************
99!> \brief Keeps symmetry information about a specific k-point
100!> \param apply_symmetry ...
101!> \param nwght kpoint multiplicity
102!> \param xkp kpoint coordinates
103!> \param rot rotation matrices
104!> \param f0 atom permutation
105!> \author JGH
106! **************************************************************************************************
108 LOGICAL :: apply_symmetry = .false.
109 INTEGER :: nwght = -1
110 INTEGER :: nwred = -1
111 REAL(kind=dp), DIMENSION(:, :), POINTER :: xkp => null()
112 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: rot => null()
113 INTEGER, DIMENSION(:), POINTER :: rotp => null()
114 INTEGER, DIMENSION(:, :), POINTER :: f0 => null()
115 END TYPE kpoint_sym_type
116
117 TYPE kpoint_sym_p_type
118 TYPE(kpoint_sym_type), POINTER :: kpoint_sym => null()
119 END TYPE kpoint_sym_p_type
120
121! **************************************************************************************************
122!> \brief Contains information about kpoints
123!> \par History
124!> 2014.07 created [JGH]
125!> \param kp_scheme [input] Type of kpoint grid
126!> \param nkp_grid [input] Grid points
127!> \param kp_shift [input] Shift of the grid
128!> \param use_real_wfn [input] real/complex wfn
129!> \param symmetry [input] use symmetry (atoms) to reduce kpoints
130!> \param full_grid [input] don't reduce kpoints at all
131!> \param verbose [input] more output information
132!> \param eps_geo [input] accuracy of atom symmetry detection
133!> \param parallel_group_size [input] kpoint group size
134!> \param nkp number of kpoints
135!> \param xkp kpoint coordinates
136!> \param wkp kpoint weights
137!> \param para_env 'global' parallel environment
138!> \param para_env_kp parallel environment of the kpoint calculation
139!> \param para_env_inter_kp parallel environment between kpoints
140!> \param iogrp this kpoint group has the IO processor
141!> \param nkp_groups number of kpoint groups
142!> \param kp_dist kpoints distribution on groups
143!> \param kp_range kpoints distribution for local processor
144!> \param blacs_env BLACS env for the kpoint group
145!> \param opmats Operator matrices
146!> \param kp_env Information for each kpoint
147!> \param mpools FM matrix pools for kpoint groups
148!> \author JGH
149! **************************************************************************************************
151 CHARACTER(LEN=default_string_length) :: kp_scheme = ""
152 INTEGER, DIMENSION(3) :: nkp_grid = -1
153 REAL(kind=dp), DIMENSION(3) :: kp_shift = 0.0_dp
154 LOGICAL :: use_real_wfn = .false.
155 LOGICAL :: symmetry = .false.
156 LOGICAL :: full_grid = .false.
157 LOGICAL :: verbose = .false.
158 REAL(kind=dp) :: eps_geo = 0.0_dp
159 INTEGER :: parallel_group_size = -1
160 INTEGER :: nkp = -1
161 REAL(kind=dp), DIMENSION(:, :), POINTER :: xkp => null()
162 REAL(kind=dp), DIMENSION(:), POINTER :: wkp => null()
163 ! parallel environment
164 TYPE(mp_para_env_type), POINTER :: para_env => null()
165 TYPE(cp_blacs_env_type), POINTER :: blacs_env_all => null()
166 TYPE(mp_para_env_type), POINTER :: para_env_kp => null(), &
167 para_env_inter_kp => null()
168 LOGICAL :: iogrp = .false.
169 INTEGER :: nkp_groups = -1
170 INTEGER, DIMENSION(:, :), POINTER :: kp_dist => null()
171 INTEGER, DIMENSION(2) :: kp_range = -1
172 TYPE(cp_blacs_env_type), POINTER :: blacs_env => null()
173 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index => null()
174 INTEGER, DIMENSION(:, :), POINTER :: index_to_cell => null()
176 DIMENSION(:), POINTER :: sab_nl => null(), &
177 sab_nl_nosym => null()
178 ! environment
179 TYPE(kpoint_env_p_type), DIMENSION(:), &
180 POINTER :: kp_env => null()
181 TYPE(kpoint_env_p_type), DIMENSION(:), &
182 POINTER :: kp_aux_env => null()
183 ! symmetry
184 TYPE(kpoint_sym_p_type), DIMENSION(:), &
185 POINTER :: kp_sym => null()
186 INTEGER, DIMENSION(:), POINTER :: atype => null()
187 INTEGER, DIMENSION(:), POINTER :: ibrot => null()
188 TYPE(kind_rotmat_type), DIMENSION(:, :), &
189 POINTER :: kind_rotmat => null()
190 ! pools
191 TYPE(qs_matrix_pools_type), POINTER :: mpools => null()
192 TYPE(qs_diis_buffer_type_kp), POINTER :: scf_diis_buffer => null()
193 TYPE(qs_matrix_pools_type), POINTER :: mpools_aux_fit => null()
194 END TYPE kpoint_type
195
196! **************************************************************************************************
197
198CONTAINS
199
200! **************************************************************************************************
201!> \brief Create a kpoint environment
202!> \param kpoint All the kpoint information
203!> \author JGH
204! **************************************************************************************************
205 SUBROUTINE kpoint_create(kpoint)
206 TYPE(kpoint_type), POINTER :: kpoint
207
208 cpassert(.NOT. ASSOCIATED(kpoint))
209
210 ALLOCATE (kpoint)
211
212 kpoint%kp_scheme = ""
213 kpoint%nkp_grid = 0
214 kpoint%kp_shift = 0.0_dp
215 kpoint%symmetry = .false.
216 kpoint%verbose = .false.
217 kpoint%full_grid = .false.
218 kpoint%use_real_wfn = .false.
219 kpoint%eps_geo = 1.0e-6_dp
220 kpoint%parallel_group_size = -1
221
222 kpoint%nkp = 0
223
224 NULLIFY (kpoint%xkp, kpoint%wkp)
225 NULLIFY (kpoint%kp_dist)
226
227 NULLIFY (kpoint%para_env)
228 NULLIFY (kpoint%blacs_env_all)
229 NULLIFY (kpoint%para_env_kp, kpoint%para_env_inter_kp)
230 NULLIFY (kpoint%blacs_env)
231 kpoint%nkp_groups = 0
232 kpoint%iogrp = .false.
233 kpoint%kp_range = 0
234
235 NULLIFY (kpoint%kp_env)
236 NULLIFY (kpoint%mpools)
237
238 ALLOCATE (kpoint%cell_to_index(0:0, 0:0, 0:0))
239 kpoint%cell_to_index(:, :, :) = 1
240
241 ALLOCATE (kpoint%index_to_cell(0:0, 0:0))
242 kpoint%index_to_cell(:, :) = 0
243
244 END SUBROUTINE kpoint_create
245
246! **************************************************************************************************
247!> \brief Release a kpoint environment, deallocate all data
248!> \param kpoint The kpoint environment
249!> \author JGH
250! **************************************************************************************************
251 SUBROUTINE kpoint_release(kpoint)
252 TYPE(kpoint_type), POINTER :: kpoint
253
254 INTEGER :: i, ik, j
255
256 IF (ASSOCIATED(kpoint)) THEN
257
258 IF (ASSOCIATED(kpoint%xkp)) THEN
259 DEALLOCATE (kpoint%xkp)
260 END IF
261 IF (ASSOCIATED(kpoint%wkp)) THEN
262 DEALLOCATE (kpoint%wkp)
263 END IF
264 IF (ASSOCIATED(kpoint%kp_dist)) THEN
265 DEALLOCATE (kpoint%kp_dist)
266 END IF
267
268 CALL mpools_release(kpoint%mpools)
269 CALL mpools_release(kpoint%mpools_aux_fit)
270
271 CALL cp_blacs_env_release(kpoint%blacs_env)
272 CALL cp_blacs_env_release(kpoint%blacs_env_all)
273
274 CALL mp_para_env_release(kpoint%para_env)
275 CALL mp_para_env_release(kpoint%para_env_kp)
276 CALL mp_para_env_release(kpoint%para_env_inter_kp)
277
278 IF (ASSOCIATED(kpoint%cell_to_index)) DEALLOCATE (kpoint%cell_to_index)
279 IF (ASSOCIATED(kpoint%index_to_cell)) DEALLOCATE (kpoint%index_to_cell)
280
281 IF (ASSOCIATED(kpoint%kp_env)) THEN
282 DO ik = 1, SIZE(kpoint%kp_env)
283 CALL kpoint_env_release(kpoint%kp_env(ik)%kpoint_env)
284 END DO
285 DEALLOCATE (kpoint%kp_env)
286 END IF
287
288 IF (ASSOCIATED(kpoint%kp_aux_env)) THEN
289 DO ik = 1, SIZE(kpoint%kp_aux_env)
290 CALL kpoint_env_release(kpoint%kp_aux_env(ik)%kpoint_env)
291 END DO
292 DEALLOCATE (kpoint%kp_aux_env)
293 END IF
294
295 IF (ASSOCIATED(kpoint%kp_sym)) THEN
296 DO ik = 1, SIZE(kpoint%kp_sym)
297 CALL kpoint_sym_release(kpoint%kp_sym(ik)%kpoint_sym)
298 END DO
299 DEALLOCATE (kpoint%kp_sym)
300 END IF
301
302 IF (ASSOCIATED(kpoint%atype)) DEALLOCATE (kpoint%atype)
303 IF (ASSOCIATED(kpoint%ibrot)) DEALLOCATE (kpoint%ibrot)
304
305 IF (ASSOCIATED(kpoint%kind_rotmat)) THEN
306 DO i = 1, SIZE(kpoint%kind_rotmat, 1)
307 DO j = 1, SIZE(kpoint%kind_rotmat, 2)
308 IF (ASSOCIATED(kpoint%kind_rotmat(i, j)%rmat)) THEN
309 DEALLOCATE (kpoint%kind_rotmat(i, j)%rmat)
310 END IF
311 END DO
312 END DO
313 DEALLOCATE (kpoint%kind_rotmat)
314 END IF
315
316 IF (ASSOCIATED(kpoint%scf_diis_buffer)) THEN
317 CALL qs_diis_b_release_kp(kpoint%scf_diis_buffer)
318 DEALLOCATE (kpoint%scf_diis_buffer)
319 END IF
320
321 DEALLOCATE (kpoint)
322
323 END IF
324
325 END SUBROUTINE kpoint_release
326
327! **************************************************************************************************
328!> \brief Retrieve information from a kpoint environment
329!> \param kpoint The kpoint environment
330!> \param kp_scheme Type of kpoint grid
331!> \param nkp_grid Grid points
332!> \param kp_shift Shift of the grid
333!> \param symmetry use symmetry (atoms) to reduce kpoints
334!> \param verbose more output information
335!> \param full_grid don't reduce kpoints at all
336!> \param use_real_wfn real/complex wfn
337!> \param eps_geo accuracy of atom symmetry detection
338!> \param parallel_group_size kpoint group size
339!> \param kp_range kpoints distribution for local processor
340!> \param nkp number of kpoints
341!> \param xkp kpoint coordinates in units of b-vector
342!> \param wkp kpoint weights
343!> \param para_env 'global' parallel environment
344!> \param blacs_env_all BLACS env for the total environment
345!> \param para_env_kp parallel environment of the kpoint calculation
346!> \param para_env_inter_kp parallel environment between kpoints
347!> \param blacs_env BLACS env for the kpoint group
348!> \param kp_env Information for each kpoint
349!> \param kp_aux_env ...
350!> \param mpools FM matrix pools for kpoint groups
351!> \param iogrp this kpoint group has the IO processor
352!> \param nkp_groups number of kpoint groups
353!> \param kp_dist kpoints distribution on groups
354!> \param cell_to_index given a cell triple, returns the real space index
355!> \param index_to_cell ...
356!> \param sab_nl neighbourlist that defines real space matrices
357!> \param sab_nl_nosym neighbourlist that defines real space matrices, non-symmetric
358!> \author JGH
359! **************************************************************************************************
360 SUBROUTINE get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, &
361 full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, &
362 para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, &
363 kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, &
364 sab_nl, sab_nl_nosym)
365 TYPE(kpoint_type), INTENT(IN) :: kpoint
366 CHARACTER(LEN=*), OPTIONAL :: kp_scheme
367 INTEGER, DIMENSION(3), OPTIONAL :: nkp_grid
368 REAL(kind=dp), DIMENSION(3), OPTIONAL :: kp_shift
369 LOGICAL, OPTIONAL :: symmetry, verbose, full_grid, &
371 REAL(kind=dp), OPTIONAL :: eps_geo
372 INTEGER, OPTIONAL :: parallel_group_size
373 INTEGER, DIMENSION(2), OPTIONAL :: kp_range
374 INTEGER, OPTIONAL :: nkp
375 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: xkp
376 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: wkp
377 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
378 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env_all
379 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env_kp, para_env_inter_kp
380 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env
381 TYPE(kpoint_env_p_type), DIMENSION(:), OPTIONAL, &
382 POINTER :: kp_env, kp_aux_env
383 TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
384 LOGICAL, OPTIONAL :: iogrp
385 INTEGER, OPTIONAL :: nkp_groups
386 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: kp_dist
387 INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER :: cell_to_index
388 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: index_to_cell
389 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
390 OPTIONAL, POINTER :: sab_nl, sab_nl_nosym
391
392 IF (PRESENT(kp_scheme)) kp_scheme = kpoint%kp_scheme
393 IF (PRESENT(nkp_grid)) nkp_grid = kpoint%nkp_grid
394 IF (PRESENT(kp_shift)) kp_shift = kpoint%kp_shift
395 IF (PRESENT(symmetry)) symmetry = kpoint%symmetry
396 IF (PRESENT(verbose)) verbose = kpoint%verbose
397 IF (PRESENT(full_grid)) full_grid = kpoint%full_grid
398 IF (PRESENT(use_real_wfn)) use_real_wfn = kpoint%use_real_wfn
399 IF (PRESENT(eps_geo)) eps_geo = kpoint%eps_geo
400 IF (PRESENT(parallel_group_size)) parallel_group_size = kpoint%parallel_group_size
401
402 IF (PRESENT(nkp)) nkp = kpoint%nkp
403 IF (PRESENT(wkp)) wkp => kpoint%wkp
404 IF (PRESENT(xkp)) xkp => kpoint%xkp
405
406 IF (PRESENT(para_env)) para_env => kpoint%para_env
407 IF (PRESENT(para_env_kp)) para_env_kp => kpoint%para_env_kp
408 IF (PRESENT(para_env_inter_kp)) para_env_inter_kp => kpoint%para_env_inter_kp
409 IF (PRESENT(blacs_env_all)) blacs_env_all => kpoint%blacs_env_all
410 IF (PRESENT(blacs_env)) blacs_env => kpoint%blacs_env
411
412 IF (PRESENT(iogrp)) iogrp = kpoint%iogrp
413 IF (PRESENT(kp_range)) kp_range = kpoint%kp_range
414 IF (PRESENT(nkp_groups)) nkp_groups = kpoint%nkp_groups
415 IF (PRESENT(kp_dist)) kp_dist => kpoint%kp_dist
416
417 IF (PRESENT(kp_env)) kp_env => kpoint%kp_env
418 IF (PRESENT(kp_aux_env)) kp_aux_env => kpoint%kp_aux_env
419 IF (PRESENT(mpools)) mpools => kpoint%mpools
420
421 IF (PRESENT(cell_to_index)) cell_to_index => kpoint%cell_to_index
422 IF (PRESENT(index_to_cell)) index_to_cell => kpoint%index_to_cell
423 IF (PRESENT(sab_nl)) sab_nl => kpoint%sab_nl
424 IF (PRESENT(sab_nl_nosym)) sab_nl_nosym => kpoint%sab_nl_nosym
425
426 END SUBROUTINE get_kpoint_info
427
428! **************************************************************************************************
429!> \brief Set information in a kpoint environment
430!> \param kpoint The kpoint environment
431!> \param kp_scheme Type of kpoint grid
432!> \param nkp_grid Grid points
433!> \param kp_shift Shift of the grid
434!> \param symmetry use symmetry (atoms) to reduce kpoints
435!> \param verbose more output information
436!> \param full_grid don't reduce kpoints at all
437!> \param use_real_wfn real/complex wfn
438!> \param eps_geo accuracy of atom symmetry detection
439!> \param parallel_group_size kpoint group size
440!> \param kp_range kpoints distribution for local processor
441!> \param nkp number of kpoints
442!> \param xkp kpoint coordinates
443!> \param wkp kpoint weights
444!> \param para_env 'global' parallel environment
445!> \param blacs_env_all BLACS env for the total environment
446!> \param para_env_kp parallel environment of the kpoint calculation
447!> \param para_env_inter_kp parallel environment between kpoints
448!> \param blacs_env BLACS env for the kpoint group
449!> \param kp_env Information for each kpoint
450!> \param kp_aux_env ...
451!> \param mpools FM matrix pools for kpoint groups
452!> \param iogrp this kpoint group has the IO processor
453!> \param nkp_groups number of kpoint groups
454!> \param kp_dist kpoints distribution on groups
455!> \param cell_to_index given a cell triple, returns the real space index
456!> \param index_to_cell ...
457!> \param sab_nl neighbourlist that defines real space matrices
458!> \param sab_nl_nosym neighbourlist that defines real space matrices
459!> \author JGH
460! **************************************************************************************************
461 SUBROUTINE set_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, &
462 full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, &
463 para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, &
464 kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, &
465 sab_nl, sab_nl_nosym)
466 TYPE(kpoint_type), INTENT(INOUT) :: kpoint
467 CHARACTER(LEN=*), OPTIONAL :: kp_scheme
468 INTEGER, DIMENSION(3), OPTIONAL :: nkp_grid
469 REAL(kind=dp), DIMENSION(3), OPTIONAL :: kp_shift
470 LOGICAL, OPTIONAL :: symmetry, verbose, full_grid, &
472 REAL(kind=dp), OPTIONAL :: eps_geo
473 INTEGER, OPTIONAL :: parallel_group_size
474 INTEGER, DIMENSION(2), OPTIONAL :: kp_range
475 INTEGER, OPTIONAL :: nkp
476 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: xkp
477 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: wkp
478 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
479 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env_all
480 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env_kp, para_env_inter_kp
481 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env
482 TYPE(kpoint_env_p_type), DIMENSION(:), OPTIONAL, &
483 POINTER :: kp_env, kp_aux_env
484 TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
485 LOGICAL, OPTIONAL :: iogrp
486 INTEGER, OPTIONAL :: nkp_groups
487 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: kp_dist
488 INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER :: cell_to_index
489 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: index_to_cell
490 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
491 OPTIONAL, POINTER :: sab_nl, sab_nl_nosym
492
493 IF (PRESENT(kp_scheme)) kpoint%kp_scheme = kp_scheme
494 IF (PRESENT(nkp_grid)) kpoint%nkp_grid = nkp_grid
495 IF (PRESENT(kp_shift)) kpoint%kp_shift = kp_shift
496 IF (PRESENT(symmetry)) kpoint%symmetry = symmetry
497 IF (PRESENT(verbose)) kpoint%verbose = verbose
498 IF (PRESENT(full_grid)) kpoint%full_grid = full_grid
499 IF (PRESENT(use_real_wfn)) kpoint%use_real_wfn = use_real_wfn
500 IF (PRESENT(eps_geo)) kpoint%eps_geo = eps_geo
501 IF (PRESENT(parallel_group_size)) kpoint%parallel_group_size = parallel_group_size
502
503 IF (PRESENT(nkp)) kpoint%nkp = nkp
504 IF (PRESENT(wkp)) kpoint%wkp => wkp
505 IF (PRESENT(xkp)) kpoint%xkp => xkp
506
507 IF (PRESENT(para_env)) kpoint%para_env => para_env
508 IF (PRESENT(para_env_kp)) kpoint%para_env_kp => para_env_kp
509 IF (PRESENT(para_env_inter_kp)) kpoint%para_env_inter_kp => para_env_inter_kp
510 IF (PRESENT(blacs_env_all)) kpoint%blacs_env_all => blacs_env_all
511 IF (PRESENT(blacs_env)) kpoint%blacs_env => blacs_env
512
513 IF (PRESENT(iogrp)) kpoint%iogrp = iogrp
514 IF (PRESENT(kp_range)) kpoint%kp_range = kp_range
515 IF (PRESENT(nkp_groups)) kpoint%nkp_groups = nkp_groups
516 IF (PRESENT(kp_dist)) kpoint%kp_dist => kp_dist
517
518 IF (PRESENT(kp_env)) kpoint%kp_env => kp_env
519 IF (PRESENT(kp_env)) kpoint%kp_aux_env => kp_aux_env
520 IF (PRESENT(mpools)) kpoint%mpools => mpools
521 IF (PRESENT(sab_nl)) kpoint%sab_nl => sab_nl
522 IF (PRESENT(sab_nl_nosym)) kpoint%sab_nl_nosym => sab_nl_nosym
523
524 IF (PRESENT(cell_to_index)) THEN
525 IF (ASSOCIATED(kpoint%cell_to_index)) DEALLOCATE (kpoint%cell_to_index)
526 kpoint%cell_to_index => cell_to_index
527 END IF
528
529 IF (PRESENT(index_to_cell)) THEN
530 IF (ASSOCIATED(kpoint%index_to_cell)) DEALLOCATE (kpoint%index_to_cell)
531 kpoint%index_to_cell => index_to_cell
532 END IF
533
534 END SUBROUTINE set_kpoint_info
535
536! **************************************************************************************************
537!> \brief Read the kpoint input section
538!> \param kpoint The kpoint environment
539!> \param kpoint_section The input section
540!> \param a_vec ...
541!> \author JGH
542! **************************************************************************************************
543 SUBROUTINE read_kpoint_section(kpoint, kpoint_section, a_vec)
544 TYPE(kpoint_type), INTENT(INOUT) :: kpoint
545 TYPE(section_vals_type), POINTER :: kpoint_section
546 REAL(kind=dp), DIMENSION(3, 3), INTENT(IN) :: a_vec
547
548 CHARACTER(LEN=default_string_length) :: ustr
549 CHARACTER(LEN=default_string_length), &
550 DIMENSION(:), POINTER :: tmpstringlist
551 INTEGER :: i, n_rep, nval, wfntype
552 LOGICAL :: available
553 REAL(kind=dp) :: ff
554 REAL(kind=dp), DIMENSION(:), POINTER :: reallist
555
556 CALL section_vals_get(kpoint_section, explicit=available)
557
558 IF (available) THEN
559 CALL section_vals_val_get(kpoint_section, "SCHEME", c_vals=tmpstringlist)
560 nval = SIZE(tmpstringlist)
561 cpassert(nval >= 1)
562 kpoint%kp_scheme = tmpstringlist(1)
563 CALL uppercase(kpoint%kp_scheme)
564
565 ! SCHEME [None, Gamma, Monkhorst-Pack, MacDonald, General]
566 SELECT CASE (kpoint%kp_scheme)
567 CASE ("NONE")
568 ! do nothing
569 CASE ("GAMMA")
570 ! do nothing
571 CASE ("MONKHORST-PACK")
572 cpassert(nval >= 4)
573 DO i = 2, 4
574 READ (tmpstringlist(i), *) kpoint%nkp_grid(i - 1)
575 END DO
576 CASE ("MACDONALD")
577 cpassert(nval >= 7)
578 DO i = 2, 4
579 READ (tmpstringlist(i), *) kpoint%nkp_grid(i - 1)
580 END DO
581 DO i = 5, 7
582 READ (tmpstringlist(i), *) kpoint%kp_shift(i - 4)
583 END DO
584 CASE ("GENERAL")
585 CALL section_vals_val_get(kpoint_section, "UNITS", c_val=ustr)
586 CALL uppercase(ustr)
587 CALL section_vals_val_get(kpoint_section, "KPOINT", n_rep_val=n_rep)
588 kpoint%nkp = n_rep
589 ALLOCATE (kpoint%xkp(3, n_rep), kpoint%wkp(n_rep))
590 DO i = 1, n_rep
591 CALL section_vals_val_get(kpoint_section, "KPOINT", i_rep_val=i, &
592 r_vals=reallist)
593 nval = SIZE(reallist)
594 cpassert(nval >= 4)
595 SELECT CASE (ustr)
596 CASE ("B_VECTOR")
597 kpoint%xkp(1:3, i) = reallist(1:3)
598 CASE ("CART_ANGSTROM")
599 kpoint%xkp(1:3, i) = (reallist(1)*a_vec(1, 1:3) + &
600 reallist(2)*a_vec(2, 1:3) + &
601 reallist(3)*a_vec(3, 1:3))/twopi*angstrom
602 CASE ("CART_BOHR")
603 kpoint%xkp(1:3, i) = (reallist(1)*a_vec(1, 1:3) + &
604 reallist(2)*a_vec(2, 1:3) + &
605 reallist(3)*a_vec(3, 1:3))/twopi
606 CASE DEFAULT
607 cpabort("Unknown Unit for kpoint definition")
608 END SELECT
609 kpoint%wkp(i) = reallist(4)
610 END DO
611 ff = 1.0_dp/sum(kpoint%wkp(:))
612 kpoint%wkp(:) = ff*kpoint%wkp(:)
613 CASE DEFAULT
614 cpabort("")
615 END SELECT
616
617 CALL section_vals_val_get(kpoint_section, "SYMMETRY", l_val=kpoint%symmetry)
618 CALL section_vals_val_get(kpoint_section, "WAVEFUNCTIONS", i_val=wfntype)
619 CALL section_vals_val_get(kpoint_section, "VERBOSE", l_val=kpoint%verbose)
620 CALL section_vals_val_get(kpoint_section, "FULL_GRID", l_val=kpoint%full_grid)
621 CALL section_vals_val_get(kpoint_section, "EPS_GEO", r_val=kpoint%eps_geo)
622 CALL section_vals_val_get(kpoint_section, "PARALLEL_GROUP_SIZE", &
623 i_val=kpoint%parallel_group_size)
624 SELECT CASE (wfntype)
625 CASE (use_real_wfn)
626 kpoint%use_real_wfn = .true.
627 CASE (use_complex_wfn)
628 kpoint%use_real_wfn = .false.
629 CASE DEFAULT
630 cpabort("")
631 END SELECT
632
633 ELSE
634 kpoint%kp_scheme = "NONE"
635 END IF
636
637 END SUBROUTINE read_kpoint_section
638
639! **************************************************************************************************
640!> \brief Write information on the kpoints to output
641!> \param kpoint The kpoint environment
642!> \param dft_section DFT section information
643!> \author JGH
644! **************************************************************************************************
645 SUBROUTINE write_kpoint_info(kpoint, dft_section)
646 TYPE(kpoint_type), INTENT(IN) :: kpoint
647 TYPE(section_vals_type), INTENT(IN) :: dft_section
648
649 INTEGER :: i, punit
650 TYPE(cp_logger_type), POINTER :: logger
651
652 NULLIFY (logger)
653 logger => cp_get_default_logger()
654
655 punit = cp_print_key_unit_nr(logger, dft_section, "PRINT%KPOINTS", extension=".Log")
656 IF (punit > 0) THEN
657
658 IF (kpoint%kp_scheme /= "NONE") THEN
659 WRITE (punit, '(/," ",79("*"),/,T37,A,/," ",79("*"))') "Kpoints"
660 END IF
661 SELECT CASE (kpoint%kp_scheme)
662 CASE ("NONE")
663 ! be silent
664 CASE ("GAMMA")
665 WRITE (punit, '(A,T57,A)') ' BRILLOUIN|', ' Gamma-point calculation'
666 CASE ("MONKHORST-PACK")
667 WRITE (punit, '(A,T61,A20)') ' BRILLOUIN| K-point scheme ', ' Monkhorst-Pack'
668 WRITE (punit, '(A,T66,3I5)') ' BRILLOUIN| K-Point grid', kpoint%nkp_grid
669 WRITE (punit, '(A,T66,G15.6)') ' BRILLOUIN| Accuracy in Symmetry determination', kpoint%eps_geo
670 CASE ("MACDONALD")
671 WRITE (punit, '(A,T71,A10)') ' BRILLOUIN| K-point scheme ', ' MacDonald'
672 WRITE (punit, '(A,T66,3I5)') ' BRILLOUIN| K-Point grid', kpoint%nkp_grid
673 WRITE (punit, '(A,T51,3F10.4)') ' BRILLOUIN| K-Point shift', kpoint%kp_shift
674 WRITE (punit, '(A,T66,G15.6)') ' BRILLOUIN| Accuracy in Symmetry determination', kpoint%eps_geo
675 CASE ("GENERAL")
676 WRITE (punit, '(A,T71,A10)') ' BRILLOUIN| K-point scheme ', ' General'
677 CASE DEFAULT
678 cpabort("")
679 END SELECT
680 IF (kpoint%kp_scheme /= "NONE") THEN
681 IF (kpoint%symmetry) THEN
682 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| K-Point point group symmetrization', ' ON'
683 ELSE
684 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| K-Point point group symmetrization', ' OFF'
685 END IF
686 IF (kpoint%use_real_wfn) THEN
687 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Wavefunction type', ' REAL'
688 ELSE
689 WRITE (punit, '(A,T73,A)') ' BRILLOUIN| Wavefunction type', ' COMPLEX'
690 END IF
691 IF (kpoint%full_grid) THEN
692 WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Use full k-point grid '
693 END IF
694 IF (kpoint%kp_scheme /= "GAMMA") THEN
695 WRITE (punit, '(A,T71,I10)') ' BRILLOUIN| List of Kpoints [2 Pi/Bohr]', kpoint%nkp
696 WRITE (punit, '(A,T30,A,T48,A,T63,A,T78,A)') &
697 ' BRILLOUIN| Number ', 'Weight', 'X', 'Y', 'Z'
698 DO i = 1, kpoint%nkp
699 WRITE (punit, '(A,I5,3X,4F15.5)') ' BRILLOUIN| ', i, kpoint%wkp(i), &
700 kpoint%xkp(1, i), kpoint%xkp(2, i), kpoint%xkp(3, i)
701 END DO
702 END IF
703 WRITE (punit, '(" ",79("*"))')
704 END IF
705
706 END IF
707 CALL cp_print_key_finished_output(punit, logger, dft_section, "PRINT%KPOINTS")
708
709 END SUBROUTINE write_kpoint_info
710
711! **************************************************************************************************
712!> \brief Create a single kpoint environment
713!> \param kp_env Single kpoint environment
714!> \author JGH
715! **************************************************************************************************
716 SUBROUTINE kpoint_env_create(kp_env)
717 TYPE(kpoint_env_type), POINTER :: kp_env
718
719 cpassert(.NOT. ASSOCIATED(kp_env))
720
721 ALLOCATE (kp_env)
722
723 kp_env%nkpoint = 0
724 kp_env%wkp = 0.0_dp
725 kp_env%xkp = 0.0_dp
726 kp_env%is_local = .false.
727
728 NULLIFY (kp_env%mos)
729 NULLIFY (kp_env%pmat)
730 NULLIFY (kp_env%wmat)
731 NULLIFY (kp_env%smat)
732 NULLIFY (kp_env%amat)
733
734 END SUBROUTINE kpoint_env_create
735
736! **************************************************************************************************
737!> \brief Release a single kpoint environment
738!> \param kp_env Single kpoint environment
739!> \author JGH
740! **************************************************************************************************
741 SUBROUTINE kpoint_env_release(kp_env)
742 TYPE(kpoint_env_type), POINTER :: kp_env
743
744 INTEGER :: ic, is
745
746 IF (ASSOCIATED(kp_env)) THEN
747
748 IF (ASSOCIATED(kp_env%mos)) THEN
749 DO is = 1, SIZE(kp_env%mos, 2)
750 DO ic = 1, SIZE(kp_env%mos, 1)
751 CALL deallocate_mo_set(kp_env%mos(ic, is))
752 END DO
753 END DO
754 DEALLOCATE (kp_env%mos)
755 END IF
756
757 CALL cp_fm_release(kp_env%pmat)
758 CALL cp_fm_release(kp_env%wmat)
759 CALL cp_fm_release(kp_env%smat)
760 CALL cp_fm_release(kp_env%amat)
761
762 DEALLOCATE (kp_env)
763
764 END IF
765
766 END SUBROUTINE kpoint_env_release
767
768! **************************************************************************************************
769!> \brief Get information from a single kpoint environment
770!> \param kpoint_env Single kpoint environment
771!> \param nkpoint Index of kpoint
772!> \param wkp Weight of kpoint
773!> \param xkp Coordinates of kpoint
774!> \param is_local Is this kpoint local (single cpu group)
775!> \param mos MOs of this kpoint
776!> \author JGH
777! **************************************************************************************************
778 SUBROUTINE get_kpoint_env(kpoint_env, nkpoint, wkp, xkp, is_local, mos)
779 TYPE(kpoint_env_type), INTENT(IN) :: kpoint_env
780 INTEGER, OPTIONAL :: nkpoint
781 REAL(kind=dp), OPTIONAL :: wkp
782 REAL(kind=dp), DIMENSION(3), OPTIONAL :: xkp
783 LOGICAL, OPTIONAL :: is_local
784 TYPE(mo_set_type), DIMENSION(:, :), OPTIONAL, &
785 POINTER :: mos
786
787 IF (PRESENT(nkpoint)) nkpoint = kpoint_env%nkpoint
788 IF (PRESENT(wkp)) wkp = kpoint_env%wkp
789 IF (PRESENT(xkp)) xkp = kpoint_env%xkp
790 IF (PRESENT(is_local)) is_local = kpoint_env%is_local
791 IF (PRESENT(mos)) mos => kpoint_env%mos
792
793 END SUBROUTINE get_kpoint_env
794
795! **************************************************************************************************
796!> \brief Create a single kpoint symmetry environment
797!> \param kp_sym ...
798!> \author JGH
799! **************************************************************************************************
800 SUBROUTINE kpoint_sym_create(kp_sym)
801 TYPE(kpoint_sym_type), POINTER :: kp_sym
802
803 cpassert(.NOT. ASSOCIATED(kp_sym))
804
805 ALLOCATE (kp_sym)
806
807 kp_sym%nwght = 0
808 kp_sym%nwred = 0
809 kp_sym%apply_symmetry = .false.
810
811 NULLIFY (kp_sym%rot)
812 NULLIFY (kp_sym%xkp)
813 NULLIFY (kp_sym%rotp)
814 NULLIFY (kp_sym%f0)
815
816 END SUBROUTINE kpoint_sym_create
817
818! **************************************************************************************************
819!> \brief Release a single kpoint symmetry environment
820!> \param kp_sym ...
821!> \author JGH
822! **************************************************************************************************
823 SUBROUTINE kpoint_sym_release(kp_sym)
824 TYPE(kpoint_sym_type), POINTER :: kp_sym
825
826 IF (ASSOCIATED(kp_sym)) THEN
827
828 IF (ASSOCIATED(kp_sym%rot)) THEN
829 DEALLOCATE (kp_sym%rot)
830 END IF
831 IF (ASSOCIATED(kp_sym%xkp)) THEN
832 DEALLOCATE (kp_sym%xkp)
833 END IF
834 IF (ASSOCIATED(kp_sym%f0)) THEN
835 DEALLOCATE (kp_sym%f0)
836 END IF
837 IF (ASSOCIATED(kp_sym%rotp)) THEN
838 DEALLOCATE (kp_sym%rotp)
839 END IF
840
841 DEALLOCATE (kp_sym)
842
843 END IF
844
845 END SUBROUTINE kpoint_sym_release
846
847! **************************************************************************************************
848
849END MODULE kpoint_types
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
various routines to log and control the output. The idea is that decisions about where to log should ...
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_real_wfn
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)
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 write_kpoint_info(kpoint, dft_section)
Write information on the kpoints to output.
subroutine, public kpoint_env_create(kp_env)
Create a single kpoint environment.
subroutine, public kpoint_release(kpoint)
Release a kpoint environment, deallocate all data.
subroutine, public kpoint_create(kpoint)
Create a 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)
Retrieve information from 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 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