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