(git:ed6f26b)
Loading...
Searching...
No Matches
rt_propagation_methods.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Routines for propagating the orbitals
10!> \author Florian Schiffmann (02.09)
11! **************************************************************************************************
13 USE bibliography, ONLY: kolafa2004,&
14 kuhne2007,&
15 cite_reference
16 USE cell_types, ONLY: cell_type
19 USE cp_cfm_types, ONLY: cp_cfm_create,&
24 USE cp_dbcsr_api, ONLY: &
29 dbcsr_type, dbcsr_type_antisymmetric
41 USE cp_fm_types, ONLY: cp_fm_create,&
51 USE input_constants, ONLY: do_arnoldi,&
52 do_bch,&
53 do_em,&
54 do_pade,&
57 USE kinds, ONLY: dp
59 USE mathlib, ONLY: binomial
66 USE qs_ks_types, ONLY: set_ks_env
74 USE rt_propagation_types, ONLY: get_rtp,&
81#include "../base/base_uses.f90"
82
83 IMPLICIT NONE
84
85 PRIVATE
86
87 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'rt_propagation_methods'
88
89 PUBLIC :: propagation_step, &
91 calc_sinvh, &
93
94CONTAINS
95
96! **************************************************************************************************
97!> \brief performs a single propagation step a(t+Dt)=U(t+Dt,t)*a(0)
98!> and calculates the new exponential
99!> \param qs_env ...
100!> \param rtp ...
101!> \param rtp_control ...
102!> \author Florian Schiffmann (02.09)
103! **************************************************************************************************
104
105 SUBROUTINE propagation_step(qs_env, rtp, rtp_control)
106
107 TYPE(qs_environment_type), POINTER :: qs_env
108 TYPE(rt_prop_type), POINTER :: rtp
109 TYPE(rtp_control_type), POINTER :: rtp_control
110
111 CHARACTER(len=*), PARAMETER :: routinen = 'propagation_step'
112
113 INTEGER :: aspc_order, handle, i, im, re, unit_nr
114 TYPE(cell_type), POINTER :: cell
115 TYPE(cp_fm_type), DIMENSION(:), POINTER :: delta_mos, mos_new
116 TYPE(cp_logger_type), POINTER :: logger
117 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: delta_p, h_last_iter, ks_mix, ks_mix_im, &
118 matrix_ks, matrix_ks_im, matrix_s, &
119 rho_new
120 TYPE(dft_control_type), POINTER :: dft_control
121
122 CALL timeset(routinen, handle)
123
124 logger => cp_get_default_logger()
125 IF (logger%para_env%is_source()) THEN
126 unit_nr = cp_logger_get_default_unit_nr(logger, local=.true.)
127 ELSE
128 unit_nr = -1
129 END IF
130
131 NULLIFY (cell, delta_p, rho_new, delta_mos, mos_new)
132 NULLIFY (ks_mix, ks_mix_im)
133 ! get everything needed and set some values
134 CALL get_qs_env(qs_env, cell=cell, matrix_s=matrix_s, dft_control=dft_control)
135
136 IF (rtp%iter == 1) THEN
137 CALL qs_energies_init(qs_env, .false.)
138 !the above recalculates matrix_s, but matrix not changed if ions are fixed
139 IF (rtp_control%fixed_ions) CALL set_ks_env(qs_env%ks_env, s_mstruct_changed=.false.)
140
141 ! add additional terms to matrix_h and matrix_h_im in the case of applied electric field,
142 ! either in the lengh or velocity gauge.
143 ! should be called after qs_energies_init and before qs_ks_update_qs_env
144 IF (dft_control%apply_efield_field) THEN
145 IF (any(cell%perd(1:3) /= 0)) &
146 cpabort("Length gauge (efield) and periodicity are not compatible")
148 ELSE IF (rtp_control%velocity_gauge) THEN
149 IF (dft_control%apply_vector_potential) &
150 CALL update_vector_potential(qs_env, dft_control)
151 CALL velocity_gauge_ks_matrix(qs_env, subtract_nl_term=.false.)
152 END IF
153
154 CALL get_qs_env(qs_env, matrix_s=matrix_s)
155 IF (.NOT. rtp_control%fixed_ions) THEN
156 CALL s_matrices_create(matrix_s, rtp)
157 END IF
158 rtp%delta_iter = 100.0_dp
159 rtp%mixing_factor = 1.0_dp
160 rtp%mixing = .false.
161 aspc_order = rtp_control%aspc_order
162 CALL aspc_extrapolate(rtp, matrix_s, aspc_order)
163 IF (rtp%linear_scaling) THEN
164 CALL calc_update_rho_sparse(qs_env)
165 ELSE
166 CALL calc_update_rho(qs_env)
167 END IF
168 CALL qs_ks_update_qs_env(qs_env, calculate_forces=.false.)
169 END IF
170 IF (.NOT. rtp_control%fixed_ions) THEN
171 CALL calc_s_derivs(qs_env)
172 END IF
173 rtp%converged = .false.
174
175 IF (rtp%linear_scaling) THEN
176 ! keep temporary copy of the starting density matrix to check for convergence
177 CALL get_rtp(rtp=rtp, rho_new=rho_new)
178 NULLIFY (delta_p)
179 CALL dbcsr_allocate_matrix_set(delta_p, SIZE(rho_new))
180 DO i = 1, SIZE(rho_new)
181 CALL dbcsr_init_p(delta_p(i)%matrix)
182 CALL dbcsr_create(delta_p(i)%matrix, template=rho_new(i)%matrix)
183 CALL dbcsr_copy(delta_p(i)%matrix, rho_new(i)%matrix)
184 END DO
185 ELSE
186 ! keep temporary copy of the starting mos to check for convergence
187 CALL get_rtp(rtp=rtp, mos_new=mos_new)
188 ALLOCATE (delta_mos(SIZE(mos_new)))
189 DO i = 1, SIZE(mos_new)
190 CALL cp_fm_create(delta_mos(i), &
191 matrix_struct=mos_new(i)%matrix_struct, &
192 name="delta_mos"//trim(adjustl(cp_to_string(i))))
193 CALL cp_fm_to_fm(mos_new(i), delta_mos(i))
194 END DO
195 END IF
196
197 CALL get_qs_env(qs_env, &
198 matrix_ks=matrix_ks, &
199 matrix_ks_im=matrix_ks_im)
200
201 CALL get_rtp(rtp=rtp, h_last_iter=h_last_iter)
202 IF (rtp%mixing) THEN
203 IF (unit_nr > 0) THEN
204 WRITE (unit_nr, '(t3,a,2f16.8)') "Mixing the Hamiltonians to improve robustness, mixing factor: ", rtp%mixing_factor
205 END IF
206 CALL dbcsr_allocate_matrix_set(ks_mix, SIZE(matrix_ks))
207 CALL dbcsr_allocate_matrix_set(ks_mix_im, SIZE(matrix_ks))
208 DO i = 1, SIZE(matrix_ks)
209 CALL dbcsr_init_p(ks_mix(i)%matrix)
210 CALL dbcsr_create(ks_mix(i)%matrix, template=matrix_ks(1)%matrix)
211 CALL dbcsr_init_p(ks_mix_im(i)%matrix)
212 CALL dbcsr_create(ks_mix_im(i)%matrix, template=matrix_ks(1)%matrix, matrix_type=dbcsr_type_antisymmetric)
213 END DO
214 DO i = 1, SIZE(matrix_ks)
215 re = 2*i - 1
216 im = 2*i
217 CALL dbcsr_add(ks_mix(i)%matrix, matrix_ks(i)%matrix, 0.0_dp, rtp%mixing_factor)
218 CALL dbcsr_add(ks_mix(i)%matrix, h_last_iter(re)%matrix, 1.0_dp, 1.0_dp - rtp%mixing_factor)
219 IF (rtp%propagate_complex_ks) THEN
220 CALL dbcsr_add(ks_mix_im(i)%matrix, matrix_ks_im(i)%matrix, 0.0_dp, rtp%mixing_factor)
221 CALL dbcsr_add(ks_mix_im(i)%matrix, h_last_iter(im)%matrix, 1.0_dp, 1.0_dp - rtp%mixing_factor)
222 END IF
223 END DO
224 CALL calc_sinvh(rtp, ks_mix, ks_mix_im, rtp_control)
225 DO i = 1, SIZE(matrix_ks)
226 re = 2*i - 1
227 im = 2*i
228 CALL dbcsr_copy(h_last_iter(re)%matrix, ks_mix(i)%matrix)
229 IF (rtp%propagate_complex_ks) THEN
230 CALL dbcsr_copy(h_last_iter(im)%matrix, ks_mix_im(i)%matrix)
231 END IF
232 END DO
233 CALL dbcsr_deallocate_matrix_set(ks_mix)
234 CALL dbcsr_deallocate_matrix_set(ks_mix_im)
235 ELSE
236 CALL calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
237 DO i = 1, SIZE(matrix_ks)
238 re = 2*i - 1
239 im = 2*i
240 CALL dbcsr_copy(h_last_iter(re)%matrix, matrix_ks(i)%matrix)
241 IF (rtp%propagate_complex_ks) THEN
242 CALL dbcsr_copy(h_last_iter(im)%matrix, matrix_ks_im(i)%matrix)
243 END IF
244 END DO
245 END IF
246
247 CALL compute_propagator_matrix(rtp, rtp_control%propagator)
248
249 SELECT CASE (rtp_control%mat_exp)
250 CASE (do_pade, do_taylor)
251 IF (rtp%linear_scaling) THEN
252 CALL propagate_exp_density(rtp, rtp_control)
253 CALL calc_update_rho_sparse(qs_env)
254 ELSE
255 CALL propagate_exp(rtp, rtp_control)
256 CALL calc_update_rho(qs_env)
257 END IF
258 CASE (do_arnoldi)
259 CALL propagate_arnoldi(rtp, rtp_control)
260 CALL calc_update_rho(qs_env)
261 CASE (do_bch)
262 CALL propagate_bch(rtp, rtp_control)
263 CALL calc_update_rho_sparse(qs_env)
264 END SELECT
265 CALL step_finalize(qs_env, rtp_control, delta_mos, delta_p)
266 IF (rtp%linear_scaling) THEN
267 CALL dbcsr_deallocate_matrix_set(delta_p)
268 ELSE
269 CALL cp_fm_release(delta_mos)
270 END IF
271
272 CALL timestop(handle)
273
274 END SUBROUTINE propagation_step
275
276! **************************************************************************************************
277!> \brief Performs all the stuff to finish the step:
278!> convergence checks
279!> copying stuff into right place for the next step
280!> updating the history for extrapolation
281!> \param qs_env ...
282!> \param rtp_control ...
283!> \param delta_mos ...
284!> \param delta_P ...
285!> \author Florian Schiffmann (02.09)
286! **************************************************************************************************
287
288 SUBROUTINE step_finalize(qs_env, rtp_control, delta_mos, delta_P)
289 TYPE(qs_environment_type), POINTER :: qs_env
290 TYPE(rtp_control_type), POINTER :: rtp_control
291 TYPE(cp_fm_type), DIMENSION(:), POINTER :: delta_mos
292 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: delta_p
293
294 CHARACTER(len=*), PARAMETER :: routinen = 'step_finalize'
295
296 INTEGER :: handle, i, ihist
297 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos_new, mos_old
298 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: exp_h_new, exp_h_old, matrix_ks, &
299 matrix_ks_im, rho_new, rho_old, s_mat
300 TYPE(qs_energy_type), POINTER :: energy
301 TYPE(rt_prop_type), POINTER :: rtp
302
303 CALL timeset(routinen, handle)
304
305 CALL get_qs_env(qs_env=qs_env, rtp=rtp, matrix_s=s_mat, &
306 matrix_ks=matrix_ks, matrix_ks_im=matrix_ks_im, energy=energy)
307 CALL get_rtp(rtp=rtp, exp_h_old=exp_h_old, exp_h_new=exp_h_new)
308
309 IF (rtp_control%sc_check_start .LT. rtp%iter) THEN
310 rtp%delta_iter_old = rtp%delta_iter
311 IF (rtp%linear_scaling) THEN
312 CALL rt_convergence_density(rtp, delta_p, rtp%delta_iter)
313 ELSE
314 CALL rt_convergence(rtp, s_mat(1)%matrix, delta_mos, rtp%delta_iter)
315 END IF
316 rtp%converged = (rtp%delta_iter .LT. rtp_control%eps_ener)
317 !Apply mixing if scf loop is not converging
318
319 !It would be better to redo the current step with mixixng,
320 !but currently the decision is made to use mixing from the next step on
321 IF (rtp_control%sc_check_start .LT. rtp%iter + 1) THEN
322 IF (rtp%delta_iter/rtp%delta_iter_old > 0.9) THEN
323 rtp%mixing_factor = max(rtp%mixing_factor/2.0_dp, 0.125_dp)
324 rtp%mixing = .true.
325 END IF
326 END IF
327 END IF
328
329 IF (rtp%converged) THEN
330 IF (rtp%linear_scaling) THEN
331 CALL get_rtp(rtp=rtp, rho_old=rho_old, rho_new=rho_new)
332 CALL purify_mcweeny_complex_nonorth(rho_new, s_mat, rtp%filter_eps, rtp%filter_eps_small, &
333 rtp_control%mcweeny_max_iter, rtp_control%mcweeny_eps)
334 IF (rtp_control%mcweeny_max_iter > 0) CALL calc_update_rho_sparse(qs_env)
335 CALL report_density_occupation(rtp%filter_eps, rho_new)
336 DO i = 1, SIZE(rho_new)
337 CALL dbcsr_copy(rho_old(i)%matrix, rho_new(i)%matrix)
338 END DO
339 ELSE
340 CALL get_rtp(rtp=rtp, mos_old=mos_old, mos_new=mos_new)
341 DO i = 1, SIZE(mos_new)
342 CALL cp_fm_to_fm(mos_new(i), mos_old(i))
343 END DO
344 END IF
345 IF (rtp_control%propagator == do_em) CALL calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
346 DO i = 1, SIZE(exp_h_new)
347 CALL dbcsr_copy(exp_h_old(i)%matrix, exp_h_new(i)%matrix)
348 END DO
349 ihist = mod(rtp%istep, rtp_control%aspc_order) + 1
350 IF (rtp_control%fixed_ions) THEN
351 CALL put_data_to_history(rtp, rho=rho_new, mos=mos_new, ihist=ihist)
352 ELSE
353 CALL put_data_to_history(rtp, rho=rho_new, mos=mos_new, s_mat=s_mat, ihist=ihist)
354 END IF
355 END IF
356
357 rtp%energy_new = energy%total
358
359 CALL timestop(handle)
360
361 END SUBROUTINE step_finalize
362
363! **************************************************************************************************
364!> \brief computes the propagator matrix for EM/ETRS, RTP/EMD
365!> \param rtp ...
366!> \param propagator ...
367!> \author Florian Schiffmann (02.09)
368! **************************************************************************************************
369
370 SUBROUTINE compute_propagator_matrix(rtp, propagator)
371 TYPE(rt_prop_type), POINTER :: rtp
372 INTEGER :: propagator
373
374 CHARACTER(len=*), PARAMETER :: routinen = 'compute_propagator_matrix'
375
376 INTEGER :: handle, i
377 REAL(kind=dp) :: dt, prefac
378 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: exp_h_new, exp_h_old, propagator_matrix
379
380 CALL timeset(routinen, handle)
381 CALL get_rtp(rtp=rtp, exp_h_new=exp_h_new, exp_h_old=exp_h_old, &
382 propagator_matrix=propagator_matrix, dt=dt)
383
384 prefac = -0.5_dp*dt
385
386 DO i = 1, SIZE(exp_h_new)
387 CALL dbcsr_add(propagator_matrix(i)%matrix, exp_h_new(i)%matrix, 0.0_dp, prefac)
388 IF (propagator == do_em) &
389 CALL dbcsr_add(propagator_matrix(i)%matrix, exp_h_old(i)%matrix, 1.0_dp, prefac)
390 END DO
391
392 CALL timestop(handle)
393
394 END SUBROUTINE compute_propagator_matrix
395
396! **************************************************************************************************
397!> \brief computes S_inv*H, if needed Sinv*B and S_inv*H_imag and store these quantities to the
398!> \brief exp_H for the real and imag part (for RTP and EMD)
399!> \param rtp ...
400!> \param matrix_ks ...
401!> \param matrix_ks_im ...
402!> \param rtp_control ...
403!> \author Florian Schiffmann (02.09)
404! **************************************************************************************************
405
406 SUBROUTINE calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
407 TYPE(rt_prop_type), POINTER :: rtp
408 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_ks_im
409 TYPE(rtp_control_type), POINTER :: rtp_control
410
411 CHARACTER(len=*), PARAMETER :: routinen = 'calc_SinvH'
412 REAL(kind=dp), PARAMETER :: one = 1.0_dp, zero = 0.0_dp
413
414 INTEGER :: handle, im, ispin, re
415 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: exp_h, sinvb, sinvh, sinvh_imag
416 TYPE(dbcsr_type) :: matrix_ks_nosym
417 TYPE(dbcsr_type), POINTER :: b_mat, s_inv
418
419 CALL timeset(routinen, handle)
420 CALL get_rtp(rtp=rtp, s_inv=s_inv, exp_h_new=exp_h)
421 DO ispin = 1, SIZE(matrix_ks)
422 re = ispin*2 - 1
423 im = ispin*2
424 CALL dbcsr_set(exp_h(re)%matrix, zero)
425 CALL dbcsr_set(exp_h(im)%matrix, zero)
426 END DO
427 CALL dbcsr_create(matrix_ks_nosym, template=matrix_ks(1)%matrix, matrix_type="N")
428
429 ! Real part of S_inv x H -> imag part of exp_H
430 DO ispin = 1, SIZE(matrix_ks)
431 re = ispin*2 - 1
432 im = ispin*2
433 CALL dbcsr_desymmetrize(matrix_ks(ispin)%matrix, matrix_ks_nosym)
434 CALL dbcsr_multiply("N", "N", one, s_inv, matrix_ks_nosym, zero, exp_h(im)%matrix, &
435 filter_eps=rtp%filter_eps)
436 IF (.NOT. rtp_control%fixed_ions) THEN
437 CALL get_rtp(rtp=rtp, sinvh=sinvh)
438 CALL dbcsr_copy(sinvh(ispin)%matrix, exp_h(im)%matrix)
439 END IF
440 END DO
441
442 ! Imag part of S_inv x H -> real part of exp_H
443 IF (rtp%propagate_complex_ks) THEN
444 DO ispin = 1, SIZE(matrix_ks)
445 re = ispin*2 - 1
446 im = ispin*2
447 CALL dbcsr_set(matrix_ks_nosym, 0.0_dp)
448 CALL dbcsr_desymmetrize(matrix_ks_im(ispin)%matrix, matrix_ks_nosym)
449 ! - SinvH_imag is added to exp_H(re)%matrix
450 CALL dbcsr_multiply("N", "N", -one, s_inv, matrix_ks_nosym, zero, exp_h(re)%matrix, &
451 filter_eps=rtp%filter_eps)
452 IF (.NOT. rtp_control%fixed_ions) THEN
453 CALL get_rtp(rtp=rtp, sinvh_imag=sinvh_imag)
454 ! -SinvH_imag is saved
455 CALL dbcsr_copy(sinvh_imag(ispin)%matrix, exp_h(re)%matrix)
456 END IF
457 END DO
458 END IF
459 ! EMD case: the real part of exp_H should be updated with B
460 IF (.NOT. rtp_control%fixed_ions) THEN
461 CALL get_rtp(rtp=rtp, b_mat=b_mat, sinvb=sinvb)
462 CALL dbcsr_set(matrix_ks_nosym, 0.0_dp)
463 CALL dbcsr_multiply("N", "N", one, s_inv, b_mat, zero, matrix_ks_nosym, filter_eps=rtp%filter_eps)
464 DO ispin = 1, SIZE(matrix_ks)
465 re = ispin*2 - 1
466 im = ispin*2
467 ! + SinvB is added to exp_H(re)%matrix
468 CALL dbcsr_add(exp_h(re)%matrix, matrix_ks_nosym, 1.0_dp, 1.0_dp)
469 ! + SinvB is saved
470 CALL dbcsr_copy(sinvb(ispin)%matrix, matrix_ks_nosym)
471 END DO
472 END IF
473 ! Otherwise no real part for exp_H
474
475 CALL dbcsr_release(matrix_ks_nosym)
476 CALL timestop(handle)
477
478 END SUBROUTINE calc_sinvh
479
480! **************************************************************************************************
481!> \brief calculates the needed overlap-like matrices
482!> depending on the way the exponential is calculated, only S^-1 is needed
483!> \param s_mat ...
484!> \param rtp ...
485!> \author Florian Schiffmann (02.09)
486! **************************************************************************************************
487
488 SUBROUTINE s_matrices_create(s_mat, rtp)
489
490 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: s_mat
491 TYPE(rt_prop_type), POINTER :: rtp
492
493 CHARACTER(len=*), PARAMETER :: routinen = 's_matrices_create'
494 REAL(kind=dp), PARAMETER :: one = 1.0_dp, zero = 0.0_dp
495
496 INTEGER :: handle
497 TYPE(dbcsr_type), POINTER :: s_half, s_inv, s_minus_half
498
499 CALL timeset(routinen, handle)
500
501 CALL get_rtp(rtp=rtp, s_inv=s_inv)
502
503 IF (rtp%linear_scaling) THEN
504 CALL get_rtp(rtp=rtp, s_half=s_half, s_minus_half=s_minus_half)
505 CALL matrix_sqrt_newton_schulz(s_half, s_minus_half, s_mat(1)%matrix, rtp%filter_eps, &
506 rtp%newton_schulz_order, rtp%lanzcos_threshold, rtp%lanzcos_max_iter)
507 CALL dbcsr_multiply("N", "N", one, s_minus_half, s_minus_half, zero, s_inv, &
508 filter_eps=rtp%filter_eps)
509 ELSE
510 CALL dbcsr_copy(s_inv, s_mat(1)%matrix)
511 CALL cp_dbcsr_cholesky_decompose(s_inv, para_env=rtp%ao_ao_fmstruct%para_env, &
512 blacs_env=rtp%ao_ao_fmstruct%context)
513 CALL cp_dbcsr_cholesky_invert(s_inv, para_env=rtp%ao_ao_fmstruct%para_env, &
514 blacs_env=rtp%ao_ao_fmstruct%context, uplo_to_full=.true.)
515 END IF
516
517 CALL timestop(handle)
518 END SUBROUTINE s_matrices_create
519
520! **************************************************************************************************
521!> \brief Calculates the frobenius norm of a complex matrix represented by two real matrices
522!> \param frob_norm ...
523!> \param mat_re ...
524!> \param mat_im ...
525!> \author Samuel Andermatt (04.14)
526! **************************************************************************************************
527
528 SUBROUTINE complex_frobenius_norm(frob_norm, mat_re, mat_im)
529
530 REAL(kind=dp), INTENT(out) :: frob_norm
531 TYPE(dbcsr_type), POINTER :: mat_re, mat_im
532
533 CHARACTER(len=*), PARAMETER :: routinen = 'complex_frobenius_norm'
534 REAL(kind=dp), PARAMETER :: one = 1.0_dp, zero = 0.0_dp
535
536 INTEGER :: col_atom, handle, row_atom
537 LOGICAL :: found
538 REAL(dp), DIMENSION(:, :), POINTER :: block_values, block_values2
539 TYPE(dbcsr_iterator_type) :: iter
540 TYPE(dbcsr_type), POINTER :: tmp
541
542 CALL timeset(routinen, handle)
543
544 NULLIFY (tmp)
545 ALLOCATE (tmp)
546 CALL dbcsr_create(tmp, template=mat_re)
547 !make sure the tmp has the same sparsity pattern as the real and the complex part combined
548 CALL dbcsr_add(tmp, mat_re, zero, one)
549 CALL dbcsr_add(tmp, mat_im, zero, one)
550 CALL dbcsr_set(tmp, zero)
551 !calculate the hadamard product
552 CALL dbcsr_iterator_start(iter, tmp)
553 DO WHILE (dbcsr_iterator_blocks_left(iter))
554 CALL dbcsr_iterator_next_block(iter, row_atom, col_atom, block_values)
555 CALL dbcsr_get_block_p(mat_re, row_atom, col_atom, block_values2, found=found)
556 IF (found) THEN
557 block_values = block_values2*block_values2
558 END IF
559 CALL dbcsr_get_block_p(mat_im, row_atom, col_atom, block_values2, found=found)
560 IF (found) THEN
561 block_values = block_values + block_values2*block_values2
562 END IF
563 block_values = sqrt(block_values)
564 END DO
565 CALL dbcsr_iterator_stop(iter)
566 frob_norm = dbcsr_frobenius_norm(tmp)
567
569
570 CALL timestop(handle)
571
572 END SUBROUTINE complex_frobenius_norm
573
574! **************************************************************************************************
575!> \brief Does McWeeny for complex matrices in the non-orthogonal basis
576!> \param P ...
577!> \param s_mat ...
578!> \param eps ...
579!> \param eps_small ...
580!> \param max_iter ...
581!> \param threshold ...
582!> \author Samuel Andermatt (04.14)
583! **************************************************************************************************
584
585 SUBROUTINE purify_mcweeny_complex_nonorth(P, s_mat, eps, eps_small, max_iter, threshold)
586
587 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: p, s_mat
588 REAL(kind=dp), INTENT(in) :: eps, eps_small
589 INTEGER, INTENT(in) :: max_iter
590 REAL(kind=dp), INTENT(in) :: threshold
591
592 CHARACTER(len=*), PARAMETER :: routinen = 'purify_mcweeny_complex_nonorth'
593 REAL(kind=dp), PARAMETER :: one = 1.0_dp, zero = 0.0_dp
594
595 INTEGER :: handle, i, im, imax, ispin, re, unit_nr
596 REAL(kind=dp) :: frob_norm
597 TYPE(cp_logger_type), POINTER :: logger
598 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ps, psp, tmp
599
600 CALL timeset(routinen, handle)
601
602 logger => cp_get_default_logger()
603 IF (logger%para_env%is_source()) THEN
604 unit_nr = cp_logger_get_default_unit_nr(logger, local=.true.)
605 ELSE
606 unit_nr = -1
607 END IF
608
609 NULLIFY (tmp, ps, psp)
610 CALL dbcsr_allocate_matrix_set(tmp, SIZE(p))
611 CALL dbcsr_allocate_matrix_set(psp, SIZE(p))
612 CALL dbcsr_allocate_matrix_set(ps, SIZE(p))
613 DO i = 1, SIZE(p)
614 CALL dbcsr_init_p(ps(i)%matrix)
615 CALL dbcsr_create(ps(i)%matrix, template=p(1)%matrix)
616 CALL dbcsr_init_p(psp(i)%matrix)
617 CALL dbcsr_create(psp(i)%matrix, template=p(1)%matrix)
618 CALL dbcsr_init_p(tmp(i)%matrix)
619 CALL dbcsr_create(tmp(i)%matrix, template=p(1)%matrix)
620 END DO
621 IF (SIZE(p) == 2) THEN
622 CALL dbcsr_scale(p(1)%matrix, one/2)
623 CALL dbcsr_scale(p(2)%matrix, one/2)
624 END IF
625 DO ispin = 1, SIZE(p)/2
626 re = 2*ispin - 1
627 im = 2*ispin
628 imax = max(max_iter, 1) !if max_iter is 0 then only the deviation from idempotency needs to be calculated
629 DO i = 1, imax
630 CALL dbcsr_multiply("N", "N", one, p(re)%matrix, s_mat(1)%matrix, &
631 zero, ps(re)%matrix, filter_eps=eps_small)
632 CALL dbcsr_multiply("N", "N", one, p(im)%matrix, s_mat(1)%matrix, &
633 zero, ps(im)%matrix, filter_eps=eps_small)
634 CALL cp_complex_dbcsr_gemm_3("N", "N", one, ps(re)%matrix, ps(im)%matrix, &
635 p(re)%matrix, p(im)%matrix, zero, psp(re)%matrix, psp(im)%matrix, &
636 filter_eps=eps_small)
637 CALL dbcsr_copy(tmp(re)%matrix, psp(re)%matrix)
638 CALL dbcsr_copy(tmp(im)%matrix, psp(im)%matrix)
639 CALL dbcsr_add(tmp(re)%matrix, p(re)%matrix, 1.0_dp, -1.0_dp)
640 CALL dbcsr_add(tmp(im)%matrix, p(im)%matrix, 1.0_dp, -1.0_dp)
641 CALL complex_frobenius_norm(frob_norm, tmp(re)%matrix, tmp(im)%matrix)
642 IF (unit_nr .GT. 0) WRITE (unit_nr, '(t3,a,2f16.8)') "Deviation from idempotency: ", frob_norm
643 IF (frob_norm .GT. threshold .AND. max_iter > 0) THEN
644 CALL dbcsr_copy(p(re)%matrix, psp(re)%matrix)
645 CALL dbcsr_copy(p(im)%matrix, psp(im)%matrix)
646 CALL cp_complex_dbcsr_gemm_3("N", "N", -2.0_dp, ps(re)%matrix, ps(im)%matrix, &
647 psp(re)%matrix, psp(im)%matrix, 3.0_dp, p(re)%matrix, p(im)%matrix, &
648 filter_eps=eps_small)
649 CALL dbcsr_filter(p(re)%matrix, eps)
650 CALL dbcsr_filter(p(im)%matrix, eps)
651 !make sure P is exactly hermitian
652 CALL dbcsr_transposed(tmp(re)%matrix, p(re)%matrix)
653 CALL dbcsr_add(p(re)%matrix, tmp(re)%matrix, one/2, one/2)
654 CALL dbcsr_transposed(tmp(im)%matrix, p(im)%matrix)
655 CALL dbcsr_add(p(im)%matrix, tmp(im)%matrix, one/2, -one/2)
656 ELSE
657 EXIT
658 END IF
659 END DO
660 !make sure P is hermitian
661 CALL dbcsr_transposed(tmp(re)%matrix, p(re)%matrix)
662 CALL dbcsr_add(p(re)%matrix, tmp(re)%matrix, one/2, one/2)
663 CALL dbcsr_transposed(tmp(im)%matrix, p(im)%matrix)
664 CALL dbcsr_add(p(im)%matrix, tmp(im)%matrix, one/2, -one/2)
665 END DO
666 IF (SIZE(p) == 2) THEN
667 CALL dbcsr_scale(p(1)%matrix, one*2)
668 CALL dbcsr_scale(p(2)%matrix, one*2)
669 END IF
673
674 CALL timestop(handle)
675
676 END SUBROUTINE purify_mcweeny_complex_nonorth
677
678! **************************************************************************************************
679!> \brief ...
680!> \param rtp ...
681!> \param matrix_s ...
682!> \param aspc_order ...
683! **************************************************************************************************
684 SUBROUTINE aspc_extrapolate(rtp, matrix_s, aspc_order)
685 TYPE(rt_prop_type), POINTER :: rtp
686 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
687 INTEGER, INTENT(in) :: aspc_order
688
689 CHARACTER(len=*), PARAMETER :: routinen = 'aspc_extrapolate'
690 COMPLEX(KIND=dp), PARAMETER :: cone = (1.0_dp, 0.0_dp), &
691 czero = (0.0_dp, 0.0_dp)
692 REAL(kind=dp), PARAMETER :: one = 1.0_dp, zero = 0.0_dp
693
694 INTEGER :: handle, i, iaspc, icol_local, ihist, &
695 imat, k, kdbl, n, naspc, ncol_local, &
696 nmat
697 REAL(kind=dp) :: alpha
698 TYPE(cp_cfm_type) :: cfm_tmp, cfm_tmp1, csc
699 TYPE(cp_fm_struct_type), POINTER :: matrix_struct, matrix_struct_new
700 TYPE(cp_fm_type) :: fm_tmp, fm_tmp1, fm_tmp2
701 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos_new
702 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: mo_hist
703 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_new, s_hist
704 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_hist
705
706 NULLIFY (rho_hist)
707 CALL timeset(routinen, handle)
708 CALL cite_reference(kolafa2004)
709 CALL cite_reference(kuhne2007)
710
711 IF (rtp%linear_scaling) THEN
712 CALL get_rtp(rtp=rtp, rho_new=rho_new)
713 ELSE
714 CALL get_rtp(rtp=rtp, mos_new=mos_new)
715 END IF
716
717 naspc = min(rtp%istep, aspc_order)
718 IF (rtp%linear_scaling) THEN
719 nmat = SIZE(rho_new)
720 rho_hist => rtp%history%rho_history
721 DO imat = 1, nmat
722 DO iaspc = 1, naspc
723 alpha = (-1.0_dp)**(iaspc + 1)*real(iaspc, kind=dp)* &
724 binomial(2*naspc, naspc - iaspc)/binomial(2*naspc - 2, naspc - 1)
725 ihist = mod(rtp%istep - iaspc, aspc_order) + 1
726 IF (iaspc == 1) THEN
727 CALL dbcsr_add(rho_new(imat)%matrix, rho_hist(imat, ihist)%matrix, zero, alpha)
728 ELSE
729 CALL dbcsr_add(rho_new(imat)%matrix, rho_hist(imat, ihist)%matrix, one, alpha)
730 END IF
731 END DO
732 END DO
733 ELSE
734 mo_hist => rtp%history%mo_history
735 nmat = SIZE(mos_new)
736 DO imat = 1, nmat
737 DO iaspc = 1, naspc
738 alpha = (-1.0_dp)**(iaspc + 1)*real(iaspc, kind=dp)* &
739 binomial(2*naspc, naspc - iaspc)/binomial(2*naspc - 2, naspc - 1)
740 ihist = mod(rtp%istep - iaspc, aspc_order) + 1
741 IF (iaspc == 1) THEN
742 CALL cp_fm_scale_and_add(zero, mos_new(imat), alpha, mo_hist(imat, ihist))
743 ELSE
744 CALL cp_fm_scale_and_add(one, mos_new(imat), alpha, mo_hist(imat, ihist))
745 END IF
746 END DO
747 END DO
748
749 mo_hist => rtp%history%mo_history
750 s_hist => rtp%history%s_history
751 DO i = 1, SIZE(mos_new)/2
752 NULLIFY (matrix_struct, matrix_struct_new)
753
754 CALL cp_fm_struct_double(matrix_struct, &
755 mos_new(2*i)%matrix_struct, &
756 mos_new(2*i)%matrix_struct%context, &
757 .true., .false.)
758
759 CALL cp_fm_create(fm_tmp, matrix_struct)
760 CALL cp_fm_create(fm_tmp1, matrix_struct)
761 CALL cp_fm_create(fm_tmp2, mos_new(2*i)%matrix_struct)
762 CALL cp_cfm_create(cfm_tmp, mos_new(2*i)%matrix_struct)
763 CALL cp_cfm_create(cfm_tmp1, mos_new(2*i)%matrix_struct)
764
765 CALL cp_fm_get_info(fm_tmp, ncol_global=kdbl)
766
767 CALL cp_fm_get_info(mos_new(2*i), &
768 nrow_global=n, &
769 ncol_global=k, &
770 ncol_local=ncol_local)
771
772 CALL cp_fm_struct_create(matrix_struct_new, &
773 template_fmstruct=mos_new(2*i)%matrix_struct, &
774 nrow_global=k, &
775 ncol_global=k)
776 CALL cp_cfm_create(csc, matrix_struct_new)
777
778 CALL cp_fm_struct_release(matrix_struct_new)
779 CALL cp_fm_struct_release(matrix_struct)
780
781 ! first the most recent
782
783! reorthogonalize vectors
784 DO icol_local = 1, ncol_local
785 fm_tmp%local_data(:, icol_local) = mos_new(2*i - 1)%local_data(:, icol_local)
786 fm_tmp%local_data(:, icol_local + ncol_local) = mos_new(2*i)%local_data(:, icol_local)
787 END DO
788
789 CALL cp_dbcsr_sm_fm_multiply(matrix_s(1)%matrix, fm_tmp, fm_tmp1, kdbl)
790
791 DO icol_local = 1, ncol_local
792 cfm_tmp%local_data(:, icol_local) = cmplx(fm_tmp1%local_data(:, icol_local), &
793 fm_tmp1%local_data(:, icol_local + ncol_local), dp)
794 cfm_tmp1%local_data(:, icol_local) = cmplx(mos_new(2*i - 1)%local_data(:, icol_local), &
795 mos_new(2*i)%local_data(:, icol_local), dp)
796 END DO
797 CALL parallel_gemm('C', 'N', k, k, n, cone, cfm_tmp1, cfm_tmp, czero, csc)
799 CALL cp_cfm_triangular_multiply(csc, cfm_tmp1, n_cols=k, side='R', invert_tr=.true.)
800 DO icol_local = 1, ncol_local
801 mos_new(2*i - 1)%local_data(:, icol_local) = real(cfm_tmp1%local_data(:, icol_local), dp)
802 mos_new(2*i)%local_data(:, icol_local) = aimag(cfm_tmp1%local_data(:, icol_local))
803 END DO
804
805! deallocate work matrices
806 CALL cp_cfm_release(csc)
807 CALL cp_fm_release(fm_tmp)
808 CALL cp_fm_release(fm_tmp1)
809 CALL cp_fm_release(fm_tmp2)
810 CALL cp_cfm_release(cfm_tmp)
811 CALL cp_cfm_release(cfm_tmp1)
812 END DO
813
814 END IF
815
816 CALL timestop(handle)
817
818 END SUBROUTINE aspc_extrapolate
819
820! **************************************************************************************************
821!> \brief ...
822!> \param rtp ...
823!> \param mos ...
824!> \param rho ...
825!> \param s_mat ...
826!> \param ihist ...
827! **************************************************************************************************
828 SUBROUTINE put_data_to_history(rtp, mos, rho, s_mat, ihist)
829 TYPE(rt_prop_type), POINTER :: rtp
830 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mos
831 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho
832 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
833 POINTER :: s_mat
834 INTEGER :: ihist
835
836 INTEGER :: i
837
838 IF (rtp%linear_scaling) THEN
839 DO i = 1, SIZE(rho)
840 CALL dbcsr_copy(rtp%history%rho_history(i, ihist)%matrix, rho(i)%matrix)
841 END DO
842 ELSE
843 DO i = 1, SIZE(mos)
844 CALL cp_fm_to_fm(mos(i), rtp%history%mo_history(i, ihist))
845 END DO
846 IF (PRESENT(s_mat)) THEN
847 IF (ASSOCIATED(rtp%history%s_history(ihist)%matrix)) THEN ! the sparsity might be different
848 ! (future struct:check)
849 CALL dbcsr_deallocate_matrix(rtp%history%s_history(ihist)%matrix)
850 END IF
851 ALLOCATE (rtp%history%s_history(ihist)%matrix)
852 CALL dbcsr_copy(rtp%history%s_history(ihist)%matrix, s_mat(1)%matrix)
853 END IF
854 END IF
855
856 END SUBROUTINE put_data_to_history
857
858END MODULE rt_propagation_methods
static int imax(int x, int y)
Returns the larger of two given integers (missing from the C standard)
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public kuhne2007
integer, save, public kolafa2004
Handles all functions related to the CELL.
Definition cell_types.F:15
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_triangular_multiply(triangular_matrix, matrix_b, side, transa_tr, invert_tr, uplo_tr, unit_diag_tr, n_rows, n_cols, alpha)
Multiplies in place by a triangular matrix: matrix_b = alpha op(triangular_matrix) matrix_b or (if si...
various cholesky decomposition related routines
subroutine, public cp_cfm_cholesky_decompose(matrix, n, info_out)
Used to replace a symmetric positive definite matrix M with its Cholesky decomposition U: M = U^T * U...
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_transposed(transposed, normal, shallow_data_copy, transpose_distribution, use_distribution)
...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
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_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_init_p(matrix)
...
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_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
Interface to (sca)lapack for the Cholesky based procedures.
subroutine, public cp_dbcsr_cholesky_decompose(matrix, n, para_env, blacs_env)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
subroutine, public cp_dbcsr_cholesky_invert(matrix, n, para_env, blacs_env, uplo_to_full)
used to replace the cholesky decomposition by the inverse
real(dp) function, public dbcsr_frobenius_norm(matrix)
Compute the frobenius norm of a dbcsr matrix.
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
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....
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_double(fmstruct, struct, context, col, row)
creates a struct with twice the number of blocks on each core. If matrix A has to be multiplied with ...
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_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_create(matrix, matrix_struct, name, use_sp)
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
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
all routins needed for a nonperiodic electric field
subroutine, public efield_potential_lengh_gauge(qs_env)
Replace the original implementation of the electric-electronic interaction in the length gauge....
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_bch
integer, parameter, public do_pade
integer, parameter, public do_taylor
integer, parameter, public do_em
integer, parameter, public do_arnoldi
Routines useful for iterative matrix calculations.
subroutine, public matrix_sqrt_newton_schulz(matrix_sqrt, matrix_sqrt_inv, matrix, threshold, order, eps_lanczos, max_iter_lanczos, symmetrize, converged, iounit)
compute the sqrt of a matrix via the sign function and the corresponding Newton-Schulz iterations the...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Routines for calculating a complex matrix exponential with dbcsr matrices. Based on the code in matri...
subroutine, public cp_complex_dbcsr_gemm_3(transa, transb, alpha, a_re, a_im, b_re, b_im, beta, c_re, c_im, filter_eps)
Convenience function. Computes the matrix multiplications needed for the multiplication of complex sp...
Collection of simple mathematical functions and subroutines.
Definition mathlib.F:15
elemental real(kind=dp) function, public binomial(n, k)
The binomial coefficient n over k for 0 <= k <= n is calculated, otherwise zero is returned.
Definition mathlib.F:206
basic linear algebra operations for full matrixes
Utility subroutine for qs energy calculation.
subroutine, public qs_energies_init(qs_env, calc_forces)
Refactoring of qs_energies_scf. Driver routine for the initial setup and calculations for a qs energy...
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_pp, 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, 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)
Get the QUICKSTEP environment.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
Routines for calculating a complex matrix exponential.
subroutine, public propagate_exp(rtp, rtp_control)
performs propagations if explicit matrix exponentials are used ETRS: exp(i*H(t+dt)*dt/2)*exp(i*H(t)*d...
subroutine, public propagate_bch(rtp, rtp_control)
Propagation using the Baker-Campbell-Hausdorff expansion, currently only works for rtp.
subroutine, public propagate_exp_density(rtp, rtp_control)
Propagation of the density matrix instead of the atomic orbitals via a matrix exponential.
subroutine, public propagate_arnoldi(rtp, rtp_control)
computes U_prop*MOs using arnoldi subspace algorithm
Routines for propagating the orbitals.
subroutine, public calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
computes S_inv*H, if needed Sinv*B and S_inv*H_imag and store these quantities to the
subroutine, public propagation_step(qs_env, rtp, rtp_control)
performs a single propagation step a(t+Dt)=U(t+Dt,t)*a(0) and calculates the new exponential
subroutine, public put_data_to_history(rtp, mos, rho, s_mat, ihist)
...
subroutine, public s_matrices_create(s_mat, rtp)
calculates the needed overlap-like matrices depending on the way the exponential is calculated,...
Routine for the real time propagation output.
subroutine, public report_density_occupation(filter_eps, rho)
Reports the sparsity pattern of the complex density matrix.
subroutine, public rt_convergence(rtp, matrix_s, delta_mos, delta_eps)
computes the convergence criterion for RTP and EMD
subroutine, public rt_convergence_density(rtp, delta_p, delta_eps)
computes the convergence criterion for RTP and EMD based on the density matrix
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 calc_s_derivs(qs_env)
Calculates dS/dR respectily the velocity weighted derivatves only needed for ehrenfest MD.
subroutine, public calc_update_rho(qs_env)
calculates the density from the complex MOs and passes the density to qs_env.
Routines to perform the RTP in the velocity gauge.
subroutine, public velocity_gauge_ks_matrix(qs_env, subtract_nl_term)
...
subroutine, public update_vector_potential(qs_env, dft_control)
Update the vector potential in the case where a time-dependant electric field is apply.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
Represent a complex full matrix.
keeps the information about the structure of a full matrix
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...