(git:ed6f26b)
Loading...
Searching...
No Matches
qs_dftb_matrices.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 Calculation of Overlap and Hamiltonian matrices in DFTB
10!> \author JGH
11! **************************************************************************************************
21 USE cp_dbcsr_api, ONLY: &
22 dbcsr_add, dbcsr_convert_offsets_to_sizes, dbcsr_copy, dbcsr_create, &
24 dbcsr_type, dbcsr_type_antisymmetric, dbcsr_type_symmetric
31 USE cp_output_handling, ONLY: cp_p_file,&
39 USE kinds, ONLY: default_string_length,&
40 dp
41 USE kpoint_types, ONLY: get_kpoint_info,&
44 USE mulliken, ONLY: mulliken_charges
52 iptr,&
58 USE qs_kind_types, ONLY: get_qs_kind,&
61 USE qs_ks_types, ONLY: get_ks_env,&
64 USE qs_mo_types, ONLY: get_mo_set,&
72 USE qs_rho_types, ONLY: qs_rho_get,&
75 USE virial_types, ONLY: virial_type
76#include "./base/base_uses.f90"
77
78 IMPLICIT NONE
79
80 INTEGER, DIMENSION(16), PARAMETER :: orbptr = (/0, 1, 1, 1, &
81 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3/)
82
83 PRIVATE
84
85 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'qs_dftb_matrices'
86
88
89CONTAINS
90
91! **************************************************************************************************
92!> \brief ...
93!> \param qs_env ...
94!> \param para_env ...
95!> \param calculate_forces ...
96! **************************************************************************************************
97 SUBROUTINE build_dftb_matrices(qs_env, para_env, calculate_forces)
98
99 TYPE(qs_environment_type), POINTER :: qs_env
100 TYPE(mp_para_env_type), POINTER :: para_env
101 LOGICAL, INTENT(IN) :: calculate_forces
102
103 CHARACTER(LEN=*), PARAMETER :: routinen = 'build_dftb_matrices'
104
105 INTEGER :: after, atom_a, atom_b, handle, i, iatom, ic, icol, ikind, img, irow, iw, jatom, &
106 jkind, l1, l2, la, lb, llm, lmaxi, lmaxj, m, n1, n2, n_urpoly, natorb_a, natorb_b, &
107 nderivatives, ngrd, ngrdcut, nimg, nkind, spdim
108 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom_of_kind
109 INTEGER, DIMENSION(3) :: cell
110 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index
111 LOGICAL :: defined, found, omit_headers, use_virial
112 REAL(kind=dp) :: ddr, dgrd, dr, erep, erepij, f0, foab, &
113 fow, s_cut, urep_cut
114 REAL(kind=dp), DIMENSION(0:3) :: eta_a, eta_b, skself
115 REAL(kind=dp), DIMENSION(10) :: urep
116 REAL(kind=dp), DIMENSION(2) :: surr
117 REAL(kind=dp), DIMENSION(3) :: drij, force_ab, force_rr, force_w, rij, &
118 srep
119 REAL(kind=dp), DIMENSION(:, :), POINTER :: dfblock, dsblock, fblock, fmatij, &
120 fmatji, pblock, sblock, scoeff, &
121 smatij, smatji, spxr, wblock
122 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
123 TYPE(atprop_type), POINTER :: atprop
124 TYPE(block_p_type), DIMENSION(2:4) :: dsblocks
125 TYPE(cp_logger_type), POINTER :: logger
126 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_h, matrix_p, matrix_s, matrix_w
127 TYPE(dft_control_type), POINTER :: dft_control
128 TYPE(dftb_control_type), POINTER :: dftb_control
129 TYPE(kpoint_type), POINTER :: kpoints
131 DIMENSION(:), POINTER :: nl_iterator
132 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
133 POINTER :: sab_orb
134 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
135 TYPE(qs_dftb_atom_type), POINTER :: dftb_kind_a, dftb_kind_b
136 TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), &
137 POINTER :: dftb_potential
138 TYPE(qs_dftb_pairpot_type), POINTER :: dftb_param_ij, dftb_param_ji
139 TYPE(qs_energy_type), POINTER :: energy
140 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
141 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
142 TYPE(qs_ks_env_type), POINTER :: ks_env
143 TYPE(qs_rho_type), POINTER :: rho
144 TYPE(virial_type), POINTER :: virial
145
146 CALL timeset(routinen, handle)
147
148 ! set pointers
149 iptr = 0
150 DO la = 0, 3
151 DO lb = 0, 3
152 llm = 0
153 DO l1 = 0, max(la, lb)
154 DO l2 = 0, min(l1, la, lb)
155 DO m = 0, l2
156 llm = llm + 1
157 iptr(l1, l2, m, la, lb) = llm
158 END DO
159 END DO
160 END DO
161 END DO
162 END DO
163
164 NULLIFY (logger, virial, atprop)
165 logger => cp_get_default_logger()
166
167 NULLIFY (matrix_h, matrix_s, matrix_p, matrix_w, atomic_kind_set, &
168 qs_kind_set, sab_orb, ks_env)
169
170 CALL get_qs_env(qs_env=qs_env, &
171 energy=energy, &
172 atomic_kind_set=atomic_kind_set, &
173 qs_kind_set=qs_kind_set, &
174 matrix_h_kp=matrix_h, &
175 matrix_s_kp=matrix_s, &
176 atprop=atprop, &
177 dft_control=dft_control, &
178 ks_env=ks_env)
179
180 dftb_control => dft_control%qs_control%dftb_control
181 nimg = dft_control%nimages
182 ! Allocate the overlap and Hamiltonian matrix
183 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb)
184 nderivatives = 0
185 IF (dftb_control%self_consistent .AND. calculate_forces) nderivatives = 1
186 CALL setup_matrices2(qs_env, nderivatives, nimg, matrix_s, "OVERLAP", sab_orb)
187 CALL setup_matrices2(qs_env, 0, nimg, matrix_h, "CORE HAMILTONIAN", sab_orb)
188 CALL set_ks_env(ks_env, matrix_s_kp=matrix_s)
189 CALL set_ks_env(ks_env, matrix_h_kp=matrix_h)
190
191 NULLIFY (dftb_potential)
192 CALL get_qs_env(qs_env=qs_env, dftb_potential=dftb_potential)
193 NULLIFY (particle_set)
194 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set)
195
196 IF (calculate_forces) THEN
197 NULLIFY (rho, force, matrix_w)
198 CALL get_qs_env(qs_env=qs_env, &
199 rho=rho, &
200 matrix_w_kp=matrix_w, &
201 virial=virial, &
202 force=force)
203 CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
204
205 IF (SIZE(matrix_p, 1) == 2) THEN
206 DO img = 1, nimg
207 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, &
208 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
209 CALL dbcsr_add(matrix_w(1, img)%matrix, matrix_w(2, img)%matrix, &
210 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
211 END DO
212 END IF
213 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, atom_of_kind=atom_of_kind)
214 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
215 END IF
216 ! atomic energy decomposition
217 IF (atprop%energy) THEN
218 CALL atprop_array_init(atprop%atecc, natom=SIZE(particle_set))
219 END IF
220
221 NULLIFY (cell_to_index)
222 IF (nimg > 1) THEN
223 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
224 CALL get_kpoint_info(kpoint=kpoints, cell_to_index=cell_to_index)
225 END IF
226
227 erep = 0._dp
228
229 nkind = SIZE(atomic_kind_set)
230
231 CALL neighbor_list_iterator_create(nl_iterator, sab_orb)
232 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
233 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, &
234 iatom=iatom, jatom=jatom, r=rij, cell=cell)
235 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind_a)
236 CALL get_dftb_atom_param(dftb_kind_a, &
237 defined=defined, lmax=lmaxi, skself=skself, &
238 eta=eta_a, natorb=natorb_a)
239 IF (.NOT. defined .OR. natorb_a < 1) cycle
240 CALL get_qs_kind(qs_kind_set(jkind), dftb_parameter=dftb_kind_b)
241 CALL get_dftb_atom_param(dftb_kind_b, &
242 defined=defined, lmax=lmaxj, eta=eta_b, natorb=natorb_b)
243
244 IF (.NOT. defined .OR. natorb_b < 1) cycle
245
246 ! retrieve information on F and S matrix
247 dftb_param_ij => dftb_potential(ikind, jkind)
248 dftb_param_ji => dftb_potential(jkind, ikind)
249 ! assume table size and type is symmetric
250 ngrd = dftb_param_ij%ngrd
251 ngrdcut = dftb_param_ij%ngrdcut
252 dgrd = dftb_param_ij%dgrd
253 ddr = dgrd*0.1_dp
254 cpassert(dftb_param_ij%llm == dftb_param_ji%llm)
255 llm = dftb_param_ij%llm
256 fmatij => dftb_param_ij%fmat
257 smatij => dftb_param_ij%smat
258 fmatji => dftb_param_ji%fmat
259 smatji => dftb_param_ji%smat
260 ! repulsive pair potential
261 n_urpoly = dftb_param_ij%n_urpoly
262 urep_cut = dftb_param_ij%urep_cut
263 urep = dftb_param_ij%urep
264 spxr => dftb_param_ij%spxr
265 scoeff => dftb_param_ij%scoeff
266 spdim = dftb_param_ij%spdim
267 s_cut = dftb_param_ij%s_cut
268 srep = dftb_param_ij%srep
269 surr = dftb_param_ij%surr
270
271 dr = sqrt(sum(rij(:)**2))
272 IF (nint(dr/dgrd) <= ngrdcut) THEN
273
274 IF (nimg == 1) THEN
275 ic = 1
276 ELSE
277 ic = cell_to_index(cell(1), cell(2), cell(3))
278 cpassert(ic > 0)
279 END IF
280
281 icol = max(iatom, jatom)
282 irow = min(iatom, jatom)
283 NULLIFY (sblock, fblock)
284 CALL dbcsr_get_block_p(matrix=matrix_s(1, ic)%matrix, &
285 row=irow, col=icol, block=sblock, found=found)
286 cpassert(found)
287 CALL dbcsr_get_block_p(matrix=matrix_h(1, ic)%matrix, &
288 row=irow, col=icol, block=fblock, found=found)
289 cpassert(found)
290
291 IF (calculate_forces) THEN
292 NULLIFY (pblock)
293 CALL dbcsr_get_block_p(matrix=matrix_p(1, ic)%matrix, &
294 row=irow, col=icol, block=pblock, found=found)
295 cpassert(ASSOCIATED(pblock))
296 NULLIFY (wblock)
297 CALL dbcsr_get_block_p(matrix=matrix_w(1, ic)%matrix, &
298 row=irow, col=icol, block=wblock, found=found)
299 cpassert(ASSOCIATED(wblock))
300 IF (dftb_control%self_consistent) THEN
301 DO i = 2, 4
302 NULLIFY (dsblocks(i)%block)
303 CALL dbcsr_get_block_p(matrix=matrix_s(i, ic)%matrix, &
304 row=irow, col=icol, block=dsblocks(i)%block, found=found)
305 cpassert(found)
306 END DO
307 END IF
308 END IF
309
310 IF (iatom == jatom .AND. dr < 0.001_dp) THEN
311 ! diagonal block
312 DO i = 1, natorb_a
313 sblock(i, i) = sblock(i, i) + 1._dp
314 fblock(i, i) = fblock(i, i) + skself(orbptr(i))
315 END DO
316 ELSE
317 ! off-diagonal block
318 CALL compute_block_sk(sblock, smatij, smatji, rij, ngrd, ngrdcut, dgrd, &
319 llm, lmaxi, lmaxj, irow, iatom)
320 CALL compute_block_sk(fblock, fmatij, fmatji, rij, ngrd, ngrdcut, dgrd, &
321 llm, lmaxi, lmaxj, irow, iatom)
322 IF (calculate_forces) THEN
323 force_ab = 0._dp
324 force_w = 0._dp
325 n1 = SIZE(fblock, 1)
326 n2 = SIZE(fblock, 2)
327 ! make sure that displacement is in the correct direction depending on the position
328 ! of the block (upper or lower triangle)
329 f0 = 1.0_dp
330 IF (irow == iatom) f0 = -1.0_dp
331
332 ALLOCATE (dfblock(n1, n2), dsblock(n1, n2))
333
334 DO i = 1, 3
335 drij = rij
336 dfblock = 0._dp; dsblock = 0._dp
337
338 drij(i) = rij(i) - ddr*f0
339 CALL compute_block_sk(dsblock, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
340 llm, lmaxi, lmaxj, irow, iatom)
341 CALL compute_block_sk(dfblock, fmatij, fmatji, drij, ngrd, ngrdcut, dgrd, &
342 llm, lmaxi, lmaxj, irow, iatom)
343
344 dsblock = -dsblock
345 dfblock = -dfblock
346
347 drij(i) = rij(i) + ddr*f0
348 CALL compute_block_sk(dsblock, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
349 llm, lmaxi, lmaxj, irow, iatom)
350 CALL compute_block_sk(dfblock, fmatij, fmatji, drij, ngrd, ngrdcut, dgrd, &
351 llm, lmaxi, lmaxj, irow, iatom)
352
353 dfblock = dfblock/(2.0_dp*ddr)
354 dsblock = dsblock/(2.0_dp*ddr)
355
356 foab = 2.0_dp*sum(dfblock*pblock)
357 fow = -2.0_dp*sum(dsblock*wblock)
358
359 force_ab(i) = force_ab(i) + foab
360 force_w(i) = force_w(i) + fow
361 IF (dftb_control%self_consistent) THEN
362 cpassert(ASSOCIATED(dsblocks(i + 1)%block))
363 dsblocks(i + 1)%block = dsblocks(i + 1)%block + dsblock
364 END IF
365 END DO
366 IF (use_virial) THEN
367 IF (iatom == jatom) f0 = 0.5_dp*f0
368 CALL virial_pair_force(virial%pv_virial, -f0, force_ab, rij)
369 CALL virial_pair_force(virial%pv_virial, -f0, force_w, rij)
370 END IF
371 DEALLOCATE (dfblock, dsblock)
372 END IF
373 END IF
374
375 IF (calculate_forces .AND. (iatom /= jatom .OR. dr > 0.001_dp)) THEN
376 atom_a = atom_of_kind(iatom)
377 atom_b = atom_of_kind(jatom)
378 IF (irow == iatom) force_ab = -force_ab
379 IF (irow == iatom) force_w = -force_w
380 force(ikind)%all_potential(:, atom_a) = force(ikind)%all_potential(:, atom_a) - force_ab(:)
381 force(jkind)%all_potential(:, atom_b) = force(jkind)%all_potential(:, atom_b) + force_ab(:)
382 force(ikind)%overlap(:, atom_a) = force(ikind)%overlap(:, atom_a) - force_w(:)
383 force(jkind)%overlap(:, atom_b) = force(jkind)%overlap(:, atom_b) + force_w(:)
384 END IF
385
386 END IF
387
388 ! repulsive potential
389 IF ((dr <= urep_cut .OR. spdim > 0) .AND. dr > 0.001_dp) THEN
390 erepij = 0._dp
391 CALL urep_egr(rij, dr, erepij, force_rr, &
392 n_urpoly, urep, spdim, s_cut, srep, spxr, scoeff, surr, calculate_forces)
393 erep = erep + erepij
394 IF (atprop%energy) THEN
395 atprop%atecc(iatom) = atprop%atecc(iatom) + 0.5_dp*erepij
396 atprop%atecc(jatom) = atprop%atecc(jatom) + 0.5_dp*erepij
397 END IF
398 IF (calculate_forces .AND. (iatom /= jatom .OR. dr > 0.001_dp)) THEN
399 atom_a = atom_of_kind(iatom)
400 atom_b = atom_of_kind(jatom)
401 force(ikind)%repulsive(:, atom_a) = &
402 force(ikind)%repulsive(:, atom_a) - force_rr(:)
403 force(jkind)%repulsive(:, atom_b) = &
404 force(jkind)%repulsive(:, atom_b) + force_rr(:)
405 IF (use_virial) THEN
406 f0 = -1.0_dp
407 IF (iatom == jatom) f0 = -0.5_dp
408 CALL virial_pair_force(virial%pv_virial, f0, force_rr, rij)
409 END IF
410 END IF
411 END IF
412
413 END DO
414 CALL neighbor_list_iterator_release(nl_iterator)
415
416 DO i = 1, SIZE(matrix_s, 1)
417 DO img = 1, nimg
418 CALL dbcsr_finalize(matrix_s(i, img)%matrix)
419 END DO
420 END DO
421 DO i = 1, SIZE(matrix_h, 1)
422 DO img = 1, nimg
423 CALL dbcsr_finalize(matrix_h(i, img)%matrix)
424 END DO
425 END DO
426
427 ! set repulsive energy
428 CALL para_env%sum(erep)
429 energy%repulsive = erep
430
431 CALL section_vals_val_get(qs_env%input, "DFT%PRINT%AO_MATRICES%OMIT_HEADERS", l_val=omit_headers)
432 IF (btest(cp_print_key_should_output(logger%iter_info, &
433 qs_env%input, "DFT%PRINT%AO_MATRICES/CORE_HAMILTONIAN"), cp_p_file)) THEN
434 iw = cp_print_key_unit_nr(logger, qs_env%input, "DFT%PRINT%AO_MATRICES/CORE_HAMILTONIAN", &
435 extension=".Log")
436 CALL section_vals_val_get(qs_env%input, "DFT%PRINT%AO_MATRICES%NDIGITS", i_val=after)
437 after = min(max(after, 1), 16)
438 DO img = 1, nimg
439 CALL cp_dbcsr_write_sparse_matrix(matrix_h(1, img)%matrix, 4, after, qs_env, para_env, &
440 output_unit=iw, omit_headers=omit_headers)
441 END DO
442
443 CALL cp_print_key_finished_output(iw, logger, qs_env%input, &
444 "DFT%PRINT%AO_MATRICES/CORE_HAMILTONIAN")
445 END IF
446
447 IF (btest(cp_print_key_should_output(logger%iter_info, &
448 qs_env%input, "DFT%PRINT%AO_MATRICES/OVERLAP"), cp_p_file)) THEN
449 iw = cp_print_key_unit_nr(logger, qs_env%input, "DFT%PRINT%AO_MATRICES/OVERLAP", &
450 extension=".Log")
451 CALL section_vals_val_get(qs_env%input, "DFT%PRINT%AO_MATRICES%NDIGITS", i_val=after)
452 after = min(max(after, 1), 16)
453 DO img = 1, nimg
454 CALL cp_dbcsr_write_sparse_matrix(matrix_s(1, img)%matrix, 4, after, qs_env, para_env, &
455 output_unit=iw, omit_headers=omit_headers)
456
457 IF (btest(cp_print_key_should_output(logger%iter_info, &
458 qs_env%input, "DFT%PRINT%AO_MATRICES/DERIVATIVES"), cp_p_file)) THEN
459 DO i = 2, SIZE(matrix_s, 1)
460 CALL cp_dbcsr_write_sparse_matrix(matrix_s(i, img)%matrix, 4, after, qs_env, para_env, &
461 output_unit=iw, omit_headers=omit_headers)
462 END DO
463 END IF
464 END DO
465
466 CALL cp_print_key_finished_output(iw, logger, qs_env%input, &
467 "DFT%PRINT%AO_MATRICES/OVERLAP")
468 END IF
469
470 IF (calculate_forces) THEN
471 IF (SIZE(matrix_p, 1) == 2) THEN
472 DO img = 1, nimg
473 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, alpha_scalar=1.0_dp, &
474 beta_scalar=-1.0_dp)
475 END DO
476 END IF
477 END IF
478
479 CALL timestop(handle)
480
481 END SUBROUTINE build_dftb_matrices
482
483! **************************************************************************************************
484!> \brief ...
485!> \param qs_env ...
486!> \param calculate_forces ...
487!> \param just_energy ...
488! **************************************************************************************************
489 SUBROUTINE build_dftb_ks_matrix(qs_env, calculate_forces, just_energy)
490 TYPE(qs_environment_type), POINTER :: qs_env
491 LOGICAL, INTENT(in) :: calculate_forces, just_energy
492
493 CHARACTER(len=*), PARAMETER :: routinen = 'build_dftb_ks_matrix'
494
495 INTEGER :: atom_a, handle, iatom, ikind, img, &
496 ispin, natom, nkind, nspins, &
497 output_unit
498 REAL(kind=dp) :: pc_ener, qmmm_el, zeff
499 REAL(kind=dp), DIMENSION(:), POINTER :: mcharge, occupation_numbers
500 REAL(kind=dp), DIMENSION(:, :), POINTER :: charges
501 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
502 TYPE(cp_logger_type), POINTER :: logger
503 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_p1, mo_derivs
504 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: ks_matrix, matrix_h, matrix_p, matrix_s
505 TYPE(dbcsr_type), POINTER :: mo_coeff
506 TYPE(dft_control_type), POINTER :: dft_control
507 TYPE(mp_para_env_type), POINTER :: para_env
508 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
509 TYPE(qs_dftb_atom_type), POINTER :: dftb_kind
510 TYPE(qs_energy_type), POINTER :: energy
511 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
512 TYPE(qs_ks_env_type), POINTER :: ks_env
513 TYPE(qs_rho_type), POINTER :: rho
514 TYPE(section_vals_type), POINTER :: scf_section
515
516 CALL timeset(routinen, handle)
517 NULLIFY (dft_control, logger, scf_section, matrix_p, particle_set, ks_env, &
518 ks_matrix, rho, energy)
519 logger => cp_get_default_logger()
520 cpassert(ASSOCIATED(qs_env))
521
522 CALL get_qs_env(qs_env, &
523 dft_control=dft_control, &
524 atomic_kind_set=atomic_kind_set, &
525 qs_kind_set=qs_kind_set, &
526 matrix_h_kp=matrix_h, &
527 para_env=para_env, &
528 ks_env=ks_env, &
529 matrix_ks_kp=ks_matrix, &
530 rho=rho, &
531 energy=energy)
532
533 energy%hartree = 0.0_dp
534 energy%qmmm_el = 0.0_dp
535
536 scf_section => section_vals_get_subs_vals(qs_env%input, "DFT%SCF")
537 nspins = dft_control%nspins
538 cpassert(ASSOCIATED(matrix_h))
539 cpassert(ASSOCIATED(rho))
540 cpassert(SIZE(ks_matrix) > 0)
541
542 DO ispin = 1, nspins
543 DO img = 1, SIZE(ks_matrix, 2)
544 ! copy the core matrix into the fock matrix
545 CALL dbcsr_copy(ks_matrix(ispin, img)%matrix, matrix_h(1, img)%matrix)
546 END DO
547 END DO
548
549 IF (dft_control%qs_control%dftb_control%self_consistent) THEN
550 ! Mulliken charges
551 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, &
552 matrix_s_kp=matrix_s)
553 CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
554 natom = SIZE(particle_set)
555 ALLOCATE (charges(natom, nspins))
556 !
557 CALL mulliken_charges(matrix_p, matrix_s, para_env, charges)
558 !
559 ALLOCATE (mcharge(natom))
560 nkind = SIZE(atomic_kind_set)
561 DO ikind = 1, nkind
562 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom)
563 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
564 CALL get_dftb_atom_param(dftb_kind, zeff=zeff)
565 DO iatom = 1, natom
566 atom_a = atomic_kind_set(ikind)%atom_list(iatom)
567 mcharge(atom_a) = zeff - sum(charges(atom_a, 1:nspins))
568 END DO
569 END DO
570 DEALLOCATE (charges)
571
572 CALL build_dftb_coulomb(qs_env, ks_matrix, rho, mcharge, energy, &
573 calculate_forces, just_energy)
574
575 CALL efield_tb_matrix(qs_env, ks_matrix, rho, mcharge, energy, &
576 calculate_forces, just_energy)
577
578 DEALLOCATE (mcharge)
579
580 END IF
581
582 IF (qs_env%qmmm) THEN
583 cpassert(SIZE(ks_matrix, 2) == 1)
584 DO ispin = 1, nspins
585 ! If QM/MM sumup the 1el Hamiltonian
586 CALL dbcsr_add(ks_matrix(ispin, 1)%matrix, qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
587 1.0_dp, 1.0_dp)
588 CALL qs_rho_get(rho, rho_ao=matrix_p1)
589 ! Compute QM/MM Energy
590 CALL dbcsr_dot(qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
591 matrix_p1(ispin)%matrix, qmmm_el)
592 energy%qmmm_el = energy%qmmm_el + qmmm_el
593 END DO
594 pc_ener = qs_env%ks_qmmm_env%pc_ener
595 energy%qmmm_el = energy%qmmm_el + pc_ener
596 END IF
597
598 energy%total = energy%core + energy%hartree + energy%qmmm_el + energy%efield + &
599 energy%repulsive + energy%dispersion + energy%dftb3
600
601 IF (dft_control%qs_control%dftb_control%self_consistent) THEN
602 output_unit = cp_print_key_unit_nr(logger, scf_section, "PRINT%DETAILED_ENERGY", &
603 extension=".scfLog")
604 IF (output_unit > 0) THEN
605 WRITE (unit=output_unit, fmt="(/,(T9,A,T60,F20.10))") &
606 "Repulsive pair potential energy: ", energy%repulsive, &
607 "Zeroth order Hamiltonian energy: ", energy%core, &
608 "Charge fluctuation energy: ", energy%hartree, &
609 "London dispersion energy: ", energy%dispersion
610 IF (abs(energy%efield) > 1.e-12_dp) THEN
611 WRITE (unit=output_unit, fmt="(T9,A,T60,F20.10)") &
612 "Electric field interaction energy: ", energy%efield
613 END IF
614 IF (dft_control%qs_control%dftb_control%dftb3_diagonal) THEN
615 WRITE (unit=output_unit, fmt="(T9,A,T60,F20.10)") &
616 "DFTB3 3rd Order Energy Correction ", energy%dftb3
617 END IF
618 IF (qs_env%qmmm) THEN
619 WRITE (unit=output_unit, fmt="(T9,A,T60,F20.10)") &
620 "QM/MM Electrostatic energy: ", energy%qmmm_el
621 END IF
622 END IF
623 CALL cp_print_key_finished_output(output_unit, logger, scf_section, &
624 "PRINT%DETAILED_ENERGY")
625 END IF
626 ! here we compute dE/dC if needed. Assumes dE/dC is H_{ks}C (plus occupation numbers)
627 IF (qs_env%requires_mo_derivs .AND. .NOT. just_energy) THEN
628 cpassert(SIZE(ks_matrix, 2) == 1)
629 block
630 TYPE(mo_set_type), DIMENSION(:), POINTER :: mo_array
631 CALL get_qs_env(qs_env, mo_derivs=mo_derivs, mos=mo_array)
632 DO ispin = 1, SIZE(mo_derivs)
633 CALL get_mo_set(mo_set=mo_array(ispin), &
634 mo_coeff_b=mo_coeff, occupation_numbers=occupation_numbers)
635 IF (.NOT. mo_array(ispin)%use_mo_coeff_b) THEN
636 cpabort("")
637 END IF
638 CALL dbcsr_multiply('n', 'n', 1.0_dp, ks_matrix(ispin, 1)%matrix, mo_coeff, &
639 0.0_dp, mo_derivs(ispin)%matrix)
640 END DO
641 END block
642 END IF
643
644 CALL timestop(handle)
645
646 END SUBROUTINE build_dftb_ks_matrix
647
648! **************************************************************************************************
649!> \brief ...
650!> \param qs_env ...
651!> \param nderivative ...
652!> \param matrix_s ...
653! **************************************************************************************************
654 SUBROUTINE build_dftb_overlap(qs_env, nderivative, matrix_s)
655
656 TYPE(qs_environment_type), POINTER :: qs_env
657 INTEGER, INTENT(IN) :: nderivative
658 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
659
660 CHARACTER(LEN=*), PARAMETER :: routinen = 'build_dftb_overlap'
661
662 INTEGER :: handle, i, iatom, icol, ikind, indder, irow, j, jatom, jkind, l1, l2, la, lb, &
663 llm, lmaxi, lmaxj, m, n1, n2, natom, natorb_a, natorb_b, ngrd, ngrdcut, nkind
664 LOGICAL :: defined, found
665 REAL(kind=dp) :: ddr, dgrd, dr, f0
666 REAL(kind=dp), DIMENSION(0:3) :: skself
667 REAL(kind=dp), DIMENSION(3) :: drij, rij
668 REAL(kind=dp), DIMENSION(:, :), POINTER :: dsblock, dsblockm, sblock, smatij, smatji
669 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: dsblock1
670 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
671 TYPE(block_p_type), DIMENSION(2:10) :: dsblocks
672 TYPE(cp_logger_type), POINTER :: logger
673 TYPE(dft_control_type), POINTER :: dft_control
674 TYPE(dftb_control_type), POINTER :: dftb_control
675 TYPE(neighbor_list_iterator_p_type), &
676 DIMENSION(:), POINTER :: nl_iterator
677 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
678 POINTER :: sab_orb
679 TYPE(qs_dftb_atom_type), POINTER :: dftb_kind_a, dftb_kind_b
680 TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), &
681 POINTER :: dftb_potential
682 TYPE(qs_dftb_pairpot_type), POINTER :: dftb_param_ij, dftb_param_ji
683 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
684
685 CALL timeset(routinen, handle)
686
687 ! set pointers
688 iptr = 0
689 DO la = 0, 3
690 DO lb = 0, 3
691 llm = 0
692 DO l1 = 0, max(la, lb)
693 DO l2 = 0, min(l1, la, lb)
694 DO m = 0, l2
695 llm = llm + 1
696 iptr(l1, l2, m, la, lb) = llm
697 END DO
698 END DO
699 END DO
700 END DO
701 END DO
702
703 NULLIFY (logger)
704 logger => cp_get_default_logger()
705
706 NULLIFY (atomic_kind_set, qs_kind_set, sab_orb)
707
708 CALL get_qs_env(qs_env=qs_env, &
709 atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
710 dft_control=dft_control)
711
712 dftb_control => dft_control%qs_control%dftb_control
713
714 NULLIFY (dftb_potential)
715 CALL get_qs_env(qs_env=qs_env, &
716 dftb_potential=dftb_potential)
717
718 nkind = SIZE(atomic_kind_set)
719
720 ! Allocate the overlap matrix
721 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb)
722 CALL setup_matrices1(qs_env, nderivative, matrix_s, 'OVERLAP', sab_orb)
723
724 CALL neighbor_list_iterator_create(nl_iterator, sab_orb)
725 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
726 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, &
727 iatom=iatom, jatom=jatom, r=rij)
728
729 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom)
730 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind_a)
731 CALL get_dftb_atom_param(dftb_kind_a, &
732 defined=defined, lmax=lmaxi, skself=skself, &
733 natorb=natorb_a)
734
735 IF (.NOT. defined .OR. natorb_a < 1) cycle
736
737 CALL get_qs_kind(qs_kind_set(jkind), dftb_parameter=dftb_kind_b)
738 CALL get_dftb_atom_param(dftb_kind_b, &
739 defined=defined, lmax=lmaxj, natorb=natorb_b)
740
741 IF (.NOT. defined .OR. natorb_b < 1) cycle
742
743 ! retrieve information on F and S matrix
744 dftb_param_ij => dftb_potential(ikind, jkind)
745 dftb_param_ji => dftb_potential(jkind, ikind)
746 ! assume table size and type is symmetric
747 ngrd = dftb_param_ij%ngrd
748 ngrdcut = dftb_param_ij%ngrdcut
749 dgrd = dftb_param_ij%dgrd
750 ddr = dgrd*0.1_dp
751 cpassert(dftb_param_ij%llm == dftb_param_ji%llm)
752 llm = dftb_param_ij%llm
753 smatij => dftb_param_ij%smat
754 smatji => dftb_param_ji%smat
755
756 dr = sqrt(sum(rij(:)**2))
757 IF (nint(dr/dgrd) <= ngrdcut) THEN
758
759 icol = max(iatom, jatom); irow = min(iatom, jatom)
760
761 NULLIFY (sblock)
762 CALL dbcsr_get_block_p(matrix=matrix_s(1)%matrix, &
763 row=irow, col=icol, block=sblock, found=found)
764 cpassert(found)
765
766 IF (nderivative .GT. 0) THEN
767 DO i = 2, SIZE(matrix_s, 1)
768 NULLIFY (dsblocks(i)%block)
769 CALL dbcsr_get_block_p(matrix=matrix_s(i)%matrix, &
770 row=irow, col=icol, block=dsblocks(i)%block, found=found)
771 END DO
772 END IF
773
774 IF (iatom == jatom .AND. dr < 0.001_dp) THEN
775 ! diagonal block
776 DO i = 1, natorb_a
777 sblock(i, i) = sblock(i, i) + 1._dp
778 END DO
779 ELSE
780 ! off-diagonal block
781 CALL compute_block_sk(sblock, smatij, smatji, rij, ngrd, ngrdcut, dgrd, &
782 llm, lmaxi, lmaxj, irow, iatom)
783
784 IF (nderivative .GE. 1) THEN
785 n1 = SIZE(sblock, 1); n2 = SIZE(sblock, 2)
786 indder = 1 ! used to put the 2nd derivatives in the correct matric (5=xx,8=yy,10=zz)
787
788 ALLOCATE (dsblock1(n1, n2, 3), dsblock(n1, n2), dsblockm(n1, n2))
789 dsblock1 = 0.0_dp
790 DO i = 1, 3
791 dsblock = 0._dp; dsblockm = 0.0_dp
792 drij = rij
793 f0 = 1.0_dp; IF (irow == iatom) f0 = -1.0_dp
794
795 drij(i) = rij(i) - ddr*f0
796 CALL compute_block_sk(dsblockm, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
797 llm, lmaxi, lmaxj, irow, iatom)
798
799 drij(i) = rij(i) + ddr*f0
800 CALL compute_block_sk(dsblock, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
801 llm, lmaxi, lmaxj, irow, iatom)
802
803 dsblock1(:, :, i) = (dsblock + dsblockm)
804 dsblock = dsblock - dsblockm
805 dsblock = dsblock/(2.0_dp*ddr)
806
807 cpassert(ASSOCIATED(dsblocks(i + 1)%block))
808 dsblocks(i + 1)%block = dsblocks(i + 1)%block + dsblock
809 IF (nderivative .GT. 1) THEN
810 indder = indder + 5 - i
811 dsblocks(indder)%block = 0.0_dp
812 dsblocks(indder)%block = dsblocks(indder)%block + &
813 (dsblock1(:, :, i) - 2.0_dp*sblock)/ddr**2
814 END IF
815 END DO
816
817 IF (nderivative .GT. 1) THEN
818 DO i = 1, 2
819 DO j = i + 1, 3
820 dsblock = 0._dp; dsblockm = 0.0_dp
821 drij = rij
822 f0 = 1.0_dp; IF (irow == iatom) f0 = -1.0_dp
823
824 drij(i) = rij(i) - ddr*f0; drij(j) = rij(j) - ddr*f0
825 CALL compute_block_sk(dsblockm, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
826 llm, lmaxi, lmaxj, irow, iatom)
827
828 drij(i) = rij(i) + ddr*f0; drij(j) = rij(j) + ddr*f0
829 CALL compute_block_sk(dsblock, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
830 llm, lmaxi, lmaxj, irow, iatom)
831
832 indder = 2 + 2*i + j
833 dsblocks(indder)%block = 0.0_dp
834 dsblocks(indder)%block = &
835 dsblocks(indder)%block + ( &
836 dsblock + dsblockm - dsblock1(:, :, i) - dsblock1(:, :, j) + 2.0_dp*sblock)/(2.0_dp*ddr**2)
837 END DO
838 END DO
839 END IF
840
841 DEALLOCATE (dsblock1, dsblock, dsblockm)
842 END IF
843 END IF
844 END IF
845 END DO
846 CALL neighbor_list_iterator_release(nl_iterator)
847
848 DO i = 1, SIZE(matrix_s, 1)
849 CALL dbcsr_finalize(matrix_s(i)%matrix)
850 END DO
851
852 CALL timestop(handle)
853
854 END SUBROUTINE build_dftb_overlap
855
856! **************************************************************************************************
857!> \brief ...
858!> \param qs_env ...
859!> \param nderivative ...
860!> \param matrices ...
861!> \param mnames ...
862!> \param sab_nl ...
863! **************************************************************************************************
864 SUBROUTINE setup_matrices1(qs_env, nderivative, matrices, mnames, sab_nl)
865
866 TYPE(qs_environment_type), POINTER :: qs_env
867 INTEGER, INTENT(IN) :: nderivative
868 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrices
869 CHARACTER(LEN=*) :: mnames
870 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
871 POINTER :: sab_nl
872
873 CHARACTER(1) :: symmetry_type
874 CHARACTER(LEN=default_string_length) :: matnames
875 INTEGER :: i, natom, neighbor_list_id, nkind, nmat, &
876 nsgf
877 INTEGER, ALLOCATABLE, DIMENSION(:) :: first_sgf, last_sgf
878 INTEGER, DIMENSION(:), POINTER :: row_blk_sizes
879 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
880 TYPE(dbcsr_distribution_type), POINTER :: dbcsr_dist
881 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
882 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
883
884 NULLIFY (particle_set, atomic_kind_set)
885
886 CALL get_qs_env(qs_env=qs_env, &
887 atomic_kind_set=atomic_kind_set, &
888 qs_kind_set=qs_kind_set, &
889 particle_set=particle_set, &
890 dbcsr_dist=dbcsr_dist, &
891 neighbor_list_id=neighbor_list_id)
892
893 nkind = SIZE(atomic_kind_set)
894 natom = SIZE(particle_set)
895
896 CALL get_qs_kind_set(qs_kind_set, nsgf=nsgf)
897
898 ALLOCATE (first_sgf(natom))
899 ALLOCATE (last_sgf(natom))
900
901 CALL get_particle_set(particle_set, qs_kind_set, &
902 first_sgf=first_sgf, &
903 last_sgf=last_sgf)
904
905 nmat = 0
906 IF (nderivative == 0) nmat = 1
907 IF (nderivative == 1) nmat = 4
908 IF (nderivative == 2) nmat = 10
909 cpassert(nmat > 0)
910
911 ALLOCATE (row_blk_sizes(natom))
912 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
913
914 CALL dbcsr_allocate_matrix_set(matrices, nmat)
915
916 ! Up to 2nd derivative take care to get the symmetries correct
917 DO i = 1, nmat
918 IF (i .GT. 1) THEN
919 matnames = trim(mnames)//" DERIVATIVE MATRIX DFTB"
920 symmetry_type = dbcsr_type_antisymmetric
921 IF (i .GT. 4) symmetry_type = dbcsr_type_symmetric
922 ELSE
923 symmetry_type = dbcsr_type_symmetric
924 matnames = trim(mnames)//" MATRIX DFTB"
925 END IF
926 ALLOCATE (matrices(i)%matrix)
927 CALL dbcsr_create(matrix=matrices(i)%matrix, &
928 name=trim(matnames), &
929 dist=dbcsr_dist, matrix_type=symmetry_type, &
930 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
931 mutable_work=.true.)
932 CALL cp_dbcsr_alloc_block_from_nbl(matrices(i)%matrix, sab_nl)
933 END DO
934
935 DEALLOCATE (first_sgf)
936 DEALLOCATE (last_sgf)
937
938 DEALLOCATE (row_blk_sizes)
939
940 END SUBROUTINE setup_matrices1
941
942! **************************************************************************************************
943!> \brief ...
944!> \param qs_env ...
945!> \param nderivative ...
946!> \param nimg ...
947!> \param matrices ...
948!> \param mnames ...
949!> \param sab_nl ...
950! **************************************************************************************************
951 SUBROUTINE setup_matrices2(qs_env, nderivative, nimg, matrices, mnames, sab_nl)
952
953 TYPE(qs_environment_type), POINTER :: qs_env
954 INTEGER, INTENT(IN) :: nderivative, nimg
955 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrices
956 CHARACTER(LEN=*) :: mnames
957 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
958 POINTER :: sab_nl
959
960 CHARACTER(1) :: symmetry_type
961 CHARACTER(LEN=default_string_length) :: matnames
962 INTEGER :: i, img, natom, neighbor_list_id, nkind, &
963 nmat, nsgf
964 INTEGER, ALLOCATABLE, DIMENSION(:) :: first_sgf, last_sgf
965 INTEGER, DIMENSION(:), POINTER :: row_blk_sizes
966 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
967 TYPE(dbcsr_distribution_type), POINTER :: dbcsr_dist
968 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
969 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
970
971 NULLIFY (particle_set, atomic_kind_set)
972
973 CALL get_qs_env(qs_env=qs_env, &
974 atomic_kind_set=atomic_kind_set, &
975 qs_kind_set=qs_kind_set, &
976 particle_set=particle_set, &
977 dbcsr_dist=dbcsr_dist, &
978 neighbor_list_id=neighbor_list_id)
979
980 nkind = SIZE(atomic_kind_set)
981 natom = SIZE(particle_set)
982
983 CALL get_qs_kind_set(qs_kind_set, nsgf=nsgf)
984
985 ALLOCATE (first_sgf(natom))
986 ALLOCATE (last_sgf(natom))
987
988 CALL get_particle_set(particle_set, qs_kind_set, &
989 first_sgf=first_sgf, &
990 last_sgf=last_sgf)
991
992 nmat = 0
993 IF (nderivative == 0) nmat = 1
994 IF (nderivative == 1) nmat = 4
995 IF (nderivative == 2) nmat = 10
996 cpassert(nmat > 0)
997
998 ALLOCATE (row_blk_sizes(natom))
999 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
1000
1001 CALL dbcsr_allocate_matrix_set(matrices, nmat, nimg)
1002
1003 ! Up to 2nd derivative take care to get the symmetries correct
1004 DO img = 1, nimg
1005 DO i = 1, nmat
1006 IF (i .GT. 1) THEN
1007 matnames = trim(mnames)//" DERIVATIVE MATRIX DFTB"
1008 symmetry_type = dbcsr_type_antisymmetric
1009 IF (i .GT. 4) symmetry_type = dbcsr_type_symmetric
1010 ELSE
1011 symmetry_type = dbcsr_type_symmetric
1012 matnames = trim(mnames)//" MATRIX DFTB"
1013 END IF
1014 ALLOCATE (matrices(i, img)%matrix)
1015 CALL dbcsr_create(matrix=matrices(i, img)%matrix, &
1016 name=trim(matnames), &
1017 dist=dbcsr_dist, matrix_type=symmetry_type, &
1018 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
1019 mutable_work=.true.)
1020 CALL cp_dbcsr_alloc_block_from_nbl(matrices(i, img)%matrix, sab_nl)
1021 END DO
1022 END DO
1023
1024 DEALLOCATE (first_sgf)
1025 DEALLOCATE (last_sgf)
1026
1027 DEALLOCATE (row_blk_sizes)
1028
1029 END SUBROUTINE setup_matrices2
1030
1031END MODULE qs_dftb_matrices
1032
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
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.
Holds information on atomic properties.
subroutine, public atprop_array_init(atarray, natom)
...
collect pointers to a block of reals
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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_finalize(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
DBCSR operations in CP2K.
DBCSR output in CP2K.
subroutine, public cp_dbcsr_write_sparse_matrix(sparse_matrix, before, after, qs_env, para_env, first_row, last_row, first_col, last_col, scale, output_unit, omit_headers)
...
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...
Calculation of electric field contributions in TB.
subroutine, public efield_tb_matrix(qs_env, ks_matrix, rho, mcharge, energy, calculate_forces, just_energy)
...
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Definition mulliken.F:13
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis)
Get the components of a particle set.
Define the data structure for the particle information.
Calculation of Coulomb contributions in DFTB.
subroutine, public build_dftb_coulomb(qs_env, ks_matrix, rho, mcharge, energy, calculate_forces, just_energy)
...
Calculation of Overlap and Hamiltonian matrices in DFTB.
subroutine, public build_dftb_ks_matrix(qs_env, calculate_forces, just_energy)
...
integer, dimension(16), parameter orbptr
subroutine, public build_dftb_matrices(qs_env, para_env, calculate_forces)
...
subroutine, public build_dftb_overlap(qs_env, nderivative, matrix_s)
...
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public urep_egr(rv, r, erep, derep, n_urpoly, urep, spdim, s_cut, srep, spxr, scoeff, surr, dograd)
...
subroutine, public compute_block_sk(block, smatij, smatji, rij, ngrd, ngrdcut, dgrd, llm, lmaxi, lmaxj, irow, iatom)
...
integer, dimension(0:3, 0:3, 0:3, 0:3, 0:3), public iptr
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
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.
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, 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, 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, init_u_ramping_each_scf, reltmat, ghost, 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, basis_type, total_zeff_corr, npgf_seg)
Get attributes of an atomic kind set.
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)
...
subroutine, public get_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, rho, rho_xc, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, 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, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
pure subroutine, public virial_pair_force(pv_virial, f0, force, rab)
Computes the contribution to the stress tensor from two-body pair-wise forces.
Provides all information about an atomic kind.
type for the atomic properties
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
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.