(git:f2099e5)
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
24 USE cp_dbcsr_api, ONLY: &
26 dbcsr_type, dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, dbcsr_type_symmetric
32 USE cp_fm_types, ONLY: cp_fm_create,&
43 USE kinds, ONLY: dp
45 USE kpoint_types, ONLY: get_kpoint_info,&
48 USE mathconstants, ONLY: pi
52 USE physcon, ONLY: angstrom
55 USE qs_kind_types, ONLY: get_qs_kind,&
58 USE qs_mo_types, ONLY: get_mo_set,&
61#include "./base/base_uses.f90"
62
63 IMPLICIT NONE
64 PRIVATE
65
66 PUBLIC :: write_kpoint_mo_data
67
68 ! Enum values for AO_EXPORT_TYPE keyword
69 INTEGER, PARAMETER, PUBLIC :: mokp_ao_gto_basis = 1, &
71
72 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'kpoint_mo_dump'
73
74CONTAINS
75
76! **************************************************************************************************
77!> \brief Write k-point resolved MO data to formatted text file.
78!>
79!> The output file contains, for each k-point:
80!> - Eigenvalues and occupations
81!> - MO coefficient matrix C(k) (real and imaginary parts)
82!> - Overlap matrix S(k) (if AO_EXPORT_TYPE = OVERLAP_MATRIX)
83!> Plus a header with cell, atom info, and either GTO basis set definition
84!> (AO_EXPORT_TYPE = GTO_BASIS) or AO metadata list (AO_EXPORT_TYPE = OVERLAP_MATRIX).
85!>
86!> Parallel strategy:
87!> MO coefficients: cp_fm_get_submatrix or cp_cfm_get_submatrix
88!> (collective on kp-group), then para_env_inter_kp%sum.
89!> S(k): Built on global communicator using rskp_transform,
90!> then copy_dbcsr_to_fm + cp_fm_get_submatrix.
91!> File write: Only on ionode (cp_print_key_unit_nr returns -1 elsewhere).
92!>
93!> \param qs_env the QS environment (after converged SCF with k-points)
94!> \param print_section the &MO_KP print key section (contains NDIGITS, AO_EXPORT_TYPE)
95! **************************************************************************************************
96 SUBROUTINE write_kpoint_mo_data(qs_env, print_section)
97 TYPE(qs_environment_type), POINTER :: qs_env
98 TYPE(section_vals_type), POINTER :: print_section
99
100 CHARACTER(len=*), PARAMETER :: routinen = 'write_kpoint_mo_data'
101 CHARACTER(LEN=6), PARAMETER :: angmom = "spdfgh"
102
103 CHARACTER(LEN=2) :: element_symbol
104 CHARACTER(LEN=20) :: fmtstr_gto, fmtstr_sparse, fmtstr_vec
105 COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: c_buf
106 INTEGER :: ao_export_type, atom_shell_index, handle, i, iao, iatom, ikind, ikp, ikp_loc, &
107 imo, ipgf, iset, isgf_global, ishell, ispin, iw, j, lshell, m_ao, n, nao, natom, ndigits, &
108 nkp, nmo, nset_atom, nspins, output_unit, unit_choice, z_nuc
109 INTEGER, ALLOCATABLE, DIMENSION(:) :: first_sgf, last_sgf
110 INTEGER, DIMENSION(2) :: kp_range
111 INTEGER, DIMENSION(:), POINTER :: npgf_set, nshell_set
112 INTEGER, DIMENSION(:, :), POINTER :: first_sgf_set, l_set, last_sgf_set
113 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index
114 LOGICAL :: use_real_wfn, write_overlap
115 REAL(kind=dp) :: expzet, prefac, scale_factor, thresh, &
116 zeff
117 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eval_buf, occ_buf
118 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: cim_buf, cre_buf, sim_buf, sre_buf
119 REAL(kind=dp), DIMENSION(:), POINTER :: eigenvalues, occupation_numbers, wkp
120 REAL(kind=dp), DIMENSION(:, :), POINTER :: xkp, zet
121 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: gcc
122 TYPE(cell_type), POINTER :: cell
123 TYPE(cp_blacs_env_type), POINTER :: blacs_env_global
124 TYPE(cp_cfm_type), POINTER :: cmo_coeff
125 TYPE(cp_fm_struct_type), POINTER :: fm_struct_s
126 TYPE(cp_fm_type) :: fm_s_global
127 TYPE(cp_fm_type), POINTER :: mo_coeff_re
128 TYPE(cp_logger_type), POINTER :: logger
129 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s
130 TYPE(dbcsr_type), POINTER :: cmatrix, rmatrix, tmpmat
131 TYPE(dft_control_type), POINTER :: dft_control
132 TYPE(gto_basis_set_type), POINTER :: orb_basis_set
133 TYPE(kpoint_env_type), POINTER :: kp
134 TYPE(kpoint_type), POINTER :: kpoints
135 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos_kp
136 TYPE(mp_para_env_type), POINTER :: para_env_global, para_env_inter_kp
137 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
138 POINTER :: sab_nl
139 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
140 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
141
142 CALL timeset(routinen, handle)
143
144 logger => cp_get_default_logger()
145 output_unit = cp_logger_get_default_io_unit(logger)
146
147 ! ================================================================
148 ! Gather all required data from qs_env
149 ! ================================================================
150 NULLIFY (cell, dft_control, kpoints, particle_set, qs_kind_set, matrix_s, &
151 sab_nl, para_env_global, blacs_env_global)
152
153 CALL get_qs_env(qs_env, &
154 cell=cell, &
155 dft_control=dft_control, &
156 kpoints=kpoints, &
157 particle_set=particle_set, &
158 qs_kind_set=qs_kind_set, &
159 matrix_s_kp=matrix_s, &
160 para_env=para_env_global, &
161 blacs_env=blacs_env_global)
162
163 nspins = dft_control%nspins
164 natom = SIZE(particle_set)
165
166 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, wkp=wkp, &
167 use_real_wfn=use_real_wfn, kp_range=kp_range, &
168 sab_nl=sab_nl, cell_to_index=cell_to_index, &
169 para_env_inter_kp=para_env_inter_kp)
170 cpassert(ASSOCIATED(sab_nl))
171
172 ! Total number of AOs and MOs
173 CALL get_qs_kind_set(qs_kind_set, nsgf=nao)
174
175 nmo = 0
176 IF (SIZE(kpoints%kp_env) > 0) THEN
177 mos_kp => kpoints%kp_env(1)%kpoint_env%mos
178 CALL get_mo_set(mo_set=mos_kp(1), nmo=nmo)
179 END IF
180 CALL para_env_inter_kp%max(nmo)
181
182 IF (output_unit > 0) THEN
183 WRITE (output_unit, '(/,T3,A)') "KPOINT_MO_DUMP| Writing k-point wavefunction data"
184 WRITE (output_unit, '(T3,A,I6,A,I6,A,I6,A,I4)') &
185 "KPOINT_MO_DUMP| nao=", nao, " nmo=", nmo, " nkp=", nkp, " nspins=", nspins
186 END IF
187
188 ! ================================================================
189 ! Read keywords
190 ! ================================================================
191 CALL section_vals_val_get(print_section, "UNIT", i_val=unit_choice)
192 IF (unit_choice == 2) THEN
193 scale_factor = angstrom
194 ELSE
195 scale_factor = 1.0_dp
196 END IF
197 CALL section_vals_val_get(print_section, "NDIGITS", i_val=ndigits)
198 ndigits = min(max(3, ndigits), 30)
199 CALL section_vals_val_get(print_section, "AO_EXPORT_TYPE", i_val=ao_export_type)
200 write_overlap = (ao_export_type == mokp_ao_overlap_matrix)
201
202 ! Build format strings controlled by NDIGITS
203 WRITE (unit=fmtstr_sparse, fmt='("(2I6,1X,ES",I0,".",I0,")")') ndigits + 10, ndigits
204 WRITE (unit=fmtstr_vec, fmt='("(5ES",I0,".",I0,")")') ndigits + 10, ndigits
205 WRITE (unit=fmtstr_gto, fmt='("(2ES",I0,".",I0,")")') ndigits + 10, ndigits
206 thresh = 10.0_dp**(-ndigits)
207
208 ! ================================================================
209 ! Build atom-to-AO mapping
210 ! ================================================================
211 ALLOCATE (first_sgf(natom), last_sgf(natom))
212 CALL get_particle_set(particle_set, qs_kind_set, &
213 first_sgf=first_sgf, last_sgf=last_sgf)
214
215 ! ================================================================
216 ! Allocate work buffers
217 ! ================================================================
218 ALLOCATE (cre_buf(nao, nmo), cim_buf(nao, nmo))
219 IF (.NOT. use_real_wfn) ALLOCATE (c_buf(nao, nmo))
220 ALLOCATE (eval_buf(nmo), occ_buf(nmo))
221
222 ! S(k) infrastructure: only needed in MATRIX mode
223 IF (write_overlap) THEN
224 ALLOCATE (sre_buf(nao, nao), sim_buf(nao, nao))
225
226 ALLOCATE (rmatrix, cmatrix, tmpmat)
227 CALL dbcsr_create(rmatrix, template=matrix_s(1, 1)%matrix, &
228 matrix_type=dbcsr_type_symmetric)
229 CALL dbcsr_create(cmatrix, template=matrix_s(1, 1)%matrix, &
230 matrix_type=dbcsr_type_antisymmetric)
231 CALL dbcsr_create(tmpmat, template=matrix_s(1, 1)%matrix, &
232 matrix_type=dbcsr_type_no_symmetry)
233 CALL cp_dbcsr_alloc_block_from_nbl(rmatrix, sab_nl)
234 CALL cp_dbcsr_alloc_block_from_nbl(cmatrix, sab_nl)
235
236 NULLIFY (fm_struct_s)
237 CALL cp_fm_struct_create(fm_struct_s, context=blacs_env_global, &
238 nrow_global=nao, ncol_global=nao, &
239 para_env=para_env_global)
240 CALL cp_fm_create(fm_s_global, fm_struct_s, name="S(k) work")
241 CALL cp_fm_struct_release(fm_struct_s)
242 END IF
243
244 ! ================================================================
245 ! Open output file via print key
246 ! ================================================================
247 iw = cp_print_key_unit_nr(logger, print_section, "", &
248 extension=".mokp", file_status="REPLACE")
249
250 ! ================================================================
251 ! WRITE HEADER
252 ! ================================================================
253 IF (iw > 0) THEN
254 WRITE (iw, '(A)') "# CP2K_KPOINT_MO_DUMP, Version 2.0"
255 IF (unit_choice == 2) THEN
256 WRITE (iw, '(A)') "# All energies in Hartree, lengths in Angstrom, k-points in fractional reciprocal coords"
257 ELSE
258 WRITE (iw, '(A)') "# All energies in Hartree, lengths in Bohr, k-points in fractional reciprocal coords"
259 END IF
260 WRITE (iw, '(A,4I8)') "# DIMENSIONS: natom nspins nao nkp =", natom, nspins, nao, nkp
261 WRITE (iw, '(A,I8)') "# NMO =", nmo
262 WRITE (iw, '(A,L2)') "# USE_REAL_WFN =", use_real_wfn
263 IF (write_overlap) THEN
264 WRITE (iw, '(A)') "# AO_EXPORT_TYPE = OVERLAP_MATRIX"
265 ELSE
266 WRITE (iw, '(A)') "# AO_EXPORT_TYPE = GTO_BASIS"
267 END IF
268 WRITE (iw, '(A,ES12.5)') "# SPARSE_THRESHOLD =", thresh
269 IF (unit_choice == 2) THEN
270 WRITE (iw, '(A)') "# CELL_VECTORS [Angstrom]"
271 ELSE
272 WRITE (iw, '(A)') "# CELL_VECTORS [Bohr]"
273 END IF
274 WRITE (iw, '(3(F12.6,3X))') &
275 cell%hmat(1, 1)*scale_factor, cell%hmat(2, 1)*scale_factor, cell%hmat(3, 1)*scale_factor
276 WRITE (iw, '(3(F12.6,3X))') &
277 cell%hmat(1, 2)*scale_factor, cell%hmat(2, 2)*scale_factor, cell%hmat(3, 2)*scale_factor
278 WRITE (iw, '(3(F12.6,3X))') &
279 cell%hmat(1, 3)*scale_factor, cell%hmat(2, 3)*scale_factor, cell%hmat(3, 3)*scale_factor
280 ! Atom table
281 IF (unit_choice == 2) THEN
282 WRITE (iw, '(A)') &
283 "# ATOM_LIST: Atom_ID Element Z_nuc Z_eff X [Ang] Y [Ang] Z [Ang] First_AO Last_AO"
284 ELSE
285 WRITE (iw, '(A)') &
286 "# ATOM_LIST: Atom_ID Element Z_nuc Z_eff X [Bohr] Y [Bohr] Z [Bohr] First_AO Last_AO"
287 END IF
288 DO iatom = 1, natom
289 ikind = particle_set(iatom)%atomic_kind%kind_number
290 CALL get_atomic_kind(atomic_kind=particle_set(iatom)%atomic_kind, &
291 element_symbol=element_symbol, z=z_nuc)
292 CALL get_qs_kind(qs_kind_set(ikind), zeff=zeff)
293 WRITE (iw, '(I6,2X,A2,2I6,3F15.6,2I10)') &
294 iatom, element_symbol, z_nuc, nint(zeff), particle_set(iatom)%r(:)*scale_factor, &
295 first_sgf(iatom), last_sgf(iatom)
296 END DO
297
298 ! K-point list
299 WRITE (iw, '(A)') "# KPOINT_LIST: ikp kx ky kz weight"
300 DO ikp = 1, nkp
301 WRITE (iw, '(I6,4ES18.8)') ikp, xkp(1:3, ikp), wkp(ikp)
302 END DO
303
304 IF (write_overlap) THEN
305 ! MATRIX mode: write AO metadata since no GTO basis definition is written.
306 ! Shell angular momentum ordering: spherical harmonics,
307 ! CP2K convention m = -l, -l+1, ..., 0, ..., +l
308 WRITE (iw, '(A)') "# AO_LIST: ao_index atom_id atom_shell_index l m"
309 DO iatom = 1, natom
310 ikind = particle_set(iatom)%atomic_kind%kind_number
311 atom_shell_index = 0
312 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
313 IF (ASSOCIATED(orb_basis_set)) THEN
314 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
315 nset=nset_atom, nshell=nshell_set, l=l_set, &
316 first_sgf=first_sgf_set, last_sgf=last_sgf_set)
317 DO iset = 1, nset_atom
318 DO ishell = 1, nshell_set(iset)
319 atom_shell_index = atom_shell_index + 1
320 lshell = l_set(ishell, iset)
321 DO i = first_sgf_set(ishell, iset), last_sgf_set(ishell, iset)
322 isgf_global = first_sgf(iatom) - 1 + i
323 m_ao = i - first_sgf_set(ishell, iset) - lshell
324 WRITE (iw, '(5I8)') isgf_global, iatom, atom_shell_index, lshell, m_ao
325 END DO
326 END DO
327 END DO
328 END IF
329 END DO
330 ELSE
331 ! GTO mode: write basis set definition
332 ! Contraction coefficients denormalized to MOLDEN convention
333 ! (i.e. for raw unnormalized primitive Gaussians).
334 ! Shell angular momentum ordering: spherical harmonics,
335 ! CP2K convention m = -l, -l+1, ..., 0, ..., +l
336 WRITE (iw, '(A)') "# GTO_BASIS (spherical, MOLDEN convention for contraction coefficients)"
337 DO iatom = 1, natom
338 ikind = particle_set(iatom)%atomic_kind%kind_number
339 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
340 IF (ASSOCIATED(orb_basis_set)) THEN
341 WRITE (iw, '(I6,I4)') iatom, 0
342 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
343 nset=nset_atom, npgf=npgf_set, &
344 nshell=nshell_set, l=l_set, &
345 zet=zet, gcc=gcc)
346 DO iset = 1, nset_atom
347 DO ishell = 1, nshell_set(iset)
348 lshell = l_set(ishell, iset)
349 IF (lshell + 1 > len(angmom)) THEN
350 cpwarn("MOKP: Angular momentum l > 5 not supported in GTO output, skipping")
351 cycle
352 END IF
353 WRITE (iw, '(A2,I6,F8.2)') &
354 angmom(lshell + 1:lshell + 1)//" ", npgf_set(iset), 1.0_dp
355 ! Denormalize gcc: undo CP2K's internal normalization
356 ! (same formula as molden_utils.F, reverse of normalise_gcc_orb)
357 prefac = 2.0_dp**lshell*(2.0_dp/pi)**0.75_dp
358 expzet = 0.25_dp*(2*lshell + 3.0_dp)
359 DO ipgf = 1, npgf_set(iset)
360 WRITE (iw, fmtstr_gto) &
361 zet(ipgf, iset), &
362 gcc(ipgf, ishell, iset)/(prefac*zet(ipgf, iset)**expzet)
363 END DO
364 END DO
365 END DO
366 WRITE (iw, '(A)') ""
367 END IF
368 END DO
369 END IF
370 END IF
371
372 ! ================================================================
373 ! WRITE PER-KPOINT DATA
374 ! ================================================================
375 DO ikp = 1, nkp
376
377 ! ==============================================================
378 ! A) MO coefficients, eigenvalues, occupations (per spin)
379 ! ==============================================================
380 DO ispin = 1, nspins
381
382 cre_buf(:, :) = 0.0_dp
383 cim_buf(:, :) = 0.0_dp
384 eval_buf(:) = 0.0_dp
385 occ_buf(:) = 0.0_dp
386
387 IF (ikp >= kp_range(1) .AND. ikp <= kp_range(2)) THEN
388 ikp_loc = ikp - kp_range(1) + 1
389 kp => kpoints%kp_env(ikp_loc)%kpoint_env
390 mos_kp => kp%mos
391
392 CALL get_mo_set(mos_kp(ispin), &
393 eigenvalues=eigenvalues, &
394 occupation_numbers=occupation_numbers)
395 eval_buf(1:nmo) = eigenvalues(1:nmo)
396 occ_buf(1:nmo) = occupation_numbers(1:nmo)
397
398 IF (use_real_wfn) THEN
399 CALL get_mo_set(mos_kp(ispin), mo_coeff=mo_coeff_re)
400 CALL cp_fm_get_submatrix(mo_coeff_re, cre_buf)
401 ELSE
402 CALL get_mo_set(mos_kp(ispin), cmo_coeff=cmo_coeff)
403 CALL cp_cfm_get_submatrix(cmo_coeff, c_buf)
404 cre_buf(:, :) = real(c_buf, kind=dp)
405 cim_buf(:, :) = aimag(c_buf)
406 END IF
407 END IF
408
409 CALL para_env_inter_kp%sum(eval_buf)
410 CALL para_env_inter_kp%sum(occ_buf)
411 CALL para_env_inter_kp%sum(cre_buf)
412 IF (.NOT. use_real_wfn) CALL para_env_inter_kp%sum(cim_buf)
413
414 IF (iw > 0) THEN
415 WRITE (iw, '(A,2I6)') "# BEGIN_KPOINT_SPIN ikp ispin =", ikp, ispin
416
417 WRITE (iw, '(A)') "# EIGENVALUES"
418 WRITE (iw, fmtstr_vec) (eval_buf(n), n=1, nmo)
419
420 WRITE (iw, '(A)') "# OCCUPATIONS"
421 WRITE (iw, fmtstr_vec) (occ_buf(n), n=1, nmo)
422
423 WRITE (iw, '(A)') "# MO_COEFF_RE (Sparse: mo_index ao_index value)"
424 DO imo = 1, nmo
425 DO iao = 1, nao
426 IF (abs(cre_buf(iao, imo)) >= thresh) THEN
427 WRITE (iw, fmtstr_sparse) imo, iao, cre_buf(iao, imo)
428 END IF
429 END DO
430 END DO
431
432 IF (.NOT. use_real_wfn) THEN
433 WRITE (iw, '(A)') "# MO_COEFF_IM (Sparse: mo_index ao_index value)"
434 DO imo = 1, nmo
435 DO iao = 1, nao
436 IF (abs(cim_buf(iao, imo)) >= thresh) THEN
437 WRITE (iw, fmtstr_sparse) imo, iao, cim_buf(iao, imo)
438 END IF
439 END DO
440 END DO
441 END IF
442 WRITE (iw, '(A,2I6)') "# END_KPOINT_SPIN ikp ispin =", ikp, ispin
443 END IF
444
445 END DO ! ispin
446
447 ! ==============================================================
448 ! B) Overlap matrix S(k) — only in MATRIX mode
449 ! ==============================================================
450 IF (write_overlap) THEN
451
452 CALL dbcsr_set(rmatrix, 0.0_dp)
453 IF (use_real_wfn) THEN
454 CALL rskp_transform(rmatrix=rmatrix, rsmat=matrix_s, ispin=1, &
455 xkp=xkp(1:3, ikp), cell_to_index=cell_to_index, &
456 sab_nl=sab_nl)
457 CALL dbcsr_desymmetrize(rmatrix, tmpmat)
458 CALL copy_dbcsr_to_fm(tmpmat, fm_s_global)
459 CALL cp_fm_get_submatrix(fm_s_global, sre_buf)
460 sim_buf(:, :) = 0.0_dp
461 ELSE
462 CALL dbcsr_set(cmatrix, 0.0_dp)
463 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix, rsmat=matrix_s, &
464 ispin=1, xkp=xkp(1:3, ikp), &
465 cell_to_index=cell_to_index, sab_nl=sab_nl)
466 CALL dbcsr_desymmetrize(rmatrix, tmpmat)
467 CALL copy_dbcsr_to_fm(tmpmat, fm_s_global)
468 CALL cp_fm_get_submatrix(fm_s_global, sre_buf)
469 CALL dbcsr_desymmetrize(cmatrix, tmpmat)
470 CALL copy_dbcsr_to_fm(tmpmat, fm_s_global)
471 CALL cp_fm_get_submatrix(fm_s_global, sim_buf)
472 END IF
473
474 IF (iw > 0) THEN
475 WRITE (iw, '(A,I6)') "# BEGIN_OVERLAP ikp =", ikp
476
477 WRITE (iw, '(A)') "# OVERLAP_RE (Sparse: ao_index_1 ao_index_2 value)"
478 DO i = 1, nao
479 DO j = 1, nao
480 IF (abs(sre_buf(i, j)) >= thresh) THEN
481 WRITE (iw, fmtstr_sparse) i, j, sre_buf(i, j)
482 END IF
483 END DO
484 END DO
485 IF (.NOT. use_real_wfn) THEN
486 WRITE (iw, '(A)') "# OVERLAP_IM (Sparse: ao_index_1 ao_index_2 value)"
487 DO i = 1, nao
488 DO j = 1, nao
489 IF (abs(sim_buf(i, j)) >= thresh) THEN
490 WRITE (iw, fmtstr_sparse) i, j, sim_buf(i, j)
491 END IF
492 END DO
493 END DO
494 END IF
495 WRITE (iw, '(A,I6)') "# END_OVERLAP ikp =", ikp
496 END IF
497
498 END IF ! write_overlap
499
500 END DO ! ikp
501
502 ! ================================================================
503 ! Finalize
504 ! ================================================================
505 IF (iw > 0) THEN
506 WRITE (iw, '(A)') "# END_OF_FILE"
507 END IF
508
509 CALL cp_print_key_finished_output(iw, logger, print_section, "")
510
511 IF (output_unit > 0) THEN
512 WRITE (output_unit, '(T3,A)') &
513 "KPOINT_MO_DUMP| Data written to .mokp file"
514 END IF
515
516 ! Release work arrays
517 IF (write_overlap) THEN
518 CALL cp_fm_release(fm_s_global)
519 CALL dbcsr_deallocate_matrix(rmatrix)
520 CALL dbcsr_deallocate_matrix(cmatrix)
521 CALL dbcsr_deallocate_matrix(tmpmat)
522 DEALLOCATE (sre_buf, sim_buf)
523 END IF
524 DEALLOCATE (cre_buf, cim_buf)
525 IF (.NOT. use_real_wfn) DEALLOCATE (c_buf)
526 DEALLOCATE (eval_buf, occ_buf)
527 DEALLOCATE (first_sgf, last_sgf)
528
529 CALL timestop(handle)
530
531 END SUBROUTINE write_kpoint_mo_data
532
533END 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
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
Extract a sub-matrix from the full matrix: op(target_m)(1:n_rows,1:n_cols) = fm(start_row:start_row+n...
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, plan)
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, lattice_fft)
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, matrix_vhxc, 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, hund_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, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, 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, do_mtlr_present, 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, cmo_coeff)
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...
Represent a complex full matrix.
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.