(git:1e0ab71)
Loading...
Searching...
No Matches
kpoint_mo_dump.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 K-point MO wavefunction dump to TEXT file for post-processing (PDOS, etc.)
10!> \par History
11!> 2026.02 created
12! **************************************************************************************************
13
15
19 USE cell_types, ONLY: cell_type
22 USE cp_dbcsr_api, ONLY: &
24 dbcsr_type, dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, dbcsr_type_symmetric
30 USE cp_fm_types, ONLY: cp_fm_create,&
41 USE kinds, ONLY: dp
43 USE kpoint_types, ONLY: get_kpoint_info,&
46 USE mathconstants, ONLY: pi
50 USE physcon, ONLY: angstrom
53 USE qs_kind_types, ONLY: get_qs_kind,&
56 USE qs_mo_types, ONLY: get_mo_set,&
59#include "./base/base_uses.f90"
60
61 IMPLICIT NONE
62 PRIVATE
63
64 PUBLIC :: write_kpoint_mo_data
65
66 ! Enum values for AO_EXPORT_TYPE keyword
67 INTEGER, PARAMETER, PUBLIC :: mokp_ao_gto_basis = 1, &
69
70 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'kpoint_mo_dump'
71
72CONTAINS
73
74! **************************************************************************************************
75!> \brief Write k-point resolved MO data to formatted text file.
76!>
77!> The output file contains, for each k-point:
78!> - Eigenvalues and occupations
79!> - MO coefficient matrix C(k) (real and imaginary parts)
80!> - Overlap matrix S(k) (if AO_EXPORT_TYPE = OVERLAP_MATRIX)
81!> Plus a header with cell, atom info, and either GTO basis set definition
82!> (AO_EXPORT_TYPE = GTO_BASIS) or AO metadata list (AO_EXPORT_TYPE = OVERLAP_MATRIX).
83!>
84!> Parallel strategy:
85!> MO coefficients: cp_fm_get_submatrix (collective on kp-group),
86!> then para_env_inter_kp%sum to collect across groups.
87!> S(k): Built on global communicator using rskp_transform,
88!> then copy_dbcsr_to_fm + cp_fm_get_submatrix.
89!> File write: Only on ionode (cp_print_key_unit_nr returns -1 elsewhere).
90!>
91!> \param qs_env the QS environment (after converged SCF with k-points)
92!> \param print_section the &MO_KP print key section (contains NDIGITS, AO_EXPORT_TYPE)
93! **************************************************************************************************
94 SUBROUTINE write_kpoint_mo_data(qs_env, print_section)
95 TYPE(qs_environment_type), POINTER :: qs_env
96 TYPE(section_vals_type), POINTER :: print_section
97
98 CHARACTER(len=*), PARAMETER :: routinen = 'write_kpoint_mo_data'
99 CHARACTER(LEN=6), PARAMETER :: angmom = "spdfgh"
100
101 CHARACTER(LEN=2) :: element_symbol
102 CHARACTER(LEN=20) :: fmtstr_gto, fmtstr_sparse, fmtstr_vec
103 INTEGER :: ao_export_type, atom_shell_index, handle, i, iao, iatom, ikind, ikp, ikp_loc, &
104 imo, ipgf, iset, isgf_global, ishell, ispin, iw, j, lshell, m_ao, n, nao, natom, ndigits, &
105 nkp, nmo, nset_atom, nspins, output_unit, unit_choice, z_nuc
106 INTEGER, ALLOCATABLE, DIMENSION(:) :: first_sgf, last_sgf
107 INTEGER, DIMENSION(2) :: kp_range
108 INTEGER, DIMENSION(:), POINTER :: npgf_set, nshell_set
109 INTEGER, DIMENSION(:, :), POINTER :: first_sgf_set, l_set, last_sgf_set
110 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index
111 LOGICAL :: use_real_wfn, write_overlap
112 REAL(kind=dp) :: expzet, prefac, scale_factor, thresh, &
113 zeff
114 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eval_buf, occ_buf
115 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: cim_buf, cre_buf, sim_buf, sre_buf
116 REAL(kind=dp), DIMENSION(:), POINTER :: eigenvalues, occupation_numbers, wkp
117 REAL(kind=dp), DIMENSION(:, :), POINTER :: xkp, zet
118 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: gcc
119 TYPE(cell_type), POINTER :: cell
120 TYPE(cp_blacs_env_type), POINTER :: blacs_env_global
121 TYPE(cp_fm_struct_type), POINTER :: fm_struct_s
122 TYPE(cp_fm_type) :: fm_s_global
123 TYPE(cp_fm_type), POINTER :: mo_coeff_im, mo_coeff_re
124 TYPE(cp_logger_type), POINTER :: logger
125 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s
126 TYPE(dbcsr_type), POINTER :: cmatrix, rmatrix, tmpmat
127 TYPE(dft_control_type), POINTER :: dft_control
128 TYPE(gto_basis_set_type), POINTER :: orb_basis_set
129 TYPE(kpoint_env_type), POINTER :: kp
130 TYPE(kpoint_type), POINTER :: kpoints
131 TYPE(mo_set_type), DIMENSION(:, :), POINTER :: mos_kp
132 TYPE(mp_para_env_type), POINTER :: para_env_global, para_env_inter_kp
133 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
134 POINTER :: sab_nl
135 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
136 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
137
138 CALL timeset(routinen, handle)
139
140 logger => cp_get_default_logger()
141 output_unit = cp_logger_get_default_io_unit(logger)
142
143 ! ================================================================
144 ! Gather all required data from qs_env
145 ! ================================================================
146 NULLIFY (cell, dft_control, kpoints, particle_set, qs_kind_set, matrix_s, &
147 sab_nl, para_env_global, blacs_env_global)
148
149 CALL get_qs_env(qs_env, &
150 cell=cell, &
151 dft_control=dft_control, &
152 kpoints=kpoints, &
153 particle_set=particle_set, &
154 qs_kind_set=qs_kind_set, &
155 matrix_s_kp=matrix_s, &
156 para_env=para_env_global, &
157 blacs_env=blacs_env_global)
158
159 nspins = dft_control%nspins
160 natom = SIZE(particle_set)
161
162 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, wkp=wkp, &
163 use_real_wfn=use_real_wfn, kp_range=kp_range, &
164 sab_nl=sab_nl, cell_to_index=cell_to_index, &
165 para_env_inter_kp=para_env_inter_kp)
166 cpassert(ASSOCIATED(sab_nl))
167
168 ! Total number of AOs and MOs
169 CALL get_qs_kind_set(qs_kind_set, nsgf=nao)
170
171 nmo = 0
172 IF (SIZE(kpoints%kp_env) > 0) THEN
173 mos_kp => kpoints%kp_env(1)%kpoint_env%mos
174 CALL get_mo_set(mo_set=mos_kp(1, 1), nmo=nmo)
175 END IF
176 CALL para_env_inter_kp%max(nmo)
177
178 IF (output_unit > 0) THEN
179 WRITE (output_unit, '(/,T3,A)') "KPOINT_MO_DUMP| Writing k-point wavefunction data"
180 WRITE (output_unit, '(T3,A,I6,A,I6,A,I6,A,I4)') &
181 "KPOINT_MO_DUMP| nao=", nao, " nmo=", nmo, " nkp=", nkp, " nspins=", nspins
182 END IF
183
184 ! ================================================================
185 ! Read keywords
186 ! ================================================================
187 CALL section_vals_val_get(print_section, "UNIT", i_val=unit_choice)
188 IF (unit_choice == 2) THEN
189 scale_factor = angstrom
190 ELSE
191 scale_factor = 1.0_dp
192 END IF
193 CALL section_vals_val_get(print_section, "NDIGITS", i_val=ndigits)
194 ndigits = min(max(3, ndigits), 30)
195 CALL section_vals_val_get(print_section, "AO_EXPORT_TYPE", i_val=ao_export_type)
196 write_overlap = (ao_export_type == mokp_ao_overlap_matrix)
197
198 ! Build format strings controlled by NDIGITS
199 WRITE (unit=fmtstr_sparse, fmt='("(2I6,1X,ES",I0,".",I0,")")') ndigits + 10, ndigits
200 WRITE (unit=fmtstr_vec, fmt='("(5ES",I0,".",I0,")")') ndigits + 10, ndigits
201 WRITE (unit=fmtstr_gto, fmt='("(2ES",I0,".",I0,")")') ndigits + 10, ndigits
202 thresh = 10.0_dp**(-ndigits)
203
204 ! ================================================================
205 ! Build atom-to-AO mapping
206 ! ================================================================
207 ALLOCATE (first_sgf(natom), last_sgf(natom))
208 CALL get_particle_set(particle_set, qs_kind_set, &
209 first_sgf=first_sgf, last_sgf=last_sgf)
210
211 ! ================================================================
212 ! Allocate work buffers
213 ! ================================================================
214 ALLOCATE (cre_buf(nao, nmo), cim_buf(nao, nmo))
215 ALLOCATE (eval_buf(nmo), occ_buf(nmo))
216
217 ! S(k) infrastructure: only needed in MATRIX mode
218 IF (write_overlap) THEN
219 ALLOCATE (sre_buf(nao, nao), sim_buf(nao, nao))
220
221 ALLOCATE (rmatrix, cmatrix, tmpmat)
222 CALL dbcsr_create(rmatrix, template=matrix_s(1, 1)%matrix, &
223 matrix_type=dbcsr_type_symmetric)
224 CALL dbcsr_create(cmatrix, template=matrix_s(1, 1)%matrix, &
225 matrix_type=dbcsr_type_antisymmetric)
226 CALL dbcsr_create(tmpmat, template=matrix_s(1, 1)%matrix, &
227 matrix_type=dbcsr_type_no_symmetry)
228 CALL cp_dbcsr_alloc_block_from_nbl(rmatrix, sab_nl)
229 CALL cp_dbcsr_alloc_block_from_nbl(cmatrix, sab_nl)
230
231 NULLIFY (fm_struct_s)
232 CALL cp_fm_struct_create(fm_struct_s, context=blacs_env_global, &
233 nrow_global=nao, ncol_global=nao, &
234 para_env=para_env_global)
235 CALL cp_fm_create(fm_s_global, fm_struct_s, name="S(k) work")
236 CALL cp_fm_struct_release(fm_struct_s)
237 END IF
238
239 ! ================================================================
240 ! Open output file via print key
241 ! ================================================================
242 iw = cp_print_key_unit_nr(logger, print_section, "", &
243 extension=".mokp", file_status="REPLACE")
244
245 ! ================================================================
246 ! WRITE HEADER
247 ! ================================================================
248 IF (iw > 0) THEN
249 WRITE (iw, '(A)') "# CP2K_KPOINT_MO_DUMP, Version 2.0"
250 IF (unit_choice == 2) THEN
251 WRITE (iw, '(A)') "# All energies in Hartree, lengths in Angstrom, k-points in fractional reciprocal coords"
252 ELSE
253 WRITE (iw, '(A)') "# All energies in Hartree, lengths in Bohr, k-points in fractional reciprocal coords"
254 END IF
255 WRITE (iw, '(A,4I8)') "# DIMENSIONS: natom nspins nao nkp =", natom, nspins, nao, nkp
256 WRITE (iw, '(A,I8)') "# NMO =", nmo
257 WRITE (iw, '(A,L2)') "# USE_REAL_WFN =", use_real_wfn
258 IF (write_overlap) THEN
259 WRITE (iw, '(A)') "# AO_EXPORT_TYPE = OVERLAP_MATRIX"
260 ELSE
261 WRITE (iw, '(A)') "# AO_EXPORT_TYPE = GTO_BASIS"
262 END IF
263 WRITE (iw, '(A,ES12.5)') "# SPARSE_THRESHOLD =", thresh
264 IF (unit_choice == 2) THEN
265 WRITE (iw, '(A)') "# CELL_VECTORS [Angstrom]"
266 ELSE
267 WRITE (iw, '(A)') "# CELL_VECTORS [Bohr]"
268 END IF
269 WRITE (iw, '(3(F12.6,3X))') &
270 cell%hmat(1, 1)*scale_factor, cell%hmat(2, 1)*scale_factor, cell%hmat(3, 1)*scale_factor
271 WRITE (iw, '(3(F12.6,3X))') &
272 cell%hmat(1, 2)*scale_factor, cell%hmat(2, 2)*scale_factor, cell%hmat(3, 2)*scale_factor
273 WRITE (iw, '(3(F12.6,3X))') &
274 cell%hmat(1, 3)*scale_factor, cell%hmat(2, 3)*scale_factor, cell%hmat(3, 3)*scale_factor
275 ! Atom table
276 IF (unit_choice == 2) THEN
277 WRITE (iw, '(A)') &
278 "# ATOM_LIST: Atom_ID Element Z_nuc Z_eff X [Ang] Y [Ang] Z [Ang] First_AO Last_AO"
279 ELSE
280 WRITE (iw, '(A)') &
281 "# ATOM_LIST: Atom_ID Element Z_nuc Z_eff X [Bohr] Y [Bohr] Z [Bohr] First_AO Last_AO"
282 END IF
283 DO iatom = 1, natom
284 ikind = particle_set(iatom)%atomic_kind%kind_number
285 CALL get_atomic_kind(atomic_kind=particle_set(iatom)%atomic_kind, &
286 element_symbol=element_symbol, z=z_nuc)
287 CALL get_qs_kind(qs_kind_set(ikind), zeff=zeff)
288 WRITE (iw, '(I6,2X,A2,2I6,3F15.6,2I10)') &
289 iatom, element_symbol, z_nuc, nint(zeff), particle_set(iatom)%r(:)*scale_factor, &
290 first_sgf(iatom), last_sgf(iatom)
291 END DO
292
293 ! K-point list
294 WRITE (iw, '(A)') "# KPOINT_LIST: ikp kx ky kz weight"
295 DO ikp = 1, nkp
296 WRITE (iw, '(I6,4ES18.8)') ikp, xkp(1:3, ikp), wkp(ikp)
297 END DO
298
299 IF (write_overlap) THEN
300 ! MATRIX mode: write AO metadata since no GTO basis definition is written.
301 ! Shell angular momentum ordering: spherical harmonics,
302 ! CP2K convention m = -l, -l+1, ..., 0, ..., +l
303 WRITE (iw, '(A)') "# AO_LIST: ao_index atom_id atom_shell_index l m"
304 DO iatom = 1, natom
305 ikind = particle_set(iatom)%atomic_kind%kind_number
306 atom_shell_index = 0
307 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
308 IF (ASSOCIATED(orb_basis_set)) THEN
309 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
310 nset=nset_atom, nshell=nshell_set, l=l_set, &
311 first_sgf=first_sgf_set, last_sgf=last_sgf_set)
312 DO iset = 1, nset_atom
313 DO ishell = 1, nshell_set(iset)
314 atom_shell_index = atom_shell_index + 1
315 lshell = l_set(ishell, iset)
316 DO i = first_sgf_set(ishell, iset), last_sgf_set(ishell, iset)
317 isgf_global = first_sgf(iatom) - 1 + i
318 m_ao = i - first_sgf_set(ishell, iset) - lshell
319 WRITE (iw, '(5I8)') isgf_global, iatom, atom_shell_index, lshell, m_ao
320 END DO
321 END DO
322 END DO
323 END IF
324 END DO
325 ELSE
326 ! GTO mode: write basis set definition
327 ! Contraction coefficients denormalized to MOLDEN convention
328 ! (i.e. for raw unnormalized primitive Gaussians).
329 ! Shell angular momentum ordering: spherical harmonics,
330 ! CP2K convention m = -l, -l+1, ..., 0, ..., +l
331 WRITE (iw, '(A)') "# GTO_BASIS (spherical, MOLDEN convention for contraction coefficients)"
332 DO iatom = 1, natom
333 ikind = particle_set(iatom)%atomic_kind%kind_number
334 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
335 IF (ASSOCIATED(orb_basis_set)) THEN
336 WRITE (iw, '(I6,I4)') iatom, 0
337 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
338 nset=nset_atom, npgf=npgf_set, &
339 nshell=nshell_set, l=l_set, &
340 zet=zet, gcc=gcc)
341 DO iset = 1, nset_atom
342 DO ishell = 1, nshell_set(iset)
343 lshell = l_set(ishell, iset)
344 IF (lshell + 1 > len(angmom)) THEN
345 cpwarn("MOKP: Angular momentum l > 5 not supported in GTO output, skipping")
346 cycle
347 END IF
348 WRITE (iw, '(A2,I6,F8.2)') &
349 angmom(lshell + 1:lshell + 1)//" ", npgf_set(iset), 1.0_dp
350 ! Denormalize gcc: undo CP2K's internal normalization
351 ! (same formula as molden_utils.F, reverse of normalise_gcc_orb)
352 prefac = 2.0_dp**lshell*(2.0_dp/pi)**0.75_dp
353 expzet = 0.25_dp*(2*lshell + 3.0_dp)
354 DO ipgf = 1, npgf_set(iset)
355 WRITE (iw, fmtstr_gto) &
356 zet(ipgf, iset), &
357 gcc(ipgf, ishell, iset)/(prefac*zet(ipgf, iset)**expzet)
358 END DO
359 END DO
360 END DO
361 WRITE (iw, '(A)') ""
362 END IF
363 END DO
364 END IF
365 END IF
366
367 ! ================================================================
368 ! WRITE PER-KPOINT DATA
369 ! ================================================================
370 DO ikp = 1, nkp
371
372 ! ==============================================================
373 ! A) MO coefficients, eigenvalues, occupations (per spin)
374 ! ==============================================================
375 DO ispin = 1, nspins
376
377 cre_buf(:, :) = 0.0_dp
378 cim_buf(:, :) = 0.0_dp
379 eval_buf(:) = 0.0_dp
380 occ_buf(:) = 0.0_dp
381
382 IF (ikp >= kp_range(1) .AND. ikp <= kp_range(2)) THEN
383 ikp_loc = ikp - kp_range(1) + 1
384 kp => kpoints%kp_env(ikp_loc)%kpoint_env
385 mos_kp => kp%mos
386
387 CALL get_mo_set(mos_kp(1, ispin), &
388 eigenvalues=eigenvalues, &
389 occupation_numbers=occupation_numbers)
390 eval_buf(1:nmo) = eigenvalues(1:nmo)
391 occ_buf(1:nmo) = occupation_numbers(1:nmo)
392
393 CALL get_mo_set(mos_kp(1, ispin), mo_coeff=mo_coeff_re)
394 CALL cp_fm_get_submatrix(mo_coeff_re, cre_buf)
395
396 IF (.NOT. use_real_wfn) THEN
397 CALL get_mo_set(mos_kp(2, ispin), mo_coeff=mo_coeff_im)
398 CALL cp_fm_get_submatrix(mo_coeff_im, cim_buf)
399 END IF
400 END IF
401
402 CALL para_env_inter_kp%sum(eval_buf)
403 CALL para_env_inter_kp%sum(occ_buf)
404 CALL para_env_inter_kp%sum(cre_buf)
405 IF (.NOT. use_real_wfn) THEN
406 CALL para_env_inter_kp%sum(cim_buf)
407 END IF
408
409 IF (iw > 0) THEN
410 WRITE (iw, '(A,2I6)') "# BEGIN_KPOINT_SPIN ikp ispin =", ikp, ispin
411
412 WRITE (iw, '(A)') "# EIGENVALUES"
413 WRITE (iw, fmtstr_vec) (eval_buf(n), n=1, nmo)
414
415 WRITE (iw, '(A)') "# OCCUPATIONS"
416 WRITE (iw, fmtstr_vec) (occ_buf(n), n=1, nmo)
417
418 WRITE (iw, '(A)') "# MO_COEFF_RE (Sparse: mo_index ao_index value)"
419 DO imo = 1, nmo
420 DO iao = 1, nao
421 IF (abs(cre_buf(iao, imo)) >= thresh) THEN
422 WRITE (iw, fmtstr_sparse) imo, iao, cre_buf(iao, imo)
423 END IF
424 END DO
425 END DO
426
427 IF (.NOT. use_real_wfn) THEN
428 WRITE (iw, '(A)') "# MO_COEFF_IM (Sparse: mo_index ao_index value)"
429 DO imo = 1, nmo
430 DO iao = 1, nao
431 IF (abs(cim_buf(iao, imo)) >= thresh) THEN
432 WRITE (iw, fmtstr_sparse) imo, iao, cim_buf(iao, imo)
433 END IF
434 END DO
435 END DO
436 END IF
437 WRITE (iw, '(A,2I6)') "# END_KPOINT_SPIN ikp ispin =", ikp, ispin
438 END IF
439
440 END DO ! ispin
441
442 ! ==============================================================
443 ! B) Overlap matrix S(k) — only in MATRIX mode
444 ! ==============================================================
445 IF (write_overlap) THEN
446
447 CALL dbcsr_set(rmatrix, 0.0_dp)
448 IF (use_real_wfn) THEN
449 CALL rskp_transform(rmatrix=rmatrix, rsmat=matrix_s, ispin=1, &
450 xkp=xkp(1:3, ikp), cell_to_index=cell_to_index, &
451 sab_nl=sab_nl)
452 CALL dbcsr_desymmetrize(rmatrix, tmpmat)
453 CALL copy_dbcsr_to_fm(tmpmat, fm_s_global)
454 CALL cp_fm_get_submatrix(fm_s_global, sre_buf)
455 sim_buf(:, :) = 0.0_dp
456 ELSE
457 CALL dbcsr_set(cmatrix, 0.0_dp)
458 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix, rsmat=matrix_s, &
459 ispin=1, xkp=xkp(1:3, ikp), &
460 cell_to_index=cell_to_index, sab_nl=sab_nl)
461 CALL dbcsr_desymmetrize(rmatrix, tmpmat)
462 CALL copy_dbcsr_to_fm(tmpmat, fm_s_global)
463 CALL cp_fm_get_submatrix(fm_s_global, sre_buf)
464 CALL dbcsr_desymmetrize(cmatrix, tmpmat)
465 CALL copy_dbcsr_to_fm(tmpmat, fm_s_global)
466 CALL cp_fm_get_submatrix(fm_s_global, sim_buf)
467 END IF
468
469 IF (iw > 0) THEN
470 WRITE (iw, '(A,I6)') "# BEGIN_OVERLAP ikp =", ikp
471
472 WRITE (iw, '(A)') "# OVERLAP_RE (Sparse: ao_index_1 ao_index_2 value)"
473 DO i = 1, nao
474 DO j = 1, nao
475 IF (abs(sre_buf(i, j)) >= thresh) THEN
476 WRITE (iw, fmtstr_sparse) i, j, sre_buf(i, j)
477 END IF
478 END DO
479 END DO
480 IF (.NOT. use_real_wfn) THEN
481 WRITE (iw, '(A)') "# OVERLAP_IM (Sparse: ao_index_1 ao_index_2 value)"
482 DO i = 1, nao
483 DO j = 1, nao
484 IF (abs(sim_buf(i, j)) >= thresh) THEN
485 WRITE (iw, fmtstr_sparse) i, j, sim_buf(i, j)
486 END IF
487 END DO
488 END DO
489 END IF
490 WRITE (iw, '(A,I6)') "# END_OVERLAP ikp =", ikp
491 END IF
492
493 END IF ! write_overlap
494
495 END DO ! ikp
496
497 ! ================================================================
498 ! Finalize
499 ! ================================================================
500 IF (iw > 0) THEN
501 WRITE (iw, '(A)') "# END_OF_FILE"
502 END IF
503
504 CALL cp_print_key_finished_output(iw, logger, print_section, "")
505
506 IF (output_unit > 0) THEN
507 WRITE (output_unit, '(T3,A)') &
508 "KPOINT_MO_DUMP| Data written to .mokp file"
509 END IF
510
511 ! Release work arrays
512 IF (write_overlap) THEN
513 CALL cp_fm_release(fm_s_global)
514 CALL dbcsr_deallocate_matrix(rmatrix)
515 CALL dbcsr_deallocate_matrix(cmatrix)
516 CALL dbcsr_deallocate_matrix(tmpmat)
517 DEALLOCATE (sre_buf, sim_buf)
518 END IF
519 DEALLOCATE (cre_buf, cim_buf)
520 DEALLOCATE (eval_buf, occ_buf)
521 DEALLOCATE (first_sgf, last_sgf)
522
523 CALL timestop(handle)
524
525 END SUBROUTINE write_kpoint_mo_data
526
527END MODULE kpoint_mo_dump
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
Handles all functions related to the CELL.
Definition cell_types.F:15
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_set(matrix, alpha)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
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,...
objects that represent the structure of input sections and the data contained in an input section
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
Routines needed for kpoint calculation.
subroutine, public rskp_transform(rmatrix, cmatrix, rsmat, ispin, xkp, cell_to_index, sab_nl, is_complex, rs_sign)
Transformation of real space matrices to a kpoint.
K-point MO wavefunction dump to TEXT file for post-processing (PDOS, etc.)
integer, parameter, public mokp_ao_gto_basis
subroutine, public write_kpoint_mo_data(qs_env, print_section)
Write k-point resolved MO data to formatted text file.
integer, parameter, public mokp_ao_overlap_matrix
Types and basic routines needed for a kpoint calculation.
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.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Interface to the message passing library MPI.
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis, ncgf)
Get the components of a particle set.
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public angstrom
Definition physcon.F:144
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a 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...
Keeps information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.