(git:98357aa)
Loading...
Searching...
No Matches
et_coupling_proj.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief calculates the electron transfer coupling elements by projection-operator approach
10!> Kondov et al. J.Phys.Chem.C 2007, 111, 11970-11981
11!> \author Z. Futera (02.2017)
12! **************************************************************************************************
14
19 USE bibliography, ONLY: futera2017,&
20 cite_reference
21 USE cell_types, ONLY: cell_type
24 USE cp_dbcsr_api, ONLY: dbcsr_p_type
34 USE cp_fm_types, ONLY: &
40 USE cp_output_handling, ONLY: cp_p_file,&
51 USE kinds, ONLY: default_path_length,&
53 dp
54 USE kpoint_types, ONLY: kpoint_type
56 USE orbital_pointers, ONLY: nso
60 USE physcon, ONLY: evolt
61 USE pw_env_types, ONLY: pw_env_get,&
63 USE pw_pool_types, ONLY: pw_pool_p_type,&
65 USE pw_types, ONLY: pw_c1d_gs_type,&
70 USE qs_kind_types, ONLY: get_qs_kind,&
73 USE qs_mo_methods, ONLY: make_mo_eig
75 USE qs_mo_types, ONLY: allocate_mo_set,&
81#include "./base/base_uses.f90"
82
83 IMPLICIT NONE
84
85 PRIVATE
86
87 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'et_coupling_proj'
88
89 ! Electronic-coupling calculation data structure
90 !
91 ! n_atoms - number of atoms in the blocks
92 ! n_blocks - number of atomic blocks (donor,acceptor,bridge,...)
93 ! fermi - system Fermi level (alpha/beta spin component)
94 ! m_transf - transformation matrix for basis-set orthogonalization (S^{-1/2})
95 ! m_transf_inv - inversion transformation matrix
96 ! block - atomic data blocks
97 TYPE et_cpl
98 INTEGER :: n_atoms = 0
99 INTEGER :: n_blocks = 0
100 REAL(KIND=dp), DIMENSION(:), POINTER :: fermi => null()
101 TYPE(cp_fm_type), POINTER :: m_transf => null()
102 TYPE(cp_fm_type), POINTER :: m_transf_inv => null()
103 TYPE(et_cpl_block), DIMENSION(:), POINTER :: block => null()
104 END TYPE et_cpl
105
106 ! Electronic-coupling data block
107 !
108 ! n_atoms - number of atoms
109 ! n_electrons - number of electrons
110 ! n_ao - number of AO basis functions
111 ! atom - list of atoms
112 ! mo - electronic states
113 ! hab - electronic-coupling elements
114 TYPE et_cpl_block
115 INTEGER :: n_atoms = 0
116 INTEGER :: n_electrons = 0
117 INTEGER :: n_ao = 0
118 TYPE(et_cpl_atom), DIMENSION(:), POINTER :: atom => null()
119 TYPE(mo_set_type), DIMENSION(:), POINTER :: mo => null()
120 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: hab => null()
121 END TYPE et_cpl_block
122
123 ! Electronic-coupling block-atom data
124 ! id - atom ID
125 ! n_ao - number of AO basis functions
126 ! ao_pos - position of atom in array of AO functions
127 TYPE et_cpl_atom
128 INTEGER :: id = 0
129 INTEGER :: n_ao = 0
130 INTEGER :: ao_pos = 0
131 END TYPE et_cpl_atom
132
133 PUBLIC :: calc_et_coupling_proj
134
135CONTAINS
136
137! **************************************************************************************************
138!> \brief Release memory allocate for electronic coupling data structures
139!> \param ec electronic coupling data structure
140!> \author Z. Futera (02.2017)
141! **************************************************************************************************
142 SUBROUTINE release_ec_data(ec)
143
144 ! Routine arguments
145 TYPE(et_cpl), POINTER :: ec
146
147 INTEGER :: i, j
148
149! Routine name for debug purposes
150
151 IF (ASSOCIATED(ec)) THEN
152
153 IF (ASSOCIATED(ec%fermi)) THEN
154 DEALLOCATE (ec%fermi)
155 END IF
156 IF (ASSOCIATED(ec%m_transf)) THEN
157 CALL cp_fm_release(matrix=ec%m_transf)
158 DEALLOCATE (ec%m_transf)
159 NULLIFY (ec%m_transf)
160 END IF
161 IF (ASSOCIATED(ec%m_transf_inv)) THEN
162 CALL cp_fm_release(matrix=ec%m_transf_inv)
163 DEALLOCATE (ec%m_transf_inv)
164 NULLIFY (ec%m_transf_inv)
165 END IF
166
167 IF (ASSOCIATED(ec%block)) THEN
168
169 DO i = 1, SIZE(ec%block)
170 IF (ASSOCIATED(ec%block(i)%atom)) THEN
171 DEALLOCATE (ec%block(i)%atom)
172 END IF
173 IF (ASSOCIATED(ec%block(i)%mo)) THEN
174 DO j = 1, SIZE(ec%block(i)%mo)
175 CALL deallocate_mo_set(ec%block(i)%mo(j))
176 END DO
177 DEALLOCATE (ec%block(i)%mo)
178 END IF
179 CALL cp_fm_release(ec%block(i)%hab)
180 END DO
181
182 DEALLOCATE (ec%block)
183
184 END IF
185
186 DEALLOCATE (ec)
187
188 END IF
189
190 END SUBROUTINE release_ec_data
191
192! **************************************************************************************************
193!> \brief check the electronic-coupling input section and set the atomic block data
194!> \param qs_env QuickStep environment containing all system data
195!> \param et_proj_sec the electronic-coupling input section
196!> \param ec electronic coupling data structure
197!> \author Z. Futera (02.2017)
198! **************************************************************************************************
199 SUBROUTINE set_block_data(qs_env, et_proj_sec, ec)
200
201 ! Routine arguments
202 TYPE(qs_environment_type), POINTER :: qs_env
203 TYPE(section_vals_type), POINTER :: et_proj_sec
204 TYPE(et_cpl), POINTER :: ec
205
206 INTEGER :: i, j, k, l, n, n_ao, n_atoms, n_set
207 INTEGER, DIMENSION(:), POINTER :: atom_id, atom_nf, atom_ps, n_shell, t
208 INTEGER, DIMENSION(:, :), POINTER :: ang_mom_id
209 LOGICAL :: found
210 TYPE(gto_basis_set_type), POINTER :: ao_basis_set
211 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
212 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
213 TYPE(section_vals_type), POINTER :: block_sec
214
215! Routine name for debug purposes
216
217 NULLIFY (ao_basis_set)
218 NULLIFY (particle_set)
219 NULLIFY (qs_kind_set)
220 NULLIFY (n_shell)
221 NULLIFY (ang_mom_id)
222 NULLIFY (atom_nf)
223 NULLIFY (atom_id)
224 NULLIFY (block_sec)
225
226 ! Initialization
227 ec%n_atoms = 0
228 ec%n_blocks = 0
229 NULLIFY (ec%fermi)
230 NULLIFY (ec%m_transf)
231 NULLIFY (ec%m_transf_inv)
232 NULLIFY (ec%block)
233
234 ! Number of atoms / atom types
235 CALL get_qs_env(qs_env, particle_set=particle_set, qs_kind_set=qs_kind_set, natom=n_atoms)
236 ! Number of AO basis functions
237 CALL get_qs_kind_set(qs_kind_set, nsgf=n_ao)
238
239 ! Number of AO functions per atom
240 ALLOCATE (atom_nf(n_atoms))
241 cpassert(ASSOCIATED(atom_nf))
242
243 atom_nf = 0
244 DO i = 1, n_atoms
245 CALL get_atomic_kind(particle_set(i)%atomic_kind, kind_number=j)
246 CALL get_qs_kind(qs_kind_set(j), basis_set=ao_basis_set)
247 IF (.NOT. ASSOCIATED(ao_basis_set)) THEN
248 cpabort('Unsupported basis set type. ')
249 END IF
250 CALL get_gto_basis_set(gto_basis_set=ao_basis_set, &
251 nset=n_set, nshell=n_shell, l=ang_mom_id)
252 DO j = 1, n_set
253 DO k = 1, n_shell(j)
254 atom_nf(i) = atom_nf(i) + nso(ang_mom_id(k, j))
255 END DO
256 END DO
257 END DO
258
259 ! Sanity check
260 n = 0
261 DO i = 1, n_atoms
262 n = n + atom_nf(i)
263 END DO
264 cpassert(n == n_ao)
265
266 ! Atom position in AO array
267 ALLOCATE (atom_ps(n_atoms))
268 cpassert(ASSOCIATED(atom_ps))
269 atom_ps = 1
270 DO i = 1, n_atoms - 1
271 atom_ps(i + 1) = atom_ps(i) + atom_nf(i)
272 END DO
273
274 ! Number of blocks
275 block_sec => section_vals_get_subs_vals(et_proj_sec, 'BLOCK')
276 CALL section_vals_get(block_sec, n_repetition=ec%n_blocks)
277 ALLOCATE (ec%block(ec%n_blocks))
278 cpassert(ASSOCIATED(ec%block))
279
280 ! Block data
281 ALLOCATE (t(n_atoms))
282 cpassert(ASSOCIATED(t))
283
284 ec%n_atoms = 0
285 DO i = 1, ec%n_blocks
286
287 ! Initialization
288 ec%block(i)%n_atoms = 0
289 ec%block(i)%n_electrons = 0
290 ec%block(i)%n_ao = 0
291 NULLIFY (ec%block(i)%atom)
292 NULLIFY (ec%block(i)%mo)
293 NULLIFY (ec%block(i)%hab)
294
295 ! Number of electrons
296 CALL section_vals_val_get(block_sec, i_rep_section=i, &
297 keyword_name='NELECTRON', i_val=ec%block(i)%n_electrons)
298
299 ! User-defined atom array
300 CALL section_vals_val_get(block_sec, i_rep_section=i, &
301 keyword_name='ATOMS', i_vals=atom_id)
302
303 ! Count unique atoms
304 DO j = 1, SIZE(atom_id)
305 ! Check atom ID validity
306 IF (atom_id(j) < 1 .OR. atom_id(j) > n_atoms) THEN
307 cpabort('invalid fragment atom ID ('//trim(adjustl(cp_to_string(atom_id(j))))//')')
308 END IF
309 ! Check if the atom is not in previously-defined blocks
310 found = .false.
311 DO k = 1, i - 1
312 DO l = 1, ec%block(k)%n_atoms
313 IF (ec%block(k)%atom(l)%id == atom_id(j)) THEN
314 cpwarn('multiple definition of atom'//trim(adjustl(cp_to_string(atom_id(j)))))
315 found = .true.
316 EXIT
317 END IF
318 END DO
319 END DO
320 ! Check if the atom is not in already defined in the present block
321 IF (.NOT. found) THEN
322 DO k = 1, ec%block(i)%n_atoms
323 IF (t(k) == atom_id(j)) THEN
324 cpwarn('multiple definition of atom'//trim(adjustl(cp_to_string(atom_id(j)))))
325 found = .true.
326 EXIT
327 END IF
328 END DO
329 END IF
330 ! Save the atom
331 IF (.NOT. found) THEN
332 ec%block(i)%n_atoms = ec%block(i)%n_atoms + 1
333 t(ec%block(i)%n_atoms) = atom_id(j)
334 END IF
335 END DO
336
337 ! Memory allocation
338 ALLOCATE (ec%block(i)%atom(ec%block(i)%n_atoms))
339 cpassert(ASSOCIATED(ec%block(i)%atom))
340
341 ! Save atom IDs and number of AOs
342 DO j = 1, ec%block(i)%n_atoms
343 ec%block(i)%atom(j)%id = t(j)
344 ec%block(i)%atom(j)%n_ao = atom_nf(ec%block(i)%atom(j)%id)
345 ec%block(i)%atom(j)%ao_pos = atom_ps(ec%block(i)%atom(j)%id)
346 ec%block(i)%n_ao = ec%block(i)%n_ao + ec%block(i)%atom(j)%n_ao
347 END DO
348
349 ec%n_atoms = ec%n_atoms + ec%block(i)%n_atoms
350 END DO
351
352 ! Clean memory
353 IF (ASSOCIATED(atom_nf)) THEN
354 DEALLOCATE (atom_nf)
355 END IF
356 IF (ASSOCIATED(atom_ps)) THEN
357 DEALLOCATE (atom_ps)
358 END IF
359 IF (ASSOCIATED(t)) THEN
360 DEALLOCATE (t)
361 END IF
362
363 END SUBROUTINE set_block_data
364
365! **************************************************************************************************
366!> \brief check the electronic-coupling input section and set the atomic block data
367!> \param ec electronic coupling data structure
368!> \param fa system Fermi level (alpha spin)
369!> \param fb system Fermi level (beta spin)
370!> \author Z. Futera (02.2017)
371! **************************************************************************************************
372 SUBROUTINE set_fermi(ec, fa, fb)
373
374 ! Routine arguments
375 TYPE(et_cpl), POINTER :: ec
376 REAL(KIND=dp) :: fa
377 REAL(KIND=dp), OPTIONAL :: fb
378
379! Routine name for debug purposes
380
381 NULLIFY (ec%fermi)
382
383 IF (PRESENT(fb)) THEN
384
385 ALLOCATE (ec%fermi(2))
386 cpassert(ASSOCIATED(ec%fermi))
387 ec%fermi(1) = fa
388 ec%fermi(2) = fb
389
390 ELSE
391
392 ALLOCATE (ec%fermi(1))
393 cpassert(ASSOCIATED(ec%fermi))
394 ec%fermi(1) = fa
395
396 END IF
397
398 END SUBROUTINE set_fermi
399
400! **************************************************************************************************
401!> \brief reorder Hamiltonian matrix according to defined atomic blocks
402!> \param ec electronic coupling data structure
403!> \param mat_h the Hamiltonian matrix
404!> \param mat_w working matrix of the same dimension
405!> \author Z. Futera (02.2017)
406! **************************************************************************************************
407 SUBROUTINE reorder_hamiltonian_matrix(ec, mat_h, mat_w)
408
409 ! Routine arguments
410 TYPE(et_cpl), POINTER :: ec
411 TYPE(cp_fm_type), INTENT(IN) :: mat_h, mat_w
412
413 INTEGER :: ic, ir, jc, jr, kc, kr, mc, mr, nc, nr
414 REAL(KIND=dp) :: xh
415
416! Routine name for debug purposes
417! Local variables
418
419 IF (.NOT. cp_fm_struct_equivalent(mat_h%matrix_struct, mat_w%matrix_struct)) THEN
420 cpabort('cannot reorder Hamiltonian, working-matrix structure is not equivalent')
421 END IF
422
423 ! Matrix-element reordering
424 nr = 1
425 ! Rows
426 DO ir = 1, ec%n_blocks
427 DO jr = 1, ec%block(ir)%n_atoms
428 DO kr = 1, ec%block(ir)%atom(jr)%n_ao
429 ! Columns
430 nc = 1
431 DO ic = 1, ec%n_blocks
432 DO jc = 1, ec%block(ic)%n_atoms
433 DO kc = 1, ec%block(ic)%atom(jc)%n_ao
434 mr = ec%block(ir)%atom(jr)%ao_pos + kr - 1
435 mc = ec%block(ic)%atom(jc)%ao_pos + kc - 1
436 CALL cp_fm_get_element(mat_h, nr, nc, xh)
437 CALL cp_fm_set_element(mat_w, nr, nc, xh)
438 nc = nc + 1
439 END DO
440 END DO
441 END DO
442 nr = nr + 1
443 END DO
444 END DO
445 END DO
446
447 ! Copy the reordered matrix to original data array
448 CALL cp_fm_to_fm(mat_w, mat_h)
449
450 END SUBROUTINE reorder_hamiltonian_matrix
451
452! **************************************************************************************************
453!> \brief calculated transformation matrix for basis-set orthogonalization (S^{-1/2})
454!> \param qs_env QuickStep environment containing all system data
455!> \param mat_t storage for the transformation matrix
456!> \param mat_i storage for the inversion transformation matrix
457!> \param mat_w working matrix of the same dimension
458!> \author Z. Futera (02.2017)
459! **************************************************************************************************
460 SUBROUTINE get_s_half_inv_matrix(qs_env, mat_t, mat_i, mat_w)
461
462 ! Routine arguments
463 TYPE(qs_environment_type), POINTER :: qs_env
464 TYPE(cp_fm_type), INTENT(INOUT) :: mat_t, mat_i
465 TYPE(cp_fm_type), INTENT(IN) :: mat_w
466
467 INTEGER :: n_deps
468 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mat_s
469 TYPE(scf_control_type), POINTER :: scf_cntrl
470
471! Routine name for debug purposes
472
473 NULLIFY (mat_s)
474 NULLIFY (scf_cntrl)
475
476 CALL get_qs_env(qs_env, matrix_s=mat_s)
477 CALL copy_dbcsr_to_fm(mat_s(1)%matrix, mat_t)
478 CALL copy_dbcsr_to_fm(mat_s(1)%matrix, mat_i)
479
480 ! Transformation S -> S^{-1/2}
481 CALL get_qs_env(qs_env, scf_control=scf_cntrl)
482 CALL cp_fm_power(mat_t, mat_w, -0.5_dp, scf_cntrl%eps_eigval, n_deps)
483 CALL cp_fm_power(mat_i, mat_w, +0.5_dp, scf_cntrl%eps_eigval, n_deps)
484 ! Sanity check
485 IF (n_deps /= 0) THEN
486 CALL cp_warn(__location__, &
487 "Overlap matrix exhibits linear dependencies. At least some "// &
488 "eigenvalues have been quenched.")
489 END IF
490
491 END SUBROUTINE get_s_half_inv_matrix
492
493! **************************************************************************************************
494!> \brief transform KS hamiltonian to orthogonalized block-separated basis set
495!> \param qs_env QuickStep environment containing all system data
496!> \param ec electronic coupling data structure
497!> \param fm_s full-matrix structure used for allocation of KS matrices
498!> \param mat_t storage for pointers to the transformed KS matrices
499!> \param mat_w working matrix of the same dimension
500!> \param n_ao total number of AO basis functions
501!> \param n_spins number of spin components
502!> \author Z. Futera (02.2017)
503! **************************************************************************************************
504 SUBROUTINE get_block_hamiltonian(qs_env, ec, fm_s, mat_t, mat_w, n_ao, n_spins)
505
506 ! Routine arguments
507 TYPE(qs_environment_type), POINTER :: qs_env
508 TYPE(et_cpl), POINTER :: ec
509 TYPE(cp_fm_struct_type), POINTER :: fm_s
510 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:), &
511 INTENT(OUT) :: mat_t
512 TYPE(cp_fm_type), INTENT(IN) :: mat_w
513 INTEGER :: n_ao, n_spins
514
515 INTEGER :: i
516 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mat_h
517
518! Routine name for debug purposes
519
520 NULLIFY (mat_h)
521
522 ! Memory allocation
523 ALLOCATE (mat_t(n_spins))
524
525 ! KS Hamiltonian
526 CALL get_qs_env(qs_env, matrix_ks=mat_h)
527 ! Transformation matrix
528 ALLOCATE (ec%m_transf, ec%m_transf_inv)
529 CALL cp_fm_create(matrix=ec%m_transf, matrix_struct=fm_s, &
530 name='S^(-1/2) TRANSFORMATION MATRIX')
531 CALL cp_fm_create(matrix=ec%m_transf_inv, matrix_struct=fm_s, &
532 name='S^(+1/2) TRANSFORMATION MATRIX')
533 CALL get_s_half_inv_matrix(qs_env, ec%m_transf, ec%m_transf_inv, mat_w)
534
535 DO i = 1, n_spins
536
537 ! Full-matrix format
538 CALL cp_fm_create(matrix=mat_t(i), matrix_struct=fm_s, &
539 name='KS HAMILTONIAN IN SEPARATED ORTHOGONALIZED BASIS SET')
540 CALL copy_dbcsr_to_fm(mat_h(i)%matrix, mat_t(i))
541
542 ! Transform KS Hamiltonian to the orthogonalized AO basis set
543 CALL parallel_gemm("N", "N", n_ao, n_ao, n_ao, 1.0_dp, ec%m_transf, mat_t(i), 0.0_dp, mat_w)
544 CALL parallel_gemm("N", "N", n_ao, n_ao, n_ao, 1.0_dp, mat_w, ec%m_transf, 0.0_dp, mat_t(i))
545
546 ! Reorder KS Hamiltonain elements to defined block structure
547 CALL reorder_hamiltonian_matrix(ec, mat_t(i), mat_w)
548
549 END DO
550
551 END SUBROUTINE get_block_hamiltonian
552
553! **************************************************************************************************
554!> \brief Diagonalize diagonal blocks of the KS hamiltonian in separated orthogonalized basis set
555!> \param qs_env QuickStep environment containing all system data
556!> \param ec electronic coupling data structure
557!> \param mat_h Hamiltonian in separated orthogonalized basis set
558!> \author Z. Futera (02.2017)
559! **************************************************************************************************
560 SUBROUTINE hamiltonian_block_diag(qs_env, ec, mat_h)
561
562 ! Routine arguments
563 TYPE(qs_environment_type), POINTER :: qs_env
564 TYPE(et_cpl), POINTER :: ec
565 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: mat_h
566
567 INTEGER :: i, j, k, l, n_spins, spin
568 REAL(KIND=dp), DIMENSION(:), POINTER :: vec_e
569 TYPE(cp_blacs_env_type), POINTER :: blacs_env
570 TYPE(cp_fm_struct_type), POINTER :: fm_s
571 TYPE(cp_fm_type) :: mat_u
572 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: dat
573 TYPE(mp_para_env_type), POINTER :: para_env
574
575! Routine name for debug purposes
576
577 NULLIFY (vec_e)
578 NULLIFY (blacs_env)
579 NULLIFY (para_env)
580 NULLIFY (fm_s)
581
582 ! Parallel environment
583 CALL get_qs_env(qs_env, para_env=para_env, blacs_env=blacs_env)
584
585 ! Storage for block sub-matrices
586 ALLOCATE (dat(ec%n_blocks))
587 cpassert(ALLOCATED(dat))
588
589 ! Storage for electronic states and couplings
590 n_spins = SIZE(mat_h)
591 DO i = 1, ec%n_blocks
592 ALLOCATE (ec%block(i)%mo(n_spins))
593 cpassert(ASSOCIATED(ec%block(i)%mo))
594 ALLOCATE (ec%block(i)%hab(n_spins, ec%n_blocks))
595 cpassert(ASSOCIATED(ec%block(i)%hab))
596 END DO
597
598 ! Spin components
599 DO spin = 1, n_spins
600
601 ! Diagonal blocks
602 j = 1
603 DO i = 1, ec%n_blocks
604
605 ! Memory allocation
606 CALL cp_fm_struct_create(fmstruct=fm_s, para_env=para_env, context=blacs_env, &
607 nrow_global=ec%block(i)%n_ao, ncol_global=ec%block(i)%n_ao)
608 CALL cp_fm_create(matrix=dat(i), matrix_struct=fm_s, &
609 name='H_KS DIAGONAL BLOCK')
610
611 ALLOCATE (vec_e(ec%block(i)%n_ao))
612 cpassert(ASSOCIATED(vec_e))
613
614 ! Copy block data
615 CALL cp_fm_to_fm_submat(mat_h(spin), &
616 dat(i), ec%block(i)%n_ao, &
617 ec%block(i)%n_ao, j, j, 1, 1)
618
619 ! Diagonalization
620 CALL cp_fm_create(matrix=mat_u, matrix_struct=fm_s, name='UNITARY MATRIX')
621 CALL choose_eigv_solver(dat(i), mat_u, vec_e)
622 CALL cp_fm_to_fm(mat_u, dat(i))
623
624 ! Save state energies / vectors
625 CALL create_block_mo_set(qs_env, ec, i, spin, mat_u, vec_e)
626
627 ! Clean memory
628 CALL cp_fm_struct_release(fmstruct=fm_s)
629 CALL cp_fm_release(matrix=mat_u)
630 DEALLOCATE (vec_e)
631
632 ! Off-set for next block
633 j = j + ec%block(i)%n_ao
634
635 END DO
636
637 ! Off-diagonal blocks
638 k = 1
639 DO i = 1, ec%n_blocks
640 l = 1
641 DO j = 1, ec%n_blocks
642 IF (i /= j) THEN
643
644 ! Memory allocation
645 CALL cp_fm_struct_create(fmstruct=fm_s, para_env=para_env, context=blacs_env, &
646 nrow_global=ec%block(i)%n_ao, ncol_global=ec%block(j)%n_ao)
647 CALL cp_fm_create(matrix=ec%block(i)%hab(spin, j), matrix_struct=fm_s, &
648 name='H_KS OFF-DIAGONAL BLOCK')
649
650 ! Copy block data
651 CALL cp_fm_to_fm_submat(mat_h(spin), &
652 ec%block(i)%hab(spin, j), ec%block(i)%n_ao, &
653 ec%block(j)%n_ao, k, l, 1, 1)
654
655 ! Transformation
656 CALL cp_fm_create(matrix=mat_u, matrix_struct=fm_s, name='FULL WORK MATRIX')
657 CALL parallel_gemm("T", "N", ec%block(i)%n_ao, ec%block(j)%n_ao, ec%block(i)%n_ao, &
658 1.0_dp, dat(i), ec%block(i)%hab(spin, j), 0.0_dp, mat_u)
659 CALL parallel_gemm("N", "N", ec%block(i)%n_ao, ec%block(j)%n_ao, ec%block(j)%n_ao, &
660 1.0_dp, mat_u, dat(j), 0.0_dp, ec%block(i)%hab(spin, j))
661
662 ! Clean memory
663 CALL cp_fm_struct_release(fmstruct=fm_s)
664 CALL cp_fm_release(matrix=mat_u)
665
666 END IF
667 ! Off-set for next block
668 l = l + ec%block(j)%n_ao
669 END DO
670 ! Off-set for next block
671 k = k + ec%block(i)%n_ao
672 END DO
673
674 ! Clean memory
675 IF (ALLOCATED(dat)) THEN
676 DO i = 1, SIZE(dat)
677 CALL cp_fm_release(dat(i))
678 END DO
679 END IF
680 END DO
681
682 ! Clean memory
683 IF (ALLOCATED(dat)) THEN
684 DEALLOCATE (dat)
685 END IF
686
687 END SUBROUTINE hamiltonian_block_diag
688
689! **************************************************************************************************
690!> \brief Return sum of selected squared MO coefficients
691!> \param blk_at list of atoms in the block
692!> \param mo array of MO sets
693!> \param id state index
694!> \param atom list of atoms for MO coefficient summing
695!> \return ...
696!> \author Z. Futera (02.2017)
697! **************************************************************************************************
698 FUNCTION get_mo_c2_sum(blk_at, mo, id, atom) RESULT(c2)
699
700 ! Routine arguments
701 TYPE(et_cpl_atom), DIMENSION(:), POINTER :: blk_at
702 TYPE(cp_fm_type), INTENT(IN) :: mo
703 INTEGER, INTENT(IN) :: id
704 INTEGER, DIMENSION(:), POINTER :: atom
705 REAL(KIND=dp) :: c2
706
707 INTEGER :: i, ir, j, k
708 LOGICAL :: found
709 REAL(KIND=dp) :: c
710
711! Returning value
712! Routine name for debug purposes
713! Local variables
714
715 ! initialization
716 c2 = 0.0d0
717
718 ! selected atoms
719 DO i = 1, SIZE(atom)
720
721 ! find atomic function offset
722 found = .false.
723 DO j = 1, SIZE(blk_at)
724 IF (blk_at(j)%id == atom(i)) THEN
725 found = .true.
726 EXIT
727 END IF
728 END DO
729
730 IF (.NOT. found) THEN
731 cpabort('MO-fraction atom ID not defined in the block')
732 END IF
733
734 ! sum MO coefficients from the atom
735 DO k = 1, blk_at(j)%n_ao
736 ir = blk_at(j)%ao_pos + k - 1
737 CALL cp_fm_get_element(mo, ir, id, c)
738 c2 = c2 + c*c
739 END DO
740
741 END DO
742
743 END FUNCTION get_mo_c2_sum
744
745! **************************************************************************************************
746!> \brief Print out specific MO coefficients
747!> \param output_unit unit number of the open output stream
748!> \param qs_env QuickStep environment containing all system data
749!> \param ec electronic coupling data structure
750!> \param blk atomic-block ID
751!> \param n_spins number of spin components
752!> \author Z. Futera (02.2017)
753! **************************************************************************************************
754 SUBROUTINE print_mo_coeff(output_unit, qs_env, ec, blk, n_spins)
755
756 ! Routine arguments
757 INTEGER, INTENT(IN) :: output_unit
758 TYPE(qs_environment_type), POINTER :: qs_env
759 TYPE(et_cpl), POINTER :: ec
760 INTEGER, INTENT(IN) :: blk, n_spins
761
762 INTEGER :: j, k, l, m, n, n_ao, n_mo
763 INTEGER, DIMENSION(:), POINTER :: list_at, list_mo
764 REAL(KIND=dp) :: c1, c2
765 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: mat_w
766 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
767 TYPE(section_vals_type), POINTER :: block_sec, print_sec
768
769! Routine name for debug purposes
770
771 NULLIFY (block_sec)
772 NULLIFY (print_sec)
773 NULLIFY (qs_kind_set)
774
775 ! Atomic block data
776 block_sec => section_vals_get_subs_vals(qs_env%input, &
777 'PROPERTIES%ET_COUPLING%PROJECTION%BLOCK')
778
779 print_sec => section_vals_get_subs_vals(block_sec, 'PRINT', i_rep_section=blk)
780
781 ! List of atoms
782 CALL section_vals_val_get(print_sec, keyword_name='MO_COEFF_ATOM', n_rep_val=n)
783
784 IF (n > 0) THEN
785
786 IF (output_unit > 0) THEN
787 WRITE (output_unit, '(/,T3,A/)') 'Block state fractions:'
788 END IF
789
790 ! Number of AO functions
791 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
792 CALL get_qs_kind_set(qs_kind_set, nsgf=n_ao)
793
794 ! MOs in orthonormal basis set
795 ALLOCATE (mat_w(n_spins))
796 DO j = 1, n_spins
797 n_mo = ec%block(blk)%n_ao
798 CALL cp_fm_create(matrix=mat_w(j), &
799 matrix_struct=ec%block(blk)%mo(j)%mo_coeff%matrix_struct, &
800 name='BLOCK MOs IN ORTHONORMAL BASIS SET')
801 CALL parallel_gemm("N", "N", n_ao, n_mo, n_ao, 1.0_dp, ec%m_transf_inv, &
802 ec%block(blk)%mo(j)%mo_coeff, 0.0_dp, mat_w(j))
803 END DO
804
805 DO j = 1, n
806 NULLIFY (list_at)
807 CALL section_vals_val_get(print_sec, keyword_name='MO_COEFF_ATOM', &
808 i_rep_val=j, i_vals=list_at)
809 IF (ASSOCIATED(list_at)) THEN
810
811 ! List of states
812 CALL section_vals_val_get(print_sec, keyword_name='MO_COEFF_ATOM_STATE', n_rep_val=m)
813
814 IF (m > 0) THEN
815
816 DO k = 1, m
817 NULLIFY (list_mo)
818 CALL section_vals_val_get(print_sec, keyword_name='MO_COEFF_ATOM_STATE', &
819 i_rep_val=k, i_vals=list_mo)
820 IF (ASSOCIATED(list_mo)) THEN
821
822 IF (j > 1) THEN
823 IF (output_unit > 0) THEN
824 WRITE (output_unit, *)
825 END IF
826 END IF
827
828 DO l = 1, SIZE(list_mo)
829
830 IF (n_spins > 1) THEN
831 c1 = get_mo_c2_sum(ec%block(blk)%atom, mat_w(1), &
832 list_mo(l), list_at)
833 c2 = get_mo_c2_sum(ec%block(blk)%atom, mat_w(2), &
834 list_mo(l), list_at)
835 IF (output_unit > 0) THEN
836 WRITE (output_unit, '(I5,A,I5,2F20.10)') j, ' /', list_mo(l), c1, c2
837 END IF
838 ELSE
839 c1 = get_mo_c2_sum(ec%block(blk)%atom, mat_w(1), &
840 list_mo(l), list_at)
841 IF (output_unit > 0) THEN
842 WRITE (output_unit, '(I5,A,I5,F20.10)') j, ' /', list_mo(l), c1
843 END IF
844 END IF
845
846 END DO
847
848 END IF
849 END DO
850
851 END IF
852
853 END IF
854 END DO
855
856 ! Clean memory
857 CALL cp_fm_release(mat_w)
858
859 END IF
860
861 END SUBROUTINE print_mo_coeff
862
863! **************************************************************************************************
864!> \brief Print out electronic states (MOs)
865!> \param output_unit unit number of the open output stream
866!> \param mo array of MO sets
867!> \param n_spins number of spin components
868!> \param label output label
869!> \param mx_mo_a maximum number of alpha states to print out
870!> \param mx_mo_b maximum number of beta states to print out
871!> \param fermi print out Fermi level and number of electrons
872!> \author Z. Futera (02.2017)
873! **************************************************************************************************
874 SUBROUTINE print_states(output_unit, mo, n_spins, label, mx_mo_a, mx_mo_b, fermi)
875
876 ! Routine arguments
877 INTEGER, INTENT(IN) :: output_unit
878 TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mo
879 INTEGER, INTENT(IN) :: n_spins
880 CHARACTER(LEN=*), INTENT(IN) :: label
881 INTEGER, INTENT(IN), OPTIONAL :: mx_mo_a, mx_mo_b
882 LOGICAL, INTENT(IN), OPTIONAL :: fermi
883
884 INTEGER :: i, mx_a, mx_b, n
885 LOGICAL :: prnt_fm
886
887! Routine name for debug purposes
888
889 prnt_fm = .false.
890 IF (PRESENT(fermi)) THEN
891 prnt_fm = fermi
892 END IF
893
894 IF (output_unit > 0) THEN
895
896 WRITE (output_unit, '(/,T3,A/)') 'State energies ('//trim(adjustl(label))//'):'
897
898 ! Spin-polarized calculation
899 IF (n_spins > 1) THEN
900
901 mx_a = mo(1)%nmo
902 IF (PRESENT(mx_mo_a)) THEN
903 mx_a = min(mo(1)%nmo, mx_mo_a)
904 END IF
905 mx_b = mo(2)%nmo
906 IF (PRESENT(mx_mo_b)) THEN
907 mx_b = min(mo(2)%nmo, mx_mo_b)
908 END IF
909 n = max(mx_a, mx_b)
910
911 DO i = 1, n
912 WRITE (output_unit, '(T3,I10)', advance='no') i
913 IF (i <= mx_a) THEN
914 WRITE (output_unit, '(2F12.4)', advance='no') &
915 mo(1)%occupation_numbers(i), mo(1)%eigenvalues(i)
916 ELSE
917 WRITE (output_unit, '(A)', advance='no') ' '
918 END IF
919 WRITE (output_unit, '(A)', advance='no') ' '
920 IF (i <= mx_b) THEN
921 WRITE (output_unit, '(2F12.4)') &
922 mo(2)%occupation_numbers(i), mo(2)%eigenvalues(i)
923 ELSE
924 WRITE (output_unit, *)
925 END IF
926 END DO
927
928 IF (prnt_fm) THEN
929 WRITE (output_unit, '(/,T3,I10,F24.4,I10,F19.4)') &
930 mo(1)%nelectron, mo(1)%mu, &
931 mo(2)%nelectron, mo(2)%mu
932 END IF
933
934 ! Spin-restricted calculation
935 ELSE
936
937 mx_a = mo(1)%nmo
938 IF (PRESENT(mx_mo_a)) THEN
939 mx_a = min(mo(1)%nmo, mx_mo_a)
940 END IF
941
942 DO i = 1, mx_a
943 WRITE (output_unit, '(T3,I10,2F12.4)') &
944 i, mo(1)%occupation_numbers(i), mo(1)%eigenvalues(i)
945 END DO
946
947 IF (prnt_fm) THEN
948 WRITE (output_unit, '(/,T3,I10,F24.4)') &
949 mo(1)%nelectron, mo(1)%mu
950 END IF
951
952 END IF
953
954 END IF
955
956 END SUBROUTINE print_states
957
958! **************************************************************************************************
959!> \brief Print out donor-acceptor state couplings
960!> \param ec_sec ...
961!> \param output_unit unit number of the open output stream
962!> \param logger ...
963!> \param ec electronic coupling data structure
964!> \param mo ...
965!> \author Z. Futera (02.2017)
966! **************************************************************************************************
967 SUBROUTINE print_couplings(ec_sec, output_unit, logger, ec, mo)
968
969 ! Routine arguments
970 TYPE(section_vals_type), POINTER :: ec_sec
971 INTEGER, INTENT(IN) :: output_unit
972 TYPE(cp_logger_type), POINTER :: logger
973 TYPE(et_cpl), POINTER :: ec
974 TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mo
975
976 CHARACTER(LEN=default_path_length) :: filename, my_pos, title
977 INTEGER :: i, j, k, l, n_states(2), nc, nr, nspins, &
978 unit_nr
979 LOGICAL :: append
980 REAL(KIND=dp), DIMENSION(:, :), POINTER :: w1, w2
981 TYPE(section_vals_type), POINTER :: print_key
982
983! Routine name for debug purposes
984! Local variables
985
986 n_states = 0
987 DO i = 1, SIZE(mo)
988 n_states(i) = mo(i)%nmo
989 END DO
990 nspins = 1
991 IF (n_states(2) > 0) nspins = 2
992
993 print_key => section_vals_get_subs_vals(section_vals=ec_sec, &
994 subsection_name="PRINT%COUPLINGS")
995
996 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), &
997 cp_p_file)) THEN
998
999 my_pos = "REWIND"
1000 append = section_get_lval(print_key, "APPEND")
1001 IF (append) THEN
1002 my_pos = "APPEND"
1003 END IF
1004
1005 IF (output_unit > 0) THEN
1006 WRITE (output_unit, '(/,T3,A/)') 'Printing coupling elements to output files'
1007 END IF
1008
1009 DO i = 1, ec%n_blocks
1010 DO j = i + 1, ec%n_blocks
1011
1012 nr = ec%block(i)%hab(1, j)%matrix_struct%nrow_global
1013 nc = ec%block(i)%hab(1, j)%matrix_struct%ncol_global
1014
1015 ALLOCATE (w1(nr, nc))
1016 cpassert(ASSOCIATED(w1))
1017 CALL cp_fm_get_submatrix(ec%block(i)%hab(1, j), w1)
1018 IF (nspins > 1) THEN
1019 ALLOCATE (w2(nr, nc))
1020 cpassert(ASSOCIATED(w2))
1021 CALL cp_fm_get_submatrix(ec%block(i)%hab(2, j), w2)
1022 END IF
1023
1024 IF (output_unit > 0) THEN
1025
1026 WRITE (filename, '(a5,I1.1,a1,I1.1)') "ET_BL_", i, "-", j
1027 unit_nr = cp_print_key_unit_nr(logger, ec_sec, "PRINT%COUPLINGS", extension=".elcoup", &
1028 middle_name=trim(filename), file_position=my_pos, log_filename=.false.)
1029
1030 WRITE (title, *) 'Coupling elements [meV] between blocks:', i, j
1031
1032 WRITE (unit_nr, *) trim(title)
1033 IF (nspins > 1) THEN
1034 WRITE (unit_nr, '(T3,A8,T13,A8,T28,A,A)') 'State A', 'State B', 'Coupling spin 1', ' Coupling spin 2'
1035 ELSE
1036 WRITE (unit_nr, '(T3,A8,T13,A8,T28,A)') 'State A', 'State B', 'Coupling'
1037 END IF
1038
1039 DO k = 1, min(ec%block(i)%n_ao, n_states(1))
1040 DO l = 1, min(ec%block(j)%n_ao, n_states(1))
1041
1042 IF (nspins > 1) THEN
1043
1044 WRITE (unit_nr, '(T3,I5,T13,I5,T22,E20.6)', advance='no') &
1045 k, l, w1(k, l)*evolt*1000.0_dp
1046 IF ((k <= n_states(2)) .AND. (l <= n_states(2))) THEN
1047 WRITE (unit_nr, '(E20.6)') &
1048 w2(k, l)*evolt*1000.0_dp
1049 ELSE
1050 WRITE (unit_nr, *)
1051 END IF
1052
1053 ELSE
1054
1055 WRITE (unit_nr, '(T3,I5,T13,I5,T22,E20.6)') &
1056 k, l, w1(k, l)*evolt*1000.0_dp
1057 END IF
1058
1059 END DO
1060 WRITE (unit_nr, *)
1061 END DO
1062 CALL cp_print_key_finished_output(unit_nr, logger, ec_sec, "PRINT%COUPLINGS")
1063
1064 END IF
1065
1066 IF (ASSOCIATED(w1)) DEALLOCATE (w1)
1067 IF (ASSOCIATED(w2)) DEALLOCATE (w2)
1068
1069 END DO
1070 END DO
1071
1072 END IF
1073 END SUBROUTINE print_couplings
1074
1075! **************************************************************************************************
1076!> \brief Normalize set of MO vectors
1077!> \param qs_env QuickStep environment containing all system data
1078!> \param mo storage for the MO data set
1079!> \param n_ao number of AO basis functions
1080!> \param n_mo number of block states
1081!> \author Z. Futera (02.2017)
1082! **************************************************************************************************
1083 SUBROUTINE normalize_mo_vectors(qs_env, mo, n_ao, n_mo)
1084
1085 ! Routine arguments
1086 TYPE(qs_environment_type), POINTER :: qs_env
1087 TYPE(mo_set_type), POINTER :: mo
1088 INTEGER, INTENT(IN) :: n_ao, n_mo
1089
1090 REAL(KIND=dp), DIMENSION(:), POINTER :: vec_t
1091 TYPE(cp_blacs_env_type), POINTER :: blacs_env
1092 TYPE(cp_fm_struct_type), POINTER :: fm_s
1093 TYPE(cp_fm_type) :: mat_sc, mat_t
1094 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mat_s
1095 TYPE(mp_para_env_type), POINTER :: para_env
1096
1097! Routine name for debug purposes
1098
1099 ! Initialization
1100 NULLIFY (blacs_env)
1101 NULLIFY (para_env)
1102 NULLIFY (fm_s)
1103 NULLIFY (mat_s)
1104 NULLIFY (vec_t)
1105
1106 ! Overlap matrix
1107 CALL get_qs_env(qs_env, matrix_s=mat_s)
1108
1109 ! Calculate S*C product
1110 CALL cp_fm_create(matrix=mat_sc, matrix_struct=mo%mo_coeff%matrix_struct, &
1111 name='S*C PRODUCT MATRIX')
1112 CALL cp_dbcsr_sm_fm_multiply(mat_s(1)%matrix, mo%mo_coeff, mat_sc, n_mo)
1113
1114 ! Calculate C^T*S*C
1115 CALL get_qs_env(qs_env, para_env=para_env, blacs_env=blacs_env)
1116 CALL cp_fm_struct_create(fmstruct=fm_s, para_env=para_env, context=blacs_env, &
1117 nrow_global=n_mo, ncol_global=n_mo)
1118 CALL cp_fm_create(matrix=mat_t, matrix_struct=fm_s, &
1119 name='C^T*S*C OVERLAP PRODUCT MATRIX')
1120 CALL parallel_gemm('T', 'N', n_mo, n_mo, n_ao, 1.0_dp, mo%mo_coeff, mat_sc, 0.0_dp, mat_t)
1121
1122 ! Normalization
1123 ALLOCATE (vec_t(n_mo))
1124 cpassert(ASSOCIATED(vec_t))
1125 CALL cp_fm_vectorssum(mat_t, vec_t)
1126 vec_t = 1.0_dp/sqrt(vec_t)
1127 CALL cp_fm_column_scale(mo%mo_coeff, vec_t)
1128
1129 ! Clean memory
1130 CALL cp_fm_struct_release(fmstruct=fm_s)
1131 CALL cp_fm_release(matrix=mat_sc)
1132 CALL cp_fm_release(matrix=mat_t)
1133 IF (ASSOCIATED(vec_t)) THEN
1134 DEALLOCATE (vec_t)
1135 END IF
1136
1137 END SUBROUTINE normalize_mo_vectors
1138
1139! **************************************************************************************************
1140!> \brief Transform block MO coefficients to original non-orthogonal basis set and save them
1141!> \param qs_env QuickStep environment containing all system data
1142!> \param ec electronic coupling data structure
1143!> \param id block ID
1144!> \param mo storage for the MO data set
1145!> \param mat_u matrix of the block states
1146!> \param n_ao number of AO basis functions
1147!> \param n_mo number of block states
1148!> \author Z. Futera (02.2017)
1149! **************************************************************************************************
1150 SUBROUTINE set_mo_coefficients(qs_env, ec, id, mo, mat_u, n_ao, n_mo)
1151
1152 ! Routine arguments
1153 TYPE(qs_environment_type), POINTER :: qs_env
1154 TYPE(et_cpl), POINTER :: ec
1155 INTEGER, INTENT(IN) :: id
1156 TYPE(mo_set_type), POINTER :: mo
1157 TYPE(cp_fm_type), INTENT(IN) :: mat_u
1158 INTEGER, INTENT(IN) :: n_ao, n_mo
1159
1160 INTEGER :: ic, ir, jc, jr, mr, nc, nr
1161 REAL(KIND=dp) :: xu
1162 TYPE(cp_fm_type) :: mat_w
1163
1164! Routine name for debug purposes
1165! Local variables
1166
1167 ! Working matrix
1168 CALL cp_fm_create(matrix=mat_w, matrix_struct=mo%mo_coeff%matrix_struct, &
1169 name='BLOCK MO-TRANSFORMATION WORKING MATRIX')
1170 CALL cp_fm_set_all(mat_w, 0.0_dp)
1171
1172 ! Matrix-element reordering
1173 nr = 1
1174 ! Rows
1175 DO ir = 1, ec%block(id)%n_atoms
1176 DO jr = 1, ec%block(id)%atom(ir)%n_ao
1177 ! Columns
1178 nc = 1
1179 DO ic = 1, ec%block(id)%n_atoms
1180 DO jc = 1, ec%block(id)%atom(ic)%n_ao
1181 mr = ec%block(id)%atom(ir)%ao_pos + jr - 1
1182 CALL cp_fm_get_element(mat_u, nr, nc, xu)
1183 CALL cp_fm_set_element(mat_w, mr, nc, xu)
1184 nc = nc + 1
1185 END DO
1186 END DO
1187 nr = nr + 1
1188 END DO
1189 END DO
1190
1191 ! Transformation to original non-orthogonal basis set
1192 CALL parallel_gemm("N", "N", n_ao, n_mo, n_ao, 1.0_dp, ec%m_transf, mat_w, 0.0_dp, mo%mo_coeff)
1193 CALL normalize_mo_vectors(qs_env, mo, n_ao, n_mo)
1194
1195 ! Clean memory
1196 CALL cp_fm_release(matrix=mat_w)
1197
1198 END SUBROUTINE set_mo_coefficients
1199
1200! **************************************************************************************************
1201!> \brief Creates MO set corresponding to one atomic data block
1202!> \param qs_env QuickStep environment containing all system data
1203!> \param ec electronic coupling data structure
1204!> \param id block ID
1205!> \param spin spin component
1206!> \param mat_u matrix of the block states
1207!> \param vec_e array of the block eigenvalues
1208!> \author Z. Futera (02.2017)
1209! **************************************************************************************************
1210 SUBROUTINE create_block_mo_set(qs_env, ec, id, spin, mat_u, vec_e)
1211
1212 ! Routine arguments
1213 TYPE(qs_environment_type), POINTER :: qs_env
1214 TYPE(et_cpl), POINTER :: ec
1215 INTEGER, INTENT(IN) :: id, spin
1216 TYPE(cp_fm_type), INTENT(IN) :: mat_u
1217 REAL(KIND=dp), DIMENSION(:), POINTER :: vec_e
1218
1219 INTEGER :: n_ao, n_el, n_mo
1220 REAL(KIND=dp) :: mx_occ
1221 TYPE(cp_blacs_env_type), POINTER :: blacs_env
1222 TYPE(cp_fm_struct_type), POINTER :: fm_s
1223 TYPE(dft_control_type), POINTER :: dft_cntrl
1224 TYPE(mo_set_type), POINTER :: mo
1225 TYPE(mp_para_env_type), POINTER :: para_env
1226 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1227 TYPE(scf_control_type), POINTER :: scf_cntrl
1228
1229! Routine name for debug purposes
1230
1231 NULLIFY (blacs_env)
1232 NULLIFY (dft_cntrl)
1233 NULLIFY (para_env)
1234 NULLIFY (qs_kind_set)
1235 NULLIFY (fm_s)
1236 NULLIFY (scf_cntrl)
1237 NULLIFY (mo)
1238
1239 ! Number of basis functions
1240 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
1241 CALL get_qs_kind_set(qs_kind_set, nsgf=n_ao)
1242
1243 ! Number of states
1244 n_mo = mat_u%matrix_struct%nrow_global
1245 IF (n_mo /= mat_u%matrix_struct%ncol_global) THEN
1246 cpabort('block state matrix is not square')
1247 END IF
1248 IF (n_mo /= SIZE(vec_e)) THEN
1249 cpabort('inconsistent number of states / energies')
1250 END IF
1251
1252 ! Maximal occupancy
1253 CALL get_qs_env(qs_env, dft_control=dft_cntrl)
1254 mx_occ = 2.0_dp
1255 IF (dft_cntrl%nspins > 1) THEN
1256 mx_occ = 1.0_dp
1257 END IF
1258
1259 ! Number of electrons
1260 n_el = ec%block(id)%n_electrons
1261 IF (dft_cntrl%nspins > 1) THEN
1262 n_el = n_el/2
1263 IF (mod(ec%block(id)%n_electrons, 2) == 1) THEN
1264 IF (spin == 1) THEN
1265 n_el = n_el + 1
1266 END IF
1267 END IF
1268 END IF
1269
1270 ! Memory allocation (Use deallocate_mo_set to prevent accidental memory leaks)
1271 CALL deallocate_mo_set(ec%block(id)%mo(spin))
1272 CALL allocate_mo_set(ec%block(id)%mo(spin), n_ao, n_mo, n_el, real(n_el, dp), mx_occ, 0.0_dp)
1273 mo => ec%block(id)%mo(spin)
1274
1275 ! State energies
1276 ALLOCATE (mo%eigenvalues(n_mo))
1277 cpassert(ASSOCIATED(mo%eigenvalues))
1278 mo%eigenvalues = vec_e
1279
1280 ! States coefficients
1281 CALL get_qs_env(qs_env, para_env=para_env, blacs_env=blacs_env)
1282 CALL cp_fm_struct_create(fmstruct=fm_s, para_env=para_env, context=blacs_env, &
1283 nrow_global=n_ao, ncol_global=n_mo)
1284 ALLOCATE (mo%mo_coeff)
1285 CALL cp_fm_create(matrix=mo%mo_coeff, matrix_struct=fm_s, name='BLOCK STATES')
1286
1287 ! Transform MO coefficients to original non-orthogonal basis set
1288 CALL set_mo_coefficients(qs_env, ec, id, mo, mat_u, n_ao, n_mo)
1289
1290 ! Occupancies
1291 ALLOCATE (mo%occupation_numbers(n_mo))
1292 cpassert(ASSOCIATED(mo%occupation_numbers))
1293 mo%occupation_numbers = 0.0_dp
1294
1295 IF (n_el > 0) THEN
1296 CALL get_qs_env(qs_env, scf_control=scf_cntrl)
1297 CALL set_mo_occupation(mo_set=mo, smear=scf_cntrl%smear)
1298 END IF
1299
1300 ! Clean memory
1301 CALL cp_fm_struct_release(fmstruct=fm_s)
1302
1303 END SUBROUTINE create_block_mo_set
1304
1305! **************************************************************************************************
1306!> \brief save given electronic state to cube files
1307!> \param qs_env QuickStep environment containing all system data
1308!> \param logger output logger
1309!> \param input input-file block print setting section
1310!> \param mo electronic states data
1311!> \param ib block ID
1312!> \param im state ID
1313!> \param is spin ID
1314!> \author Z. Futera (02.2017)
1315! **************************************************************************************************
1316 SUBROUTINE save_mo_cube(qs_env, logger, input, mo, ib, im, is)
1317
1318 ! Routine arguments
1319 TYPE(qs_environment_type), POINTER :: qs_env
1320 TYPE(cp_logger_type), POINTER :: logger
1321 TYPE(section_vals_type), POINTER :: input
1322 TYPE(mo_set_type), POINTER :: mo
1323 INTEGER, INTENT(IN) :: ib, im, is
1324
1325 CHARACTER(LEN=default_path_length) :: filename
1326 CHARACTER(LEN=default_string_length) :: title
1327 INTEGER :: unit_nr
1328 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1329 TYPE(cell_type), POINTER :: cell
1330 TYPE(dft_control_type), POINTER :: dft_control
1331 TYPE(particle_list_type), POINTER :: particles
1332 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1333 TYPE(pw_c1d_gs_type) :: wf_g
1334 TYPE(pw_env_type), POINTER :: pw_env
1335 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1336 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1337 TYPE(pw_r3d_rs_type) :: wf_r
1338 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1339 TYPE(qs_subsys_type), POINTER :: subsys
1340
1341! Routine name for debug purposes
1342
1343 ! Initialization
1344 NULLIFY (particles)
1345 NULLIFY (subsys)
1346
1347 NULLIFY (pw_env)
1348 NULLIFY (pw_pools)
1349 NULLIFY (auxbas_pw_pool)
1350
1351 NULLIFY (atomic_kind_set)
1352 NULLIFY (cell)
1353 NULLIFY (dft_control)
1354 NULLIFY (particle_set)
1355 NULLIFY (qs_kind_set)
1356
1357 ! Name of the cube file
1358 WRITE (filename, '(A4,I1.1,A1,I5.5,A1,I1.1)') 'BWF_', ib, '_', im, '_', is
1359 ! Open the file
1360 unit_nr = cp_print_key_unit_nr(logger, input, 'MO_CUBES', extension='.cube', &
1361 middle_name=trim(filename), file_position='REWIND', log_filename=.false.)
1362 ! Title of the file
1363 WRITE (title, *) 'WAVEFUNCTION ', im, ' block ', ib, ' spin ', is
1364
1365 ! List of all atoms
1366 CALL get_qs_env(qs_env, subsys=subsys)
1367 CALL qs_subsys_get(subsys, particles=particles)
1368
1369 ! Grids for wavefunction
1370 CALL get_qs_env(qs_env, pw_env=pw_env)
1371 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1372 CALL auxbas_pw_pool%create_pw(wf_r)
1373 CALL auxbas_pw_pool%create_pw(wf_g)
1374
1375 ! Calculate the grid values
1376 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1377 cell=cell, dft_control=dft_control, particle_set=particle_set)
1378 CALL calculate_wavefunction(mo%mo_coeff, im, wf_r, wf_g, atomic_kind_set, &
1379 qs_kind_set, cell, dft_control, particle_set, pw_env)
1380 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, &
1381 stride=section_get_ivals(input, 'MO_CUBES%STRIDE'))
1382
1383 ! Close file
1384 CALL cp_print_key_finished_output(unit_nr, logger, input, 'MO_CUBES')
1385
1386 ! Clean memory
1387 CALL auxbas_pw_pool%give_back_pw(wf_r)
1388 CALL auxbas_pw_pool%give_back_pw(wf_g)
1389
1390 END SUBROUTINE save_mo_cube
1391
1392! **************************************************************************************************
1393!> \brief save specified electronic states to cube files
1394!> \param qs_env QuickStep environment containing all system data
1395!> \param ec electronic coupling data structure
1396!> \param n_spins number of spin states
1397!> \author Z. Futera (02.2017)
1398! **************************************************************************************************
1399 SUBROUTINE save_el_states(qs_env, ec, n_spins)
1400
1401 ! Routine arguments
1402 TYPE(qs_environment_type), POINTER :: qs_env
1403 TYPE(et_cpl), POINTER :: ec
1404 INTEGER, INTENT(IN) :: n_spins
1405
1406 INTEGER :: i, j, k, l, n
1407 INTEGER, DIMENSION(:), POINTER :: list
1408 TYPE(cp_logger_type), POINTER :: logger
1409 TYPE(mo_set_type), POINTER :: mo
1410 TYPE(section_vals_type), POINTER :: block_sec, mo_sec, print_sec
1411
1412! Routine name for debug purposes
1413
1414 NULLIFY (logger)
1415 NULLIFY (block_sec)
1416 NULLIFY (print_sec)
1417 NULLIFY (mo_sec)
1418
1419 ! Output logger
1420 logger => cp_get_default_logger()
1421 block_sec => section_vals_get_subs_vals(qs_env%input, &
1422 'PROPERTIES%ET_COUPLING%PROJECTION%BLOCK')
1423
1424 ! Print states of all blocks
1425 DO i = 1, ec%n_blocks
1426
1427 print_sec => section_vals_get_subs_vals(block_sec, 'PRINT', i_rep_section=i)
1428
1429 ! Check if the print input section is active
1430 IF (btest(cp_print_key_should_output(logger%iter_info, &
1431 print_sec, 'MO_CUBES'), cp_p_file)) THEN
1432
1433 mo_sec => section_vals_get_subs_vals(print_sec, 'MO_CUBES')
1434
1435 ! Spin states
1436 DO j = 1, n_spins
1437
1438 mo => ec%block(i)%mo(j)
1439
1440 CALL section_vals_val_get(mo_sec, keyword_name='MO_LIST', n_rep_val=n)
1441
1442 ! List of specific MOs
1443 IF (n > 0) THEN
1444
1445 DO k = 1, n
1446 NULLIFY (list)
1447 CALL section_vals_val_get(mo_sec, keyword_name='MO_LIST', &
1448 i_rep_val=k, i_vals=list)
1449 IF (ASSOCIATED(list)) THEN
1450 DO l = 1, SIZE(list)
1451 CALL save_mo_cube(qs_env, logger, print_sec, mo, i, list(l), j)
1452 END DO
1453 END IF
1454 END DO
1455
1456 ! Frontier MOs
1457 ELSE
1458
1459 ! Occupied states
1460 CALL section_vals_val_get(mo_sec, keyword_name='NHOMO', i_val=n)
1461
1462 IF (n > 0) THEN
1463 DO k = max(1, mo%homo - n + 1), mo%homo
1464 CALL save_mo_cube(qs_env, logger, print_sec, mo, i, k, j)
1465 END DO
1466 END IF
1467
1468 ! Unoccupied states
1469 CALL section_vals_val_get(mo_sec, keyword_name='NLUMO', i_val=n)
1470
1471 IF (n > 0) THEN
1472 DO k = mo%lfomo, min(mo%lfomo + n - 1, mo%nmo)
1473 CALL save_mo_cube(qs_env, logger, print_sec, mo, i, k, j)
1474 END DO
1475 END IF
1476
1477 END IF
1478
1479 END DO
1480
1481 END IF
1482
1483 END DO
1484
1485 END SUBROUTINE save_el_states
1486
1487! **************************************************************************************************
1488!> \brief calculates the electron transfer coupling elements by projection-operator approach
1489!> Kondov et al. J.Phys.Chem.C 2007, 111, 11970-11981
1490!> \param qs_env QuickStep environment containing all system data
1491!> \author Z. Futera (02.2017)
1492! **************************************************************************************************
1493 SUBROUTINE calc_et_coupling_proj(qs_env)
1494
1495 ! Routine arguments
1496 TYPE(qs_environment_type), POINTER :: qs_env
1497
1498 INTEGER :: i, j, k, n_ao, n_atoms, output_unit
1499 LOGICAL :: do_kp, master
1500 TYPE(cp_blacs_env_type), POINTER :: blacs_env
1501 TYPE(cp_fm_struct_type), POINTER :: fm_s
1502 TYPE(cp_fm_type) :: mat_w
1503 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: mat_h
1504 TYPE(cp_logger_type), POINTER :: logger
1505 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks, mo_der
1506 TYPE(dft_control_type), POINTER :: dft_cntrl
1507 TYPE(et_cpl), POINTER :: ec
1508 TYPE(kpoint_type), POINTER :: kpoints
1509 TYPE(mo_set_type), DIMENSION(:), POINTER :: mo
1510 TYPE(mp_para_env_type), POINTER :: para_env
1511 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1512 TYPE(scf_control_type), POINTER :: scf_control
1513 TYPE(section_vals_type), POINTER :: et_proj_sec
1514
1515! Routine name for debug purposes
1516
1517 ! Pointer initialization
1518 NULLIFY (logger)
1519
1520 NULLIFY (blacs_env)
1521 NULLIFY (para_env)
1522 NULLIFY (dft_cntrl)
1523 NULLIFY (kpoints)
1524 NULLIFY (qs_kind_set)
1525 NULLIFY (et_proj_sec)
1526
1527 NULLIFY (fm_s)
1528 NULLIFY (ks, mo_der)
1529
1530 NULLIFY (ec)
1531
1532 ! Reference
1533 CALL cite_reference(futera2017)
1534
1535 ! Stream for output to LOG file
1536 logger => cp_get_default_logger()
1537
1538 et_proj_sec => section_vals_get_subs_vals(qs_env%input, 'PROPERTIES%ET_COUPLING%PROJECTION')
1539
1540 output_unit = cp_print_key_unit_nr(logger, et_proj_sec, &
1541 'PROGRAM_RUN_INFO', extension='.log')
1542
1543 ! Parallel calculation - master thread
1544 master = .false.
1545 IF (output_unit > 0) THEN
1546 master = .true.
1547 END IF
1548
1549 ! Header
1550 IF (master) THEN
1551 WRITE (output_unit, '(/,T2,A)') &
1552 '!-----------------------------------------------------------------------------!'
1553 WRITE (output_unit, '(T17,A)') &
1554 'Electronic coupling - Projection-operator method'
1555 END IF
1556
1557 ! Main data structure
1558 ALLOCATE (ec)
1559 cpassert(ASSOCIATED(ec))
1560 CALL set_block_data(qs_env, et_proj_sec, ec)
1561
1562 ! Number of atoms and AO functions
1563 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, natom=n_atoms)
1564 CALL get_qs_kind_set(qs_kind_set, nsgf=n_ao)
1565
1566 ! Print out info about system partitioning
1567 IF (master) THEN
1568
1569 WRITE (output_unit, '(/,T3,A,I10)') &
1570 'Number of atoms = ', n_atoms
1571 WRITE (output_unit, '(T3,A,I10)') &
1572 'Number of fragments = ', ec%n_blocks
1573 WRITE (output_unit, '(T3,A,I10)') &
1574 'Number of fragment atoms = ', ec%n_atoms
1575 WRITE (output_unit, '(T3,A,I10)') &
1576 'Number of unassigned atoms = ', n_atoms - ec%n_atoms
1577 WRITE (output_unit, '(T3,A,I10)') &
1578 'Number of AO basis functions = ', n_ao
1579
1580 DO i = 1, ec%n_blocks
1581
1582 WRITE (output_unit, '(/,T3,A,I0,A)') &
1583 'Block ', i, ':'
1584 WRITE (output_unit, '(T3,A,I10)') &
1585 'Number of block atoms = ', ec%block(i)%n_atoms
1586 WRITE (output_unit, '(T3,A,I10)') &
1587 'Number of block electrons = ', ec%block(i)%n_electrons
1588 WRITE (output_unit, '(T3,A,I10)') &
1589 'Number of block AO functions = ', ec%block(i)%n_ao
1590
1591 IF (ec%block(i)%n_atoms < 10) THEN
1592
1593 WRITE (output_unit, '(T3,A,10I6)') &
1594 'Block atom IDs = ', &
1595 (ec%block(i)%atom(j)%id, j=1, ec%block(i)%n_atoms)
1596
1597 ELSE
1598
1599 WRITE (output_unit, '(T3,A)') 'Block atom IDs ='
1600 DO j = 1, ec%block(i)%n_atoms/10
1601 WRITE (output_unit, '(T3,A,10I6)') ' ', &
1602 (ec%block(i)%atom((j - 1)*10 + k)%id, k=1, 10)
1603 END DO
1604 IF (mod(ec%block(i)%n_atoms, 10) /= 0) THEN
1605 WRITE (output_unit, '(T3,A,10I6)') ' ', &
1606 (ec%block(i)%atom(k + 10*(ec%block(i)%n_atoms/10))%id, &
1607 k=1, mod(ec%block(i)%n_atoms, 10))
1608 END IF
1609
1610 END IF
1611
1612 END DO
1613
1614 END IF
1615
1616 ! Full matrix data structure
1617 CALL get_qs_env(qs_env, para_env=para_env, blacs_env=blacs_env)
1618 CALL cp_fm_struct_create(fmstruct=fm_s, para_env=para_env, context=blacs_env, &
1619 nrow_global=n_ao, ncol_global=n_ao)
1620 CALL cp_fm_create(matrix=mat_w, matrix_struct=fm_s, name='FULL WORK MATRIX')
1621
1622 ! Spin polarization / K-point sampling
1623 CALL get_qs_env(qs_env, dft_control=dft_cntrl, do_kpoints=do_kp)
1624 CALL get_qs_env(qs_env, mos=mo, matrix_ks=ks, mo_derivs=mo_der, scf_control=scf_control)
1625 CALL make_mo_eig(mo, dft_cntrl%nspins, ks, scf_control, mo_der)
1626
1627 IF (do_kp) THEN
1628 cpabort('ET_COUPLING not implemented with kpoints')
1629 ELSE
1630 ! no K-points
1631 IF (master) THEN
1632 WRITE (output_unit, '(T3,A)') 'No K-point sampling (Gamma point only)'
1633 END IF
1634 END IF
1635
1636 IF (dft_cntrl%nspins == 2) THEN
1637
1638 IF (master) THEN
1639 WRITE (output_unit, '(/,T3,A)') 'Spin-polarized calculation'
1640 END IF
1641
1642 !<--- Open shell / No K-points ------------------------------------------------>!
1643
1644 ! State eneries of the whole system
1645 IF (mo(1)%nao /= mo(2)%nao) THEN
1646 cpabort('different number of alpha/beta AO basis functions')
1647 END IF
1648 IF (master) THEN
1649 WRITE (output_unit, '(/,T3,A,I10)') &
1650 'Number of AO basis functions = ', mo(1)%nao
1651 WRITE (output_unit, '(T3,A,I10)') &
1652 'Number of alpha states = ', mo(1)%nmo
1653 WRITE (output_unit, '(T3,A,I10)') &
1654 'Number of beta states = ', mo(2)%nmo
1655 END IF
1656 CALL print_states(output_unit, mo, dft_cntrl%nspins, 'the whole system', fermi=.true.)
1657 CALL set_fermi(ec, mo(1)%mu, mo(2)%mu)
1658
1659 ! KS Hamiltonian
1660 CALL get_block_hamiltonian(qs_env, ec, fm_s, mat_h, mat_w, n_ao, dft_cntrl%nspins)
1661
1662 ! Block diagonization
1663 CALL hamiltonian_block_diag(qs_env, ec, mat_h)
1664
1665 ! Print out energies and couplings
1666 DO i = 1, ec%n_blocks
1667 IF (output_unit > 0) THEN
1668 CALL print_states(output_unit, ec%block(i)%mo, dft_cntrl%nspins, &
1669 'block '//trim(adjustl(cp_to_string(i)))//' states', &
1670 mx_mo_a=mo(1)%nmo, mx_mo_b=mo(2)%nmo, fermi=.true.)
1671 END IF
1672 CALL print_mo_coeff(output_unit, qs_env, ec, i, dft_cntrl%nspins)
1673 END DO
1674
1675 CALL print_couplings(et_proj_sec, output_unit, logger, ec, mo)
1676
1677 ELSE
1678
1679 IF (master) THEN
1680 WRITE (output_unit, '(/,T3,A)') 'Spin-restricted calculation'
1681 END IF
1682
1683 !<--- Close shell / No K-points ----------------------------------------------->!
1684
1685 ! State eneries of the whole system
1686 IF (master) THEN
1687 WRITE (output_unit, '(/,T3,A,I10)') &
1688 'Number of AO basis functions = ', mo(1)%nao
1689 WRITE (output_unit, '(T3,A,I10)') &
1690 'Number of states = ', mo(1)%nmo
1691 END IF
1692 CALL print_states(output_unit, mo, dft_cntrl%nspins, 'the whole system', fermi=.true.)
1693 CALL set_fermi(ec, mo(1)%mu)
1694
1695 ! KS Hamiltonian
1696 CALL get_block_hamiltonian(qs_env, ec, fm_s, mat_h, mat_w, n_ao, dft_cntrl%nspins)
1697
1698 ! Block diagonization
1699 CALL hamiltonian_block_diag(qs_env, ec, mat_h)
1700
1701 ! Print out energies and couplings
1702 DO i = 1, ec%n_blocks
1703 IF (output_unit > 0) THEN
1704 CALL print_states(output_unit, ec%block(i)%mo, dft_cntrl%nspins, &
1705 'block '//trim(adjustl(cp_to_string(i)))//' states', &
1706 mx_mo_a=mo(1)%nmo, fermi=.true.)
1707 END IF
1708 CALL print_mo_coeff(output_unit, qs_env, ec, i, dft_cntrl%nspins)
1709 END DO
1710
1711 CALL print_couplings(et_proj_sec, output_unit, logger, ec, mo)
1712
1713 END IF
1714
1715 ! Save electronic states
1716 CALL save_el_states(qs_env, ec, dft_cntrl%nspins)
1717
1718 ! Footer
1719 IF (master) WRITE (output_unit, '(/,T2,A)') &
1720 '!-----------------------------------------------------------------------------!'
1721
1722 ! Clean memory
1723 CALL cp_fm_struct_release(fmstruct=fm_s)
1724 CALL cp_fm_release(matrix=mat_w)
1725 IF (ALLOCATED(mat_h)) THEN
1726 DO i = 1, SIZE(mat_h)
1727 CALL cp_fm_release(matrix=mat_h(i))
1728 END DO
1729 DEALLOCATE (mat_h)
1730 END IF
1731 CALL release_ec_data(ec)
1732
1733 ! Close output stream
1734 CALL cp_print_key_finished_output(output_unit, logger, et_proj_sec, 'PROGRAM_RUN_INFO')
1735
1736 END SUBROUTINE calc_et_coupling_proj
1737
1738END MODULE et_coupling_proj
Definition atom.F:9
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public futera2017
Handles all functions related to the CELL.
Definition cell_types.F:15
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
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_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
...
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:245
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
logical function, public cp_fm_struct_equivalent(fmstruct1, fmstruct2)
returns true if the two matrix structures are equivalent, false otherwise.
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_vectorssum(matrix, sum_array, dir)
summing up all the elements along the matrix's i-th index or
subroutine, public cp_fm_get_element(matrix, irow_global, icol_global, alpha, local)
returns an element of a fm this value is valid on every cpu using this call is expensive
subroutine, public cp_fm_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the matrix
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
subroutine, public cp_fm_set_element(matrix, irow_global, icol_global, alpha)
sets an element of a matrix
various routines to log and control the output. The idea is that decisions about where to log should ...
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, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
...
calculates the electron transfer coupling elements by projection-operator approach Kondov et al....
subroutine release_ec_data(ec)
Release memory allocate for electronic coupling data structures.
subroutine, public calc_et_coupling_proj(qs_env)
calculates the electron transfer coupling elements by projection-operator approach Kondov et al....
objects that represent the structure of input sections and the data contained in an input section
integer function, dimension(:), pointer, public section_get_ivals(section_vals, keyword_name)
...
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
logical function, public section_get_lval(section_vals, keyword_name)
...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Types and basic routines needed for a kpoint calculation.
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition list.F:24
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nso
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
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type)
maps a given wavefunction on the grid
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
collects routines that perform operations directly related to MOs
subroutine, public make_mo_eig(mos, nspins, ks_rmpv, scf_control, mo_derivs, admm_env, hairy_probes, probe)
Calculate KS eigenvalues starting from OF MOS.
Set occupation of molecular orbitals.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
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)
...
parameters that control an scf iteration
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
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...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
contained for different pw related things
to create arrays of pools
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.