(git:4cc4584)
Loading...
Searching...
No Matches
qs_efield_berry.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 energy contribution and the mo_derivative of
10!> a static periodic electric field
11!> \par History
12!> none
13!> \author fschiff (06.2010)
14! **************************************************************************************************
16 USE ai_moments, ONLY: expikr
23 USE cell_types, ONLY: cell_type,&
24 pbc
27 USE cp_cfm_types, ONLY: cp_cfm_create,&
32 USE cp_dbcsr_api, ONLY: dbcsr_copy,&
35 dbcsr_set,&
46 USE cp_fm_types, ONLY: cp_fm_create,&
50 USE kinds, ONLY: dp
51 USE mathconstants, ONLY: gaussi,&
52 pi,&
53 twopi,&
54 z_one,&
55 z_zero
57 USE orbital_pointers, ONLY: ncoset
65 USE qs_kind_types, ONLY: get_qs_kind,&
68 USE qs_mo_types, ONLY: get_mo_set,&
81 USE virial_types, ONLY: virial_type
82#include "./base/base_uses.f90"
83
84 IMPLICIT NONE
85
86 PRIVATE
87
88 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_efield_berry'
89
90 ! *** Public subroutines ***
91
92 PUBLIC :: qs_efield_berry_phase
93
94! **************************************************************************************************
95
96CONTAINS
97
98! **************************************************************************************************
99
100! **************************************************************************************************
101!> \brief ...
102!> \param qs_env ...
103!> \param just_energy ...
104!> \param calculate_forces ...
105! **************************************************************************************************
106 SUBROUTINE qs_efield_berry_phase(qs_env, just_energy, calculate_forces)
107
108 TYPE(qs_environment_type), POINTER :: qs_env
109 LOGICAL, INTENT(IN) :: just_energy, calculate_forces
110
111 CHARACTER(LEN=*), PARAMETER :: routinen = 'qs_efield_berry_phase'
112
113 INTEGER :: handle
114 LOGICAL :: s_mstruct_changed
115 TYPE(dft_control_type), POINTER :: dft_control
116
117 CALL timeset(routinen, handle)
118
119 NULLIFY (dft_control)
120 CALL get_qs_env(qs_env, s_mstruct_changed=s_mstruct_changed, &
121 dft_control=dft_control)
122
123 IF (dft_control%apply_period_efield) THEN
124 ! check if the periodic efield should be applied in the current step
125 IF (dft_control%period_efield%start_frame <= qs_env%sim_step .AND. &
126 (dft_control%period_efield%end_frame == -1 .OR. dft_control%period_efield%end_frame >= qs_env%sim_step)) THEN
127
128 IF (s_mstruct_changed) CALL qs_efield_integrals(qs_env)
129 IF (dft_control%period_efield%displacement_field) THEN
130 CALL qs_dispfield_derivatives(qs_env, just_energy, calculate_forces)
131 ELSE
132 CALL qs_efield_derivatives(qs_env, just_energy, calculate_forces)
133 END IF
134 END IF
135 END IF
136
137 CALL timestop(handle)
138
139 END SUBROUTINE qs_efield_berry_phase
140
141! **************************************************************************************************
142!> \brief ...
143!> \param qs_env ...
144! **************************************************************************************************
145 SUBROUTINE qs_efield_integrals(qs_env)
146
147 TYPE(qs_environment_type), POINTER :: qs_env
148
149 CHARACTER(LEN=*), PARAMETER :: routinen = 'qs_efield_integrals'
150
151 INTEGER :: handle, i
152 REAL(dp), DIMENSION(3) :: kvec
153 TYPE(cell_type), POINTER :: cell
154 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: cosmat, matrix_s, sinmat
155 TYPE(dft_control_type), POINTER :: dft_control
156 TYPE(efield_berry_type), POINTER :: efield
157
158 CALL timeset(routinen, handle)
159 cpassert(ASSOCIATED(qs_env))
160
161 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
162 NULLIFY (matrix_s)
163 CALL get_qs_env(qs_env=qs_env, efield=efield, cell=cell, matrix_s=matrix_s)
164 CALL init_efield_matrices(efield)
165 ALLOCATE (cosmat(3), sinmat(3))
166 DO i = 1, 3
167 ALLOCATE (cosmat(i)%matrix, sinmat(i)%matrix)
168
169 CALL dbcsr_copy(cosmat(i)%matrix, matrix_s(1)%matrix, 'COS MAT')
170 CALL dbcsr_copy(sinmat(i)%matrix, matrix_s(1)%matrix, 'SIN MAT')
171
172 kvec(:) = twopi*cell%h_inv(i, :)
173 CALL build_berry_moment_matrix(qs_env, cosmat(i)%matrix, sinmat(i)%matrix, kvec)
174 END DO
175 CALL set_efield_matrices(efield=efield, cosmat=cosmat, sinmat=sinmat)
176 CALL set_qs_env(qs_env=qs_env, efield=efield)
177 CALL timestop(handle)
178
179 END SUBROUTINE qs_efield_integrals
180
181! **************************************************************************************************
182!> \brief ...
183!> \param qs_env ...
184!> \param just_energy ...
185!> \param calculate_forces ...
186! **************************************************************************************************
187 SUBROUTINE qs_efield_derivatives(qs_env, just_energy, calculate_forces)
188 TYPE(qs_environment_type), POINTER :: qs_env
189 LOGICAL, INTENT(IN) :: just_energy, calculate_forces
190
191 CHARACTER(LEN=*), PARAMETER :: routinen = 'qs_efield_derivatives'
192
193 COMPLEX(dp) :: zdet, zdeta, zi(3)
194 COMPLEX(dp), ALLOCATABLE :: dexpab(:, :, :, :), expab(:, :)
195 INTEGER :: atom_a, atom_b, handle, i, ia, iatom, icenter, icol, idir, ikind, irow, iset, &
196 ispin, j, jatom, jkind, jset, ldab, ldsa, ldsb, lsab, n1, n2, nao, natom, ncoa, ncob, &
197 nkind, nmo, nseta, nsetb, sgfa, sgfb
198 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom_of_kind
199 INTEGER, DIMENSION(:), POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
200 npgfb, nsgfa, nsgfb
201 INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfb
202 LOGICAL :: found, uniform, use_virial
203 REAL(dp) :: charge, ci(3), cqi(3), dab, dd, &
204 ener_field, f0, fab, fieldpol(3), &
205 focc, fpolvec(3), hmat(3, 3), occ, &
206 qi(3), strength, ti(3)
207 REAL(dp), DIMENSION(3) :: forcea, forceb, kvec, ra, rab, rb, ria
208 REAL(dp), DIMENSION(:, :), POINTER :: iblock, rblock, work
209 REAL(kind=dp), DIMENSION(:), POINTER :: set_radius_a, set_radius_b
210 REAL(kind=dp), DIMENSION(:, :), POINTER :: rpgfa, rpgfb, sphi_a, sphi_b, zeta, zetb
211 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
212 TYPE(block_p_type), DIMENSION(3, 2) :: dcost, dsint
213 TYPE(cell_type), POINTER :: cell
214 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: eigrmat, inv_mat
215 TYPE(cp_fm_struct_type), POINTER :: tmp_fm_struct
216 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: mo_coeff_tmp, mo_derivs_tmp
217 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: inv_work, op_fm_set, opvec
218 TYPE(cp_fm_type), POINTER :: mo_coeff
219 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s, mo_derivs
220 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: tempmat
221 TYPE(dbcsr_type), POINTER :: cosmat, mo_coeff_b, sinmat
222 TYPE(dft_control_type), POINTER :: dft_control
223 TYPE(efield_berry_type), POINTER :: efield
224 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_list
225 TYPE(gto_basis_set_type), POINTER :: basis_set_a, basis_set_b
226 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
227 TYPE(mp_para_env_type), POINTER :: para_env
229 DIMENSION(:), POINTER :: nl_iterator
230 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
231 POINTER :: sab_orb
232 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
233 TYPE(qs_energy_type), POINTER :: energy
234 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
235 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
236 TYPE(qs_kind_type), POINTER :: qs_kind
237 TYPE(virial_type), POINTER :: virial
238
239 CALL timeset(routinen, handle)
240
241 NULLIFY (dft_control, cell, particle_set)
242 CALL get_qs_env(qs_env, dft_control=dft_control, cell=cell, &
243 particle_set=particle_set, virial=virial)
244 NULLIFY (qs_kind_set, efield, para_env, sab_orb)
245 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
246 efield=efield, energy=energy, para_env=para_env, sab_orb=sab_orb)
247
248 ! calculate stress only if forces requested also
249 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
250 use_virial = use_virial .AND. calculate_forces
251 ! disable stress calculation
252 IF (use_virial) THEN
253 cpabort("Stress tensor for periodic E-field not implemented")
254 END IF
255
256 ! if an intensities list is given, select the value for the current step
257 strength = dft_control%period_efield%strength
258 IF (ALLOCATED(dft_control%period_efield%strength_list)) THEN
259 strength = dft_control%period_efield%strength_list(mod(qs_env%sim_step &
260 - dft_control%period_efield%start_frame, SIZE(dft_control%period_efield%strength_list)) + 1)
261 END IF
262
263 fieldpol = dft_control%period_efield%polarisation
264 fieldpol = fieldpol/norm2(fieldpol)
265 fieldpol = -fieldpol*strength
266 hmat = cell%hmat(:, :)/twopi
267 DO idir = 1, 3
268 fpolvec(idir) = fieldpol(1)*hmat(1, idir) + fieldpol(2)*hmat(2, idir) + fieldpol(3)*hmat(3, idir)
269 END DO
270
271 ! nuclear contribution
272 natom = SIZE(particle_set)
273 IF (calculate_forces) THEN
274 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, force=force)
275 CALL get_atomic_kind_set(atomic_kind_set, atom_of_kind=atom_of_kind)
276 END IF
277 zi(:) = cmplx(1._dp, 0._dp, dp)
278 DO ia = 1, natom
279 CALL get_atomic_kind(particle_set(ia)%atomic_kind, kind_number=ikind)
280 CALL get_qs_kind(qs_kind_set(ikind), core_charge=charge)
281 ria = particle_set(ia)%r
282 ria = pbc(ria, cell)
283 DO idir = 1, 3
284 kvec(:) = twopi*cell%h_inv(idir, :)
285 dd = sum(kvec(:)*ria(:))
286 zdeta = cmplx(cos(dd), sin(dd), kind=dp)**charge
287 zi(idir) = zi(idir)*zdeta
288 END DO
289 IF (calculate_forces) THEN
290 IF (para_env%mepos == 0) THEN
291 iatom = atom_of_kind(ia)
292 forcea(:) = fieldpol(:)*charge
293 force(ikind)%efield(:, iatom) = force(ikind)%efield(:, iatom) + forcea(:)
294 END IF
295 END IF
296 IF (use_virial) THEN
297 IF (para_env%mepos == 0) THEN
298 CALL virial_pair_force(virial%pv_virial, 1.0_dp, forcea, ria)
299 END IF
300 END IF
301 END DO
302 qi = aimag(log(zi))
303
304 ! check uniform occupation
305 NULLIFY (mos)
306 CALL get_qs_env(qs_env=qs_env, mos=mos)
307 DO ispin = 1, dft_control%nspins
308 CALL get_mo_set(mo_set=mos(ispin), maxocc=occ, uniform_occupation=uniform)
309 IF (.NOT. uniform) THEN
310 cpabort("Berry phase moments for non uniform MOs' occupation numbers not implemented")
311 END IF
312 END DO
313
314 NULLIFY (mo_derivs)
315 CALL get_qs_env(qs_env=qs_env, mo_derivs=mo_derivs)
316 ! initialize all work matrices needed
317 ALLOCATE (op_fm_set(2, dft_control%nspins))
318 ALLOCATE (opvec(2, dft_control%nspins))
319 ALLOCATE (eigrmat(dft_control%nspins))
320 ALLOCATE (inv_mat(dft_control%nspins))
321 ALLOCATE (inv_work(2, dft_control%nspins))
322 ALLOCATE (mo_derivs_tmp(SIZE(mo_derivs)))
323 ALLOCATE (mo_coeff_tmp(SIZE(mo_derivs)))
324
325 ! Allocate temp matrices for the wavefunction derivatives
326 DO ispin = 1, dft_control%nspins
327 NULLIFY (tmp_fm_struct, mo_coeff)
328 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
329 CALL cp_fm_struct_create(tmp_fm_struct, nrow_global=nmo, &
330 ncol_global=nmo, para_env=para_env, context=mo_coeff%matrix_struct%context)
331 CALL cp_fm_create(mo_derivs_tmp(ispin), mo_coeff%matrix_struct)
332 CALL cp_fm_create(mo_coeff_tmp(ispin), mo_coeff%matrix_struct)
333 CALL copy_dbcsr_to_fm(mo_derivs(ispin)%matrix, mo_derivs_tmp(ispin))
334 DO i = 1, SIZE(op_fm_set, 1)
335 CALL cp_fm_create(opvec(i, ispin), mo_coeff%matrix_struct)
336 CALL cp_fm_create(op_fm_set(i, ispin), tmp_fm_struct)
337 CALL cp_fm_create(inv_work(i, ispin), op_fm_set(i, ispin)%matrix_struct)
338 END DO
339 CALL cp_cfm_create(eigrmat(ispin), op_fm_set(1, ispin)%matrix_struct)
340 CALL cp_cfm_create(inv_mat(ispin), op_fm_set(1, ispin)%matrix_struct)
341 CALL cp_fm_struct_release(tmp_fm_struct)
342 END DO
343 ! temp matrices for force calculation
344 IF (calculate_forces) THEN
345 NULLIFY (matrix_s)
346 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s)
347 ALLOCATE (tempmat(2, dft_control%nspins))
348 DO ispin = 1, dft_control%nspins
349 ALLOCATE (tempmat(1, ispin)%matrix, tempmat(2, ispin)%matrix)
350 CALL dbcsr_copy(tempmat(1, ispin)%matrix, matrix_s(1)%matrix, 'TEMPMAT')
351 CALL dbcsr_copy(tempmat(2, ispin)%matrix, matrix_s(1)%matrix, 'TEMPMAT')
352 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
353 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
354 END DO
355 ! integration
356 CALL get_qs_kind_set(qs_kind_set, maxco=ldab, maxsgf=lsab)
357 ALLOCATE (expab(ldab, ldab), work(ldab, ldab))
358 ALLOCATE (dexpab(ldab, ldab, 3, 2))
359 lsab = max(ldab, lsab)
360 DO i = 1, 3
361 ALLOCATE (dcost(i, 1)%block(lsab, lsab), dsint(i, 1)%block(lsab, lsab))
362 ALLOCATE (dcost(i, 2)%block(lsab, lsab), dsint(i, 2)%block(lsab, lsab))
363 END DO
364 END IF
365
366 !Start the MO derivative calculation
367 !loop over all cell vectors
368 DO idir = 1, 3
369 ci(idir) = 0.0_dp
370 zi(idir) = z_zero
371 IF (abs(fpolvec(idir)) > 1.0e-12_dp) THEN
372 cosmat => efield%cosmat(idir)%matrix
373 sinmat => efield%sinmat(idir)%matrix
374 !evaluate the expression needed for the derivative (S_berry * C and [C^T S_berry C]^-1)
375 !first step S_berry * C and C^T S_berry C
376 DO ispin = 1, dft_control%nspins ! spin
377 IF (mos(ispin)%use_mo_coeff_b) THEN
378 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff_b=mo_coeff_b, nmo=nmo)
379 CALL copy_dbcsr_to_fm(mo_coeff_b, mo_coeff_tmp(ispin))
380 ELSE
381 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff=mo_coeff, nmo=nmo)
382 mo_coeff_tmp(ispin) = mo_coeff
383 END IF
384 CALL cp_dbcsr_sm_fm_multiply(cosmat, mo_coeff_tmp(ispin), opvec(1, ispin), ncol=nmo)
385 CALL parallel_gemm("T", "N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(1, ispin), 0.0_dp, &
386 op_fm_set(1, ispin))
387 CALL cp_dbcsr_sm_fm_multiply(sinmat, mo_coeff_tmp(ispin), opvec(2, ispin), ncol=nmo)
388 CALL parallel_gemm("T", "N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(2, ispin), 0.0_dp, &
389 op_fm_set(2, ispin))
390 END DO
391 !second step invert C^T S_berry C
392 zdet = z_one
393 DO ispin = 1, dft_control%nspins
394 CALL cp_cfm_scale_and_add_fm(z_zero, eigrmat(ispin), z_one, op_fm_set(1, ispin))
395 CALL cp_cfm_scale_and_add_fm(z_one, eigrmat(ispin), -gaussi, op_fm_set(2, ispin))
396 CALL cp_cfm_set_all(inv_mat(ispin), z_zero, z_one)
397 CALL cp_cfm_solve(eigrmat(ispin), inv_mat(ispin), zdeta)
398 zdet = zdet*zdeta
399 END DO
400 zi(idir) = zdet**occ
401 ci(idir) = aimag(log(zdet**occ))
402
403 IF (.NOT. just_energy) THEN
404 !compute the orbital derivative
405 focc = fpolvec(idir)
406 DO ispin = 1, dft_control%nspins
407 inv_work(1, ispin)%local_data(:, :) = real(inv_mat(ispin)%local_data(:, :), dp)
408 inv_work(2, ispin)%local_data(:, :) = aimag(inv_mat(ispin)%local_data(:, :))
409 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
410 CALL parallel_gemm("N", "N", nao, nmo, nmo, focc, opvec(1, ispin), inv_work(2, ispin), &
411 1.0_dp, mo_derivs_tmp(ispin))
412 CALL parallel_gemm("N", "N", nao, nmo, nmo, -focc, opvec(2, ispin), inv_work(1, ispin), &
413 1.0_dp, mo_derivs_tmp(ispin))
414 END DO
415 END IF
416
417 !compute nuclear forces
418 IF (calculate_forces) THEN
419 nkind = SIZE(qs_kind_set)
420 natom = SIZE(particle_set)
421 kvec(:) = twopi*cell%h_inv(idir, :)
422
423 ! calculate: C [C^T S_berry C]^(-1) C^T
424 ! Store this matrix in DBCSR form (only S overlap blocks)
425 DO ispin = 1, dft_control%nspins
426 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
427 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
428 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
429 CALL parallel_gemm("N", "N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(1, ispin), 0.0_dp, &
430 opvec(1, ispin))
431 CALL parallel_gemm("N", "N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(2, ispin), 0.0_dp, &
432 opvec(2, ispin))
433 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=tempmat(1, ispin)%matrix, &
434 matrix_v=opvec(1, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
435 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=tempmat(2, ispin)%matrix, &
436 matrix_v=opvec(2, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
437 END DO
438
439 ! Calculation of derivative integrals (da|eikr|b) and (a|eikr|db)
440 ALLOCATE (basis_set_list(nkind))
441 DO ikind = 1, nkind
442 qs_kind => qs_kind_set(ikind)
443 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set_a)
444 IF (ASSOCIATED(basis_set_a)) THEN
445 basis_set_list(ikind)%gto_basis_set => basis_set_a
446 ELSE
447 NULLIFY (basis_set_list(ikind)%gto_basis_set)
448 END IF
449 END DO
450 !
451 CALL neighbor_list_iterator_create(nl_iterator, sab_orb)
452 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
453 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, &
454 iatom=iatom, jatom=jatom, r=rab)
455 basis_set_a => basis_set_list(ikind)%gto_basis_set
456 IF (.NOT. ASSOCIATED(basis_set_a)) cycle
457 basis_set_b => basis_set_list(jkind)%gto_basis_set
458 IF (.NOT. ASSOCIATED(basis_set_b)) cycle
459 ! basis ikind
460 first_sgfa => basis_set_a%first_sgf
461 la_max => basis_set_a%lmax
462 la_min => basis_set_a%lmin
463 npgfa => basis_set_a%npgf
464 nseta = basis_set_a%nset
465 nsgfa => basis_set_a%nsgf_set
466 rpgfa => basis_set_a%pgf_radius
467 set_radius_a => basis_set_a%set_radius
468 sphi_a => basis_set_a%sphi
469 zeta => basis_set_a%zet
470 ! basis jkind
471 first_sgfb => basis_set_b%first_sgf
472 lb_max => basis_set_b%lmax
473 lb_min => basis_set_b%lmin
474 npgfb => basis_set_b%npgf
475 nsetb = basis_set_b%nset
476 nsgfb => basis_set_b%nsgf_set
477 rpgfb => basis_set_b%pgf_radius
478 set_radius_b => basis_set_b%set_radius
479 sphi_b => basis_set_b%sphi
480 zetb => basis_set_b%zet
481
482 atom_a = atom_of_kind(iatom)
483 atom_b = atom_of_kind(jatom)
484
485 ldsa = SIZE(sphi_a, 1)
486 ldsb = SIZE(sphi_b, 1)
487 ra(:) = pbc(particle_set(iatom)%r(:), cell)
488 rb(:) = ra + rab
489 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
490
491 IF (iatom <= jatom) THEN
492 irow = iatom
493 icol = jatom
494 ELSE
495 irow = jatom
496 icol = iatom
497 END IF
498
499 IF (iatom == jatom) THEN
500 fab = 1.0_dp*occ
501 ELSE
502 fab = 2.0_dp*occ
503 END IF
504
505 DO i = 1, 3
506 dcost(i, 1)%block = 0.0_dp
507 dsint(i, 1)%block = 0.0_dp
508 dcost(i, 2)%block = 0.0_dp
509 dsint(i, 2)%block = 0.0_dp
510 END DO
511
512 DO iset = 1, nseta
513 ncoa = npgfa(iset)*ncoset(la_max(iset))
514 sgfa = first_sgfa(1, iset)
515 DO jset = 1, nsetb
516 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
517 ncob = npgfb(jset)*ncoset(lb_max(jset))
518 sgfb = first_sgfb(1, jset)
519 ! Calculate both basis-center derivatives from one primitive recurrence.
520 CALL expikr(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
521 lb_max(jset), npgfb(jset), zetb(:, jset), rpgfb(:, jset), lb_min(jset), &
522 ra, rb, kvec, expab, dexpab(:, :, :, 1), dexpab(:, :, :, 2))
523 DO icenter = 1, 2
524 DO i = 1, 3
525 CALL contract_all(dcost(i, icenter)%block, dsint(i, icenter)%block, &
526 ncoa, nsgfa(iset), sgfa, sphi_a, ldsa, &
527 ncob, nsgfb(jset), sgfb, sphi_b, ldsb, &
528 REAL(dexpab(1:ncoa, 1:ncob, i, icenter), kind=dp), &
529 aimag(dexpab(1:ncoa, 1:ncob, i, icenter)), ncoa, work, ldab)
530 END DO
531 END DO
532 END DO
533 END DO
534 forcea = 0.0_dp
535 forceb = 0.0_dp
536 DO ispin = 1, dft_control%nspins
537 NULLIFY (rblock, iblock)
538 CALL dbcsr_get_block_p(matrix=tempmat(1, ispin)%matrix, &
539 row=irow, col=icol, block=rblock, found=found)
540 cpassert(found)
541 CALL dbcsr_get_block_p(matrix=tempmat(2, ispin)%matrix, &
542 row=irow, col=icol, block=iblock, found=found)
543 cpassert(found)
544 n1 = SIZE(rblock, 1)
545 n2 = SIZE(rblock, 2)
546 cpassert(SIZE(iblock, 1) == n1)
547 cpassert(SIZE(iblock, 2) == n2)
548 cpassert(lsab >= n1)
549 cpassert(lsab >= n2)
550 IF (iatom <= jatom) THEN
551 DO i = 1, 3
552 forcea(i) = forcea(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 1)%block(1:n1, 1:n2)) &
553 - sum(iblock(1:n1, 1:n2)*dcost(i, 1)%block(1:n1, 1:n2))
554 forceb(i) = forceb(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 2)%block(1:n1, 1:n2)) &
555 - sum(iblock(1:n1, 1:n2)*dcost(i, 2)%block(1:n1, 1:n2))
556 END DO
557 ELSE
558 DO i = 1, 3
559 forcea(i) = forcea(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 1)%block(1:n2, 1:n1)) &
560 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 1)%block(1:n2, 1:n1))
561 forceb(i) = forceb(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 2)%block(1:n2, 1:n1)) &
562 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 2)%block(1:n2, 1:n1))
563 END DO
564 END IF
565 END DO
566 force(ikind)%efield(1:3, atom_a) = force(ikind)%efield(1:3, atom_a) - fab*fpolvec(idir)*forcea(1:3)
567 force(jkind)%efield(1:3, atom_b) = force(jkind)%efield(1:3, atom_b) - fab*fpolvec(idir)*forceb(1:3)
568 IF (use_virial) THEN
569 f0 = -fab*fpolvec(idir)
570 CALL virial_pair_force(virial%pv_virial, f0, forcea, ra)
571 CALL virial_pair_force(virial%pv_virial, f0, forceb, rb)
572 END IF
573
574 END DO
575 CALL neighbor_list_iterator_release(nl_iterator)
576 DEALLOCATE (basis_set_list)
577
578 END IF
579 END IF
580 END DO
581
582 ! Energy
583 ener_field = 0.0_dp
584 ti = 0.0_dp
585 DO idir = 1, 3
586 ! make sure the total normalized polarization is within [-1:1]
587 cqi(idir) = qi(idir) + ci(idir)
588 IF (cqi(idir) > pi) cqi(idir) = cqi(idir) - twopi
589 IF (cqi(idir) < -pi) cqi(idir) = cqi(idir) + twopi
590 ! now check for log branch
591 IF (abs(efield%polarisation(idir) - cqi(idir)) > pi) THEN
592 ti(idir) = (efield%polarisation(idir) - cqi(idir))/pi
593 DO i = 1, 10
594 cqi(idir) = cqi(idir) + sign(1.0_dp, ti(idir))*twopi
595 IF (abs(efield%polarisation(idir) - cqi(idir)) < pi) EXIT
596 END DO
597 END IF
598 ener_field = ener_field + fpolvec(idir)*cqi(idir)
599 END DO
600
601 ! update the references
602 IF (calculate_forces) THEN
603 ! check for smoothness of energy surface
604 IF (abs(efield%field_energy - ener_field) > pi*abs(sum(fpolvec))) THEN
605 cpwarn("Large change of e-field energy detected. Correct for non-smooth energy surface")
606 END IF
607 efield%field_energy = ener_field
608 efield%polarisation(:) = cqi(:)
609 END IF
610 energy%efield = ener_field
611
612 IF (.NOT. just_energy) THEN
613 ! Add the result to mo_derivativs
614 DO ispin = 1, dft_control%nspins
615 CALL copy_fm_to_dbcsr(mo_derivs_tmp(ispin), mo_derivs(ispin)%matrix)
616 END DO
617 IF (use_virial) THEN
618 ti = 0.0_dp
619 DO i = 1, 3
620 DO j = 1, 3
621 ti(j) = ti(j) + hmat(j, i)*cqi(i)
622 END DO
623 END DO
624 DO i = 1, 3
625 DO j = 1, 3
626 virial%pv_virial(i, j) = virial%pv_virial(i, j) - fieldpol(i)*ti(j)
627 END DO
628 END DO
629 END IF
630 END IF
631
632 DO ispin = 1, dft_control%nspins
633 CALL cp_cfm_release(eigrmat(ispin))
634 CALL cp_cfm_release(inv_mat(ispin))
635 CALL cp_fm_release(mo_derivs_tmp(ispin))
636 IF (mos(ispin)%use_mo_coeff_b) CALL cp_fm_release(mo_coeff_tmp(ispin))
637 DO i = 1, SIZE(op_fm_set, 1)
638 CALL cp_fm_release(opvec(i, ispin))
639 CALL cp_fm_release(op_fm_set(i, ispin))
640 CALL cp_fm_release(inv_work(i, ispin))
641 END DO
642 END DO
643 DEALLOCATE (inv_mat, inv_work, op_fm_set, opvec, eigrmat)
644 DEALLOCATE (mo_coeff_tmp, mo_derivs_tmp)
645
646 IF (calculate_forces) THEN
647 DO ikind = 1, SIZE(atomic_kind_set)
648 CALL para_env%sum(force(ikind)%efield)
649 END DO
650 DEALLOCATE (expab, work, dexpab)
651 DO i = 1, 3
652 DEALLOCATE (dcost(i, 1)%block, dsint(i, 1)%block)
653 DEALLOCATE (dcost(i, 2)%block, dsint(i, 2)%block)
654 END DO
655 CALL dbcsr_deallocate_matrix_set(tempmat)
656 END IF
657 CALL timestop(handle)
658
659 END SUBROUTINE qs_efield_derivatives
660
661! **************************************************************************************************
662!> \brief ...
663!> \param qs_env ...
664!> \param just_energy ...
665!> \param calculate_forces ...
666! **************************************************************************************************
667 SUBROUTINE qs_dispfield_derivatives(qs_env, just_energy, calculate_forces)
668 TYPE(qs_environment_type), POINTER :: qs_env
669 LOGICAL, INTENT(IN) :: just_energy, calculate_forces
670
671 CHARACTER(LEN=*), PARAMETER :: routinen = 'qs_dispfield_derivatives'
672
673 COMPLEX(dp) :: zdet, zdeta, zi(3)
674 COMPLEX(dp), ALLOCATABLE :: dexpab(:, :, :, :), expab(:, :)
675 INTEGER :: handle, i, ia, iatom, icenter, icol, idir, ikind, iodeb, irow, iset, ispin, &
676 jatom, jkind, jset, ldab, ldsa, ldsb, lsab, n1, n2, nao, natom, ncoa, ncob, nkind, nmo, &
677 nseta, nsetb, sgfa, sgfb
678 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom_of_kind
679 INTEGER, DIMENSION(:), POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
680 npgfb, nsgfa, nsgfb
681 INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfb
682 LOGICAL :: found, uniform, use_virial
683 REAL(dp) :: charge, ci(3), cqi(3), dab, dd, di(3), ener_field, fab, fieldpol(3), focc, &
684 hmat(3, 3), occ, omega, qi(3), rlog(3), strength, zlog(3)
685 REAL(dp), DIMENSION(3) :: dfilter, forcea, forceb, kvec, ra, rab, &
686 rb, ria
687 REAL(dp), DIMENSION(:, :), POINTER :: iblock, rblock, work
688 REAL(dp), DIMENSION(:, :, :), POINTER :: force_tmp
689 REAL(kind=dp), DIMENSION(:), POINTER :: set_radius_a, set_radius_b
690 REAL(kind=dp), DIMENSION(:, :), POINTER :: rpgfa, rpgfb, sphi_a, sphi_b, zeta, zetb
691 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
692 TYPE(block_p_type), DIMENSION(3, 2) :: dcost, dsint
693 TYPE(cell_type), POINTER :: cell
694 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: eigrmat, inv_mat
695 TYPE(cp_fm_struct_type), POINTER :: tmp_fm_struct
696 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: mo_coeff_tmp
697 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: inv_work, mo_derivs_tmp, op_fm_set, opvec
698 TYPE(cp_fm_type), POINTER :: mo_coeff
699 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s, mo_derivs
700 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: tempmat
701 TYPE(dbcsr_type), POINTER :: cosmat, mo_coeff_b, sinmat
702 TYPE(dft_control_type), POINTER :: dft_control
703 TYPE(efield_berry_type), POINTER :: efield
704 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_list
705 TYPE(gto_basis_set_type), POINTER :: basis_set_a, basis_set_b
706 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
707 TYPE(mp_para_env_type), POINTER :: para_env
709 DIMENSION(:), POINTER :: nl_iterator
710 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
711 POINTER :: sab_orb
712 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
713 TYPE(qs_energy_type), POINTER :: energy
714 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
715 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
716 TYPE(qs_kind_type), POINTER :: qs_kind
717 TYPE(virial_type), POINTER :: virial
718
719 CALL timeset(routinen, handle)
720
721 NULLIFY (dft_control, cell, particle_set)
722 CALL get_qs_env(qs_env, dft_control=dft_control, cell=cell, &
723 particle_set=particle_set, virial=virial)
724 NULLIFY (qs_kind_set, efield, para_env, sab_orb)
725 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
726 efield=efield, energy=energy, para_env=para_env, sab_orb=sab_orb)
727
728 ! calculate stress only if forces requested also
729 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
730 use_virial = use_virial .AND. calculate_forces
731 ! disable stress calculation
732 IF (use_virial) THEN
733 cpabort("Stress tensor for periodic D-field not implemented")
734 END IF
735
736 dfilter(1:3) = dft_control%period_efield%d_filter(1:3)
737
738 ! if an intensities list is given, select the value for the current step
739 strength = dft_control%period_efield%strength
740 IF (ALLOCATED(dft_control%period_efield%strength_list)) THEN
741 strength = dft_control%period_efield%strength_list(mod(qs_env%sim_step &
742 - dft_control%period_efield%start_frame, SIZE(dft_control%period_efield%strength_list)) + 1)
743 END IF
744
745 fieldpol = dft_control%period_efield%polarisation
746 fieldpol = fieldpol/norm2(fieldpol)
747 fieldpol = fieldpol*strength
748
749 omega = cell%deth
750 hmat = cell%hmat(:, :)/(twopi*omega)
751
752 ! nuclear contribution to polarization
753 natom = SIZE(particle_set)
754 IF (calculate_forces) THEN
755 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, force=force)
756 CALL get_atomic_kind_set(atomic_kind_set, atom_of_kind=atom_of_kind)
757 ALLOCATE (force_tmp(natom, 3, 3))
758 force_tmp = 0.0_dp
759 END IF
760 zi(:) = cmplx(1._dp, 0._dp, dp)
761 DO ia = 1, natom
762 CALL get_atomic_kind(particle_set(ia)%atomic_kind, kind_number=ikind)
763 CALL get_qs_kind(qs_kind_set(ikind), core_charge=charge)
764 ria = particle_set(ia)%r
765 ria = pbc(ria, cell)
766 DO idir = 1, 3
767 kvec(:) = twopi*cell%h_inv(idir, :)
768 dd = sum(kvec(:)*ria(:))
769 zdeta = cmplx(cos(dd), sin(dd), kind=dp)**charge
770 zi(idir) = zi(idir)*zdeta
771 END DO
772 IF (calculate_forces) THEN
773 IF (para_env%mepos == 0) THEN
774 DO i = 1, 3
775 force_tmp(ia, i, i) = force_tmp(ia, i, i) + charge/omega
776 END DO
777 END IF
778 END IF
779 END DO
780 rlog = aimag(log(zi))
781
782 ! check uniform occupation
783 NULLIFY (mos)
784 CALL get_qs_env(qs_env=qs_env, mos=mos)
785 DO ispin = 1, dft_control%nspins
786 CALL get_mo_set(mo_set=mos(ispin), maxocc=occ, uniform_occupation=uniform)
787 IF (.NOT. uniform) THEN
788 cpabort("Berry phase moments for non uniform MO occupation numbers not implemented")
789 END IF
790 END DO
791
792 ! initialize all work matrices needed
793 NULLIFY (mo_derivs)
794 CALL get_qs_env(qs_env=qs_env, mo_derivs=mo_derivs)
795 ALLOCATE (op_fm_set(2, dft_control%nspins))
796 ALLOCATE (opvec(2, dft_control%nspins))
797 ALLOCATE (eigrmat(dft_control%nspins))
798 ALLOCATE (inv_mat(dft_control%nspins))
799 ALLOCATE (inv_work(2, dft_control%nspins))
800 ALLOCATE (mo_derivs_tmp(3, SIZE(mo_derivs)))
801 ALLOCATE (mo_coeff_tmp(SIZE(mo_derivs)))
802
803 ! Allocate temp matrices for the wavefunction derivatives
804 DO ispin = 1, dft_control%nspins
805 NULLIFY (tmp_fm_struct, mo_coeff)
806 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
807 CALL cp_fm_struct_create(tmp_fm_struct, nrow_global=nmo, &
808 ncol_global=nmo, para_env=para_env, context=mo_coeff%matrix_struct%context)
809 CALL cp_fm_create(mo_coeff_tmp(ispin), mo_coeff%matrix_struct)
810 DO i = 1, 3
811 CALL cp_fm_create(mo_derivs_tmp(i, ispin), mo_coeff%matrix_struct)
812 CALL cp_fm_set_all(matrix=mo_derivs_tmp(i, ispin), alpha=0.0_dp)
813 END DO
814 DO i = 1, SIZE(op_fm_set, 1)
815 CALL cp_fm_create(opvec(i, ispin), mo_coeff%matrix_struct)
816 CALL cp_fm_create(op_fm_set(i, ispin), tmp_fm_struct)
817 CALL cp_fm_create(inv_work(i, ispin), op_fm_set(i, ispin)%matrix_struct)
818 END DO
819 CALL cp_cfm_create(eigrmat(ispin), op_fm_set(1, ispin)%matrix_struct)
820 CALL cp_cfm_create(inv_mat(ispin), op_fm_set(1, ispin)%matrix_struct)
821 CALL cp_fm_struct_release(tmp_fm_struct)
822 END DO
823 ! temp matrices for force calculation
824 IF (calculate_forces) THEN
825 NULLIFY (matrix_s)
826 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s)
827 ALLOCATE (tempmat(2, dft_control%nspins))
828 DO ispin = 1, dft_control%nspins
829 ALLOCATE (tempmat(1, ispin)%matrix, tempmat(2, ispin)%matrix)
830 CALL dbcsr_copy(tempmat(1, ispin)%matrix, matrix_s(1)%matrix, 'TEMPMAT')
831 CALL dbcsr_copy(tempmat(2, ispin)%matrix, matrix_s(1)%matrix, 'TEMPMAT')
832 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
833 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
834 END DO
835 ! integration
836 CALL get_qs_kind_set(qs_kind_set, maxco=ldab, maxsgf=lsab)
837 ALLOCATE (expab(ldab, ldab), work(ldab, ldab))
838 ALLOCATE (dexpab(ldab, ldab, 3, 2))
839 lsab = max(lsab, ldab)
840 DO i = 1, 3
841 ALLOCATE (dcost(i, 1)%block(lsab, lsab), dsint(i, 1)%block(lsab, lsab))
842 ALLOCATE (dcost(i, 2)%block(lsab, lsab), dsint(i, 2)%block(lsab, lsab))
843 END DO
844 END IF
845
846 !Start the MO derivative calculation
847 !loop over all cell vectors
848 DO idir = 1, 3
849 zi(idir) = z_zero
850 cosmat => efield%cosmat(idir)%matrix
851 sinmat => efield%sinmat(idir)%matrix
852 !evaluate the expression needed for the derivative (S_berry * C and [C^T S_berry C]^-1)
853 !first step S_berry * C and C^T S_berry C
854 DO ispin = 1, dft_control%nspins ! spin
855 IF (mos(ispin)%use_mo_coeff_b) THEN
856 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff_b=mo_coeff_b, nmo=nmo)
857 CALL copy_dbcsr_to_fm(mo_coeff_b, mo_coeff_tmp(ispin))
858 ELSE
859 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff=mo_coeff, nmo=nmo)
860 mo_coeff_tmp(ispin) = mo_coeff
861 END IF
862 CALL cp_dbcsr_sm_fm_multiply(cosmat, mo_coeff_tmp(ispin), opvec(1, ispin), ncol=nmo)
863 CALL parallel_gemm("T", "N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(1, ispin), 0.0_dp, &
864 op_fm_set(1, ispin))
865 CALL cp_dbcsr_sm_fm_multiply(sinmat, mo_coeff_tmp(ispin), opvec(2, ispin), ncol=nmo)
866 CALL parallel_gemm("T", "N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(2, ispin), 0.0_dp, &
867 op_fm_set(2, ispin))
868 END DO
869 !second step invert C^T S_berry C
870 zdet = z_one
871 DO ispin = 1, dft_control%nspins
872 CALL cp_cfm_scale_and_add_fm(z_zero, eigrmat(ispin), z_one, op_fm_set(1, ispin))
873 CALL cp_cfm_scale_and_add_fm(z_one, eigrmat(ispin), -gaussi, op_fm_set(2, ispin))
874 CALL cp_cfm_set_all(inv_mat(ispin), z_zero, z_one)
875 CALL cp_cfm_solve(eigrmat(ispin), inv_mat(ispin), zdeta)
876 zdet = zdet*zdeta
877 END DO
878 zi(idir) = zdet**occ
879 zlog(idir) = aimag(log(zi(idir)))
880
881 IF (.NOT. just_energy) THEN
882 !compute the orbital derivative
883 DO ispin = 1, dft_control%nspins
884 inv_work(1, ispin)%local_data(:, :) = real(inv_mat(ispin)%local_data(:, :), dp)
885 inv_work(2, ispin)%local_data(:, :) = aimag(inv_mat(ispin)%local_data(:, :))
886 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
887 DO i = 1, 3
888 focc = hmat(idir, i)
889 CALL parallel_gemm("N", "N", nao, nmo, nmo, focc, opvec(1, ispin), inv_work(2, ispin), &
890 1.0_dp, mo_derivs_tmp(idir, ispin))
891 CALL parallel_gemm("N", "N", nao, nmo, nmo, -focc, opvec(2, ispin), inv_work(1, ispin), &
892 1.0_dp, mo_derivs_tmp(idir, ispin))
893 END DO
894 END DO
895 END IF
896
897 !compute nuclear forces
898 IF (calculate_forces) THEN
899 nkind = SIZE(qs_kind_set)
900 natom = SIZE(particle_set)
901 kvec(:) = twopi*cell%h_inv(idir, :)
902
903 ! calculate: C [C^T S_berry C]^(-1) C^T
904 ! Store this matrix in DBCSR form (only S overlap blocks)
905 DO ispin = 1, dft_control%nspins
906 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
907 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
908 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
909 CALL parallel_gemm("N", "N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(1, ispin), 0.0_dp, &
910 opvec(1, ispin))
911 CALL parallel_gemm("N", "N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(2, ispin), 0.0_dp, &
912 opvec(2, ispin))
913 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=tempmat(1, ispin)%matrix, &
914 matrix_v=opvec(1, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
915 CALL cp_dbcsr_plus_fm_fm_t(sparse_matrix=tempmat(2, ispin)%matrix, &
916 matrix_v=opvec(2, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
917 END DO
918
919 ! Calculation of derivative integrals (da|eikr|b) and (a|eikr|db)
920 ALLOCATE (basis_set_list(nkind))
921 DO ikind = 1, nkind
922 qs_kind => qs_kind_set(ikind)
923 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set_a)
924 IF (ASSOCIATED(basis_set_a)) THEN
925 basis_set_list(ikind)%gto_basis_set => basis_set_a
926 ELSE
927 NULLIFY (basis_set_list(ikind)%gto_basis_set)
928 END IF
929 END DO
930 !
931 CALL neighbor_list_iterator_create(nl_iterator, sab_orb)
932 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
933 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, &
934 iatom=iatom, jatom=jatom, r=rab)
935 basis_set_a => basis_set_list(ikind)%gto_basis_set
936 IF (.NOT. ASSOCIATED(basis_set_a)) cycle
937 basis_set_b => basis_set_list(jkind)%gto_basis_set
938 IF (.NOT. ASSOCIATED(basis_set_b)) cycle
939 ! basis ikind
940 first_sgfa => basis_set_a%first_sgf
941 la_max => basis_set_a%lmax
942 la_min => basis_set_a%lmin
943 npgfa => basis_set_a%npgf
944 nseta = basis_set_a%nset
945 nsgfa => basis_set_a%nsgf_set
946 rpgfa => basis_set_a%pgf_radius
947 set_radius_a => basis_set_a%set_radius
948 sphi_a => basis_set_a%sphi
949 zeta => basis_set_a%zet
950 ! basis jkind
951 first_sgfb => basis_set_b%first_sgf
952 lb_max => basis_set_b%lmax
953 lb_min => basis_set_b%lmin
954 npgfb => basis_set_b%npgf
955 nsetb = basis_set_b%nset
956 nsgfb => basis_set_b%nsgf_set
957 rpgfb => basis_set_b%pgf_radius
958 set_radius_b => basis_set_b%set_radius
959 sphi_b => basis_set_b%sphi
960 zetb => basis_set_b%zet
961
962 ldsa = SIZE(sphi_a, 1)
963 ldsb = SIZE(sphi_b, 1)
964 ra(:) = pbc(particle_set(iatom)%r(:), cell)
965 rb(:) = ra + rab
966 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
967
968 IF (iatom <= jatom) THEN
969 irow = iatom
970 icol = jatom
971 ELSE
972 irow = jatom
973 icol = iatom
974 END IF
975
976 IF (iatom == jatom) THEN
977 fab = 1.0_dp*occ
978 ELSE
979 fab = 2.0_dp*occ
980 END IF
981
982 DO i = 1, 3
983 dcost(i, 1)%block = 0.0_dp
984 dsint(i, 1)%block = 0.0_dp
985 dcost(i, 2)%block = 0.0_dp
986 dsint(i, 2)%block = 0.0_dp
987 END DO
988
989 DO iset = 1, nseta
990 ncoa = npgfa(iset)*ncoset(la_max(iset))
991 sgfa = first_sgfa(1, iset)
992 DO jset = 1, nsetb
993 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
994 ncob = npgfb(jset)*ncoset(lb_max(jset))
995 sgfb = first_sgfb(1, jset)
996 ! Calculate both basis-center derivatives from one primitive recurrence.
997 CALL expikr(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
998 lb_max(jset), npgfb(jset), zetb(:, jset), rpgfb(:, jset), lb_min(jset), &
999 ra, rb, kvec, expab, dexpab(:, :, :, 1), dexpab(:, :, :, 2))
1000 DO icenter = 1, 2
1001 DO i = 1, 3
1002 CALL contract_all(dcost(i, icenter)%block, dsint(i, icenter)%block, &
1003 ncoa, nsgfa(iset), sgfa, sphi_a, ldsa, &
1004 ncob, nsgfb(jset), sgfb, sphi_b, ldsb, &
1005 REAL(dexpab(1:ncoa, 1:ncob, i, icenter), kind=dp), &
1006 aimag(dexpab(1:ncoa, 1:ncob, i, icenter)), ncoa, work, ldab)
1007 END DO
1008 END DO
1009 END DO
1010 END DO
1011 forcea = 0.0_dp
1012 forceb = 0.0_dp
1013 DO ispin = 1, dft_control%nspins
1014 NULLIFY (rblock, iblock)
1015 CALL dbcsr_get_block_p(matrix=tempmat(1, ispin)%matrix, &
1016 row=irow, col=icol, block=rblock, found=found)
1017 cpassert(found)
1018 CALL dbcsr_get_block_p(matrix=tempmat(2, ispin)%matrix, &
1019 row=irow, col=icol, block=iblock, found=found)
1020 cpassert(found)
1021 n1 = SIZE(rblock, 1)
1022 n2 = SIZE(rblock, 2)
1023 cpassert(SIZE(iblock, 1) == n1)
1024 cpassert(SIZE(iblock, 2) == n2)
1025 cpassert(lsab >= n1)
1026 cpassert(lsab >= n2)
1027 IF (iatom <= jatom) THEN
1028 DO i = 1, 3
1029 forcea(i) = forcea(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 1)%block(1:n1, 1:n2)) &
1030 - sum(iblock(1:n1, 1:n2)*dcost(i, 1)%block(1:n1, 1:n2))
1031 forceb(i) = forceb(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 2)%block(1:n1, 1:n2)) &
1032 - sum(iblock(1:n1, 1:n2)*dcost(i, 2)%block(1:n1, 1:n2))
1033 END DO
1034 ELSE
1035 DO i = 1, 3
1036 forcea(i) = forcea(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 1)%block(1:n2, 1:n1)) &
1037 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 1)%block(1:n2, 1:n1))
1038 forceb(i) = forceb(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 2)%block(1:n2, 1:n1)) &
1039 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 2)%block(1:n2, 1:n1))
1040 END DO
1041 END IF
1042 END DO
1043 DO i = 1, 3
1044 force_tmp(iatom, :, i) = force_tmp(iatom, :, i) - fab*hmat(i, idir)*forcea(:)
1045 force_tmp(jatom, :, i) = force_tmp(jatom, :, i) - fab*hmat(i, idir)*forceb(:)
1046 END DO
1047 END DO
1048 CALL neighbor_list_iterator_release(nl_iterator)
1049 DEALLOCATE (basis_set_list)
1050 END IF
1051 END DO
1052
1053 ! make sure the total normalized polarization is within [-1:1]
1054 DO idir = 1, 3
1055 cqi(idir) = rlog(idir) + zlog(idir)
1056 IF (cqi(idir) > pi) cqi(idir) = cqi(idir) - twopi
1057 IF (cqi(idir) < -pi) cqi(idir) = cqi(idir) + twopi
1058 ! now check for log branch
1059 IF (calculate_forces) THEN
1060 IF (abs(efield%polarisation(idir) - cqi(idir)) > pi) THEN
1061 di(idir) = (efield%polarisation(idir) - cqi(idir))/pi
1062 DO i = 1, 10
1063 cqi(idir) = cqi(idir) + sign(1.0_dp, di(idir))*twopi
1064 IF (abs(efield%polarisation(idir) - cqi(idir)) < pi) EXIT
1065 END DO
1066 END IF
1067 END IF
1068 END DO
1069 DO idir = 1, 3
1070 qi(idir) = 0.0_dp
1071 ci(idir) = 0.0_dp
1072 DO i = 1, 3
1073 ci(idir) = ci(idir) + hmat(idir, i)*cqi(i)
1074 END DO
1075 END DO
1076
1077 ! update the references
1078 IF (calculate_forces) THEN
1079 ener_field = sum(ci)
1080 ! check for smoothness of energy surface
1081 IF (abs(efield%field_energy - ener_field) > pi*abs(sum(hmat))) THEN
1082 cpwarn("Large change of e-field energy detected. Correct for non-smooth energy surface")
1083 END IF
1084 efield%field_energy = ener_field
1085 efield%polarisation(:) = cqi(:)
1086 END IF
1087
1088 ! Energy
1089 ener_field = 0.0_dp
1090 DO i = 1, 3
1091 ener_field = ener_field + dfilter(i)*(fieldpol(i) - 2._dp*twopi*ci(i))**2
1092 END DO
1093 energy%efield = 0.25_dp*omega/twopi*ener_field
1094
1095 ! debugging output
1096 IF (para_env%is_source()) THEN
1097 iodeb = -1
1098 IF (iodeb > 0) THEN
1099 WRITE (iodeb, '(A,T61,F20.10)') " Polarisation Quantum: ", 2._dp*twopi*twopi*hmat(3, 3)
1100 WRITE (iodeb, '(A,T21,3F20.10)') " Polarisation: ", 2._dp*twopi*ci(1:3)
1101 WRITE (iodeb, '(A,T21,3F20.10)') " Displacement: ", fieldpol(1:3)
1102 WRITE (iodeb, '(A,T21,3F20.10)') " E-Field: ", ((fieldpol(i) - 2._dp*twopi*ci(i)), i=1, 3)
1103 WRITE (iodeb, '(A,T61,F20.10)') " Disp Free Energy:", energy%efield
1104 END IF
1105 END IF
1106
1107 IF (.NOT. just_energy) THEN
1108 DO i = 1, 3
1109 di(i) = -omega*(fieldpol(i) - 2._dp*twopi*ci(i))*dfilter(i)
1110 END DO
1111 ! Add the result to mo_derivativs
1112 DO ispin = 1, dft_control%nspins
1113 CALL copy_dbcsr_to_fm(mo_derivs(ispin)%matrix, mo_coeff_tmp(ispin))
1114 DO idir = 1, 3
1115 CALL cp_fm_scale_and_add(1.0_dp, mo_coeff_tmp(ispin), di(idir), &
1116 mo_derivs_tmp(idir, ispin))
1117 END DO
1118 END DO
1119 DO ispin = 1, dft_control%nspins
1120 CALL copy_fm_to_dbcsr(mo_coeff_tmp(ispin), mo_derivs(ispin)%matrix)
1121 END DO
1122 END IF
1123
1124 IF (calculate_forces) THEN
1125 DO i = 1, 3
1126 DO ia = 1, natom
1127 CALL get_atomic_kind(particle_set(ia)%atomic_kind, kind_number=ikind)
1128 iatom = atom_of_kind(ia)
1129 force(ikind)%efield(1:3, iatom) = force(ikind)%efield(1:3, iatom) + di(i)*force_tmp(ia, 1:3, i)
1130 END DO
1131 END DO
1132 END IF
1133
1134 DO ispin = 1, dft_control%nspins
1135 CALL cp_cfm_release(eigrmat(ispin))
1136 CALL cp_cfm_release(inv_mat(ispin))
1137 IF (mos(ispin)%use_mo_coeff_b) CALL cp_fm_release(mo_coeff_tmp(ispin))
1138 DO i = 1, 3
1139 CALL cp_fm_release(mo_derivs_tmp(i, ispin))
1140 END DO
1141 DO i = 1, SIZE(op_fm_set, 1)
1142 CALL cp_fm_release(opvec(i, ispin))
1143 CALL cp_fm_release(op_fm_set(i, ispin))
1144 CALL cp_fm_release(inv_work(i, ispin))
1145 END DO
1146 END DO
1147 DEALLOCATE (inv_mat, inv_work, op_fm_set, opvec, eigrmat)
1148 DEALLOCATE (mo_coeff_tmp, mo_derivs_tmp)
1149
1150 IF (calculate_forces) THEN
1151 DO ikind = 1, SIZE(atomic_kind_set)
1152 CALL para_env%sum(force(ikind)%efield)
1153 END DO
1154 DEALLOCATE (force_tmp)
1155 DEALLOCATE (expab, work, dexpab)
1156 DO i = 1, 3
1157 DEALLOCATE (dcost(i, 1)%block, dsint(i, 1)%block)
1158 DEALLOCATE (dcost(i, 2)%block, dsint(i, 2)%block)
1159 END DO
1160 CALL dbcsr_deallocate_matrix_set(tempmat)
1161 END IF
1162 CALL timestop(handle)
1163
1164 END SUBROUTINE qs_dispfield_derivatives
1165
1166! **************************************************************************************************
1167!> \brief ...
1168!> \param cos_block ...
1169!> \param sin_block ...
1170!> \param ncoa ...
1171!> \param nsgfa ...
1172!> \param sgfa ...
1173!> \param sphi_a ...
1174!> \param ldsa ...
1175!> \param ncob ...
1176!> \param nsgfb ...
1177!> \param sgfb ...
1178!> \param sphi_b ...
1179!> \param ldsb ...
1180!> \param cosab ...
1181!> \param sinab ...
1182!> \param ldab ...
1183!> \param work ...
1184!> \param ldwork ...
1185! **************************************************************************************************
1186 SUBROUTINE contract_all(cos_block, sin_block, &
1187 ncoa, nsgfa, sgfa, sphi_a, ldsa, &
1188 ncob, nsgfb, sgfb, sphi_b, ldsb, &
1189 cosab, sinab, ldab, work, ldwork)
1190
1191 REAL(dp), DIMENSION(:, :), POINTER :: cos_block, sin_block
1192 INTEGER, INTENT(IN) :: ncoa, nsgfa, sgfa
1193 REAL(dp), DIMENSION(:, :), INTENT(IN) :: sphi_a
1194 INTEGER, INTENT(IN) :: ldsa, ncob, nsgfb, sgfb
1195 REAL(dp), DIMENSION(:, :), INTENT(IN) :: sphi_b
1196 INTEGER, INTENT(IN) :: ldsb
1197 REAL(dp), DIMENSION(:, :), INTENT(IN) :: cosab, sinab
1198 INTEGER, INTENT(IN) :: ldab
1199 REAL(dp), DIMENSION(:, :) :: work
1200 INTEGER, INTENT(IN) :: ldwork
1201
1202! Calculate cosine
1203
1204 CALL dgemm("N", "N", ncoa, nsgfb, ncob, 1.0_dp, cosab(1, 1), ldab, &
1205 sphi_b(1, sgfb), ldsb, 0.0_dp, work(1, 1), ldwork)
1206
1207 CALL dgemm("T", "N", nsgfa, nsgfb, ncoa, 1.0_dp, sphi_a(1, sgfa), ldsa, &
1208 work(1, 1), ldwork, 1.0_dp, cos_block(sgfa, sgfb), SIZE(cos_block, 1))
1209
1210 ! Calculate sine
1211 CALL dgemm("N", "N", ncoa, nsgfb, ncob, 1.0_dp, sinab(1, 1), ldab, &
1212 sphi_b(1, sgfb), ldsb, 0.0_dp, work(1, 1), ldwork)
1213
1214 CALL dgemm("T", "N", nsgfa, nsgfb, ncoa, 1.0_dp, sphi_a(1, sgfa), ldsa, &
1215 work(1, 1), ldwork, 1.0_dp, sin_block(sgfa, sgfb), SIZE(sin_block, 1))
1216
1217 END SUBROUTINE contract_all
1218
1219END MODULE qs_efield_berry
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Calculation of the moment integrals over Cartesian Gaussian-type functions.
Definition ai_moments.F:17
subroutine, public expikr(la_max_set, npgfa, zeta, rpgfa, la_min_set, lb_max, npgfb, zetb, rpgfb, lb_min, rac, rbc, kvec, expab, dexpab, dexpba, momentab)
Evaluate primitive exp(i k.r) integrals through the complex overlap recurrence.
Definition ai_moments.F:163
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.
collect pointers to a block of reals
Handles all functions related to the CELL.
Definition cell_types.F:15
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_solve(matrix_a, general_a, determinant)
Solve the system of linear equations A*b=A_general using LU decomposition. Pay attention that both ma...
subroutine, public cp_cfm_scale_and_add_fm(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b). where b is a real matrix (adapted from cp_cf...
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
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_set(matrix, alpha)
...
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, plan, check_plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_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_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
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 pi
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public gaussi
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Calculates the energy contribution and the mo_derivative of a static periodic electric field.
subroutine, public qs_efield_berry_phase(qs_env, just_energy, calculate_forces)
...
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.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set 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.
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, cmo_coeff)
Get the components of a MO set data structure.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>.
Definition qs_moments.F:14
subroutine, public build_berry_moment_matrix(qs_env, cosmat, sinmat, kvec, sab_orb_external, basis_type)
...
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)
...
type for berry phase efield matrices. At the moment only used for cosmat and sinmat
subroutine, public set_efield_matrices(efield, sinmat, cosmat, dipmat)
...
subroutine, public init_efield_matrices(efield)
...
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 defining parameters related to the simulation cell.
Definition cell_types.F:60
Represent a complex full matrix.
keeps the information about the structure of a full matrix
represent a full matrix
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.