(git:34ef472)
qs_tddfpt2_properties.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
9  USE atomic_kind_types, ONLY: atomic_kind_type
10  USE bibliography, ONLY: martin2003,&
11  cite_reference
12  USE cell_types, ONLY: cell_type
13  USE cp_blacs_env, ONLY: cp_blacs_env_type
15  USE cp_cfm_types, ONLY: cp_cfm_create,&
18  cp_cfm_to_fm,&
19  cp_cfm_type,&
21  USE cp_control_types, ONLY: dft_control_type,&
22  tddfpt2_control_type
28  USE cp_fm_basic_linalg, ONLY: cp_fm_scale,&
30  cp_fm_trace
31  USE cp_fm_diag, ONLY: choose_eigv_solver,&
35  cp_fm_struct_type
36  USE cp_fm_types, ONLY: cp_fm_create,&
38  cp_fm_release,&
40  cp_fm_to_fm,&
41  cp_fm_type,&
45  cp_logger_type
46  USE cp_output_handling, ONLY: cp_p_file,&
51  USE dbcsr_api, ONLY: &
52  dbcsr_copy, dbcsr_get_block_p, dbcsr_get_info, dbcsr_init_p, dbcsr_iterator_blocks_left, &
53  dbcsr_iterator_next_block, dbcsr_iterator_start, dbcsr_iterator_stop, dbcsr_iterator_type, &
54  dbcsr_p_type, dbcsr_set, dbcsr_type
59  section_vals_type,&
61  USE kahan_sum, ONLY: accurate_dot_product
62  USE kinds, ONLY: default_path_length,&
63  dp,&
64  int_8
65  USE mathconstants, ONLY: twopi,&
66  z_one,&
67  z_zero
68  USE message_passing, ONLY: mp_comm_type,&
69  mp_para_env_type,&
70  mp_request_type
73  USE parallel_gemm_api, ONLY: parallel_gemm
74  USE particle_list_types, ONLY: particle_list_type
75  USE particle_types, ONLY: particle_type
76  USE physcon, ONLY: evolt
77  USE pw_env_types, ONLY: pw_env_get,&
78  pw_env_type
79  USE pw_poisson_types, ONLY: pw_poisson_type
80  USE pw_pool_types, ONLY: pw_pool_p_type,&
81  pw_pool_type
82  USE pw_types, ONLY: pw_c1d_gs_type,&
83  pw_r3d_rs_type
85  USE qs_environment_types, ONLY: get_qs_env,&
86  qs_environment_type
87  USE qs_kind_types, ONLY: qs_kind_type
88  USE qs_ks_types, ONLY: qs_ks_env_type
89  USE qs_mo_types, ONLY: allocate_mo_set,&
91  get_mo_set,&
92  init_mo_set,&
93  mo_set_type,&
96  USE qs_neighbor_list_types, ONLY: neighbor_list_set_p_type
97  USE qs_operators_ao, ONLY: rrc_xyz_ao
99  USE qs_subsys_types, ONLY: qs_subsys_get,&
100  qs_subsys_type
101  USE qs_tddfpt2_types, ONLY: tddfpt_ground_state_mos
103  USE util, ONLY: sort
104 #include "./base/base_uses.f90"
105 
106  IMPLICIT NONE
107 
108  PRIVATE
109 
110  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_tddfpt2_properties'
111 
112  ! number of first derivative components (3: d/dx, d/dy, d/dz)
113  INTEGER, PARAMETER, PRIVATE :: nderivs = 3
114  INTEGER, PARAMETER, PRIVATE :: maxspins = 2
115 
118 
119 ! **************************************************************************************************
120 
121 CONTAINS
122 
123 ! **************************************************************************************************
124 !> \brief Compute the action of the dipole operator on the ground state wave function.
125 !> \param dipole_op_mos_occ 2-D array [x,y,z ; spin] of matrices where to put the computed quantity
126 !> (allocated and initialised on exit)
127 !> \param tddfpt_control TDDFPT control parameters
128 !> \param gs_mos molecular orbitals optimised for the ground state
129 !> \param qs_env Quickstep environment
130 !> \par History
131 !> * 05.2016 created as 'tddfpt_print_summary' [Sergey Chulkov]
132 !> * 06.2018 dipole operator based on the Berry-phase formula [Sergey Chulkov]
133 !> * 08.2018 splited of from 'tddfpt_print_summary' and merged with code from 'tddfpt'
134 !> [Sergey Chulkov]
135 !> \note \parblock
136 !> Adapted version of the subroutine find_contributions() which was originally created
137 !> by Thomas Chassaing on 02.2005.
138 !>
139 !> The relation between dipole integrals in velocity and length forms are the following:
140 !> \f[<\psi_i|\nabla|\psi_a> = <\psi_i|\vec{r}|\hat{H}\psi_a> - <\hat{H}\psi_i|\vec{r}|\psi_a>
141 !> = (\epsilon_a - \epsilon_i) <\psi_i|\vec{r}|\psi_a> .\f],
142 !> due to the commutation identity:
143 !> \f[\vec{r}\hat{H} - \hat{H}\vec{r} = [\vec{r},\hat{H}] = [\vec{r},-1/2 \nabla^2] = \nabla\f] .
144 !> \endparblock
145 ! **************************************************************************************************
146  SUBROUTINE tddfpt_dipole_operator(dipole_op_mos_occ, tddfpt_control, gs_mos, qs_env)
147  TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :), &
148  INTENT(inout) :: dipole_op_mos_occ
149  TYPE(tddfpt2_control_type), POINTER :: tddfpt_control
150  TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
151  INTENT(in) :: gs_mos
152  TYPE(qs_environment_type), POINTER :: qs_env
153 
154  CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_dipole_operator'
155 
156  INTEGER :: handle, i_cos_sin, icol, ideriv, irow, &
157  ispin, jderiv, nao, ncols_local, &
158  ndim_periodic, nrows_local, nspins
159  INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
160  INTEGER, DIMENSION(maxspins) :: nmo_occ, nmo_virt
161  REAL(kind=dp) :: eval_occ
162  REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :), &
163  POINTER :: local_data_ediff, local_data_wfm
164  REAL(kind=dp), DIMENSION(3) :: kvec, reference_point
165  TYPE(cell_type), POINTER :: cell
166  TYPE(cp_blacs_env_type), POINTER :: blacs_env
167  TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: gamma_00, gamma_inv_00
168  TYPE(cp_fm_struct_type), POINTER :: fm_struct
169  TYPE(cp_fm_type) :: ediff_inv, rrc_mos_occ, wfm_ao_ao, &
170  wfm_mo_virt_mo_occ
171  TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: s_mos_virt
172  TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: dberry_mos_occ, gamma_real_imag, opvec
173  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: berry_cossin_xyz, matrix_s, rrc_xyz, scrm
174  TYPE(dft_control_type), POINTER :: dft_control
175  TYPE(neighbor_list_set_p_type), DIMENSION(:), &
176  POINTER :: sab_orb
177  TYPE(pw_env_type), POINTER :: pw_env
178  TYPE(pw_poisson_type), POINTER :: poisson_env
179  TYPE(qs_ks_env_type), POINTER :: ks_env
180 
181  CALL timeset(routinen, handle)
182 
183  NULLIFY (blacs_env, cell, matrix_s, pw_env)
184  CALL get_qs_env(qs_env, blacs_env=blacs_env, cell=cell, matrix_s=matrix_s, pw_env=pw_env)
185 
186  nspins = SIZE(gs_mos)
187  CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao)
188  DO ispin = 1, nspins
189  nmo_occ(ispin) = SIZE(gs_mos(ispin)%evals_occ)
190  nmo_virt(ispin) = SIZE(gs_mos(ispin)%evals_virt)
191  END DO
192 
193  ! +++ allocate dipole operator matrices (must be deallocated elsewhere)
194  ALLOCATE (dipole_op_mos_occ(nderivs, nspins))
195  DO ispin = 1, nspins
196  CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, matrix_struct=fm_struct)
197 
198  DO ideriv = 1, nderivs
199  CALL cp_fm_create(dipole_op_mos_occ(ideriv, ispin), fm_struct)
200  END DO
201  END DO
202 
203  ! +++ allocate work matrices
204  ALLOCATE (s_mos_virt(nspins))
205  DO ispin = 1, nspins
206  CALL cp_fm_get_info(gs_mos(ispin)%mos_virt, matrix_struct=fm_struct)
207  CALL cp_fm_create(s_mos_virt(ispin), fm_struct)
208  CALL cp_dbcsr_sm_fm_multiply(matrix_s(1)%matrix, &
209  gs_mos(ispin)%mos_virt, &
210  s_mos_virt(ispin), &
211  ncol=nmo_virt(ispin), alpha=1.0_dp, beta=0.0_dp)
212  END DO
213 
214  ! check that the chosen dipole operator is consistent with the periodic boundary conditions used
215  CALL pw_env_get(pw_env, poisson_env=poisson_env)
216  ndim_periodic = count(poisson_env%parameters%periodic == 1)
217 
218  ! select default for dipole form
219  IF (tddfpt_control%dipole_form == 0) THEN
220  CALL get_qs_env(qs_env, dft_control=dft_control)
221  IF (dft_control%qs_control%xtb) THEN
222  IF (ndim_periodic == 0) THEN
223  tddfpt_control%dipole_form = tddfpt_dipole_length
224  ELSE
225  tddfpt_control%dipole_form = tddfpt_dipole_berry
226  END IF
227  ELSE
228  tddfpt_control%dipole_form = tddfpt_dipole_velocity
229  END IF
230  END IF
231 
232  SELECT CASE (tddfpt_control%dipole_form)
233  CASE (tddfpt_dipole_berry)
234  IF (ndim_periodic /= 3) THEN
235  CALL cp_warn(__location__, &
236  "Fully periodic Poisson solver (PERIODIC xyz) is needed "// &
237  "for oscillator strengths based on the Berry phase formula")
238  END IF
239 
240  NULLIFY (berry_cossin_xyz)
241  ! index: 1 = Re[exp(-i * G_t * t)],
242  ! 2 = Im[exp(-i * G_t * t)];
243  ! t = x,y,z
244  CALL dbcsr_allocate_matrix_set(berry_cossin_xyz, 2)
245 
246  DO i_cos_sin = 1, 2
247  CALL dbcsr_init_p(berry_cossin_xyz(i_cos_sin)%matrix)
248  CALL dbcsr_copy(berry_cossin_xyz(i_cos_sin)%matrix, matrix_s(1)%matrix)
249  END DO
250 
251  ! +++ allocate berry-phase-related work matrices
252  ALLOCATE (gamma_00(nspins), gamma_inv_00(nspins), gamma_real_imag(2, nspins), opvec(2, nspins))
253  ALLOCATE (dberry_mos_occ(nderivs, nspins))
254  DO ispin = 1, nspins
255  NULLIFY (fm_struct)
256  CALL cp_fm_struct_create(fm_struct, nrow_global=nmo_occ(ispin), &
257  ncol_global=nmo_occ(ispin), context=blacs_env)
258 
259  CALL cp_cfm_create(gamma_00(ispin), fm_struct)
260  CALL cp_cfm_create(gamma_inv_00(ispin), fm_struct)
261 
262  DO i_cos_sin = 1, 2
263  CALL cp_fm_create(gamma_real_imag(i_cos_sin, ispin), fm_struct)
264  END DO
265  CALL cp_fm_struct_release(fm_struct)
266 
267  ! G_real C_0, G_imag C_0
268  CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, matrix_struct=fm_struct)
269  DO i_cos_sin = 1, 2
270  CALL cp_fm_create(opvec(i_cos_sin, ispin), fm_struct)
271  END DO
272 
273  ! dBerry * C_0
274  DO ideriv = 1, nderivs
275  CALL cp_fm_create(dberry_mos_occ(ideriv, ispin), fm_struct)
276  CALL cp_fm_set_all(dberry_mos_occ(ideriv, ispin), 0.0_dp)
277  END DO
278  END DO
279 
280  DO ideriv = 1, nderivs
281  kvec(:) = twopi*cell%h_inv(ideriv, :)
282  DO i_cos_sin = 1, 2
283  CALL dbcsr_set(berry_cossin_xyz(i_cos_sin)%matrix, 0.0_dp)
284  END DO
285  CALL build_berry_moment_matrix(qs_env, berry_cossin_xyz(1)%matrix, &
286  berry_cossin_xyz(2)%matrix, kvec)
287 
288  DO ispin = 1, nspins
289  ! i_cos_sin = 1: cos (real) component; opvec(1) = gamma_real C_0
290  ! i_cos_sin = 2: sin (imaginary) component; opvec(2) = gamma_imag C_0
291  DO i_cos_sin = 1, 2
292  CALL cp_dbcsr_sm_fm_multiply(berry_cossin_xyz(i_cos_sin)%matrix, &
293  gs_mos(ispin)%mos_occ, &
294  opvec(i_cos_sin, ispin), &
295  ncol=nmo_occ(ispin), alpha=1.0_dp, beta=0.0_dp)
296  END DO
297 
298  CALL parallel_gemm('T', 'N', nmo_occ(ispin), nmo_occ(ispin), nao, &
299  1.0_dp, gs_mos(ispin)%mos_occ, opvec(1, ispin), &
300  0.0_dp, gamma_real_imag(1, ispin))
301 
302  CALL parallel_gemm('T', 'N', nmo_occ(ispin), nmo_occ(ispin), nao, &
303  -1.0_dp, gs_mos(ispin)%mos_occ, opvec(2, ispin), &
304  0.0_dp, gamma_real_imag(2, ispin))
305 
306  CALL cp_fm_to_cfm(msourcer=gamma_real_imag(1, ispin), &
307  msourcei=gamma_real_imag(2, ispin), &
308  mtarget=gamma_00(ispin))
309 
310  ! gamma_inv_00 = Q = [C_0^T (gamma_real - i gamma_imag) C_0] ^ {-1}
311  CALL cp_cfm_set_all(gamma_inv_00(ispin), z_zero, z_one)
312  CALL cp_cfm_solve(gamma_00(ispin), gamma_inv_00(ispin))
313 
314  CALL cp_cfm_to_fm(msource=gamma_inv_00(ispin), &
315  mtargetr=gamma_real_imag(1, ispin), &
316  mtargeti=gamma_real_imag(2, ispin))
317 
318  ! dBerry_mos_occ is identical to dBerry_psi0 from qs_linres_op % polar_operators()
319  CALL parallel_gemm("N", "N", nao, nmo_occ(ispin), nmo_occ(ispin), &
320  1.0_dp, opvec(1, ispin), gamma_real_imag(2, ispin), &
321  0.0_dp, dipole_op_mos_occ(1, ispin))
322  CALL parallel_gemm("N", "N", nao, nmo_occ(ispin), nmo_occ(ispin), &
323  -1.0_dp, opvec(2, ispin), gamma_real_imag(1, ispin), &
324  1.0_dp, dipole_op_mos_occ(1, ispin))
325 
326  DO jderiv = 1, nderivs
327  CALL cp_fm_scale_and_add(1.0_dp, dberry_mos_occ(jderiv, ispin), &
328  cell%hmat(jderiv, ideriv), dipole_op_mos_occ(1, ispin))
329  END DO
330  END DO
331  END DO
332 
333  ! --- release berry-phase-related work matrices
334  CALL cp_fm_release(opvec)
335  CALL cp_fm_release(gamma_real_imag)
336  DO ispin = nspins, 1, -1
337  CALL cp_cfm_release(gamma_inv_00(ispin))
338  CALL cp_cfm_release(gamma_00(ispin))
339  END DO
340  DEALLOCATE (gamma_00, gamma_inv_00)
341  CALL dbcsr_deallocate_matrix_set(berry_cossin_xyz)
342 
343  NULLIFY (fm_struct)
344  CALL cp_fm_struct_create(fm_struct, nrow_global=nao, ncol_global=nao, context=blacs_env)
345  CALL cp_fm_create(wfm_ao_ao, fm_struct)
346  CALL cp_fm_struct_release(fm_struct)
347 
348  ! trans_dipole = 2|e|/|G_mu| * Tr Imag(evects^T * (gamma_real - i gamma_imag) * C_0 * gamma_inv_00) +
349  ! 2|e|/|G_mu| * Tr Imag(C_0^T * (gamma_real - i gamma_imag) * evects * gamma_inv_00) ,
350  !
351  ! Taking into account the symmetry of the matrices 'gamma_real' and 'gamma_imag' and the fact
352  ! that the response wave-function is a real-valued function, the above expression can be simplified as
353  ! trans_dipole = 4|e|/|G_mu| * Tr Imag(evects^T * (gamma_real - i gamma_imag) * C_0 * gamma_inv_00)
354  !
355  ! 1/|G_mu| = |lattice_vector_mu| / (2*pi) .
356  DO ispin = 1, nspins
357  ! wfm_ao_ao = S * mos_virt * mos_virt^T
358  CALL parallel_gemm('N', 'T', nao, nao, nmo_virt(ispin), &
359  1.0_dp/twopi, s_mos_virt(ispin), gs_mos(ispin)%mos_virt, &
360  0.0_dp, wfm_ao_ao)
361 
362  DO ideriv = 1, nderivs
363  CALL parallel_gemm('N', 'N', nao, nmo_occ(ispin), nao, &
364  1.0_dp, wfm_ao_ao, dberry_mos_occ(ideriv, ispin), &
365  0.0_dp, dipole_op_mos_occ(ideriv, ispin))
366  END DO
367  END DO
368 
369  CALL cp_fm_release(wfm_ao_ao)
370  CALL cp_fm_release(dberry_mos_occ)
371 
372  CASE (tddfpt_dipole_length)
373  IF (ndim_periodic /= 0) THEN
374  CALL cp_warn(__location__, &
375  "Non-periodic Poisson solver (PERIODIC none) is needed "// &
376  "for oscillator strengths based on the length operator")
377  END IF
378 
379  ! compute components of the dipole operator in the length form
380  NULLIFY (rrc_xyz)
381  CALL dbcsr_allocate_matrix_set(rrc_xyz, nderivs)
382 
383  DO ideriv = 1, nderivs
384  CALL dbcsr_init_p(rrc_xyz(ideriv)%matrix)
385  CALL dbcsr_copy(rrc_xyz(ideriv)%matrix, matrix_s(1)%matrix)
386  END DO
387 
388  CALL get_reference_point(reference_point, qs_env=qs_env, &
389  reference=tddfpt_control%dipole_reference, &
390  ref_point=tddfpt_control%dipole_ref_point)
391 
392  CALL rrc_xyz_ao(op=rrc_xyz, qs_env=qs_env, rc=reference_point, order=1, &
393  minimum_image=.false., soft=.false.)
394 
395  NULLIFY (fm_struct)
396  CALL cp_fm_struct_create(fm_struct, nrow_global=nao, ncol_global=nao, context=blacs_env)
397  CALL cp_fm_create(wfm_ao_ao, fm_struct)
398  CALL cp_fm_struct_release(fm_struct)
399 
400  DO ispin = 1, nspins
401  CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, matrix_struct=fm_struct)
402  CALL cp_fm_create(rrc_mos_occ, fm_struct)
403 
404  ! wfm_ao_ao = S * mos_virt * mos_virt^T
405  CALL parallel_gemm('N', 'T', nao, nao, nmo_virt(ispin), &
406  1.0_dp, s_mos_virt(ispin), gs_mos(ispin)%mos_virt, &
407  0.0_dp, wfm_ao_ao)
408 
409  DO ideriv = 1, nderivs
410  CALL cp_dbcsr_sm_fm_multiply(rrc_xyz(ideriv)%matrix, &
411  gs_mos(ispin)%mos_occ, &
412  rrc_mos_occ, &
413  ncol=nmo_occ(ispin), alpha=1.0_dp, beta=0.0_dp)
414 
415  CALL parallel_gemm('N', 'N', nao, nmo_occ(ispin), nao, &
416  1.0_dp, wfm_ao_ao, rrc_mos_occ, &
417  0.0_dp, dipole_op_mos_occ(ideriv, ispin))
418  END DO
419 
420  CALL cp_fm_release(rrc_mos_occ)
421  END DO
422 
423  CALL cp_fm_release(wfm_ao_ao)
424  CALL dbcsr_deallocate_matrix_set(rrc_xyz)
425 
427  ! generate overlap derivatives
428  CALL get_qs_env(qs_env, ks_env=ks_env, sab_orb=sab_orb)
429  NULLIFY (scrm)
430  CALL build_overlap_matrix(ks_env, matrix_s=scrm, nderivative=1, &
431  basis_type_a="ORB", basis_type_b="ORB", &
432  sab_nl=sab_orb)
433 
434  DO ispin = 1, nspins
435  NULLIFY (fm_struct)
436  CALL cp_fm_struct_create(fm_struct, nrow_global=nmo_virt(ispin), &
437  ncol_global=nmo_occ(ispin), context=blacs_env)
438  CALL cp_fm_create(ediff_inv, fm_struct)
439  CALL cp_fm_create(wfm_mo_virt_mo_occ, fm_struct)
440  CALL cp_fm_struct_release(fm_struct)
441 
442  CALL cp_fm_get_info(ediff_inv, nrow_local=nrows_local, ncol_local=ncols_local, &
443  row_indices=row_indices, col_indices=col_indices, local_data=local_data_ediff)
444  CALL cp_fm_get_info(wfm_mo_virt_mo_occ, local_data=local_data_wfm)
445 
446 !$OMP PARALLEL DO DEFAULT(NONE), &
447 !$OMP PRIVATE(eval_occ, icol, irow), &
448 !$OMP SHARED(col_indices, gs_mos, ispin, local_data_ediff, ncols_local, nrows_local, row_indices)
449  DO icol = 1, ncols_local
450  ! E_occ_i ; imo_occ = col_indices(icol)
451  eval_occ = gs_mos(ispin)%evals_occ(col_indices(icol))
452 
453  DO irow = 1, nrows_local
454  ! ediff_inv_weights(a, i) = 1.0 / (E_virt_a - E_occ_i)
455  ! imo_virt = row_indices(irow)
456  local_data_ediff(irow, icol) = 1.0_dp/(gs_mos(ispin)%evals_virt(row_indices(irow)) - eval_occ)
457  END DO
458  END DO
459 !$OMP END PARALLEL DO
460 
461  DO ideriv = 1, nderivs
462  CALL cp_dbcsr_sm_fm_multiply(scrm(ideriv + 1)%matrix, &
463  gs_mos(ispin)%mos_occ, &
464  dipole_op_mos_occ(ideriv, ispin), &
465  ncol=nmo_occ(ispin), alpha=1.0_dp, beta=0.0_dp)
466 
467  CALL parallel_gemm('T', 'N', nmo_virt(ispin), nmo_occ(ispin), nao, &
468  1.0_dp, gs_mos(ispin)%mos_virt, dipole_op_mos_occ(ideriv, ispin), &
469  0.0_dp, wfm_mo_virt_mo_occ)
470 
471  ! in-place element-wise (Schur) product;
472  ! avoid allocation of a temporary [nmo_virt x nmo_occ] matrix which is needed
473  ! for cp_fm_schur_product() subroutine call
474 
475 !$OMP PARALLEL DO DEFAULT(NONE), &
476 !$OMP PRIVATE(icol, irow), &
477 !$OMP SHARED(ispin, local_data_ediff, local_data_wfm, ncols_local, nrows_local)
478  DO icol = 1, ncols_local
479  DO irow = 1, nrows_local
480  local_data_wfm(irow, icol) = local_data_wfm(irow, icol)*local_data_ediff(irow, icol)
481  END DO
482  END DO
483 !$OMP END PARALLEL DO
484 
485  CALL parallel_gemm('N', 'N', nao, nmo_occ(ispin), nmo_virt(ispin), &
486  1.0_dp, s_mos_virt(ispin), wfm_mo_virt_mo_occ, &
487  0.0_dp, dipole_op_mos_occ(ideriv, ispin))
488  END DO
489 
490  CALL cp_fm_release(wfm_mo_virt_mo_occ)
491  CALL cp_fm_release(ediff_inv)
492  END DO
493  CALL dbcsr_deallocate_matrix_set(scrm)
494 
495  CASE DEFAULT
496  cpabort("Unimplemented form of the dipole operator")
497  END SELECT
498 
499  ! --- release work matrices
500  CALL cp_fm_release(s_mos_virt)
501 
502  CALL timestop(handle)
503  END SUBROUTINE tddfpt_dipole_operator
504 
505 ! **************************************************************************************************
506 !> \brief Print final TDDFPT excitation energies and oscillator strengths.
507 !> \param log_unit output unit
508 !> \param evects TDDFPT trial vectors (SIZE(evects,1) -- number of spins;
509 !> SIZE(evects,2) -- number of excited states to print)
510 !> \param evals TDDFPT eigenvalues
511 !> \param ostrength TDDFPT oscillator strength
512 !> \param mult multiplicity
513 !> \param dipole_op_mos_occ action of the dipole operator on the ground state wave function
514 !> [x,y,z ; spin]
515 !> \param dipole_form ...
516 !> \par History
517 !> * 05.2016 created [Sergey Chulkov]
518 !> * 06.2016 transition dipole moments and oscillator strengths [Sergey Chulkov]
519 !> * 07.2016 spin-unpolarised electron density [Sergey Chulkov]
520 !> * 08.2018 compute 'dipole_op_mos_occ' in a separate subroutine [Sergey Chulkov]
521 !> \note \parblock
522 !> Adapted version of the subroutine find_contributions() which was originally created
523 !> by Thomas Chassaing on 02.2005.
524 !>
525 !> Transition dipole moment along direction 'd' is computed as following:
526 !> \f[ t_d(spin) = Tr[evects^T dipole\_op\_mos\_occ(d, spin)] .\f]
527 !> \endparblock
528 ! **************************************************************************************************
529  SUBROUTINE tddfpt_print_summary(log_unit, evects, evals, ostrength, mult, &
530  dipole_op_mos_occ, dipole_form)
531  INTEGER, INTENT(in) :: log_unit
532  TYPE(cp_fm_type), DIMENSION(:, :), INTENT(in) :: evects
533  REAL(kind=dp), DIMENSION(:), INTENT(in) :: evals
534  REAL(kind=dp), DIMENSION(:), INTENT(inout) :: ostrength
535  INTEGER, INTENT(in) :: mult
536  TYPE(cp_fm_type), DIMENSION(:, :), INTENT(in) :: dipole_op_mos_occ
537  INTEGER, INTENT(in) :: dipole_form
538 
539  CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_print_summary'
540 
541  CHARACTER(len=1) :: lsd_str
542  CHARACTER(len=20) :: mult_str
543  INTEGER :: handle, ideriv, ispin, istate, nspins, &
544  nstates
545  REAL(kind=dp) :: osc_strength
546  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: trans_dipoles
547 
548  CALL timeset(routinen, handle)
549 
550  nspins = SIZE(evects, 1)
551  nstates = SIZE(evects, 2)
552 
553  IF (nspins > 1) THEN
554  lsd_str = 'U'
555  ELSE
556  lsd_str = 'R'
557  END IF
558 
559  ! *** summary header ***
560  IF (log_unit > 0) THEN
561  CALL integer_to_string(mult, mult_str)
562  WRITE (log_unit, '(/,1X,A1,A,1X,A)') lsd_str, "-TDDFPT states of multiplicity", trim(mult_str)
563  SELECT CASE (dipole_form)
564  CASE (tddfpt_dipole_berry)
565  WRITE (log_unit, '(1X,A,/)') "Transition dipoles calculated using Berry operator formulation"
566  CASE (tddfpt_dipole_length)
567  WRITE (log_unit, '(1X,A,/)') "Transition dipoles calculated using length formulation"
569  WRITE (log_unit, '(1X,A,/)') "Transition dipoles calculated using velocity formulation"
570  CASE DEFAULT
571  cpabort("Unimplemented form of the dipole operator")
572  END SELECT
573 
574  WRITE (log_unit, '(T10,A,T19,A,T37,A,T69,A)') "State", "Excitation", &
575  "Transition dipole (a.u.)", "Oscillator"
576  WRITE (log_unit, '(T10,A,T19,A,T37,A,T49,A,T61,A,T67,A)') "number", "energy (eV)", &
577  "x", "y", "z", "strength (a.u.)"
578  WRITE (log_unit, '(T10,72("-"))')
579  END IF
580 
581  ! transition dipole moment
582  ALLOCATE (trans_dipoles(nstates, nderivs, nspins))
583  trans_dipoles(:, :, :) = 0.0_dp
584 
585  ! nspins == 1 .AND. mult == 3 : spin-flip transitions are forbidden due to symmetry reasons
586  IF (nspins > 1 .OR. mult == 1) THEN
587  DO ispin = 1, nspins
588  DO ideriv = 1, nderivs
589  CALL cp_fm_trace(evects(ispin, :), dipole_op_mos_occ(ideriv, ispin), &
590  trans_dipoles(:, ideriv, ispin))
591  END DO
592  END DO
593 
594  IF (nspins == 1) THEN
595  trans_dipoles(:, :, 1) = sqrt(2.0_dp)*trans_dipoles(:, :, 1)
596  ELSE
597  trans_dipoles(:, :, 1) = sqrt(trans_dipoles(:, :, 1)**2 + trans_dipoles(:, :, 2)**2)
598  END IF
599  END IF
600 
601  ! *** summary information ***
602  DO istate = 1, nstates
603  osc_strength = 2.0_dp/3.0_dp*evals(istate)* &
604  accurate_dot_product(trans_dipoles(istate, :, 1), trans_dipoles(istate, :, 1))
605  ostrength(istate) = osc_strength
606  IF (log_unit > 0) THEN
607  WRITE (log_unit, '(1X,A,T9,I7,T19,F11.5,T31,3(1X,ES11.4E2),T69,ES12.5E2)') &
608  "TDDFPT|", istate, evals(istate)*evolt, trans_dipoles(istate, 1:nderivs, 1), osc_strength
609  END IF
610  END DO
611 
612  ! punch a checksum for the regs
613  IF (log_unit > 0) THEN
614  WRITE (log_unit, '(/,T2,A,E14.6)') 'TDDFPT : CheckSum =', sqrt(sum(evals**2))
615  END IF
616 
617  DEALLOCATE (trans_dipoles)
618 
619  CALL timestop(handle)
620  END SUBROUTINE tddfpt_print_summary
621 
622 ! **************************************************************************************************
623 !> \brief Print excitation analysis.
624 !> \param log_unit output unit
625 !> \param evects TDDFPT trial vectors (SIZE(evects,1) -- number of spins;
626 !> SIZE(evects,2) -- number of excited states to print)
627 !> \param evals TDDFPT eigenvalues
628 !> \param gs_mos molecular orbitals optimised for the ground state
629 !> \param matrix_s overlap matrix
630 !> \param min_amplitude the smallest excitation amplitude to print
631 !> \par History
632 !> * 05.2016 created as 'tddfpt_print_summary' [Sergey Chulkov]
633 !> * 08.2018 splited of from 'tddfpt_print_summary' [Sergey Chulkov]
634 ! **************************************************************************************************
635  SUBROUTINE tddfpt_print_excitation_analysis(log_unit, evects, evals, gs_mos, matrix_s, min_amplitude)
636  INTEGER, INTENT(in) :: log_unit
637  TYPE(cp_fm_type), DIMENSION(:, :), INTENT(in) :: evects
638  REAL(kind=dp), DIMENSION(:), INTENT(in) :: evals
639  TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
640  INTENT(in) :: gs_mos
641  TYPE(dbcsr_type), POINTER :: matrix_s
642  REAL(kind=dp), INTENT(in) :: min_amplitude
643 
644  CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_print_excitation_analysis'
645 
646  CHARACTER(len=5) :: spin_label
647  INTEGER :: handle, icol, iproc, irow, ispin, &
648  istate, nao, ncols_local, nrows_local, &
649  nspins, nstates, state_spin
650  INTEGER(kind=int_8) :: iexc, imo_occ, imo_virt, ind, nexcs, &
651  nexcs_local, nexcs_max_local, &
652  nmo_virt_occ, nmo_virt_occ_alpha
653  INTEGER(kind=int_8), ALLOCATABLE, DIMENSION(:) :: inds_local, inds_recv, nexcs_recv
654  INTEGER(kind=int_8), DIMENSION(1) :: nexcs_send
655  INTEGER(kind=int_8), DIMENSION(maxspins) :: nmo_occ8, nmo_virt8
656  INTEGER, ALLOCATABLE, DIMENSION(:) :: inds
657  INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
658  INTEGER, DIMENSION(maxspins) :: nmo_occ, nmo_virt
659  LOGICAL :: do_exc_analysis
660  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: weights_local, weights_neg_abs_recv, &
661  weights_recv
662  REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :), &
663  POINTER :: local_data
664  TYPE(cp_blacs_env_type), POINTER :: blacs_env
665  TYPE(cp_fm_struct_type), POINTER :: fm_struct
666  TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: s_mos_virt, weights_fm
667  TYPE(mp_para_env_type), POINTER :: para_env
668  TYPE(mp_request_type) :: send_handler, send_handler2
669  TYPE(mp_request_type), ALLOCATABLE, DIMENSION(:) :: recv_handlers, recv_handlers2
670 
671  CALL timeset(routinen, handle)
672 
673  nspins = SIZE(evects, 1)
674  nstates = SIZE(evects, 2)
675  do_exc_analysis = min_amplitude < 1.0_dp
676 
677  CALL cp_fm_get_info(gs_mos(1)%mos_occ, context=blacs_env, para_env=para_env)
678  CALL dbcsr_get_info(matrix_s, nfullrows_total=nao)
679 
680  DO ispin = 1, nspins
681  nmo_occ(ispin) = SIZE(gs_mos(ispin)%evals_occ)
682  nmo_virt(ispin) = SIZE(gs_mos(ispin)%evals_virt)
683  nmo_occ8(ispin) = SIZE(gs_mos(ispin)%evals_occ, kind=int_8)
684  nmo_virt8(ispin) = SIZE(gs_mos(ispin)%evals_virt, kind=int_8)
685  END DO
686 
687  ! *** excitation analysis ***
688  IF (do_exc_analysis) THEN
689  cpassert(log_unit <= 0 .OR. para_env%is_source())
690  nmo_virt_occ_alpha = int(nmo_virt(1), int_8)*int(nmo_occ(1), int_8)
691 
692  IF (log_unit > 0) THEN
693  WRITE (log_unit, "(1X,A)") "", &
694  "-------------------------------------------------------------------------------", &
695  "- Excitation analysis -", &
696  "-------------------------------------------------------------------------------"
697  WRITE (log_unit, '(8X,A,T27,A,T49,A,T69,A)') "State", "Occupied", "Virtual", "Excitation"
698  WRITE (log_unit, '(8X,A,T28,A,T49,A,T69,A)') "number", "orbital", "orbital", "amplitude"
699  WRITE (log_unit, '(1X,79("-"))')
700 
701  IF (nspins == 1) THEN
702  state_spin = 1
703  spin_label = ' '
704  END IF
705  END IF
706 
707  ALLOCATE (s_mos_virt(nspins), weights_fm(nspins))
708  DO ispin = 1, nspins
709  CALL cp_fm_get_info(gs_mos(ispin)%mos_virt, matrix_struct=fm_struct)
710  CALL cp_fm_create(s_mos_virt(ispin), fm_struct)
711  CALL cp_dbcsr_sm_fm_multiply(matrix_s, &
712  gs_mos(ispin)%mos_virt, &
713  s_mos_virt(ispin), &
714  ncol=nmo_virt(ispin), alpha=1.0_dp, beta=0.0_dp)
715 
716  NULLIFY (fm_struct)
717  CALL cp_fm_struct_create(fm_struct, nrow_global=nmo_virt(ispin), ncol_global=nmo_occ(ispin), &
718  context=blacs_env)
719  CALL cp_fm_create(weights_fm(ispin), fm_struct)
720  CALL cp_fm_struct_release(fm_struct)
721  END DO
722 
723  nexcs_max_local = 0
724  DO ispin = 1, nspins
725  CALL cp_fm_get_info(weights_fm(ispin), nrow_local=nrows_local, ncol_local=ncols_local)
726  nexcs_max_local = nexcs_max_local + int(nrows_local, int_8)*int(ncols_local, int_8)
727  END DO
728 
729  ALLOCATE (weights_local(nexcs_max_local), inds_local(nexcs_max_local))
730 
731  DO istate = 1, nstates
732  nexcs_local = 0
733  nmo_virt_occ = 0
734 
735  ! analyse matrix elements locally and transfer only significant
736  ! excitations to the master node for subsequent ordering
737  DO ispin = 1, nspins
738  ! compute excitation amplitudes
739  CALL parallel_gemm('T', 'N', nmo_virt(ispin), nmo_occ(ispin), nao, 1.0_dp, s_mos_virt(ispin), &
740  evects(ispin, istate), 0.0_dp, weights_fm(ispin))
741 
742  CALL cp_fm_get_info(weights_fm(ispin), nrow_local=nrows_local, ncol_local=ncols_local, &
743  row_indices=row_indices, col_indices=col_indices, local_data=local_data)
744 
745  ! locate single excitations with significant amplitudes (>= min_amplitude)
746  DO icol = 1, ncols_local
747  DO irow = 1, nrows_local
748  IF (abs(local_data(irow, icol)) >= min_amplitude) THEN
749  ! number of non-negligible excitations
750  nexcs_local = nexcs_local + 1
751  ! excitation amplitude
752  weights_local(nexcs_local) = local_data(irow, icol)
753  ! index of single excitation (ivirt, iocc, ispin) in compressed form
754  inds_local(nexcs_local) = nmo_virt_occ + int(row_indices(irow), int_8) + &
755  int(col_indices(icol) - 1, int_8)*nmo_virt8(ispin)
756  END IF
757  END DO
758  END DO
759 
760  nmo_virt_occ = nmo_virt_occ + nmo_virt8(ispin)*nmo_occ8(ispin)
761  END DO
762 
763  IF (para_env%is_source()) THEN
764  ! master node
765  ALLOCATE (nexcs_recv(para_env%num_pe), recv_handlers(para_env%num_pe), recv_handlers2(para_env%num_pe))
766 
767  ! collect number of non-negligible excitations from other nodes
768  DO iproc = 1, para_env%num_pe
769  IF (iproc - 1 /= para_env%mepos) THEN
770  CALL para_env%irecv(nexcs_recv(iproc:iproc), iproc - 1, recv_handlers(iproc), 0)
771  ELSE
772  nexcs_recv(iproc) = nexcs_local
773  END IF
774  END DO
775 
776  DO iproc = 1, para_env%num_pe
777  IF (iproc - 1 /= para_env%mepos) &
778  CALL recv_handlers(iproc)%wait()
779  END DO
780 
781  ! compute total number of non-negligible excitations
782  nexcs = 0
783  DO iproc = 1, para_env%num_pe
784  nexcs = nexcs + nexcs_recv(iproc)
785  END DO
786 
787  ! receive indices and amplitudes of selected excitations
788  ALLOCATE (weights_recv(nexcs), weights_neg_abs_recv(nexcs))
789  ALLOCATE (inds_recv(nexcs), inds(nexcs))
790 
791  nmo_virt_occ = 0
792  DO iproc = 1, para_env%num_pe
793  IF (nexcs_recv(iproc) > 0) THEN
794  IF (iproc - 1 /= para_env%mepos) THEN
795  ! excitation amplitudes
796  CALL para_env%irecv(weights_recv(nmo_virt_occ + 1:nmo_virt_occ + nexcs_recv(iproc)), &
797  iproc - 1, recv_handlers(iproc), 1)
798  ! compressed indices
799  CALL para_env%irecv(inds_recv(nmo_virt_occ + 1:nmo_virt_occ + nexcs_recv(iproc)), &
800  iproc - 1, recv_handlers2(iproc), 2)
801  ELSE
802  ! data on master node
803  weights_recv(nmo_virt_occ + 1:nmo_virt_occ + nexcs_recv(iproc)) = weights_local(1:nexcs_recv(iproc))
804  inds_recv(nmo_virt_occ + 1:nmo_virt_occ + nexcs_recv(iproc)) = inds_local(1:nexcs_recv(iproc))
805  END IF
806 
807  nmo_virt_occ = nmo_virt_occ + nexcs_recv(iproc)
808  END IF
809  END DO
810 
811  DO iproc = 1, para_env%num_pe
812  IF (iproc - 1 /= para_env%mepos .AND. nexcs_recv(iproc) > 0) THEN
813  CALL recv_handlers(iproc)%wait()
814  CALL recv_handlers2(iproc)%wait()
815  END IF
816  END DO
817 
818  DEALLOCATE (nexcs_recv, recv_handlers, recv_handlers2)
819  ELSE
820  ! working node: send the number of selected excited states to the master node
821  nexcs_send(1) = nexcs_local
822  CALL para_env%isend(nexcs_send, para_env%source, send_handler, 0)
823  CALL send_handler%wait()
824 
825  IF (nexcs_local > 0) THEN
826  ! send excitation amplitudes
827  CALL para_env%isend(weights_local(1:nexcs_local), para_env%source, send_handler, 1)
828  ! send compressed indices
829  CALL para_env%isend(inds_local(1:nexcs_local), para_env%source, send_handler2, 2)
830 
831  CALL send_handler%wait()
832  CALL send_handler2%wait()
833  END IF
834  END IF
835 
836  ! sort non-negligible excitations on the master node according to their amplitudes,
837  ! uncompress indices and print summary information
838  IF (para_env%is_source() .AND. log_unit > 0) THEN
839  weights_neg_abs_recv(:) = -abs(weights_recv)
840  CALL sort(weights_neg_abs_recv, int(nexcs), inds)
841 
842  WRITE (log_unit, '(T7,I8,F10.5,A)') istate, evals(istate)*evolt, " eV"
843 
844  DO iexc = 1, nexcs
845  ind = inds_recv(inds(iexc)) - 1
846  IF (nspins > 1) THEN
847  IF (ind < nmo_virt_occ_alpha) THEN
848  state_spin = 1
849  spin_label = '(alp)'
850  ELSE
851  state_spin = 2
852  ind = ind - nmo_virt_occ_alpha
853  spin_label = '(bet)'
854  END IF
855  END IF
856 
857  imo_occ = ind/nmo_virt8(state_spin) + 1
858  imo_virt = mod(ind, nmo_virt8(state_spin)) + 1
859 
860  WRITE (log_unit, '(T27,I8,1X,A5,T48,I8,1X,A5,T70,F9.6)') imo_occ, spin_label, &
861  nmo_occ8(state_spin) + imo_virt, spin_label, weights_recv(inds(iexc))
862  END DO
863  END IF
864 
865  ! deallocate temporary arrays
866  IF (para_env%is_source()) &
867  DEALLOCATE (weights_recv, weights_neg_abs_recv, inds_recv, inds)
868  END DO
869 
870  DEALLOCATE (weights_local, inds_local)
871  IF (log_unit > 0) THEN
872  WRITE (log_unit, "(1X,A)") &
873  "-------------------------------------------------------------------------------"
874  END IF
875  END IF
876 
877  CALL cp_fm_release(weights_fm)
878  CALL cp_fm_release(s_mos_virt)
879 
880  CALL timestop(handle)
881 
882  END SUBROUTINE tddfpt_print_excitation_analysis
883 
884 ! **************************************************************************************************
885 !> \brief Print natural transition orbital analysis.
886 !> \param qs_env Information on Kinds and Particles
887 !> \param evects TDDFPT trial vectors (SIZE(evects,1) -- number of spins;
888 !> SIZE(evects,2) -- number of excited states to print)
889 !> \param evals TDDFPT eigenvalues
890 !> \param ostrength ...
891 !> \param gs_mos molecular orbitals optimised for the ground state
892 !> \param matrix_s overlap matrix
893 !> \param print_section ...
894 !> \par History
895 !> * 06.2019 created [JGH]
896 ! **************************************************************************************************
897  SUBROUTINE tddfpt_print_nto_analysis(qs_env, evects, evals, ostrength, gs_mos, matrix_s, print_section)
898  TYPE(qs_environment_type), POINTER :: qs_env
899  TYPE(cp_fm_type), DIMENSION(:, :), INTENT(in) :: evects
900  REAL(kind=dp), DIMENSION(:), INTENT(in) :: evals, ostrength
901  TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
902  INTENT(in) :: gs_mos
903  TYPE(dbcsr_type), POINTER :: matrix_s
904  TYPE(section_vals_type), POINTER :: print_section
905 
906  CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_print_nto_analysis'
907  INTEGER, PARAMETER :: ntomax = 10
908 
909  CHARACTER(LEN=20), DIMENSION(2) :: nto_name
910  INTEGER :: handle, i, ia, icg, iounit, ispin, &
911  istate, j, nao, nlist, nmax, nmo, &
912  nnto, nspins, nstates
913  INTEGER, DIMENSION(2) :: iv
914  INTEGER, DIMENSION(2, ntomax) :: ia_index
915  INTEGER, DIMENSION(:), POINTER :: slist, stride
916  LOGICAL :: append_cube, cube_file, explicit
917  REAL(kind=dp) :: os_threshold, sume, threshold
918  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eigvals
919  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: eigenvalues
920  REAL(kind=dp), DIMENSION(ntomax) :: ia_eval
921  TYPE(cp_fm_struct_type), POINTER :: fm_mo_struct, fm_struct
922  TYPE(cp_fm_type) :: sev, smat, tmat, wmat, work, wvec
923  TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: teig
924  TYPE(cp_logger_type), POINTER :: logger
925  TYPE(mo_set_type), ALLOCATABLE, DIMENSION(:) :: nto_set
926  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
927  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
928  TYPE(section_vals_type), POINTER :: molden_section, nto_section
929 
930  CALL timeset(routinen, handle)
931 
932  logger => cp_get_default_logger()
933  iounit = cp_logger_get_default_io_unit(logger)
934 
935  IF (btest(cp_print_key_should_output(logger%iter_info, print_section, &
936  "NTO_ANALYSIS"), cp_p_file)) THEN
937 
938  CALL cite_reference(martin2003)
939 
940  CALL section_vals_val_get(print_section, "NTO_ANALYSIS%THRESHOLD", r_val=threshold)
941  CALL section_vals_val_get(print_section, "NTO_ANALYSIS%INTENSITY_THRESHOLD", r_val=os_threshold)
942  CALL section_vals_val_get(print_section, "NTO_ANALYSIS%STATE_LIST", explicit=explicit)
943 
944  IF (explicit) THEN
945  CALL section_vals_val_get(print_section, "NTO_ANALYSIS%STATE_LIST", i_vals=slist)
946  nlist = SIZE(slist)
947  ELSE
948  nlist = 0
949  END IF
950 
951  IF (iounit > 0) THEN
952  WRITE (iounit, "(1X,A)") "", &
953  "-------------------------------------------------------------------------------", &
954  "- Natural Orbital analysis -", &
955  "-------------------------------------------------------------------------------"
956  END IF
957 
958  nspins = SIZE(evects, 1)
959  nstates = SIZE(evects, 2)
960  CALL dbcsr_get_info(matrix_s, nfullrows_total=nao)
961 
962  DO istate = 1, nstates
963  IF (os_threshold > ostrength(istate)) THEN
964  IF (iounit > 0) THEN
965  WRITE (iounit, "(1X,A,I6)") " Skipping state ", istate
966  END IF
967  cycle
968  END IF
969  IF (nlist > 0) THEN
970  IF (.NOT. any(slist == istate)) THEN
971  IF (iounit > 0) THEN
972  WRITE (iounit, "(1X,A,I6)") " Skipping state ", istate
973  END IF
974  cycle
975  END IF
976  END IF
977  IF (iounit > 0) THEN
978  WRITE (iounit, "(1X,A,I6,T30,F10.5,A)") " STATE NR. ", istate, evals(istate)*evolt, " eV"
979  END IF
980  nmax = 0
981  DO ispin = 1, nspins
982  CALL cp_fm_get_info(evects(ispin, istate), matrix_struct=fm_struct, ncol_global=nmo)
983  nmax = max(nmax, nmo)
984  END DO
985  ALLOCATE (eigenvalues(nmax, nspins))
986  eigenvalues = 0.0_dp
987  ! SET 1: Hole states
988  ! SET 2: Particle states
989  nto_name(1) = 'Hole_states'
990  nto_name(2) = 'Particle_states'
991  ALLOCATE (nto_set(2))
992  DO i = 1, 2
993  CALL allocate_mo_set(nto_set(i), nao, ntomax, 0, 0.0_dp, 1.0_dp, 0.0_dp)
994  CALL cp_fm_get_info(evects(1, istate), matrix_struct=fm_struct)
995  CALL cp_fm_struct_create(fmstruct=fm_mo_struct, template_fmstruct=fm_struct, &
996  ncol_global=ntomax)
997  CALL cp_fm_create(tmat, fm_mo_struct)
998  CALL init_mo_set(nto_set(i), fm_ref=tmat, name=nto_name(i))
999  CALL cp_fm_release(tmat)
1000  CALL cp_fm_struct_release(fm_mo_struct)
1001  END DO
1002  !
1003  ALLOCATE (teig(nspins))
1004  ! hole states
1005  ! Diagonalize X(T)*S*X
1006  DO ispin = 1, nspins
1007  associate(ev => evects(ispin, istate))
1008  CALL cp_fm_get_info(ev, matrix_struct=fm_struct, ncol_global=nmo)
1009  CALL cp_fm_create(sev, fm_struct)
1010  CALL cp_fm_struct_create(fmstruct=fm_mo_struct, template_fmstruct=fm_struct, &
1011  nrow_global=nmo, ncol_global=nmo)
1012  CALL cp_fm_create(tmat, fm_mo_struct)
1013  CALL cp_fm_create(teig(ispin), fm_mo_struct)
1014  CALL cp_dbcsr_sm_fm_multiply(matrix_s, ev, sev, ncol=nmo, alpha=1.0_dp, beta=0.0_dp)
1015  CALL parallel_gemm('T', 'N', nmo, nmo, nao, 1.0_dp, ev, sev, 0.0_dp, tmat)
1016  END associate
1017 
1018  CALL choose_eigv_solver(tmat, teig(ispin), eigenvalues(1:nmo, ispin))
1019 
1020  CALL cp_fm_struct_release(fm_mo_struct)
1021  CALL cp_fm_release(tmat)
1022  CALL cp_fm_release(sev)
1023  END DO
1024  ! find major determinants i->a
1025  ia_index = 0
1026  sume = 0.0_dp
1027  nnto = 0
1028  DO i = 1, ntomax
1029  iv = maxloc(eigenvalues)
1030  ia_eval(i) = eigenvalues(iv(1), iv(2))
1031  ia_index(1:2, i) = iv(1:2)
1032  sume = sume + ia_eval(i)
1033  eigenvalues(iv(1), iv(2)) = 0.0_dp
1034  nnto = nnto + 1
1035  IF (sume > threshold) EXIT
1036  END DO
1037  ! store hole states
1038  CALL set_mo_set(nto_set(1), nmo=nnto)
1039  DO i = 1, nnto
1040  ia = ia_index(1, i)
1041  ispin = ia_index(2, i)
1042  CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, ncol_global=nmo)
1043  CALL cp_fm_get_info(teig(ispin), matrix_struct=fm_struct)
1044  CALL cp_fm_struct_create(fmstruct=fm_mo_struct, template_fmstruct=fm_struct, &
1045  nrow_global=nmo, ncol_global=1)
1046  CALL cp_fm_create(tmat, fm_mo_struct)
1047  CALL cp_fm_struct_release(fm_mo_struct)
1048  CALL cp_fm_get_info(gs_mos(1)%mos_occ, matrix_struct=fm_struct)
1049  CALL cp_fm_struct_create(fmstruct=fm_mo_struct, template_fmstruct=fm_struct, &
1050  ncol_global=1)
1051  CALL cp_fm_create(wvec, fm_mo_struct)
1052  CALL cp_fm_struct_release(fm_mo_struct)
1053  CALL cp_fm_to_fm(teig(ispin), tmat, 1, ia, 1)
1054  CALL parallel_gemm('N', 'N', nao, 1, nmo, 1.0_dp, gs_mos(ispin)%mos_occ, &
1055  tmat, 0.0_dp, wvec)
1056  CALL cp_fm_to_fm(wvec, nto_set(1)%mo_coeff, 1, 1, i)
1057  CALL cp_fm_release(wvec)
1058  CALL cp_fm_release(tmat)
1059  END DO
1060  ! particle states
1061  ! Solve generalized eigenvalue equation: (S*X)*(S*X)(T)*v = lambda*S*v
1062  CALL set_mo_set(nto_set(2), nmo=nnto)
1063  DO ispin = 1, nspins
1064  associate(ev => evects(ispin, istate))
1065  CALL cp_fm_get_info(ev, matrix_struct=fm_struct, nrow_global=nao, ncol_global=nmo)
1066  ALLOCATE (eigvals(nao))
1067  eigvals = 0.0_dp
1068  CALL cp_fm_create(sev, fm_struct)
1069  CALL cp_dbcsr_sm_fm_multiply(matrix_s, ev, sev, ncol=nmo, alpha=1.0_dp, beta=0.0_dp)
1070  END associate
1071  CALL cp_fm_struct_create(fmstruct=fm_mo_struct, template_fmstruct=fm_struct, &
1072  nrow_global=nao, ncol_global=nao)
1073  CALL cp_fm_create(tmat, fm_mo_struct)
1074  CALL cp_fm_create(smat, fm_mo_struct)
1075  CALL cp_fm_create(wmat, fm_mo_struct)
1076  CALL cp_fm_create(work, fm_mo_struct)
1077  CALL cp_fm_struct_release(fm_mo_struct)
1078  CALL copy_dbcsr_to_fm(matrix_s, smat)
1079  CALL parallel_gemm('N', 'T', nao, nao, nmo, 1.0_dp, sev, sev, 0.0_dp, tmat)
1080  CALL cp_fm_geeig(tmat, smat, wmat, eigvals, work)
1081  DO i = 1, nnto
1082  IF (ispin == ia_index(2, i)) THEN
1083  icg = 0
1084  DO j = 1, nao
1085  IF (abs(eigvals(j) - ia_eval(i)) < 1.e-6_dp) THEN
1086  icg = j
1087  EXIT
1088  END IF
1089  END DO
1090  IF (icg == 0) THEN
1091  CALL cp_warn(__location__, &
1092  "Could not locate particle state associated with hole state.")
1093  ELSE
1094  CALL cp_fm_to_fm(wmat, nto_set(2)%mo_coeff, 1, icg, i)
1095  END IF
1096  END IF
1097  END DO
1098  DEALLOCATE (eigvals)
1099  CALL cp_fm_release(sev)
1100  CALL cp_fm_release(tmat)
1101  CALL cp_fm_release(smat)
1102  CALL cp_fm_release(wmat)
1103  CALL cp_fm_release(work)
1104  END DO
1105  ! print
1106  IF (iounit > 0) THEN
1107  sume = 0.0_dp
1108  DO i = 1, nnto
1109  sume = sume + ia_eval(i)
1110  WRITE (iounit, "(T6,A,i2,T30,A,i1,T42,A,F8.5,T63,A,F8.5)") &
1111  "Particle-Hole state:", i, " Spin:", ia_index(2, i), &
1112  "Eigenvalue:", ia_eval(i), " Sum Eigv:", sume
1113  END DO
1114  END IF
1115  ! Cube and Molden files
1116  nto_section => section_vals_get_subs_vals(print_section, "NTO_ANALYSIS")
1117  CALL section_vals_val_get(nto_section, "CUBE_FILES", l_val=cube_file)
1118  CALL section_vals_val_get(nto_section, "STRIDE", i_vals=stride)
1119  CALL section_vals_val_get(nto_section, "APPEND", l_val=append_cube)
1120  IF (cube_file) THEN
1121  CALL print_nto_cubes(qs_env, nto_set, istate, stride, append_cube, nto_section)
1122  END IF
1123  CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, particle_set=particle_set)
1124  molden_section => section_vals_get_subs_vals(print_section, "MOS_MOLDEN")
1125  CALL write_mos_molden(nto_set, qs_kind_set, particle_set, molden_section)
1126  !
1127  DEALLOCATE (eigenvalues)
1128  CALL cp_fm_release(teig)
1129  !
1130  DO i = 1, 2
1131  CALL deallocate_mo_set(nto_set(i))
1132  END DO
1133  DEALLOCATE (nto_set)
1134  END DO
1135 
1136  IF (iounit > 0) THEN
1137  WRITE (iounit, "(1X,A)") &
1138  "-------------------------------------------------------------------------------"
1139  END IF
1140 
1141  END IF
1142 
1143  CALL timestop(handle)
1144 
1145  END SUBROUTINE tddfpt_print_nto_analysis
1146 
1147 ! **************************************************************************************************
1148 !> \brief ...
1149 !> \param vin ...
1150 !> \param vout ...
1151 !> \param mos_occ ...
1152 !> \param matrix_s ...
1153 ! **************************************************************************************************
1154  SUBROUTINE project_vector(vin, vout, mos_occ, matrix_s)
1155  TYPE(dbcsr_type) :: vin, vout
1156  TYPE(cp_fm_type), INTENT(IN) :: mos_occ
1157  TYPE(dbcsr_type), POINTER :: matrix_s
1158 
1159  CHARACTER(LEN=*), PARAMETER :: routinen = 'project_vector'
1160 
1161  INTEGER :: handle, nao, nmo
1162  REAL(kind=dp) :: norm(1)
1163  TYPE(cp_fm_struct_type), POINTER :: fm_struct, fm_vec_struct
1164  TYPE(cp_fm_type) :: csvec, svec, vec
1165 
1166  CALL timeset(routinen, handle)
1167 
1168  CALL cp_fm_get_info(mos_occ, matrix_struct=fm_struct, nrow_global=nao, ncol_global=nmo)
1169  CALL cp_fm_struct_create(fmstruct=fm_vec_struct, template_fmstruct=fm_struct, &
1170  nrow_global=nao, ncol_global=1)
1171  CALL cp_fm_create(vec, fm_vec_struct)
1172  CALL cp_fm_create(svec, fm_vec_struct)
1173  CALL cp_fm_struct_release(fm_vec_struct)
1174  CALL cp_fm_struct_create(fmstruct=fm_vec_struct, template_fmstruct=fm_struct, &
1175  nrow_global=nmo, ncol_global=1)
1176  CALL cp_fm_create(csvec, fm_vec_struct)
1177  CALL cp_fm_struct_release(fm_vec_struct)
1178 
1179  CALL copy_dbcsr_to_fm(vin, vec)
1180  CALL cp_dbcsr_sm_fm_multiply(matrix_s, vec, svec, ncol=1, alpha=1.0_dp, beta=0.0_dp)
1181  CALL parallel_gemm('T', 'N', nmo, 1, nao, 1.0_dp, mos_occ, svec, 0.0_dp, csvec)
1182  CALL parallel_gemm('N', 'N', nao, 1, nmo, -1.0_dp, mos_occ, csvec, 1.0_dp, vec)
1183  CALL cp_fm_vectorsnorm(vec, norm)
1184  cpassert(norm(1) > 1.e-14_dp)
1185  norm(1) = sqrt(1._dp/norm(1))
1186  CALL cp_fm_scale(norm(1), vec)
1187  CALL copy_fm_to_dbcsr(vec, vout, keep_sparsity=.false.)
1188 
1189  CALL cp_fm_release(csvec)
1190  CALL cp_fm_release(svec)
1191  CALL cp_fm_release(vec)
1192 
1193  CALL timestop(handle)
1194 
1195  END SUBROUTINE project_vector
1196 
1197 ! **************************************************************************************************
1198 !> \brief ...
1199 !> \param va ...
1200 !> \param vb ...
1201 !> \param res ...
1202 ! **************************************************************************************************
1203  SUBROUTINE vec_product(va, vb, res)
1204  TYPE(dbcsr_type) :: va, vb
1205  REAL(kind=dp), INTENT(OUT) :: res
1206 
1207  CHARACTER(LEN=*), PARAMETER :: routinen = 'vec_product'
1208 
1209  INTEGER :: blk, group_handle, handle, icol, irow
1210  LOGICAL :: found
1211  REAL(kind=dp), DIMENSION(:, :), POINTER :: vba, vbb
1212  TYPE(dbcsr_iterator_type) :: iter
1213  TYPE(mp_comm_type) :: group
1214 
1215  CALL timeset(routinen, handle)
1216 
1217  res = 0.0_dp
1218 
1219  CALL dbcsr_get_info(va, group=group_handle)
1220  CALL group%set_handle(group_handle)
1221  CALL dbcsr_iterator_start(iter, va)
1222  DO WHILE (dbcsr_iterator_blocks_left(iter))
1223  CALL dbcsr_iterator_next_block(iter, irow, icol, vba, blk)
1224  CALL dbcsr_get_block_p(vb, row=irow, col=icol, block=vbb, found=found)
1225  res = res + sum(vba*vbb)
1226  cpassert(found)
1227  END DO
1228  CALL dbcsr_iterator_stop(iter)
1229  CALL group%sum(res)
1230 
1231  CALL timestop(handle)
1232 
1233  END SUBROUTINE vec_product
1234 
1235 ! **************************************************************************************************
1236 !> \brief ...
1237 !> \param qs_env ...
1238 !> \param mos ...
1239 !> \param istate ...
1240 !> \param stride ...
1241 !> \param append_cube ...
1242 !> \param print_section ...
1243 ! **************************************************************************************************
1244  SUBROUTINE print_nto_cubes(qs_env, mos, istate, stride, append_cube, print_section)
1245 
1246  TYPE(qs_environment_type), POINTER :: qs_env
1247  TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mos
1248  INTEGER, INTENT(IN) :: istate
1249  INTEGER, DIMENSION(:), POINTER :: stride
1250  LOGICAL, INTENT(IN) :: append_cube
1251  TYPE(section_vals_type), POINTER :: print_section
1252 
1253  CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1254  INTEGER :: i, iset, nmo, unit_nr
1255  LOGICAL :: mpi_io
1256  TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1257  TYPE(cell_type), POINTER :: cell
1258  TYPE(cp_fm_type), POINTER :: mo_coeff
1259  TYPE(cp_logger_type), POINTER :: logger
1260  TYPE(dft_control_type), POINTER :: dft_control
1261  TYPE(particle_list_type), POINTER :: particles
1262  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1263  TYPE(pw_c1d_gs_type) :: wf_g
1264  TYPE(pw_env_type), POINTER :: pw_env
1265  TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1266  TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1267  TYPE(pw_r3d_rs_type) :: wf_r
1268  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1269  TYPE(qs_subsys_type), POINTER :: subsys
1270 
1271  logger => cp_get_default_logger()
1272 
1273  CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, pw_env=pw_env)
1274  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1275  CALL auxbas_pw_pool%create_pw(wf_r)
1276  CALL auxbas_pw_pool%create_pw(wf_g)
1277 
1278  CALL get_qs_env(qs_env, subsys=subsys)
1279  CALL qs_subsys_get(subsys, particles=particles)
1280 
1281  my_pos_cube = "REWIND"
1282  IF (append_cube) THEN
1283  my_pos_cube = "APPEND"
1284  END IF
1285 
1286  CALL get_qs_env(qs_env=qs_env, &
1287  atomic_kind_set=atomic_kind_set, &
1288  qs_kind_set=qs_kind_set, &
1289  cell=cell, &
1290  particle_set=particle_set)
1291 
1292  DO iset = 1, 2
1293  CALL get_mo_set(mo_set=mos(iset), mo_coeff=mo_coeff, nmo=nmo)
1294  DO i = 1, nmo
1295  CALL calculate_wavefunction(mo_coeff, i, wf_r, wf_g, atomic_kind_set, qs_kind_set, &
1296  cell, dft_control, particle_set, pw_env)
1297  IF (iset == 1) THEN
1298  WRITE (filename, '(a4,I3.3,I2.2,a11)') "NTO_STATE", istate, i, "_Hole_State"
1299  ELSEIF (iset == 2) THEN
1300  WRITE (filename, '(a4,I3.3,I2.2,a15)') "NTO_STATE", istate, i, "_Particle_State"
1301  END IF
1302  mpi_io = .true.
1303  unit_nr = cp_print_key_unit_nr(logger, print_section, '', extension=".cube", &
1304  middle_name=trim(filename), file_position=my_pos_cube, &
1305  log_filename=.false., ignore_should_output=.true., mpi_io=mpi_io)
1306  IF (iset == 1) THEN
1307  WRITE (title, *) "Natural Transition Orbital Hole State", i
1308  ELSEIF (iset == 2) THEN
1309  WRITE (title, *) "Natural Transition Orbital Particle State", i
1310  END IF
1311  CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, stride=stride, mpi_io=mpi_io)
1312  CALL cp_print_key_finished_output(unit_nr, logger, print_section, '', &
1313  ignore_should_output=.true., mpi_io=mpi_io)
1314  END DO
1315  END DO
1316 
1317  CALL auxbas_pw_pool%give_back_pw(wf_g)
1318  CALL auxbas_pw_pool%give_back_pw(wf_r)
1319 
1320  END SUBROUTINE print_nto_cubes
1321 
1322 END MODULE qs_tddfpt2_properties
Define the atomic kind types and their sub types.
collects all references to literature in CP2K as new algorithms / method are included from literature...
Definition: bibliography.F:28
integer, save, public martin2003
Definition: bibliography.F:43
Handles all functions related to the CELL.
Definition: cell_types.F:15
methods related to the blacs parallel environment
Definition: cp_blacs_env.F:15
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_solve(matrix_a, general_a, determinant)
Solve the system of linear equations A*b=A_general using LU decomposition. Pay attention that both ma...
Represents a complex full matrix distributed on many processors.
Definition: cp_cfm_types.F:12
subroutine, public cp_cfm_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
Definition: cp_cfm_types.F:121
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
Definition: cp_cfm_types.F:159
subroutine, public cp_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
Definition: cp_cfm_types.F:817
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
Definition: cp_cfm_types.F:179
subroutine, public cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
Definition: cp_cfm_types.F:765
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
basic linear algebra operations for full matrices
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
subroutine, public cp_fm_scale(alpha, matrix_a)
scales a matrix matrix_a = alpha * matrix_b
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
Definition: cp_fm_diag.F:17
subroutine, public cp_fm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
Definition: cp_fm_diag.F:1274
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
Definition: cp_fm_diag.F:208
represent the structure of a full matrix
Definition: cp_fm_struct.F:14
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
Definition: cp_fm_struct.F:125
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
Definition: cp_fm_struct.F:320
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
Definition: cp_fm_types.F:1016
subroutine, public cp_fm_vectorsnorm(matrix, norm_array)
find the inorm of each column norm_{j}= sqrt( \sum_{i} A_{ij}*A_{ij} )
Definition: cp_fm_types.F:1207
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
Definition: cp_fm_types.F:535
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Definition: cp_fm_types.F:167
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,...
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...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, stride, zero_tails, silent, mpi_io)
...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public tddfpt_dipole_berry
integer, parameter, public tddfpt_dipole_velocity
integer, parameter, public tddfpt_dipole_length
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
sums arrays of real/complex numbers with much reduced round-off as compared to a naive implementation...
Definition: kahan_sum.F:29
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public int_8
Definition: kinds.F:54
integer, parameter, public dp
Definition: kinds.F:34
integer, parameter, public default_path_length
Definition: kinds.F:58
Definition of mathematical constants and functions.
Definition: mathconstants.F:16
complex(kind=dp), parameter, public z_one
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
Functions handling the MOLDEN format. Split from mode_selective.
Definition: molden_utils.F:12
subroutine, public write_mos_molden(mos, qs_kind_set, particle_set, print_section)
Write out the MOs in molden format for visualisation.
Definition: molden_utils.F:65
Calculates the moment integrals <a|r^m|b>
Definition: moments_utils.F:15
subroutine, public get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, ifirst, ilast)
...
Definition: moments_utils.F:61
basic linear algebra operations for full matrixes
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 evolt
Definition: physcon.F:183
container for various plainwaves related things
Definition: pw_env_types.F:14
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
Definition: pw_env_types.F:113
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Definition: pw_pool_types.F:24
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, external_vector)
maps a given wavefunction on the grid
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, 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_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Definition: qs_kind_types.F:23
Definition and initialisation of the mo data type.
Definition: qs_mo_types.F:22
subroutine, public set_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, uniform_occupation, kTS, mu, flexible_electron_count)
Set the components of a MO set data structure.
Definition: qs_mo_types.F:452
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...
Definition: qs_mo_types.F:206
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
Definition: qs_mo_types.F:352
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kTS, mu, flexible_electron_count)
Get the components of a MO set data structure.
Definition: qs_mo_types.F:397
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
Definition: qs_mo_types.F:245
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>
Definition: qs_moments.F:14
subroutine, public build_berry_moment_matrix(qs_env, cosmat, sinmat, kvec, sab_orb_external, basis_type)
...
Definition: qs_moments.F:1336
Define the neighbor list data types and the corresponding functionality.
subroutine, public rrc_xyz_ao(op, qs_env, rc, order, minimum_image, soft)
Calculation of the components of the dipole operator in the length form by taking the relative positi...
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)
Calculation of the overlap matrix over Cartesian Gaussian functions.
Definition: qs_overlap.F:120
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)
...
subroutine, public tddfpt_print_excitation_analysis(log_unit, evects, evals, gs_mos, matrix_s, min_amplitude)
Print excitation analysis.
subroutine, public tddfpt_dipole_operator(dipole_op_mos_occ, tddfpt_control, gs_mos, qs_env)
Compute the action of the dipole operator on the ground state wave function.
subroutine, public tddfpt_print_nto_analysis(qs_env, evects, evals, ostrength, gs_mos, matrix_s, print_section)
Print natural transition orbital analysis.
subroutine, public tddfpt_print_summary(log_unit, evects, evals, ostrength, mult, dipole_op_mos_occ, dipole_form)
Print final TDDFPT excitation energies and oscillator strengths.
Utilities for string manipulations.
subroutine, public integer_to_string(inumber, string)
Converts an integer number to a string. The WRITE statement will return an error message,...
All kind of helpful little routines.
Definition: util.F:14