(git:ed6f26b)
Loading...
Searching...
No Matches
xtb_ehess_force.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 forces for Coulomb contributions in response xTB
10!> \author JGH
11! **************************************************************************************************
15 USE cell_types, ONLY: cell_type,&
16 get_cell,&
17 pbc
20 USE cp_dbcsr_api, ONLY: &
32 USE kinds, ONLY: dp
33 USE mathconstants, ONLY: oorootpi,&
34 pi
45 USE qs_kind_types, ONLY: get_qs_kind,&
53 USE qs_rho_types, ONLY: qs_rho_type
54 USE virial_types, ONLY: virial_type
55 USE xtb_coulomb, ONLY: dgamma_rab_sr,&
57 USE xtb_types, ONLY: get_xtb_atom_param,&
59#include "./base/base_uses.f90"
60
61 IMPLICIT NONE
62
63 PRIVATE
64
65 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xtb_ehess_force'
66
67 PUBLIC :: calc_xtb_ehess_force
68
69! **************************************************************************************************
70
71CONTAINS
72
73! **************************************************************************************************
74!> \brief ...
75!> \param qs_env ...
76!> \param matrix_p0 ...
77!> \param matrix_p1 ...
78!> \param charges0 ...
79!> \param mcharge0 ...
80!> \param charges1 ...
81!> \param mcharge1 ...
82!> \param debug_forces ...
83! **************************************************************************************************
84 SUBROUTINE calc_xtb_ehess_force(qs_env, matrix_p0, matrix_p1, charges0, mcharge0, &
85 charges1, mcharge1, debug_forces)
86
87 TYPE(qs_environment_type), POINTER :: qs_env
88 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_p0, matrix_p1
89 REAL(kind=dp), DIMENSION(:, :), INTENT(in) :: charges0
90 REAL(kind=dp), DIMENSION(:), INTENT(in) :: mcharge0
91 REAL(kind=dp), DIMENSION(:, :), INTENT(in) :: charges1
92 REAL(kind=dp), DIMENSION(:), INTENT(in) :: mcharge1
93 LOGICAL, INTENT(IN) :: debug_forces
94
95 CHARACTER(len=*), PARAMETER :: routinen = 'calc_xtb_ehess_force'
96
97 INTEGER :: atom_i, atom_j, ewald_type, handle, i, ia, iatom, icol, ikind, iounit, irow, j, &
98 jatom, jkind, la, lb, lmaxa, lmaxb, natom, natorb_a, natorb_b, ni, nimg, nj, nkind, nmat, &
99 za, zb
100 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom_of_kind, kind_of
101 INTEGER, DIMENSION(25) :: laoa, laob
102 INTEGER, DIMENSION(3) :: cellind, periodic
103 LOGICAL :: calculate_forces, defined, do_ewald, &
104 found, just_energy, use_virial
105 REAL(kind=dp) :: alpha, deth, dr, etaa, etab, fi, gmij0, &
106 gmij1, kg, rcut, rcuta, rcutb
107 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: xgamma
108 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: gammab, gcij0, gcij1, gmcharge0, &
109 gmcharge1
110 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: gchrg0, gchrg1
111 REAL(kind=dp), DIMENSION(3) :: fij, fodeb, rij
112 REAL(kind=dp), DIMENSION(5) :: kappaa, kappab
113 REAL(kind=dp), DIMENSION(:, :), POINTER :: dsblock, pblock0, pblock1, sblock
114 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
115 TYPE(cell_type), POINTER :: cell
116 TYPE(cp_logger_type), POINTER :: logger
117 TYPE(dbcsr_iterator_type) :: iter
118 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s
119 TYPE(dft_control_type), POINTER :: dft_control
120 TYPE(distribution_1d_type), POINTER :: local_particles
121 TYPE(ewald_environment_type), POINTER :: ewald_env
122 TYPE(ewald_pw_type), POINTER :: ewald_pw
123 TYPE(mp_para_env_type), POINTER :: para_env
125 DIMENSION(:), POINTER :: nl_iterator
126 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
127 POINTER :: n_list
128 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
129 TYPE(qs_energy_type), POINTER :: energy
130 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
131 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
132 TYPE(qs_rho_type), POINTER :: rho
133 TYPE(virial_type), POINTER :: virial
134 TYPE(xtb_atom_type), POINTER :: xtb_atom_a, xtb_atom_b, xtb_kind
135 TYPE(xtb_control_type), POINTER :: xtb_control
136
137 CALL timeset(routinen, handle)
138
139 logger => cp_get_default_logger()
140 IF (logger%para_env%is_source()) THEN
141 iounit = cp_logger_get_default_unit_nr(logger, local=.true.)
142 ELSE
143 iounit = -1
144 END IF
145
146 cpassert(ASSOCIATED(matrix_p1))
147
148 CALL get_qs_env(qs_env, &
149 qs_kind_set=qs_kind_set, &
150 particle_set=particle_set, &
151 cell=cell, &
152 rho=rho, &
153 energy=energy, &
154 virial=virial, &
155 dft_control=dft_control)
156
157 xtb_control => dft_control%qs_control%xtb_control
158
159 calculate_forces = .true.
160 just_energy = .false.
161 use_virial = .false.
162 nmat = 4
163 nimg = dft_control%nimages
164 IF (nimg > 1) THEN
165 cpabort('xTB-sTDA forces for k-points not available')
166 END IF
167
168 CALL get_qs_env(qs_env, nkind=nkind, natom=natom)
169 ALLOCATE (gchrg0(natom, 5, nmat))
170 gchrg0 = 0._dp
171 ALLOCATE (gmcharge0(natom, nmat))
172 gmcharge0 = 0._dp
173 ALLOCATE (gchrg1(natom, 5, nmat))
174 gchrg1 = 0._dp
175 ALLOCATE (gmcharge1(natom, nmat))
176 gmcharge1 = 0._dp
177
178 ! short range contribution (gamma)
179 ! loop over all atom pairs (sab_xtbe)
180 kg = xtb_control%kg
181 NULLIFY (n_list)
182 CALL get_qs_env(qs_env=qs_env, sab_xtbe=n_list)
183 CALL neighbor_list_iterator_create(nl_iterator, n_list)
184 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
185 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, &
186 iatom=iatom, jatom=jatom, r=rij, cell=cellind)
187 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_atom_a)
188 CALL get_xtb_atom_param(xtb_atom_a, defined=defined, natorb=natorb_a)
189 IF (.NOT. defined .OR. natorb_a < 1) cycle
190 CALL get_qs_kind(qs_kind_set(jkind), xtb_parameter=xtb_atom_b)
191 CALL get_xtb_atom_param(xtb_atom_b, defined=defined, natorb=natorb_b)
192 IF (.NOT. defined .OR. natorb_b < 1) cycle
193 ! atomic parameters
194 CALL get_xtb_atom_param(xtb_atom_a, eta=etaa, lmax=lmaxa, kappa=kappaa, rcut=rcuta)
195 CALL get_xtb_atom_param(xtb_atom_b, eta=etab, lmax=lmaxb, kappa=kappab, rcut=rcutb)
196 ! gamma matrix
197 ni = lmaxa + 1
198 nj = lmaxb + 1
199 ALLOCATE (gammab(ni, nj))
200 rcut = rcuta + rcutb
201 dr = sqrt(sum(rij(:)**2))
202 CALL gamma_rab_sr(gammab, dr, ni, kappaa, etaa, nj, kappab, etab, kg, rcut)
203 gchrg0(iatom, 1:ni, 1) = gchrg0(iatom, 1:ni, 1) + matmul(gammab, charges0(jatom, 1:nj))
204 gchrg1(iatom, 1:ni, 1) = gchrg1(iatom, 1:ni, 1) + matmul(gammab, charges1(jatom, 1:nj))
205 IF (iatom /= jatom) THEN
206 gchrg0(jatom, 1:nj, 1) = gchrg0(jatom, 1:nj, 1) + matmul(charges0(iatom, 1:ni), gammab)
207 gchrg1(jatom, 1:nj, 1) = gchrg1(jatom, 1:nj, 1) + matmul(charges1(iatom, 1:ni), gammab)
208 END IF
209 IF (dr > 1.e-6_dp) THEN
210 CALL dgamma_rab_sr(gammab, dr, ni, kappaa, etaa, nj, kappab, etab, kg, rcut)
211 DO i = 1, 3
212 gchrg0(iatom, 1:ni, i + 1) = gchrg0(iatom, 1:ni, i + 1) &
213 + matmul(gammab, charges0(jatom, 1:nj))*rij(i)/dr
214 gchrg1(iatom, 1:ni, i + 1) = gchrg1(iatom, 1:ni, i + 1) &
215 + matmul(gammab, charges1(jatom, 1:nj))*rij(i)/dr
216 IF (iatom /= jatom) THEN
217 gchrg0(jatom, 1:nj, i + 1) = gchrg0(jatom, 1:nj, i + 1) &
218 - matmul(charges0(iatom, 1:ni), gammab)*rij(i)/dr
219 gchrg1(jatom, 1:nj, i + 1) = gchrg1(jatom, 1:nj, i + 1) &
220 - matmul(charges1(iatom, 1:ni), gammab)*rij(i)/dr
221 END IF
222 END DO
223 END IF
224 DEALLOCATE (gammab)
225 END DO
226 CALL neighbor_list_iterator_release(nl_iterator)
227
228 ! 1/R contribution
229
230 IF (xtb_control%coulomb_lr) THEN
231 do_ewald = xtb_control%do_ewald
232 IF (do_ewald) THEN
233 ! Ewald sum
234 NULLIFY (ewald_env, ewald_pw)
235 CALL get_qs_env(qs_env=qs_env, &
236 ewald_env=ewald_env, ewald_pw=ewald_pw)
237 CALL get_cell(cell=cell, periodic=periodic, deth=deth)
238 CALL ewald_env_get(ewald_env, alpha=alpha, ewald_type=ewald_type)
239 CALL get_qs_env(qs_env=qs_env, sab_tbe=n_list)
240 CALL tb_ewald_overlap(gmcharge0, mcharge0, alpha, n_list, virial, use_virial)
241 CALL tb_ewald_overlap(gmcharge1, mcharge1, alpha, n_list, virial, use_virial)
242 SELECT CASE (ewald_type)
243 CASE DEFAULT
244 cpabort("Invalid Ewald type")
245 CASE (do_ewald_none)
246 cpabort("Not allowed with DFTB")
247 CASE (do_ewald_ewald)
248 cpabort("Standard Ewald not implemented in DFTB")
249 CASE (do_ewald_pme)
250 cpabort("PME not implemented in DFTB")
251 CASE (do_ewald_spme)
252 CALL tb_spme_zforce(ewald_env, ewald_pw, particle_set, cell, gmcharge0, mcharge0)
253 CALL tb_spme_zforce(ewald_env, ewald_pw, particle_set, cell, gmcharge1, mcharge1)
254 END SELECT
255 ELSE
256 ! direct sum
257 CALL get_qs_env(qs_env=qs_env, local_particles=local_particles)
258 DO ikind = 1, SIZE(local_particles%n_el)
259 DO ia = 1, local_particles%n_el(ikind)
260 iatom = local_particles%list(ikind)%array(ia)
261 DO jatom = 1, iatom - 1
262 rij = particle_set(iatom)%r - particle_set(jatom)%r
263 rij = pbc(rij, cell)
264 dr = sqrt(sum(rij(:)**2))
265 IF (dr > 1.e-6_dp) THEN
266 gmcharge0(iatom, 1) = gmcharge0(iatom, 1) + mcharge0(jatom)/dr
267 gmcharge0(jatom, 1) = gmcharge0(jatom, 1) + mcharge0(iatom)/dr
268 gmcharge1(iatom, 1) = gmcharge1(iatom, 1) + mcharge1(jatom)/dr
269 gmcharge1(jatom, 1) = gmcharge1(jatom, 1) + mcharge1(iatom)/dr
270 DO i = 2, nmat
271 gmcharge0(iatom, i) = gmcharge0(iatom, i) + rij(i - 1)*mcharge0(jatom)/dr**3
272 gmcharge0(jatom, i) = gmcharge0(jatom, i) - rij(i - 1)*mcharge0(iatom)/dr**3
273 gmcharge1(iatom, i) = gmcharge1(iatom, i) + rij(i - 1)*mcharge1(jatom)/dr**3
274 gmcharge1(jatom, i) = gmcharge1(jatom, i) - rij(i - 1)*mcharge1(iatom)/dr**3
275 END DO
276 END IF
277 END DO
278 END DO
279 END DO
280 cpassert(.NOT. use_virial)
281 END IF
282 END IF
283
284 ! global sum of gamma*p arrays
285 CALL get_qs_env(qs_env=qs_env, &
286 atomic_kind_set=atomic_kind_set, &
287 force=force, para_env=para_env)
288 CALL para_env%sum(gmcharge0(:, 1))
289 CALL para_env%sum(gchrg0(:, :, 1))
290 CALL para_env%sum(gmcharge1(:, 1))
291 CALL para_env%sum(gchrg1(:, :, 1))
292
293 IF (xtb_control%coulomb_lr) THEN
294 IF (do_ewald) THEN
295 ! add self charge interaction and background charge contribution
296 gmcharge0(:, 1) = gmcharge0(:, 1) - 2._dp*alpha*oorootpi*mcharge0(:)
297 IF (any(periodic(:) == 1)) THEN
298 gmcharge0(:, 1) = gmcharge0(:, 1) - pi/alpha**2/deth
299 END IF
300 gmcharge1(:, 1) = gmcharge1(:, 1) - 2._dp*alpha*oorootpi*mcharge1(:)
301 IF (any(periodic(:) == 1)) THEN
302 gmcharge1(:, 1) = gmcharge1(:, 1) - pi/alpha**2/deth
303 END IF
304 END IF
305 END IF
306
307 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
308 kind_of=kind_of, &
309 atom_of_kind=atom_of_kind)
310
311 IF (debug_forces) fodeb(1:3) = force(1)%rho_elec(1:3, 1)
312 DO iatom = 1, natom
313 ikind = kind_of(iatom)
314 atom_i = atom_of_kind(iatom)
315 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
316 CALL get_xtb_atom_param(xtb_kind, lmax=ni)
317 ni = ni + 1
318 ! short range
319 fij = 0.0_dp
320 DO i = 1, 3
321 fij(i) = sum(charges0(iatom, 1:ni)*gchrg1(iatom, 1:ni, i + 1)) + &
322 sum(charges1(iatom, 1:ni)*gchrg0(iatom, 1:ni, i + 1))
323 END DO
324 force(ikind)%rho_elec(1, atom_i) = force(ikind)%rho_elec(1, atom_i) - fij(1)
325 force(ikind)%rho_elec(2, atom_i) = force(ikind)%rho_elec(2, atom_i) - fij(2)
326 force(ikind)%rho_elec(3, atom_i) = force(ikind)%rho_elec(3, atom_i) - fij(3)
327 ! long range
328 fij = 0.0_dp
329 DO i = 1, 3
330 fij(i) = gmcharge1(iatom, i + 1)*mcharge0(iatom) + &
331 gmcharge0(iatom, i + 1)*mcharge1(iatom)
332 END DO
333 force(ikind)%rho_elec(1, atom_i) = force(ikind)%rho_elec(1, atom_i) - fij(1)
334 force(ikind)%rho_elec(2, atom_i) = force(ikind)%rho_elec(2, atom_i) - fij(2)
335 force(ikind)%rho_elec(3, atom_i) = force(ikind)%rho_elec(3, atom_i) - fij(3)
336 END DO
337 IF (debug_forces) THEN
338 fodeb(1:3) = force(1)%rho_elec(1:3, 1) - fodeb(1:3)
339 CALL para_env%sum(fodeb)
340 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: P*dH[Pz] ", fodeb
341 END IF
342
343 CALL get_qs_env(qs_env=qs_env, matrix_s_kp=matrix_s)
344
345 IF (SIZE(matrix_p0) == 2) THEN
346 CALL dbcsr_add(matrix_p0(1)%matrix, matrix_p0(2)%matrix, &
347 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
348 CALL dbcsr_add(matrix_p1(1)%matrix, matrix_p1(2)%matrix, &
349 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
350 END IF
351
352 ! no k-points; all matrices have been transformed to periodic bsf
353 IF (debug_forces) fodeb(1:3) = force(1)%rho_elec(1:3, 1)
354 CALL dbcsr_iterator_start(iter, matrix_s(1, 1)%matrix)
355 DO WHILE (dbcsr_iterator_blocks_left(iter))
356 CALL dbcsr_iterator_next_block(iter, irow, icol, sblock)
357 ikind = kind_of(irow)
358 jkind = kind_of(icol)
359
360 ! atomic parameters
361 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_atom_a)
362 CALL get_qs_kind(qs_kind_set(jkind), xtb_parameter=xtb_atom_b)
363 CALL get_xtb_atom_param(xtb_atom_a, z=za, lao=laoa)
364 CALL get_xtb_atom_param(xtb_atom_b, z=zb, lao=laob)
365
366 ni = SIZE(sblock, 1)
367 nj = SIZE(sblock, 2)
368 ALLOCATE (gcij0(ni, nj))
369 ALLOCATE (gcij1(ni, nj))
370 DO i = 1, ni
371 DO j = 1, nj
372 la = laoa(i) + 1
373 lb = laob(j) + 1
374 gcij0(i, j) = 0.5_dp*(gchrg0(irow, la, 1) + gchrg0(icol, lb, 1))
375 gcij1(i, j) = 0.5_dp*(gchrg1(irow, la, 1) + gchrg1(icol, lb, 1))
376 END DO
377 END DO
378 gmij0 = 0.5_dp*(gmcharge0(irow, 1) + gmcharge0(icol, 1))
379 gmij1 = 0.5_dp*(gmcharge1(irow, 1) + gmcharge1(icol, 1))
380 atom_i = atom_of_kind(irow)
381 atom_j = atom_of_kind(icol)
382 NULLIFY (pblock0)
383 CALL dbcsr_get_block_p(matrix=matrix_p0(1)%matrix, &
384 row=irow, col=icol, block=pblock0, found=found)
385 cpassert(found)
386 NULLIFY (pblock1)
387 CALL dbcsr_get_block_p(matrix=matrix_p1(1)%matrix, &
388 row=irow, col=icol, block=pblock1, found=found)
389 cpassert(found)
390 DO i = 1, 3
391 NULLIFY (dsblock)
392 CALL dbcsr_get_block_p(matrix=matrix_s(1 + i, 1)%matrix, &
393 row=irow, col=icol, block=dsblock, found=found)
394 cpassert(found)
395 ! short range
396 fi = -2.0_dp*sum(pblock0*dsblock*gcij1) - 2.0_dp*sum(pblock1*dsblock*gcij0)
397 force(ikind)%rho_elec(i, atom_i) = force(ikind)%rho_elec(i, atom_i) + fi
398 force(jkind)%rho_elec(i, atom_j) = force(jkind)%rho_elec(i, atom_j) - fi
399 ! long range
400 fi = -2.0_dp*gmij1*sum(pblock0*dsblock) - 2.0_dp*gmij0*sum(pblock1*dsblock)
401 force(ikind)%rho_elec(i, atom_i) = force(ikind)%rho_elec(i, atom_i) + fi
402 force(jkind)%rho_elec(i, atom_j) = force(jkind)%rho_elec(i, atom_j) - fi
403 END DO
404 DEALLOCATE (gcij0, gcij1)
405 END DO
406 CALL dbcsr_iterator_stop(iter)
407 IF (debug_forces) THEN
408 fodeb(1:3) = force(1)%rho_elec(1:3, 1) - fodeb(1:3)
409 CALL para_env%sum(fodeb)
410 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Pz*H[P]*dS ", fodeb
411 END IF
412
413 IF (xtb_control%tb3_interaction) THEN
414 CALL get_qs_env(qs_env, nkind=nkind)
415 ALLOCATE (xgamma(nkind))
416 DO ikind = 1, nkind
417 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
418 CALL get_xtb_atom_param(xtb_kind, xgamma=xgamma(ikind))
419 END DO
420 ! Diagonal 3rd order correction (DFTB3)
421 IF (debug_forces) fodeb(1:3) = force(1)%rho_elec(1:3, 1)
422 CALL dftb3_diagonal_hessian_force(qs_env, mcharge0, mcharge1, &
423 matrix_p0(1)%matrix, matrix_p1(1)%matrix, xgamma)
424 IF (debug_forces) THEN
425 fodeb(1:3) = force(1)%rho_elec(1:3, 1) - fodeb(1:3)
426 CALL para_env%sum(fodeb)
427 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Pz*H3[P] ", fodeb
428 END IF
429 DEALLOCATE (xgamma)
430 END IF
431
432 IF (SIZE(matrix_p0) == 2) THEN
433 CALL dbcsr_add(matrix_p0(1)%matrix, matrix_p0(2)%matrix, &
434 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
435 CALL dbcsr_add(matrix_p1(1)%matrix, matrix_p1(2)%matrix, &
436 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
437 END IF
438
439 ! QMMM
440 IF (qs_env%qmmm .AND. qs_env%qmmm_periodic) THEN
441 cpabort("Not Available")
442 END IF
443
444 DEALLOCATE (gmcharge0, gchrg0, gmcharge1, gchrg1)
445
446 CALL timestop(handle)
447
448 END SUBROUTINE calc_xtb_ehess_force
449
450! **************************************************************************************************
451!> \brief ...
452!> \param qs_env ...
453!> \param mcharge0 ...
454!> \param mcharge1 ...
455!> \param matrixp0 ...
456!> \param matrixp1 ...
457!> \param xgamma ...
458! **************************************************************************************************
459 SUBROUTINE dftb3_diagonal_hessian_force(qs_env, mcharge0, mcharge1, &
460 matrixp0, matrixp1, xgamma)
461
462 TYPE(qs_environment_type), POINTER :: qs_env
463 REAL(dp), DIMENSION(:) :: mcharge0, mcharge1
464 TYPE(dbcsr_type), POINTER :: matrixp0, matrixp1
465 REAL(dp), DIMENSION(:) :: xgamma
466
467 CHARACTER(len=*), PARAMETER :: routinen = 'dftb3_diagonal_hessian_force'
468
469 INTEGER :: atom_i, atom_j, handle, i, icol, ikind, &
470 irow, jkind
471 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom_of_kind, kind_of
472 LOGICAL :: found
473 REAL(kind=dp) :: fi, gmijp, gmijq, ui, uj
474 REAL(kind=dp), DIMENSION(:, :), POINTER :: dsblock, p0block, p1block, sblock
475 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
476 TYPE(dbcsr_iterator_type) :: iter
477 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
478 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
479
480 CALL timeset(routinen, handle)
481 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s)
482 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set)
483 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
484 kind_of=kind_of, atom_of_kind=atom_of_kind)
485 CALL get_qs_env(qs_env=qs_env, force=force)
486 ! no k-points; all matrices have been transformed to periodic bsf
487 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
488 DO WHILE (dbcsr_iterator_blocks_left(iter))
489 CALL dbcsr_iterator_next_block(iter, irow, icol, sblock)
490 ikind = kind_of(irow)
491 atom_i = atom_of_kind(irow)
492 ui = xgamma(ikind)
493 jkind = kind_of(icol)
494 atom_j = atom_of_kind(icol)
495 uj = xgamma(jkind)
496 !
497 gmijp = ui*mcharge0(irow)*mcharge1(irow) + uj*mcharge0(icol)*mcharge1(icol)
498 gmijq = 0.5_dp*ui*mcharge0(irow)**2 + 0.5_dp*uj*mcharge0(icol)**2
499 !
500 NULLIFY (p0block)
501 CALL dbcsr_get_block_p(matrix=matrixp0, &
502 row=irow, col=icol, block=p0block, found=found)
503 cpassert(found)
504 NULLIFY (p1block)
505 CALL dbcsr_get_block_p(matrix=matrixp1, &
506 row=irow, col=icol, block=p1block, found=found)
507 cpassert(found)
508 DO i = 1, 3
509 NULLIFY (dsblock)
510 CALL dbcsr_get_block_p(matrix=matrix_s(1 + i)%matrix, &
511 row=irow, col=icol, block=dsblock, found=found)
512 cpassert(found)
513 fi = gmijp*sum(p0block*dsblock) + gmijq*sum(p1block*dsblock)
514 force(ikind)%rho_elec(i, atom_i) = force(ikind)%rho_elec(i, atom_i) + fi
515 force(jkind)%rho_elec(i, atom_j) = force(jkind)%rho_elec(i, atom_j) - fi
516 END DO
517 END DO
518 CALL dbcsr_iterator_stop(iter)
519
520 CALL timestop(handle)
521
522 END SUBROUTINE dftb3_diagonal_hessian_force
523
524END MODULE xtb_ehess_force
525
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.
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
Definition cell_types.F:195
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
Calculation of Ewald contributions in DFTB.
subroutine, public tb_spme_zforce(ewald_env, ewald_pw, particle_set, box, gmcharge, mcharge)
...
subroutine, public tb_ewald_overlap(gmcharge, mcharge, alpha, n_list, virial, use_virial)
...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public oorootpi
real(kind=dp), parameter, public pi
Interface to the message passing library MPI.
Define the data structure for the particle information.
functions related to the poisson solver on regular grids
integer, parameter, public do_ewald_pme
integer, parameter, public do_ewald_ewald
integer, parameter, public do_ewald_none
integer, parameter, public do_ewald_spme
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.
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...
Calculation of Coulomb contributions in xTB.
Definition xtb_coulomb.F:12
subroutine, public gamma_rab_sr(gmat, rab, nla, kappaa, etaa, nlb, kappab, etab, kg, rcut)
Computes the short-range gamma parameter from Nataga-Mishimoto-Ohno-Klopman formula for xTB WARNING: ...
subroutine, public dgamma_rab_sr(dgmat, rab, nla, kappaa, etaa, nlb, kappab, etab, kg, rcut)
Computes the derivative of the short-range gamma parameter from Nataga-Mishimoto-Ohno-Klopman formula...
Calculation of forces for Coulomb contributions in response xTB.
subroutine, public calc_xtb_ehess_force(qs_env, matrix_p0, matrix_p1, charges0, mcharge0, charges1, mcharge1, debug_forces)
...
Definition of the xTB parameter types.
Definition xtb_types.F:20
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, xi, kappa0, alpg, occupation, electronegativity, chmax, en, kqat2, kcn, kq)
...
Definition xtb_types.F:199
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
type of a logger, at the moment it contains just a print level starting at which level it should be l...
structure to store local (to a processor) ordered lists of integers.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.