(git:08825b9)
Loading...
Searching...
No Matches
qs_quadratic_pseudospectrum.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 Finite or periodic quadratic pseudospectrum analysis after SCF.
10!> \author Thomas D. Kuehne, tkuehne@cp2k.org
11! **************************************************************************************************
17 cell_type,&
20 USE cp_dbcsr_api, ONLY: dbcsr_get_info,&
28 USE ieee_arithmetic, ONLY: ieee_is_finite
34 USE kinds, ONLY: dp
35 USE mathconstants, ONLY: twopi
52#include "./base/base_uses.f90"
53
54 IMPLICIT NONE
55 PRIVATE
56 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_quadratic_pseudospectrum'
57 PUBLIC :: qs_scf_post_quadratic
58CONTAINS
59! **************************************************************************************************
60!> \brief Evaluate scans of quadratic gaps and localized joint approximate eigenstates.
61!> \param qs_env Converged Quickstep environment
62! **************************************************************************************************
63 SUBROUTINE qs_scf_post_quadratic(qs_env)
64 TYPE(qs_environment_type), POINTER :: qs_env
65
66 CHARACTER(len=*), PARAMETER :: routinen = 'qs_scf_post_quadratic'
67
68 CHARACTER(len=256) :: matrix_error
69 COMPLEX(dp), ALLOCATABLE :: complex_shift(:), dense_metric(:, :), &
70 dense_operators(:, :, :), &
71 temporary(:, :)
72 INTEGER :: ao, axis, cell_periodic, formulation, handle, i, ie, ik, ip, iw, j, max_ao, &
73 max_iter, max_space, n, nao, ndim, nobs, npositions, nstates, nt, output_unit, periodic, &
74 spin, status
75 INTEGER, ALLOCATABLE :: directions(:)
76 INTEGER, POINTER :: grid(:)
77 LOGICAL :: active, do_kpoints, do_soc, explicit_grid, explicit_value, periodic_analysis, &
78 torus_analysis, translation_analysis, valid
79 LOGICAL, ALLOCATABLE :: unitary(:)
80 REAL(dp) :: eps_eigen, eps_metric, &
81 hermiticity_error, &
82 max_hermiticity_error, query(3)
83 REAL(dp), ALLOCATABLE :: angles(:), radii(:), shift(:), &
84 translations(:, :), weights(:)
85 REAL(dp), POINTER :: energies(:), kappas(:), point(:)
86 TYPE(cell_type), POINTER :: cell
87 TYPE(cp_logger_type), POINTER :: logger
88 TYPE(dbcsr_p_type), POINTER :: cosines(:), images_h(:, :), &
89 images_s(:, :), matrix_ks(:), &
90 matrix_s(:), positions(:), sines(:), &
91 soc(:, :)
92 TYPE(dft_control_type), POINTER :: dft_control
93 TYPE(localizer_matrix_type) :: metric
94 TYPE(localizer_matrix_type), ALLOCATABLE :: operators(:)
95 TYPE(mp_para_env_type), POINTER :: para_env
96 TYPE(quadratic_result_type) :: result
97 TYPE(section_vals_type), POINTER :: input, section
98
99 CALL timeset(routinen, handle)
100 CALL get_qs_env(qs_env, input=input)
101 section => section_vals_get_subs_vals(input, 'PROPERTIES%QUADRATIC_PSEUDOSPECTRUM')
102 CALL section_vals_val_get(section, '_SECTION_PARAMETERS_', l_val=active)
103 IF (.NOT. active) THEN
104 CALL timestop(handle)
105 RETURN
106 END IF
107 IF (.NOT. qs_env%scf_convergence_available .OR. .NOT. qs_env%scf_converged) THEN
108 cpabort('QUADRATIC_PSEUDOSPECTRUM requires converged SCF.')
109 END IF
110 CALL get_qs_env(qs_env, matrix_s_kp=images_s, matrix_ks_kp=images_h, para_env=para_env, &
111 cell=cell, dft_control=dft_control, do_kpoints=do_kpoints)
112 matrix_s => images_s(:, 1)
113 matrix_ks => images_h(:, 1)
114 SELECT CASE (dft_control%qs_control%method_id)
116 CASE DEFAULT
117 cpabort('QUADRATIC_PSEUDOSPECTRUM supports GPW/GAPW only.')
118 END SELECT
119 CALL section_vals_val_get(section, 'FORMULATION', i_val=formulation)
120 periodic_analysis = formulation == 1
121 translation_analysis = formulation == 2
122 torus_analysis = periodic_analysis .OR. (translation_analysis .AND. any(cell%perd /= 0))
123 CALL section_vals_val_get(section, 'MP_GRID', i_vals=grid, explicit=explicit_grid)
124 IF (any(grid < 1)) cpabort('Quadratic MP_GRID must be positive.')
125 IF (.NOT. torus_analysis .AND. explicit_grid) THEN
126 cpabort('Quadratic MP_GRID requires a periodic property analysis.')
127 END IF
128 IF (any(grid /= 1 .AND. cell%perd == 0)) THEN
129 cpabort('Quadratic MP_GRID must be one in open directions.')
130 END IF
131 CALL section_vals_val_get(input, 'DFT%POISSON%PERIODIC', i_val=periodic)
132 IF (torus_analysis) THEN
133 CALL section_vals_val_get(input, 'SUBSYS%CELL%PERIODIC', i_val=cell_periodic)
134 IF (cell_periodic /= periodic .OR. count(cell%perd /= 0) == 0) THEN
135 cpabort('Quadratic torus needs matching, nonempty CELL/POISSON PERIODIC.')
136 END IF
137 ndim = count(cell%perd /= 0)
138 ALLOCATE (directions(ndim))
139 directions(:) = pack([1, 2, 3], cell%perd /= 0)
140 IF (periodic_analysis) THEN
141 nobs = 1 + 2*ndim
142 ALLOCATE (radii(ndim), angles(ndim))
143 DO i = 1, ndim
144 axis = directions(i)
145 radii(i) = real(grid(axis), dp)/(twopi*sqrt(sum(cell%h_inv(axis, :)**2)))
146 END DO
147 END IF
148 ELSE
149 IF (periodic /= use_perd_none .OR. any(cell%perd /= 0) .OR. do_kpoints) THEN
150 cpabort('Finite quadratic analysis requires PERIODIC NONE without KPOINTS.')
151 END IF
152 nobs = 4
153 END IF
154 IF (translation_analysis) THEN
155 CALL section_vals_val_get(section, 'TRANSLATION_VECTOR', n_rep_val=nt)
156 IF (nt < 1) THEN
157 cpabort('Quadratic TRANSLATION requires at least one TRANSLATION_VECTOR.')
158 END IF
159 nobs = 1 + nt
160 ALLOCATE (translations(3, nt), complex_shift(nobs), unitary(nobs))
161 unitary = .true.
162 unitary(1) = .false.
163 DO i = 1, nt
164 CALL section_vals_val_get(section, 'TRANSLATION_VECTOR', i_rep_val=i, r_vals=point)
165 IF (.NOT. all(ieee_is_finite(point))) THEN
166 cpabort('Quadratic TRANSLATION_VECTOR must be finite.')
167 END IF
168 translations(:, i) = point
169 CALL cell_transform_input_cartesian(cell, translations(:, i))
170 END DO
171 CALL section_vals_val_get(section, 'POSITION', explicit=explicit_value)
172 IF (explicit_value) THEN
173 cpabort('Quadratic TRANSLATION uses WAVE_VECTOR, not POSITION.')
174 END IF
175 CALL section_vals_val_get(section, 'KAPPA', explicit=explicit_value)
176 IF (explicit_value) THEN
177 cpabort('Quadratic TRANSLATION uses TRANSLATION_SCALE, not KAPPA.')
178 END IF
179 ELSE
180 CALL section_vals_val_get(section, 'TRANSLATION_VECTOR', explicit=explicit_value)
181 IF (explicit_value) THEN
182 cpabort('TRANSLATION_VECTOR requires quadratic FORMULATION TRANSLATION.')
183 END IF
184 CALL section_vals_val_get(section, 'WAVE_VECTOR', explicit=explicit_value)
185 IF (explicit_value) THEN
186 cpabort('WAVE_VECTOR requires quadratic FORMULATION TRANSLATION.')
187 END IF
188 CALL section_vals_val_get(section, 'TRANSLATION_SCALE', explicit=explicit_value)
189 IF (explicit_value) THEN
190 cpabort('TRANSLATION_SCALE requires quadratic FORMULATION TRANSLATION.')
191 END IF
192 END IF
193 ALLOCATE (operators(nobs), shift(nobs), weights(nobs))
194 CALL section_vals_val_get(section, 'SPIN_CHANNEL', i_val=spin)
195 IF (spin < 1 .OR. spin > SIZE(matrix_ks)) THEN
196 cpabort('Quadratic SPIN_CHANNEL is unavailable.')
197 END IF
198 CALL section_vals_val_get(section, 'SOC', l_val=do_soc)
199 IF (do_soc .AND. spin /= 1) cpabort('Quadratic SOC requires SPIN_CHANNEL 1.')
200 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao)
201 CALL section_vals_val_get(section, 'MAX_AO', i_val=max_ao)
202 IF (nao > max_ao .OR. max_ao < 1) cpabort('QUADRATIC_PSEUDOSPECTRUM exceeds MAX_AO.')
203 DO axis = 1, 3
204 IF (grid(axis) > max_ao/nao) cpabort('Quadratic full AO torus exceeds MAX_AO.')
205 nao = nao*grid(axis)
206 END DO
207 n = nao
208 IF (do_soc) n = 2*nao
209 CALL section_vals_val_get(section, 'NSTATES', i_val=nstates)
210 max_space = n
211 max_iter = 1
212 CALL section_vals_val_get(section, 'EPS_EIGEN', r_val=eps_eigen)
213 CALL section_vals_val_get(section, 'EPS_METRIC', r_val=eps_metric)
214 CALL section_vals_val_get(section, 'ENERGY', r_vals=energies)
215 CALL section_vals_val_get(section, 'KAPPA', r_vals=kappas)
216 CALL section_vals_val_get(section, 'POSITION', n_rep_val=npositions)
217 IF (translation_analysis) THEN
218 CALL section_vals_val_get(section, 'TRANSLATION_SCALE', r_vals=kappas)
219 CALL section_vals_val_get(section, 'WAVE_VECTOR', n_rep_val=npositions)
220 END IF
221 IF (nstates < 1 .OR. nstates > n .OR. max_iter < 1) THEN
222 cpabort('Invalid quadratic state/iteration limits.')
223 END IF
224 IF (.NOT. all(ieee_is_finite([energies, kappas, eps_eigen, eps_metric]))) THEN
225 cpabort('Quadratic analysis requires finite parameters.')
226 END IF
227 IF (any(kappas <= 0.0_dp) .OR. eps_eigen <= 0.0_dp .OR. eps_metric <= 0.0_dp .OR. eps_metric >= 1.0_dp) THEN
228 cpabort('Invalid quadratic scales or tolerances.')
229 END IF
231 IF (translation_analysis) CALL cite_reference(bairnsfather2026)
232 NULLIFY (positions, soc)
233 IF (periodic_analysis) THEN
234 CALL localizer_torus_operators(qs_env, grid, directions, do_soc, matrix_ks, matrix_s, cosines, sines, soc)
235 ALLOCATE (positions(2*ndim))
236 DO i = 1, ndim
237 positions(2*i - 1)%matrix => cosines(i)%matrix
238 positions(2*i)%matrix => sines(directions(i))%matrix
239 END DO
240 ELSE IF (translation_analysis) THEN
241 IF (torus_analysis) THEN
242 CALL torus_translation_operators(qs_env, grid, translations, do_soc, matrix_ks, matrix_s, positions, soc)
243 ELSE
244 CALL ao_translation_matrices(qs_env, translations, positions)
245 END IF
246 ELSE
247 CALL finite_ao_positions(qs_env, positions)
248 END IF
249 IF (do_soc .AND. .NOT. torus_analysis) THEN
250 CALL finite_ao_soc(qs_env, soc)
251 END IF
252 IF (do_soc) THEN
253 CALL localizer_ao_operators(matrix_ks(spin)%matrix, matrix_s(1)%matrix, positions, operators, metric, soc)
255 ELSE
256 CALL localizer_ao_operators(matrix_ks(spin)%matrix, matrix_s(1)%matrix, positions, operators, metric)
257 END IF
258 IF (periodic_analysis) THEN
259 DEALLOCATE (positions)
260 CALL dbcsr_deallocate_matrix_set(cosines)
262 ELSE
263 CALL dbcsr_deallocate_matrix_set(positions)
264 END IF
265 IF (torus_analysis) THEN
266 CALL dbcsr_deallocate_matrix_set(matrix_ks)
267 CALL dbcsr_deallocate_matrix_set(matrix_s)
268 END IF
269 CALL localizer_dbcsr_check(metric, para_env, 1.e-10_dp, valid, max_hermiticity_error)
270 IF (.NOT. valid) cpabort('Quadratic AO metric is nonfinite or not Hermitian.')
271 DO i = 1, nobs
272 IF (translation_analysis .AND. i > 1) cycle
273 CALL localizer_dbcsr_check(operators(i), para_env, 1.e-10_dp, valid, hermiticity_error)
274 max_hermiticity_error = max(max_hermiticity_error, hermiticity_error)
275 IF (.NOT. valid) THEN
276 WRITE (matrix_error, '(A,I0,A,ES12.4,A)') 'Quadratic AO operator ', i, &
277 ' is nonfinite or not Hermitian (relative error ', hermiticity_error, &
278 '). Check QS%EPS_PPNL/EPS_PGF_ORB and integration thresholds; no symmetrization is applied.'
279 cpabort(trim(matrix_error))
280 END IF
281 END DO
282 ALLOCATE (dense_operators(n, n, nobs))
283 CALL localizer_dbcsr_dense(metric, para_env, dense_metric)
284 DO i = 1, nobs
285 CALL localizer_dbcsr_dense(operators(i), para_env, temporary)
286 dense_operators(:, :, i) = temporary
287 DEALLOCATE (temporary)
288 END DO
289 logger => cp_get_default_logger()
290 output_unit = cp_logger_get_default_io_unit(logger)
291 iw = cp_print_key_unit_nr(logger, section, 'STATES', extension='.states')
292 IF (iw > 0) WRITE (iw, '(A)') '# Quadratic eigenstates: S-normalized AO coefficients, spin-major for SOC'
293 IF (iw > 0 .AND. torus_analysis) WRITE (iw, '(A,3I8)') '# Cell-major AO torus within each spin block; grid ', grid
294 IF (output_unit > 0) THEN
295 WRITE (output_unit, '(/,T2,A,I0)') 'QUADRATIC_PSEUDOSPECTRUM| AO/spinor dimension: ', n
296 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Relative Hermiticity error: ', max_hermiticity_error
297 WRITE (output_unit, '(T2,A)') 'QUADRATIC_PSEUDOSPECTRUM| Dense finite-basis reference'
298 WRITE (output_unit, '(T2,A)') 'QUADRATIC_PSEUDOSPECTRUM| Joint approximate states, not a topology index.'
299 IF (translation_analysis) THEN
300 WRITE (output_unit, '(T2,A)') 'QUADRATIC_PSEUDOSPECTRUM| Continuum translations U(a) psi(r) = psi(r+a).'
301 WRITE (output_unit, '(T2,A)') 'QUADRATIC_PSEUDOSPECTRUM| Full translation norms include loss outside the AO span.'
302 WRITE (output_unit, '(T2,A)') 'QUADRATIC_PSEUDOSPECTRUM| Energy residual still uses the projected AO Hamiltonian.'
303 DO i = 1, nt
304 WRITE (output_unit, '(T2,A,I0,A,3ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Translation ', i, &
305 ' internal [bohr]: ', translations(:, i)
306 END DO
307 END IF
308 IF (torus_analysis) THEN
309 WRITE (output_unit, '(T2,A,3I6)') 'QUADRATIC_PSEUDOSPECTRUM| Full analysis mesh: ', grid
310 WRITE (output_unit, '(T2,A,3I4)') 'QUADRATIC_PSEUDOSPECTRUM| Periodic lattice directions: ', directions
311 IF (translation_analysis) THEN
312 WRITE (output_unit, '(T2,A)') 'QUADRATIC_PSEUDOSPECTRUM| Periodized translations on the full AO torus.'
313 ELSE
314 WRITE (output_unit, '(T2,A)') 'QUADRATIC_PSEUDOSPECTRUM| Torus chord metric; open directions are not localized.'
315 END IF
316 END IF
317 END IF
318 DO ip = 1, npositions
319 IF (translation_analysis) THEN
320 CALL section_vals_val_get(section, 'WAVE_VECTOR', i_rep_val=ip, r_vals=point)
321 ELSE
322 CALL section_vals_val_get(section, 'POSITION', i_rep_val=ip, r_vals=point)
323 END IF
324 IF (.NOT. all(ieee_is_finite(point))) THEN
325 cpabort('Quadratic POSITION or WAVE_VECTOR must be finite.')
326 END IF
327 IF (translation_analysis) THEN
328 query = point
329 CALL cell_transform_input_reciprocal(cell, query)
330 DO i = 1, nt
331 complex_shift(i + 1) = exp(cmplx(0.0_dp, dot_product(query, translations(:, i)), dp))
332 END DO
333 ELSE IF (periodic_analysis) THEN
334 query = point
335 CALL cell_transform_input_cartesian(cell, query)
336 DO i = 1, ndim
337 axis = directions(i)
338 angles(i) = twopi*modulo(dot_product(cell%h_inv(axis, :), query)/real(grid(axis), dp), 1.0_dp)
339 shift(2*i) = cos(angles(i))
340 shift(2*i + 1) = sin(angles(i))
341 END DO
342 ELSE
343 shift(2:) = point
344 END IF
345 DO ik = 1, SIZE(kappas)
346 DO ie = 1, SIZE(energies)
347 shift(1) = energies(ie)
348 weights = kappas(ik)
349 weights(1) = 1.0_dp
350 IF (periodic_analysis) THEN
351 DO i = 1, ndim
352 weights(2*i:2*i + 1) = kappas(ik)*radii(i)
353 END DO
354 END IF
355 IF (para_env%is_source()) THEN
356 IF (translation_analysis) THEN
357 complex_shift(1) = energies(ie)
358 CALL quadratic_dense(dense_operators, dense_metric, complex_shift, weights, nstates, .false., max_space, &
359 max_iter, eps_eigen, eps_metric, result, status, unitary)
360 ELSE
361 CALL quadratic_dense(dense_operators, dense_metric, shift, weights, nstates, .false., max_space, &
362 max_iter, eps_eigen, eps_metric, result, status)
363 END IF
364 END IF
365 CALL para_env%bcast(status, para_env%source)
366 IF (status /= 0) THEN
367 IF (status == 1) THEN
368 IF (output_unit > 0) THEN
369 WRITE (output_unit, '(T2,A,I0,A,ES23.14)') &
370 'QUADRATIC_PSEUDOSPECTRUM| Unconverged after ', result%iterations, &
371 ' iterations; maximum residual: ', maxval(result%residuals)
372 END IF
373 cpabort('Quadratic eigensolver unconverged.')
374 END IF
375 cpabort('Quadratic analysis failed numerical checks.')
376 END IF
377 IF (output_unit > 0) THEN
378 IF (translation_analysis) THEN
379 WRITE (output_unit, '(T2,A,3ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Wave vector [bohr^-1]: ', point
380 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Translation scale [hartree]: ', kappas(ik)
381 ELSE
382 WRITE (output_unit, '(T2,A,3ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Position [bohr]: ', point
383 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Kappa [hartree/bohr]: ', kappas(ik)
384 END IF
385 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Energy [hartree]: ', energies(ie)
386 WRITE (output_unit, '(T2,A,I0)') 'QUADRATIC_PSEUDOSPECTRUM| Ritz iterations: ', result%iterations
387 DO j = 1, nstates
388 WRITE (output_unit, '(T2,A,I0)') 'QUADRATIC_PSEUDOSPECTRUM| State: ', j
389 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Gap [hartree]: ', &
390 sqrt(result%eigenvalues(j))
391 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Energy residual [hartree]: ', &
392 result%errors(1, j)
393 IF (translation_analysis) THEN
394 DO i = 2, nobs
395 WRITE (output_unit, '(T2,A,I0,A,3ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Translation residual ', i - 1, &
396 ' full/projected/leakage: ', result%errors(i, j), result%projected_errors(i, j), result%leakage(i, j)
397 WRITE (output_unit, '(T2,A,I0,A,2ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Translation expectation ', i - 1, &
398 ' real/imag: ', result%complex_means(i, j)
399 END DO
400 ELSE IF (periodic_analysis) THEN
401 DO i = 1, ndim
402 WRITE (output_unit, '(T2,A,I1,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Chord residual axis ', &
403 directions(i), ' [bohr]: ', radii(i)*sqrt(sum(result%errors(2*i:2*i + 1, j)**2))
404 WRITE (output_unit, '(T2,A,I1,A,2ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Mean cos/sin axis ', &
405 directions(i), ': ', result%means(2*i:2*i + 1, j)
406 END DO
407 ELSE
408 WRITE (output_unit, '(T2,A,3ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Position residuals [bohr]: ', &
409 result%errors(2:4, j)
410 END IF
411 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Eigenpair residual [hartree^2]: ', &
412 result%residuals(j)
413 WRITE (output_unit, '(T2,A,ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Mean energy [hartree]: ', result%means(1, j)
414 IF (.NOT. periodic_analysis .AND. .NOT. translation_analysis) THEN
415 WRITE (output_unit, '(T2,A,3ES23.14)') 'QUADRATIC_PSEUDOSPECTRUM| Mean position [bohr]: ', &
416 result%means(2:4, j)
417 END IF
418 END DO
419 END IF
420 IF (iw > 0) THEN
421 IF (translation_analysis) THEN
422 WRITE (iw, '(A,3I8,A,5ES24.15)') '# Query ', ip, ie, ik, ' E/kx/ky/kz/scale ', energies(ie), point, kappas(ik)
423 ELSE
424 WRITE (iw, '(A,3I8,A,5ES24.15)') '# Query ', ip, ie, ik, ' E/x/y/z/kappa ', energies(ie), point, kappas(ik)
425 END IF
426 DO j = 1, nstates
427 WRITE (iw, '(A,I8,A,ES24.15)') '# State ', j, ' lambda [hartree^2] ', result%eigenvalues(j)
428 DO ao = 1, n
429 WRITE (iw, '(I10,2ES25.16)') ao, real(result%states(ao, j), dp), aimag(result%states(ao, j))
430 END DO
431 END DO
432 END IF
433 END DO
434 END DO
435 END DO
436 CALL cp_print_key_finished_output(iw, logger, section, 'STATES')
437 DO i = 1, nobs
438 CALL localizer_dbcsr_release(operators(i))
439 END DO
440 CALL localizer_dbcsr_release(metric)
441 CALL timestop(handle)
442 END SUBROUTINE qs_scf_post_quadratic
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public bairnsfather2026
integer, save, public cerjan2023
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public cell_transform_input_reciprocal(cell, vector)
Transform a Cartesian reciprocal-space vector from the user input cell frame into CP2K's canonical in...
Definition cell_types.F:302
integer, parameter, public use_perd_none
Definition cell_types.F:42
subroutine, public cell_transform_input_cartesian(cell, vector)
Transform a Cartesian real-space vector from the user input cell frame into CP2K's canonical internal...
Definition cell_types.F:285
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
DBCSR operations in CP2K.
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,...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_method_gpw
integer, parameter, public do_method_gapw
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
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
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
Analytic translations of finite or periodized Gaussian AO functions.
subroutine, public ao_translation_matrices(qs_env, shifts, translations, periodic_grid)
Overlaps with translated ket Gaussians, U(a) psi(r) = psi(r+a).
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.
Shared finite-system AO position and SOC operators for post-SCF analyses.
subroutine, public finite_ao_soc(qs_env, soc_matrices)
Validate and construct post-SCF GTH SOC components shared by finite AO analyses.
subroutine, public finite_ao_positions(qs_env, positions)
Analytic covariant first moments in the coordinate frame of SUBSYS/COORD.
Full Born-von-Karman AO operators at a frozen SCF potential.
subroutine, public torus_translation_operators(qs_env, grid, shifts, do_soc, h, s, translations, soc)
Full AO torus with translated, periodized Gaussians instead of position coordinates.
subroutine, public localizer_torus_operators(qs_env, grid, directions, do_soc, h, s, cosines, sines, soc)
Lift scalar image operators and ordered Berry integrals to a full real-cell torus.
Finite or periodic quadratic pseudospectrum analysis after SCF.
subroutine, public qs_scf_post_quadratic(qs_env)
Evaluate scans of quadratic gaps and localized joint approximate eigenstates.
Metric-aware quadratic pseudospectra for finite AO operators.
provides a uniform framework to add references to CP2K cite and output these
subroutine, public cite_reference(key)
marks a given reference as cited.
Distributed block-sparse finite localizers, retaining the covariant AO metric.
subroutine, public localizer_ao_operators(h, s, positions, operators, metric, soc)
Shared AO Hamiltonian, Hermitian scalar observables and optional GTH physical-spin SOC.
subroutine, public localizer_dbcsr_dense(matrix, para_env, dense)
Collect the size-limited dense oracle; sparse solvers must not call this routine.
subroutine, public localizer_dbcsr_release(matrix)
Release both real components of a complex sparse operator.
subroutine, public localizer_dbcsr_check(matrix, para_env, tolerance, valid, relative_error)
Check both components before a sparse solver discards the upper triangle.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment