(git:3f0d10b)
Loading...
Searching...
No Matches
rt_propagation_utils.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 Routines needed for EMD
10!> \author Florian Schiffmann (02.09)
11! **************************************************************************************************
12
15 USE cell_types, ONLY: cell_type
19 USE cp_dbcsr_api, ONLY: &
27 USE cp_files, ONLY: close_file,&
31 USE cp_fm_types, ONLY: cp_fm_create,&
41 USE cp_output_handling, ONLY: cp_p_file,&
47 USE efield_utils, ONLY: make_field
57 USE kinds, ONLY: default_path_length,&
59 dp
60 USE mathconstants, ONLY: zero
63 USE orbital_pointers, ONLY: ncoset
66 USE physcon, ONLY: femtoseconds
67 USE pw_env_types, ONLY: pw_env_get,&
69 USE pw_methods, ONLY: pw_multiply,&
71 USE pw_pool_types, ONLY: pw_pool_p_type,&
73 USE pw_types, ONLY: pw_c1d_gs_type,&
81 USE qs_ks_types, ONLY: qs_ks_did_change,&
86 USE qs_mo_types, ONLY: allocate_mo_set,&
94 USE qs_rho_types, ONLY: qs_rho_get,&
98 USE qs_scf_wfn_mix, ONLY: wfn_mix
101 USE rt_propagation_types, ONLY: get_rtp,&
103#include "../base/base_uses.f90"
104
105 IMPLICIT NONE
106 PRIVATE
107
108 PUBLIC :: get_restart_wfn, &
116 read_moments, &
118
119 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'rt_propagation_utils'
120
121CONTAINS
122
123! **************************************************************************************************
124!> \brief Calculates dS/dR respectily the velocity weighted derivatves
125!> only needed for ehrenfest MD.
126!>
127!> \param qs_env the qs environment
128!> \par History
129!> 02.2009 created [Manuel Guidon]
130!> 02.2014 switched to dbcsr matrices [Samuel Andermatt]
131!> \author Florian Schiffmann
132! **************************************************************************************************
133 SUBROUTINE calc_s_derivs(qs_env)
134 TYPE(qs_environment_type), POINTER :: qs_env
135
136 CHARACTER(LEN=*), PARAMETER :: routinen = 'calc_S_derivs'
137 REAL(kind=dp), PARAMETER :: one = 1.0_dp, zero = 0.0_dp
138
139 INTEGER :: col_atom, handle, i, j, m, maxder, n, &
140 nder, row_atom
141 INTEGER, DIMENSION(6, 2) :: c_map_mat
142 LOGICAL :: return_s_derivatives
143 REAL(dp), DIMENSION(:, :), POINTER :: block_values
144 TYPE(dbcsr_iterator_type) :: iter
145 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: c_mat, s_der, s_derivs
146 TYPE(dbcsr_type), POINTER :: b_mat, tmp_mat, tmp_mat2
147 TYPE(dft_control_type), POINTER :: dft_control
148 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
149 POINTER :: sab_orb
150 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
151 TYPE(qs_ks_env_type), POINTER :: ks_env
152 TYPE(rt_prop_type), POINTER :: rtp
153
154 CALL timeset(routinen, handle)
155
156 return_s_derivatives = .true.
157
158 NULLIFY (particle_set)
159 NULLIFY (rtp)
160 NULLIFY (s_derivs)
161 NULLIFY (dft_control)
162 NULLIFY (ks_env)
163
164 CALL get_qs_env(qs_env=qs_env, &
165 rtp=rtp, &
166 particle_set=particle_set, &
167 sab_orb=sab_orb, &
168 dft_control=dft_control, &
169 ks_env=ks_env)
170
171 CALL get_rtp(rtp=rtp, b_mat=b_mat, c_mat=c_mat, s_der=s_der)
172
173 nder = 2
174 maxder = ncoset(nder)
175
176 NULLIFY (tmp_mat)
177 ALLOCATE (tmp_mat)
178 CALL dbcsr_create(tmp_mat, template=s_der(1)%matrix, matrix_type="N")
179
180 IF (rtp%iter < 2) THEN
181 ! calculate the overlap derivative matrices
182 IF (dft_control%qs_control%dftb) THEN
183 CALL build_dftb_overlap(qs_env, nder, s_derivs)
184 ELSE
185 CALL build_overlap_matrix(ks_env, nderivative=nder, matrix_s=s_derivs, &
186 basis_type_a="ORB", basis_type_b="ORB", sab_nl=sab_orb)
187 END IF
188
189 NULLIFY (tmp_mat2)
190 ALLOCATE (tmp_mat2)
191 CALL dbcsr_create(tmp_mat2, template=s_der(1)%matrix, matrix_type="S")
192 DO m = 1, 9
193 CALL dbcsr_copy(tmp_mat2, s_derivs(m + 1)%matrix)
194 CALL dbcsr_desymmetrize(tmp_mat2, s_der(m)%matrix)
195 CALL dbcsr_scale(s_der(m)%matrix, -one)
196 CALL dbcsr_filter(s_der(m)%matrix, rtp%filter_eps)
197 !The diagonal should be zero
198 CALL dbcsr_iterator_start(iter, s_der(m)%matrix)
199 DO WHILE (dbcsr_iterator_blocks_left(iter))
200 CALL dbcsr_iterator_next_block(iter, row_atom, col_atom, block_values)
201 IF (row_atom == col_atom) block_values = 0.0_dp
202 END DO
203 CALL dbcsr_iterator_stop(iter)
204 END DO
205 CALL dbcsr_deallocate_matrix_set(s_derivs)
206 CALL dbcsr_deallocate_matrix(tmp_mat2)
207 END IF
208
209 !calculate scalar product v(Rb)*<alpha|d/dRb beta> (B_mat), and store the first derivatives
210
211 CALL dbcsr_set(b_mat, zero)
212 DO m = 1, 3
213 CALL dbcsr_copy(tmp_mat, s_der(m)%matrix)
214 CALL dbcsr_iterator_start(iter, tmp_mat)
215 DO WHILE (dbcsr_iterator_blocks_left(iter))
216 CALL dbcsr_iterator_next_block(iter, row_atom, col_atom, block_values)
217 IF (row_atom == col_atom) block_values = 0.0_dp
218 block_values = block_values*particle_set(col_atom)%v(m)
219 END DO
220 CALL dbcsr_iterator_stop(iter)
221 CALL dbcsr_add(b_mat, tmp_mat, one, one)
222 END DO
223 CALL dbcsr_filter(b_mat, rtp%filter_eps)
224 !calculate C matrix: v(Rb)*<d/dRa alpha| d/dRb beta>
225
226 c_map_mat = 0
227 n = 0
228 DO j = 1, 3
229 DO m = j, 3
230 n = n + 1
231 c_map_mat(n, 1) = j
232 IF (m == j) cycle
233 c_map_mat(n, 2) = m
234 END DO
235 END DO
236
237 DO i = 1, 3
238 CALL dbcsr_set(c_mat(i)%matrix, zero)
239 END DO
240 DO m = 1, 6
241 CALL dbcsr_copy(tmp_mat, s_der(m + 3)%matrix)
242 DO j = 1, 2
243 IF (c_map_mat(m, j) == 0) cycle
244 CALL dbcsr_add(c_mat(c_map_mat(m, j))%matrix, tmp_mat, one, one)
245 END DO
246 END DO
247
248 DO m = 1, 3
249 CALL dbcsr_iterator_start(iter, c_mat(m)%matrix)
250 DO WHILE (dbcsr_iterator_blocks_left(iter))
251 CALL dbcsr_iterator_next_block(iter, row_atom, col_atom, block_values)
252 block_values = block_values*particle_set(row_atom)%v(m)
253 END DO
254 CALL dbcsr_iterator_stop(iter)
255 CALL dbcsr_filter(c_mat(m)%matrix, rtp%filter_eps)
256 END DO
257
258 CALL dbcsr_deallocate_matrix(tmp_mat)
259 CALL timestop(handle)
260 END SUBROUTINE calc_s_derivs
261
262! **************************************************************************************************
263!> \brief reads the restart file. At the moment only SCF (means only real)
264!> \param qs_env ...
265!> \author Florian Schiffmann (02.09)
266! **************************************************************************************************
267
268 SUBROUTINE get_restart_wfn(qs_env)
269 TYPE(qs_environment_type), POINTER :: qs_env
270
271 CHARACTER(LEN=default_path_length) :: file_name, project_name
272 INTEGER :: i, id_nr, im, ispin, ncol, nspin, &
273 output_unit, re, unit_nr
274 REAL(kind=dp) :: alpha, cs_pos
275 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
276 TYPE(cp_fm_type) :: mos_occ
277 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos_old
278 TYPE(cp_logger_type), POINTER :: logger
279 TYPE(dbcsr_distribution_type) :: dist
280 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: p_rmpv, rho_new, rho_old
281 TYPE(dft_control_type), POINTER :: dft_control
282 TYPE(mo_set_type), DIMENSION(:), POINTER :: mo_array
283 TYPE(mp_para_env_type), POINTER :: para_env
284 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
285 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
286 TYPE(qs_rho_type), POINTER :: rho_struct
287 TYPE(rt_prop_type), POINTER :: rtp
288 TYPE(section_vals_type), POINTER :: dft_section, input
289
290 NULLIFY (atomic_kind_set, qs_kind_set, mo_array, particle_set, rho_struct, para_env)
291
292 CALL get_qs_env(qs_env, &
293 qs_kind_set=qs_kind_set, &
294 atomic_kind_set=atomic_kind_set, &
295 particle_set=particle_set, &
296 mos=mo_array, &
297 input=input, &
298 rtp=rtp, &
299 dft_control=dft_control, &
300 rho=rho_struct, &
301 para_env=para_env)
302 logger => cp_get_default_logger()
303 output_unit = cp_logger_get_default_io_unit(logger)
304
305 IF (logger%para_env%is_source()) THEN
306 unit_nr = cp_logger_get_default_unit_nr(logger, local=.true.)
307 ELSE
308 unit_nr = -1
309 END IF
310
311 id_nr = 0
312 nspin = SIZE(mo_array)
313 CALL qs_rho_get(rho_struct, rho_ao=p_rmpv)
314 dft_section => section_vals_get_subs_vals(input, "DFT")
315 SELECT CASE (dft_control%rtp_control%initial_wfn)
316 CASE (use_restart_wfn)
317 CALL read_mo_set_from_restart(mo_array, qs_kind_set, particle_set, para_env, &
318 id_nr=id_nr, multiplicity=dft_control%multiplicity, &
319 dft_section=dft_section)
320 CALL set_uniform_occupation_mo_array(mo_array, nspin)
321
322 IF (dft_control%rtp_control%apply_wfn_mix_init_restart) THEN
323 CALL wfn_mix(mo_array, particle_set, dft_section, qs_kind_set, para_env, output_unit, &
324 for_rtp=.true.)
325 END IF
326
327 DO ispin = 1, nspin
328 CALL calculate_density_matrix(mo_array(ispin), p_rmpv(ispin)%matrix)
329 END DO
330 IF (rtp%linear_scaling) THEN
331 CALL get_rtp(rtp=rtp, rho_old=rho_old, rho_new=rho_new)
332 DO ispin = 1, nspin
333 re = 2*ispin - 1
334 im = 2*ispin
335 CALL cp_fm_get_info(mo_array(ispin)%mo_coeff, ncol_global=ncol)
336 CALL cp_fm_create(mos_occ, &
337 matrix_struct=mo_array(ispin)%mo_coeff%matrix_struct, &
338 name="mos_occ")
339 CALL cp_fm_to_fm(mo_array(ispin)%mo_coeff, mos_occ)
340 IF (mo_array(ispin)%uniform_occupation) THEN
341 alpha = 3.0_dp - real(nspin, dp)
342 CALL cp_fm_column_scale(mos_occ, mo_array(ispin)%occupation_numbers/alpha)
343 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=rho_old(re)%matrix, &
344 matrix_v=mos_occ, &
345 ncol=ncol, &
346 alpha=alpha, keep_sparsity=.false.)
347 ELSE
348 alpha = 1.0_dp
349 CALL cp_fm_column_scale(mos_occ, mo_array(ispin)%occupation_numbers/alpha)
350 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=rho_old(re)%matrix, &
351 matrix_v=mo_array(ispin)%mo_coeff, &
352 matrix_g=mos_occ, &
353 ncol=ncol, &
354 alpha=alpha, keep_sparsity=.false.)
355 END IF
356 CALL dbcsr_filter(rho_old(re)%matrix, rtp%filter_eps)
357 CALL dbcsr_copy(rho_new(re)%matrix, rho_old(re)%matrix)
358 CALL cp_fm_release(mos_occ)
359 END DO
360 CALL calc_update_rho_sparse(qs_env)
361 ELSE
362 CALL get_rtp(rtp=rtp, mos_old=mos_old)
363 DO i = 1, SIZE(qs_env%mos)
364 CALL cp_fm_to_fm(mo_array(i)%mo_coeff, mos_old(2*i - 1))
365 CALL cp_fm_set_all(mos_old(2*i), zero, zero)
366 END DO
367 END IF
368 CASE (use_rt_restart)
369 IF (rtp%linear_scaling) THEN
370 CALL get_rtp(rtp=rtp, rho_old=rho_old, rho_new=rho_new)
371 project_name = logger%iter_info%project_name
372 DO ispin = 1, nspin
373 re = 2*ispin - 1
374 im = 2*ispin
375 WRITE (file_name, '(A,I0,A)') trim(project_name)//"_LS_DM_SPIN_RE", ispin, "_RESTART.dm"
376 CALL dbcsr_get_info(rho_old(re)%matrix, distribution=dist)
377 CALL dbcsr_binary_read(file_name, distribution=dist, matrix_new=rho_old(re)%matrix)
378 cs_pos = dbcsr_checksum(rho_old(re)%matrix, pos=.true.)
379 IF (unit_nr > 0) THEN
380 WRITE (unit_nr, '(T2,A,E20.8)') "Read restart DM "//trim(file_name)//" with checksum: ", cs_pos
381 END IF
382 WRITE (file_name, '(A,I0,A)') trim(project_name)//"_LS_DM_SPIN_IM", ispin, "_RESTART.dm"
383 CALL dbcsr_get_info(rho_old(im)%matrix, distribution=dist)
384 CALL dbcsr_binary_read(file_name, distribution=dist, matrix_new=rho_old(im)%matrix)
385 cs_pos = dbcsr_checksum(rho_old(im)%matrix, pos=.true.)
386 IF (unit_nr > 0) THEN
387 WRITE (unit_nr, '(T2,A,E20.8)') "Read restart DM "//trim(file_name)//" with checksum: ", cs_pos
388 END IF
389 END DO
390 DO i = 1, SIZE(rho_new)
391 CALL dbcsr_copy(rho_new(i)%matrix, rho_old(i)%matrix)
392 END DO
393 CALL calc_update_rho_sparse(qs_env)
394 ELSE
395 CALL get_rtp(rtp=rtp, mos_old=mos_old)
396 CALL read_rt_mos_from_restart(mo_array, mos_old, qs_kind_set, particle_set, para_env, &
397 id_nr, dft_control%multiplicity, dft_section)
398 CALL set_uniform_occupation_mo_array(mo_array, nspin)
399 DO ispin = 1, nspin
400 CALL calculate_density_matrix(mo_array(ispin), &
401 p_rmpv(ispin)%matrix)
402 END DO
403 END IF
404 END SELECT
405
406 END SUBROUTINE get_restart_wfn
407
408! **************************************************************************************************
409!> \brief Set mo_array(ispin)%uniform_occupation after a restart
410!> \param mo_array ...
411!> \param nspin ...
412!> \author Guillaume Le Breton (03.23)
413! **************************************************************************************************
414
415 SUBROUTINE set_uniform_occupation_mo_array(mo_array, nspin)
416
417 TYPE(mo_set_type), DIMENSION(:), POINTER :: mo_array
418 INTEGER :: nspin
419
420 INTEGER :: ispin, mo
421 LOGICAL :: is_uniform
422
423 DO ispin = 1, nspin
424 is_uniform = .true.
425 DO mo = 1, mo_array(ispin)%nmo
426 IF (mo_array(ispin)%occupation_numbers(mo) /= 0.0_dp .AND. &
427 mo_array(ispin)%occupation_numbers(mo) /= 1.0_dp .AND. &
428 mo_array(ispin)%occupation_numbers(mo) /= 2.0_dp) THEN
429 is_uniform = .false.
430 END IF
431 END DO
432 mo_array(ispin)%uniform_occupation = is_uniform
433 END DO
434
435 END SUBROUTINE set_uniform_occupation_mo_array
436
437! **************************************************************************************************
438!> \brief calculates the density from the complex MOs and passes the density to
439!> qs_env.
440!> \param qs_env ...
441!> \author Florian Schiffmann (02.09)
442! **************************************************************************************************
443
444 SUBROUTINE calc_update_rho(qs_env)
445
446 TYPE(qs_environment_type), POINTER :: qs_env
447
448 CHARACTER(len=*), PARAMETER :: routinen = 'calc_update_rho'
449 REAL(kind=dp), PARAMETER :: one = 1.0_dp, zero = 0.0_dp
450
451 INTEGER :: handle, i, im, ncol, re
452 REAL(kind=dp) :: alpha
453 TYPE(cp_fm_type) :: mos_occ
454 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos_new
455 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao, rho_ao_im
456 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
457 TYPE(qs_ks_env_type), POINTER :: ks_env
458 TYPE(qs_rho_type), POINTER :: rho
459 TYPE(rt_prop_type), POINTER :: rtp
460
461 CALL timeset(routinen, handle)
462
463 NULLIFY (rho, ks_env, mos_new, rtp)
464 CALL get_qs_env(qs_env, &
465 ks_env=ks_env, &
466 rho=rho, &
467 rtp=rtp, &
468 mos=mos)
469 CALL get_rtp(rtp=rtp, mos_new=mos_new)
470 CALL qs_rho_get(rho_struct=rho, rho_ao=rho_ao)
471 DO i = 1, SIZE(mos_new)/2
472 re = 2*i - 1; im = 2*i
473 CALL dbcsr_set(rho_ao(i)%matrix, zero)
474 CALL cp_fm_get_info(mos_new(re), ncol_global=ncol)
475 CALL cp_fm_create(mos_occ, &
476 matrix_struct=mos(i)%mo_coeff%matrix_struct, &
477 name="mos_occ")
478 CALL cp_fm_to_fm(mos_new(re), mos_occ)
479 IF (mos(i)%uniform_occupation) THEN
480 alpha = 3*one - real(SIZE(mos_new)/2, dp)
481 CALL cp_fm_column_scale(mos_occ, mos(i)%occupation_numbers/alpha)
482 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=rho_ao(i)%matrix, &
483 matrix_v=mos_occ, &
484 ncol=ncol, &
485 alpha=alpha)
486 ELSE
487 alpha = 1.0_dp
488 CALL cp_fm_column_scale(mos_occ, mos(i)%occupation_numbers/alpha)
489 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=rho_ao(i)%matrix, &
490 matrix_v=mos_new(re), &
491 matrix_g=mos_occ, &
492 ncol=ncol, &
493 alpha=alpha)
494 END IF
495
496 ! It is actually complex conjugate but i*i=-1 therefore it must be added
497 CALL cp_fm_to_fm(mos_new(im), mos_occ)
498 IF (mos(i)%uniform_occupation) THEN
499 alpha = 3*one - real(SIZE(mos_new)/2, dp)
500 CALL cp_fm_column_scale(mos_occ, mos(i)%occupation_numbers/alpha)
501 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=rho_ao(i)%matrix, &
502 matrix_v=mos_occ, &
503 ncol=ncol, &
504 alpha=alpha)
505 ELSE
506 alpha = 1.0_dp
507 CALL cp_fm_column_scale(mos_occ, mos(i)%occupation_numbers/alpha)
508 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=rho_ao(i)%matrix, &
509 matrix_v=mos_new(im), &
510 matrix_g=mos_occ, &
511 ncol=ncol, &
512 alpha=alpha)
513 END IF
514 CALL cp_fm_release(mos_occ)
515 END DO
516 CALL qs_rho_update_rho(rho, qs_env)
517
518 IF (rtp%track_imag_density) THEN
519 CALL qs_rho_get(rho_struct=rho, rho_ao_im=rho_ao_im)
520 CALL calculate_p_imaginary(qs_env, rtp, rho_ao_im, keep_sparsity=.true.)
521 CALL qs_rho_set(rho, rho_ao_im=rho_ao_im)
522 END IF
523
524 CALL qs_ks_did_change(ks_env, rho_changed=.true.)
525
526 CALL timestop(handle)
527
528 END SUBROUTINE calc_update_rho
529
530! **************************************************************************************************
531!> \brief Copies the density matrix back into the qs_env%rho%rho_ao
532!> \param qs_env ...
533!> \author Samuel Andermatt (3.14)
534! **************************************************************************************************
535
536 SUBROUTINE calc_update_rho_sparse(qs_env)
537
538 TYPE(qs_environment_type), POINTER :: qs_env
539
540 CHARACTER(len=*), PARAMETER :: routinen = 'calc_update_rho_sparse'
541 REAL(kind=dp), PARAMETER :: zero = 0.0_dp
542
543 INTEGER :: handle, ispin
544 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao, rho_ao_im, rho_new
545 TYPE(dft_control_type), POINTER :: dft_control
546 TYPE(qs_ks_env_type), POINTER :: ks_env
547 TYPE(qs_rho_type), POINTER :: rho
548 TYPE(rt_prop_type), POINTER :: rtp
549 TYPE(rtp_control_type), POINTER :: rtp_control
550
551 NULLIFY (rho, ks_env, rtp, dft_control)
552 CALL timeset(routinen, handle)
553 CALL get_qs_env(qs_env, &
554 ks_env=ks_env, &
555 rho=rho, &
556 rtp=rtp, &
557 dft_control=dft_control)
558 rtp_control => dft_control%rtp_control
559 CALL get_rtp(rtp=rtp, rho_new=rho_new)
560 CALL qs_rho_get(rho_struct=rho, rho_ao=rho_ao)
561 IF (rtp%track_imag_density) CALL qs_rho_get(rho_struct=rho, rho_ao_im=rho_ao_im)
562 DO ispin = 1, SIZE(rho_ao)
563 CALL dbcsr_set(rho_ao(ispin)%matrix, zero)
564 CALL dbcsr_copy(rho_ao(ispin)%matrix, rho_new(ispin*2 - 1)%matrix, keep_sparsity=.true.)
565 IF (rtp%track_imag_density) THEN
566 CALL dbcsr_copy(rho_ao_im(ispin)%matrix, rho_new(ispin*2)%matrix, keep_sparsity=.true.)
567 END IF
568 END DO
569
570 CALL qs_rho_update_rho(rho, qs_env)
571 CALL qs_ks_did_change(ks_env, rho_changed=.true.)
572
573 CALL timestop(handle)
574
575 END SUBROUTINE calc_update_rho_sparse
576
577! **************************************************************************************************
578!> \brief ...
579!> \param qs_env ...
580!> \param rtp ...
581!> \param matrix_p_im ...
582!> \param keep_sparsity ...
583! **************************************************************************************************
584 SUBROUTINE calculate_p_imaginary(qs_env, rtp, matrix_p_im, keep_sparsity)
585 TYPE(qs_environment_type), POINTER :: qs_env
586 TYPE(rt_prop_type), POINTER :: rtp
587 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_p_im
588 LOGICAL, OPTIONAL :: keep_sparsity
589
590 INTEGER :: i, im, ncol, re
591 LOGICAL :: my_keep_sparsity
592 REAL(kind=dp) :: alpha
593 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos_new, mos_occ
594 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
595
596 CALL get_rtp(rtp=rtp, mos_new=mos_new)
597
598 my_keep_sparsity = .false.
599 IF (PRESENT(keep_sparsity)) my_keep_sparsity = keep_sparsity
600 CALL get_qs_env(qs_env, mos=mos)
601 ALLOCATE (mos_occ(SIZE(mos)*2))
602
603 DO i = 1, SIZE(mos_new)/2
604 re = 2*i - 1; im = 2*i
605 alpha = 3.0_dp - real(SIZE(matrix_p_im), dp)
606 CALL cp_fm_create(mos_occ(re), &
607 matrix_struct=mos(i)%mo_coeff%matrix_struct, &
608 name="mos_occ")
609 CALL cp_fm_create(mos_occ(im), &
610 matrix_struct=mos(i)%mo_coeff%matrix_struct, &
611 name="mos_occ")
612 CALL dbcsr_set(matrix_p_im(i)%matrix, 0.0_dp)
613 CALL cp_fm_get_info(mos_new(re), ncol_global=ncol)
614 CALL cp_fm_to_fm(mos_new(re), mos_occ(re))
615 CALL cp_fm_column_scale(mos_occ(re), mos(i)%occupation_numbers/alpha)
616 CALL cp_fm_to_fm(mos_new(im), mos_occ(im))
617 CALL cp_fm_column_scale(mos_occ(im), mos(i)%occupation_numbers/alpha)
618 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=matrix_p_im(i)%matrix, &
619 matrix_v=mos_occ(im), &
620 matrix_g=mos_occ(re), &
621 ncol=ncol, &
622 keep_sparsity=my_keep_sparsity, &
623 alpha=2.0_dp*alpha, &
624 symmetry_mode=-1)
625 END DO
626 CALL cp_fm_release(mos_occ)
627
628 END SUBROUTINE calculate_p_imaginary
629
630! **************************************************************************************************
631!> \brief ...
632!> \param qs_env ...
633!> \param rtp ...
634! **************************************************************************************************
635 SUBROUTINE write_rtp_mos_to_output_unit(qs_env, rtp)
636 TYPE(qs_environment_type), POINTER :: qs_env
637 TYPE(rt_prop_type), POINTER :: rtp
638
639 CHARACTER(len=*), PARAMETER :: routinen = 'write_rtp_mos_to_output_unit'
640
641 CHARACTER(LEN=10) :: spin
642 CHARACTER(LEN=2*default_string_length) :: name
643 INTEGER :: handle, i, ispin, nao, nelectron, nmo, &
644 nspins
645 LOGICAL :: print_eigvecs, print_mo_info
646 REAL(kind=dp) :: flexible_electron_count, maxocc, n_el_f
647 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
648 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos_new
649 TYPE(cp_logger_type), POINTER :: logger
650 TYPE(mo_set_type) :: mo_set_rtp
651 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
652 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
653 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
654 TYPE(section_vals_type), POINTER :: dft_section, input
655
656 NULLIFY (atomic_kind_set, particle_set, qs_kind_set, input, mos, dft_section)
657
658 CALL timeset(routinen, handle)
659
660 CALL get_qs_env(qs_env, &
661 atomic_kind_set=atomic_kind_set, &
662 qs_kind_set=qs_kind_set, &
663 particle_set=particle_set, &
664 input=input, &
665 mos=mos)
666 ! Quick return, if no printout of MO information is requested
667 dft_section => section_vals_get_subs_vals(input, "DFT")
668 CALL section_vals_val_get(dft_section, "PRINT%MO%EIGENVECTORS", l_val=print_eigvecs)
669
670 NULLIFY (logger)
671 logger => cp_get_default_logger()
672 print_mo_info = (cp_print_key_should_output(logger%iter_info, &
673 dft_section, "PRINT%MO") /= 0) .OR. &
674 (qs_env%sim_step == 1)
675
676 IF ((.NOT. print_mo_info) .OR. (.NOT. print_eigvecs)) THEN
677 CALL timestop(handle)
678 RETURN
679 END IF
680
681 CALL get_rtp(rtp=rtp, mos_new=mos_new)
682
683 nspins = SIZE(mos_new)/2
684
685 DO ispin = 1, nspins
686 ! initiate mo_set
687 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo, nelectron=nelectron, &
688 n_el_f=n_el_f, maxocc=maxocc, flexible_electron_count=flexible_electron_count)
689
690 CALL allocate_mo_set(mo_set_rtp, &
691 nao=nao, &
692 nmo=nmo, &
693 nelectron=nelectron, &
694 n_el_f=n_el_f, &
695 maxocc=maxocc, &
696 flexible_electron_count=flexible_electron_count)
697
698 WRITE (name, fmt="(A,I6)") "RTP MO SET, SPIN ", ispin
699 CALL init_mo_set(mo_set_rtp, fm_ref=mos_new(2*ispin - 1), name=name)
700
701 IF (nspins > 1) THEN
702 IF (ispin == 1) THEN
703 spin = "ALPHA SPIN"
704 ELSE
705 spin = "BETA SPIN"
706 END IF
707 ELSE
708 spin = ""
709 END IF
710
711 mo_set_rtp%occupation_numbers = mos(ispin)%occupation_numbers
712
713 !loop for real (odd) and imaginary (even) parts
714 DO i = 1, 0, -1
715 CALL cp_fm_to_fm(mos_new(2*ispin - i), mo_set_rtp%mo_coeff)
716 CALL write_mo_set_to_output_unit(mo_set_rtp, qs_kind_set, particle_set, &
717 dft_section, 4, 0, rtp=.true., spin=trim(spin), &
718 cpart=mod(i, 2), sim_step=qs_env%sim_step)
719 END DO
720
721 CALL deallocate_mo_set(mo_set_rtp)
722 END DO
723
724 CALL timestop(handle)
725
726 END SUBROUTINE write_rtp_mos_to_output_unit
727
728! **************************************************************************************************
729!> \brief Write the time dependent amplitude of the MOs in real grid.
730!> Very close to qs_scf_post_gpw/qs_scf_post_occ_cubes subroutine.
731!> \param qs_env ...
732!> \param rtp ...
733!> \author Guillaume Le Breton (11.22)
734! **************************************************************************************************
735 SUBROUTINE write_rtp_mo_cubes(qs_env, rtp)
736 TYPE(qs_environment_type), POINTER :: qs_env
737 TYPE(rt_prop_type), POINTER :: rtp
738
739 CHARACTER(LEN=*), PARAMETER :: routinen = 'write_rtp_mo_cubes'
740
741 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
742 INTEGER :: handle, homo, i, ir, ispin, ivector, &
743 n_rep, nhomo, nlist, nspins, &
744 rt_time_step, unit_nr
745 INTEGER, DIMENSION(:), POINTER :: list, list_index
746 LOGICAL :: append_cube, do_kpoints, mpi_io
747 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: zcharge
748 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
749 TYPE(cell_type), POINTER :: cell
750 TYPE(cp_blacs_env_type), POINTER :: blacs_env
751 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos_new
752 TYPE(cp_fm_type), POINTER :: mo_coeff
753 TYPE(cp_logger_type), POINTER :: logger
754 TYPE(dft_control_type), POINTER :: dft_control
755 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
756 TYPE(mp_para_env_type), POINTER :: para_env
757 TYPE(particle_list_type), POINTER :: particles
758 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
759 TYPE(pw_c1d_gs_type) :: wf_g
760 TYPE(pw_env_type), POINTER :: pw_env
761 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
762 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
763 TYPE(pw_r3d_rs_type) :: density_r, wf_r
764 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
765 TYPE(qs_subsys_type), POINTER :: subsys
766 TYPE(section_vals_type), POINTER :: dft_section, input
767
768 CALL timeset(routinen, handle)
769
770 NULLIFY (logger, auxbas_pw_pool, pw_pools, pw_env)
771
772 ! Get all the info from qs:
773 CALL get_qs_env(qs_env, do_kpoints=do_kpoints, &
774 input=input)
775
776 ! Kill the run in the case of K points
777 IF (do_kpoints) THEN
778 cpabort("K points not handled yet for printing MO_CUBE")
779 END IF
780
781 dft_section => section_vals_get_subs_vals(input, "DFT")
782 logger => cp_get_default_logger()
783
784 ! Quick return if no print required
785 IF (.NOT. btest(cp_print_key_should_output(logger%iter_info, dft_section, &
786 "PRINT%MO_CUBES"), cp_p_file)) THEN
787 CALL timestop(handle)
788 RETURN
789 END IF
790
791 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, &
792 mos=mos, &
793 blacs_env=blacs_env, &
794 qs_kind_set=qs_kind_set, &
795 pw_env=pw_env, &
796 subsys=subsys, &
797 para_env=para_env, &
798 particle_set=particle_set, &
799 dft_control=dft_control)
800 CALL qs_subsys_get(subsys, particles=particles)
801 CALL get_effective_core_charges(qs_env, zcharge)
802
803 nspins = dft_control%nspins
804 rt_time_step = qs_env%sim_step
805
806 ! Setup the grids needed to compute a wavefunction given a vector
807 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
808 pw_pools=pw_pools)
809 CALL auxbas_pw_pool%create_pw(wf_r)
810 CALL auxbas_pw_pool%create_pw(wf_g)
811 CALL auxbas_pw_pool%create_pw(density_r)
812 CALL get_rtp(rtp=rtp, mos_new=mos_new)
813
814 DO ispin = 1, nspins
815 CALL get_mo_set(mo_set=mos(ispin), homo=homo)
816
817 nhomo = section_get_ival(dft_section, "PRINT%MO_CUBES%NHOMO")
818 append_cube = section_get_lval(dft_section, "PRINT%MO_CUBES%APPEND")
819 my_pos_cube = "REWIND"
820 IF (append_cube) THEN
821 my_pos_cube = "APPEND"
822 END IF
823 CALL section_vals_val_get(dft_section, "PRINT%MO_CUBES%HOMO_LIST", n_rep_val=n_rep)
824 IF (n_rep > 0) THEN ! write the cubes of the list
825 nlist = 0
826 DO ir = 1, n_rep
827 NULLIFY (list)
828 CALL section_vals_val_get(dft_section, "PRINT%MO_CUBES%HOMO_LIST", i_rep_val=ir, &
829 i_vals=list)
830 IF (ASSOCIATED(list)) THEN
831 CALL reallocate(list_index, 1, nlist + SIZE(list))
832 DO i = 1, SIZE(list)
833 list_index(i + nlist) = list(i)
834 END DO
835 nlist = nlist + SIZE(list)
836 END IF
837 END DO
838 ELSE
839
840 IF (nhomo == -1) nhomo = homo
841 nlist = homo - max(1, homo - nhomo + 1) + 1
842 ALLOCATE (list_index(nlist))
843 DO i = 1, nlist
844 list_index(i) = max(1, homo - nhomo + 1) + i - 1
845 END DO
846 END IF
847 DO i = 1, nlist
848 ivector = list_index(i)
849 CALL get_qs_env(qs_env=qs_env, &
850 atomic_kind_set=atomic_kind_set, &
851 qs_kind_set=qs_kind_set, &
852 cell=cell, &
853 particle_set=particle_set, &
854 pw_env=pw_env)
855
856 ! density_r contains the density of the MOs
857 CALL pw_zero(density_r)
858 mo_coeff => mos_new(2*ispin - 1)!Real coeff
859 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, qs_kind_set, &
860 cell, dft_control, particle_set, pw_env)
861 ! Adding the real part
862 CALL pw_multiply(density_r, wf_r, wf_r, 1.0_dp)
863
864 mo_coeff => mos_new(2*ispin) !Im coeff
865 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, qs_kind_set, &
866 cell, dft_control, particle_set, pw_env)
867 ! Adding the im part
868 CALL pw_multiply(density_r, wf_r, wf_r, 1.0_dp)
869
870 WRITE (filename, '(a4,I5.5,a1,I1.1)') "WFN_", ivector, "_", ispin
871 mpi_io = .true.
872 unit_nr = cp_print_key_unit_nr(logger, input, "DFT%PRINT%MO_CUBES", extension=".cube", &
873 middle_name=trim(filename), file_position=my_pos_cube, log_filename=.false., &
874 mpi_io=mpi_io)
875 WRITE (title, *) "DENSITY ", ivector, " spin ", ispin, " i.e. HOMO - ", ivector - homo
876 CALL cp_pw_to_cube(density_r, unit_nr, title, particles=particles, zeff=zcharge, &
877 stride=section_get_ivals(dft_section, "PRINT%MO_CUBES%STRIDE"), mpi_io=mpi_io)
878 CALL cp_print_key_finished_output(unit_nr, logger, input, "DFT%PRINT%MO_CUBES", mpi_io=mpi_io)
879 END DO
880 IF (ASSOCIATED(list_index)) DEALLOCATE (list_index)
881 END DO
882
883 ! Deallocate grids needed to compute wavefunctions
884 CALL auxbas_pw_pool%give_back_pw(wf_r)
885 CALL auxbas_pw_pool%give_back_pw(wf_g)
886 CALL auxbas_pw_pool%give_back_pw(density_r)
887 DEALLOCATE (zcharge)
888
889 CALL timestop(handle)
890
891 END SUBROUTINE write_rtp_mo_cubes
892
893! **************************************************************************************************
894!> \brief Warn about unused sections of the print section - only implemented for some of the methods
895!> \param section Parent section
896!> \param subsection_name Name of the subsection which is not used even when explicitly included
897!> \param error_message Message to display as warning
898!> \author Stepan Marek (01.25)
899! **************************************************************************************************
900 SUBROUTINE warn_section_unused(section, subsection_name, error_message)
901 TYPE(section_vals_type), POINTER :: section
902 CHARACTER(len=*) :: subsection_name, error_message
903
904 LOGICAL :: explicit
905 TYPE(section_vals_type), POINTER :: target_section
906
907 target_section => section_vals_get_subs_vals(section, subsection_name)
908 CALL section_vals_get(target_section, explicit=explicit)
909 IF (explicit) cpwarn(error_message)
910 END SUBROUTINE warn_section_unused
911! **************************************************************************************************
912!> \brief Attempt to read the moments from a previously written file
913!> \param moments_section Print key section for the moments trace
914!> \param orig_start Index from which the original calculation started (given by input file)
915!> \param current_start The current start index from which the calculation continues
916!> \param moments Moment trace, where the read entries are overwritten
917!> \param times Optional time trace, where again the read entries are overwritten
918!> \param mom_read Whether moments were actually read
919!> \author Stepan Marek (11.25)
920! **************************************************************************************************
921 SUBROUTINE read_moments(moments_section, orig_start, current_start, moments, times, mom_read)
922 TYPE(section_vals_type), POINTER :: moments_section
923 INTEGER :: orig_start, current_start
924 COMPLEX(kind=dp), DIMENSION(:, :, :), POINTER :: moments
925 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: times
926 LOGICAL, OPTIONAL :: mom_read
927
928 CHARACTER(len=14), DIMENSION(4) :: file_extensions
929 CHARACTER(len=default_path_length) :: save_name_im, save_name_re
930 INTEGER :: i, k, max_n, n, n_spin, unit_im, unit_re
931 REAL(kind=dp) :: time
932 REAL(kind=dp), DIMENSION(3) :: moments_im, moments_re
933 TYPE(cp_logger_type), POINTER :: logger
934
935! Whether at least some moments where extracted from the files
936
937 file_extensions(1) = "_SPIN_A_RE.dat"
938 file_extensions(2) = "_SPIN_A_IM.dat"
939 file_extensions(3) = "_SPIN_B_RE.dat"
940 file_extensions(4) = "_SPIN_B_IM.dat"
941
942 IF (PRESENT(mom_read)) mom_read = .false.
943
944 n_spin = SIZE(moments, 1)
945
946 logger => cp_get_default_logger()
947 max_n = current_start - orig_start + 1
948
949 DO i = 1, n_spin
950 ! Open the relevant files
951 save_name_re = cp_print_key_generate_filename(logger, moments_section, &
952 extension=file_extensions(2*i - 1), my_local=.false.)
953 save_name_im = cp_print_key_generate_filename(logger, moments_section, &
954 extension=file_extensions(2*i), my_local=.false.)
955 IF (file_exists(save_name_re) .AND. file_exists(save_name_im)) THEN
956 CALL open_file(save_name_re, file_status="OLD", file_form="FORMATTED", file_action="READ", &
957 unit_number=unit_re)
958 CALL open_file(save_name_im, file_status="OLD", file_form="FORMATTED", file_action="READ", &
959 unit_number=unit_im)
960 ! Skip the headers
961 READ (unit_re, '()')
962 READ (unit_im, '()')
963 DO n = 1, max_n
964 ! Read the data
965 READ (unit_re, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') time, &
966 moments_re(1), moments_re(2), moments_re(3)
967 READ (unit_im, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') time, &
968 moments_im(1), moments_im(2), moments_im(3)
969 DO k = 1, 3
970 moments(i, k, n) = cmplx(moments_re(k), moments_im(k), kind=dp)
971 END DO
972 IF (PRESENT(times)) THEN
973 times(n) = time/femtoseconds
974 END IF
975 END DO
976 IF (PRESENT(mom_read)) mom_read = .true.
977 CALL close_file(unit_re)
978 CALL close_file(unit_im)
979 ELSE
980 moments(i, :, 1:max_n) = cmplx(0.0, 0.0, kind=dp)
981 cpwarn("Could not read at least one moments file - missing trace is set to zero.")
982 END IF
983 END DO
984 END SUBROUTINE read_moments
985
986! **************************************************************************************************
987!> \brief Recalculates the field for index range given by orig_start and i_start,
988!> with times taken from the times array
989!> \param fields Array, where relevant indices are recalculated
990!> \param times Array of input times
991!> \param orig_start original start (in case of restarts)
992!> \param i_start current start
993!> \param dft_control DFT parameters
994!> \date 11.2025
995!> \author Stepan Marek
996! **************************************************************************************************
997 SUBROUTINE recalculate_fields(fields, times, orig_start, i_start, dft_control)
998 COMPLEX(kind=dp), DIMENSION(:, :), POINTER :: fields
999 REAL(kind=dp), DIMENSION(:), POINTER :: times
1000 INTEGER :: orig_start, i_start
1001 TYPE(dft_control_type), POINTER :: dft_control
1002
1003 INTEGER :: i, max_n
1004 REAL(kind=dp), DIMENSION(3) :: field
1005
1006 max_n = i_start - orig_start + 1
1007
1008 IF (dft_control%rtp_control%apply_delta_pulse .OR. &
1009 dft_control%rtp_control%apply_delta_pulse_mag) THEN
1010 fields(:, 1:max_n) = 0.0_dp
1011 ELSE
1012 DO i = 1, max_n
1013 CALL make_field(dft_control, field, i + orig_start - 1, times(i))
1014 fields(:, i) = field(:)
1015 END DO
1016 END IF
1017 END SUBROUTINE recalculate_fields
1018
1019END MODULE rt_propagation_utils
Define the atomic kind types and their sub types.
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_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
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)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_binary_read(filepath, distribution, matrix_new)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
real(kind=dp) function, public dbcsr_checksum(matrix, pos)
Calculates the checksum of a DBCSR matrix.
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
Utility routines to open and close files.
Definition cp_files.F:22
logical function, public file_exists(file_name)
Checks if a file exists, considering also the file discovery mechanism.
Definition cp_files.F:518
subroutine, public open_file(file_name, unit_number, file_status, file_form, file_action, file_position, file_pad, file_access, debug)
Opens a file and returns its logical unit number.
Definition cp_files.F:197
subroutine, public close_file(unit_number, file_status)
Closes an open file given by its logical unit number.
Definition cp_files.F:64
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_column_scale(matrixa, scaling, first_col, source)
Scales columns of the full matrix by corresponding factors.
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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
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...
character(len=default_path_length) function, public cp_print_key_generate_filename(logger, print_key, middle_name, extension, my_local)
Utility function that returns a unit number to write the print key. Might open a file with a unique f...
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,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
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, file_access)
...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
...
all routins needed for a nonperiodic electric field
subroutine, public make_field(dft_control, field, sim_step, sim_time)
computes the amplitude of the efield within a given envelop
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public use_restart_wfn
integer, parameter, public use_rt_restart
objects that represent the structure of input sections and the data contained in an input section
integer function, dimension(:), pointer, public section_get_ivals(section_vals, keyword_name)
...
integer function, public section_get_ival(section_vals, keyword_name)
...
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_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
logical function, public section_get_lval(section_vals, keyword_name)
...
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
integer, parameter, public default_path_length
Definition kinds.F:58
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition list.F:24
Definition of mathematical constants and functions.
real(kind=dp), parameter, public one
real(kind=dp), parameter, public zero
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
represent a simple array based list of the given type
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public femtoseconds
Definition physcon.F:153
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type)
maps a given wavefunction on the grid
collects routines that calculate density matrices
Calculation of Overlap and Hamiltonian matrices in DFTB.
subroutine, public build_dftb_overlap(qs_env, nderivative, matrix_s)
...
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 qs_ks_did_change(ks_env, s_mstruct_changed, rho_changed, potential_changed, full_reset)
tells that some of the things relevant to the ks calculation did change. has to be called when change...
Definition and initialisation of the mo data type.
Definition qs_mo_io.F:21
subroutine, public read_mo_set_from_restart(mo_array, qs_kind_set, particle_set, para_env, id_nr, multiplicity, dft_section, natom_mismatch, cdft, out_unit)
...
Definition qs_mo_io.F:526
subroutine, public read_rt_mos_from_restart(mo_array, rt_mos, qs_kind_set, particle_set, para_env, id_nr, multiplicity, dft_section)
...
Definition qs_mo_io.F:619
subroutine, public write_mo_set_to_output_unit(mo_set, qs_kind_set, particle_set, dft_section, before, kpoint, final_mos, spin, solver_method, rtp, cpart, sim_step, umo_set, qs_env, para_env_inter_kp)
Write MO information to output file (eigenvalues, occupation numbers, coefficients).
Definition qs_mo_io.F:1027
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name, counter, complex_coeff)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
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.
Calculation of overlap matrix, its derivatives and forces.
Definition qs_overlap.F:19
subroutine, public build_overlap_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p, ext_kpoints)
Calculation of the overlap matrix over Cartesian Gaussian functions.
Definition qs_overlap.F:121
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public get_effective_core_charges(qs_env, zcharge)
Collects the effective core charge for every atom in a QS environment.
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, output_unit, unoccupied_orbs, scf_env, matrix_s, marked_states, for_rtp)
writes a new 'mixed' set of mos to restart file, without touching the current MOs
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
Types and set_get for real time propagation depending on runtype and diagonalization method different...
subroutine, public get_rtp(rtp, exp_h_old, exp_h_new, h_last_iter, rho_old, rho_next, rho_new, mos, mos_new, mos_old, mos_next, s_inv, s_half, s_minus_half, b_mat, c_mat, propagator_matrix, mixing, mixing_factor, s_der, dt, nsteps, sinvh, sinvh_imag, sinvb, admm_mos)
...
Routines needed for EMD.
subroutine, public calc_update_rho_sparse(qs_env)
Copies the density matrix back into the qs_envrhorho_ao.
subroutine, public recalculate_fields(fields, times, orig_start, i_start, dft_control)
Recalculates the field for index range given by orig_start and i_start, with times taken from the tim...
subroutine, public calc_s_derivs(qs_env)
Calculates dS/dR respectily the velocity weighted derivatves only needed for ehrenfest MD.
subroutine, public write_rtp_mos_to_output_unit(qs_env, rtp)
...
subroutine, public write_rtp_mo_cubes(qs_env, rtp)
Write the time dependent amplitude of the MOs in real grid. Very close to qs_scf_post_gpw/qs_scf_post...
subroutine, public read_moments(moments_section, orig_start, current_start, moments, times, mom_read)
Attempt to read the moments from a previously written file.
subroutine, public calculate_p_imaginary(qs_env, rtp, matrix_p_im, keep_sparsity)
...
subroutine, public calc_update_rho(qs_env)
calculates the density from the complex MOs and passes the density to qs_env.
subroutine, public warn_section_unused(section, subsection_name, error_message)
Warn about unused sections of the print section - only implemented for some of the methods.
subroutine, public get_restart_wfn(qs_env)
reads the restart file. At the moment only SCF (means only real)
Provides all information about an atomic kind.
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 full matrix
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
contained for different pw related things
to create arrays of pools
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.