(git:e7e05ae)
qs_electric_field_gradient.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
8 ! **************************************************************************************************
9 !> \brief Calculates electric field gradients
10 !> H.M. Petrili, P.E. Blochl, P. Blaha, K. Schwarz, PRB 57, 14690 (1998)
11 !> \par History
12 !> 12.2007 Added checksum for interpolation regtest [rdeclerck]
13 !> \author JGH (03-05-2006)
14 ! **************************************************************************************************
16  USE atomic_kind_types, ONLY: atomic_kind_type,&
19  gto_basis_set_type
20  USE cp_control_types, ONLY: dft_control_type
22  cp_logger_type
24  USE eigenvalueproblems, ONLY: diagonalise
27  section_vals_type,&
29  USE kinds, ONLY: dp
30  USE mathconstants, ONLY: fac,&
31  fourpi
32  USE message_passing, ONLY: mp_para_env_type
33  USE orbital_pointers, ONLY: indso,&
34  nsoset
35  USE particle_types, ONLY: particle_type
37  USE physcon, ONLY: a_bohr,&
38  e_charge,&
39  joule
40  USE pw_env_types, ONLY: pw_env_get,&
41  pw_env_type
42  USE pw_methods, ONLY: pw_dr2,&
43  pw_integral_ab,&
44  pw_smoothing,&
46  pw_transfer
47  USE pw_poisson_methods, ONLY: pw_poisson_solve
48  USE pw_poisson_types, ONLY: pw_poisson_type
49  USE pw_pool_types, ONLY: pw_pool_type
50  USE pw_spline_utils, ONLY: &
53  pw_spline_precond_type, spl3_pbc
54  USE pw_types, ONLY: pw_c1d_gs_type,&
55  pw_r3d_rs_type
56  USE qs_environment_types, ONLY: get_qs_env,&
57  qs_environment_type
59  USE qs_harmonics_atom, ONLY: get_none0_cg_list,&
60  harmonics_atom_type
61  USE qs_kind_types, ONLY: get_qs_kind,&
62  qs_kind_type
64  USE qs_rho_atom_types, ONLY: rho_atom_type
65  USE qs_rho_types, ONLY: qs_rho_type
66  USE util, ONLY: get_limit,&
67  sort
68 #include "./base/base_uses.f90"
69 
70  IMPLICIT NONE
71 
72  PRIVATE
73  PUBLIC :: qs_efg_calc
74 
75  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_electric_field_gradient'
76 
77 CONTAINS
78 
79 ! **************************************************************************************************
80 !> \brief ...
81 !> \param qs_env ...
82 ! **************************************************************************************************
83  SUBROUTINE qs_efg_calc(qs_env)
84 
85  TYPE(qs_environment_type), POINTER :: qs_env
86 
87  CHARACTER(LEN=*), PARAMETER :: routinen = 'qs_efg_calc'
88 
89  CHARACTER(LEN=2) :: element_symbol
90  INTEGER :: aint_precond, handle, i, iat, iatom, ij, &
91  ikind, j, max_iter, natom, natomkind, &
92  nkind, nspins, precond_kind, unit_nr
93  INTEGER, DIMENSION(:), POINTER :: atom_list
94  LOGICAL :: efg_debug, efg_interpolation, gapw, &
95  paw_atom, smoothing, success
96  REAL(kind=dp) :: chk_spl, ecut, efg_units, efg_val, &
97  ehartree, eps_r, eps_x, f1, f2, sigma
98  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: efg_diagval, vh0
99  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: efg_pw, efg_tensor
100  REAL(kind=dp), DIMENSION(3) :: eigenvalues, ra
101  REAL(kind=dp), DIMENSION(3, 3) :: eigenvectors
102  REAL(kind=dp), DIMENSION(:), POINTER :: rvals
103  TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
104  TYPE(cp_logger_type), POINTER :: logger
105  TYPE(dft_control_type), POINTER :: dft_control
106  TYPE(mp_para_env_type), POINTER :: para_env
107  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
108  TYPE(pw_c1d_gs_type) :: rho_tot_gspace, structure_factor, &
109  v_hartree_gspace
110  TYPE(pw_c1d_gs_type), DIMENSION(6) :: dvr2
111  TYPE(pw_env_type), POINTER :: pw_env
112  TYPE(pw_poisson_type), POINTER :: poisson_env
113  TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
114  TYPE(pw_r3d_rs_type) :: dvr2rs
115  TYPE(pw_r3d_rs_type), DIMENSION(6) :: dvspl
116  TYPE(pw_spline_precond_type) :: precond
117  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
118  TYPE(qs_rho_type), POINTER :: rho
119  TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
120  TYPE(section_vals_type), POINTER :: dft_section, input, interp_section
121 
122  NULLIFY (atomic_kind_set, qs_kind_set, dft_control, para_env, particle_set, rho, &
123  rho_atom_set, input, dft_section, interp_section)
124 
125  CALL timeset(routinen, handle)
126 
127  logger => cp_get_default_logger()
128 
129  chk_spl = 0.0_dp
130  efg_units = joule/a_bohr**2/e_charge*1.e-21_dp
131  f1 = sqrt(15._dp/fourpi)
132  f2 = sqrt(5._dp/fourpi)
133 
134  CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, &
135  rho=rho, qs_kind_set=qs_kind_set, &
136  atomic_kind_set=atomic_kind_set, &
137  rho_atom_set=rho_atom_set, pw_env=pw_env, &
138  particle_set=particle_set, para_env=para_env, &
139  input=input)
140 
141  dft_section => section_vals_get_subs_vals(input, "DFT")
142 
143  efg_interpolation = section_get_lval(section_vals=dft_section, &
144  keyword_name="PRINT%ELECTRIC_FIELD_GRADIENT%INTERPOLATION")
145  efg_debug = section_get_lval(section_vals=dft_section, &
146  keyword_name="PRINT%ELECTRIC_FIELD_GRADIENT%DEBUG")
147  CALL section_vals_val_get(dft_section, &
148  "PRINT%ELECTRIC_FIELD_GRADIENT%GSPACE_SMOOTHING", &
149  r_vals=rvals)
150  ecut = rvals(1)
151  sigma = rvals(2)
152  IF (ecut == 0._dp .AND. sigma <= 0._dp) THEN
153  smoothing = .false.
154  ecut = 1.e10_dp ! not used, just to have vars defined
155  sigma = 1._dp ! not used, just to have vars defined
156  ELSEIF (ecut == -1._dp .AND. sigma == -1._dp) THEN
157  smoothing = .true.
158  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
159  CALL auxbas_pw_pool%create_pw(dvr2rs)
160  ecut = 2._dp*dvr2rs%pw_grid%cutoff*0.875_dp
161  sigma = 2._dp*dvr2rs%pw_grid%cutoff*0.125_dp
162  CALL auxbas_pw_pool%give_back_pw(dvr2rs)
163  ELSE
164  smoothing = .true.
165  END IF
166  cpassert(ecut > 0._dp)
167  cpassert(sigma > 0._dp)
168 
169  unit_nr = cp_print_key_unit_nr(logger, dft_section, "PRINT%ELECTRIC_FIELD_GRADIENT", &
170  extension=".efg", log_filename=.false.)
171 
172  IF (unit_nr > 0) THEN
173  WRITE (unit_nr, "(/,A,/)") " ELECTRIC FIELD GRADIENTS [10**21 V/m^2]"
174  IF (efg_interpolation) THEN
175  WRITE (unit_nr, "(T16,A)") &
176  " Smooth potential contribution calculated by spline interpolation"
177  ELSE
178  WRITE (unit_nr, "(T12,A)") &
179  " Smooth potential contribution calculated by plane wave interpolation"
180  END IF
181  IF (smoothing) THEN
182  WRITE (unit_nr, "(T36,A)") &
183  " G-Space potential smoothed by Fermi function"
184  WRITE (unit_nr, "(T36,A,T71,F10.4)") " Cutoff (eV) ", ecut
185  WRITE (unit_nr, "(T36,A,T71,F10.4)") " Width (eV) ", sigma
186  END IF
187  WRITE (unit_nr, *)
188  END IF
189 
190  gapw = dft_control%qs_control%gapw
191  nspins = dft_control%nspins
192 
193  natom = SIZE(particle_set, 1)
194  ALLOCATE (efg_tensor(3, 3, natom))
195  efg_tensor = 0._dp
196  IF (efg_debug) THEN
197  ALLOCATE (efg_pw(3, 3, natom))
198  efg_pw = 0._dp
199  END IF
200  ALLOCATE (efg_diagval(3, natom))
201  efg_diagval = 0._dp
202 
203  ALLOCATE (vh0(1:natom, -2:2))
204  vh0 = 0._dp
205 
206  !prepare calculation
207  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
208  poisson_env=poisson_env)
209  IF (gapw) CALL prepare_gapw_den(qs_env, do_rho0=.true.)
210 
211  !calculate electrostatic potential
212  CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
213  CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
214  CALL calc_rho_tot_gspace(rho_tot_gspace, qs_env, rho)
215 
216  CALL pw_poisson_solve(poisson_env, rho_tot_gspace, ehartree, &
217  v_hartree_gspace)
218  CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
219 
220  ! smoothing of potential
221  IF (smoothing) CALL pw_smoothing(v_hartree_gspace, ecut, sigma)
222 
223  DO i = 1, 3
224  DO j = 1, i
225  ij = (i*(i - 1))/2 + j
226  CALL auxbas_pw_pool%create_pw(dvr2(ij))
227  CALL pw_dr2(v_hartree_gspace, dvr2(ij), i, j)
228  END DO
229  END DO
230 
231  IF (.NOT. efg_interpolation) THEN
232  CALL auxbas_pw_pool%create_pw(structure_factor)
233  ELSE
234 
235  interp_section => section_vals_get_subs_vals(dft_section, &
236  "PRINT%ELECTRIC_FIELD_GRADIENT%INTERPOLATOR")
237  CALL section_vals_val_get(interp_section, "aint_precond", &
238  i_val=aint_precond)
239  CALL section_vals_val_get(interp_section, "precond", i_val=precond_kind)
240  CALL section_vals_val_get(interp_section, "max_iter", i_val=max_iter)
241  CALL section_vals_val_get(interp_section, "eps_r", r_val=eps_r)
242  CALL section_vals_val_get(interp_section, "eps_x", r_val=eps_x)
243 
244  CALL auxbas_pw_pool%create_pw(dvr2rs)
245  DO i = 1, 6
246  CALL auxbas_pw_pool%create_pw(dvspl(i))
247  CALL pw_transfer(dvr2(i), dvr2rs)
248  ! calculate spline coefficients
249  CALL pw_spline_precond_create(precond, precond_kind=aint_precond, &
250  pool=auxbas_pw_pool, pbc=.true., transpose=.false.)
251  CALL pw_spline_do_precond(precond, dvr2rs, dvspl(i))
252  CALL pw_spline_precond_set_kind(precond, precond_kind)
253  success = find_coeffs(values=dvr2rs, coeffs=dvspl(i), &
254  linop=spl3_pbc, preconditioner=precond, pool=auxbas_pw_pool, &
255  eps_r=eps_r, eps_x=eps_x, max_iter=max_iter)
256  cpassert(success)
257  CALL pw_spline_precond_release(precond)
258  CALL auxbas_pw_pool%give_back_pw(dvr2(i))
259  END DO
260  CALL auxbas_pw_pool%give_back_pw(dvr2rs)
261  END IF
262 
263  nkind = SIZE(qs_kind_set)
264 
265  DO ikind = 1, nkind
266  NULLIFY (atom_list)
267  CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natomkind)
268  CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
269  DO iat = 1, natomkind
270  iatom = atom_list(iat)
271  ra = particle_set(iatom)%r
272  IF (efg_interpolation) THEN
273  DO i = 1, 3
274  DO j = 1, i
275  ij = (i*(i - 1))/2 + j
276  efg_val = eval_interp_spl3_pbc(ra, dvspl(ij))
277  efg_tensor(i, j, iatom) = -efg_val
278  efg_tensor(j, i, iatom) = efg_tensor(i, j, iatom)
279  IF (efg_debug) THEN
280  chk_spl = chk_spl + efg_val + &
281  sum(eval_d_interp_spl3_pbc(ra, dvspl(ij)))
282  END IF
283  END DO
284  END DO
285  ELSE
286  CALL pw_structure_factor(structure_factor, ra)
287  DO i = 1, 3
288  DO j = 1, i
289  ij = (i*(i - 1))/2 + j
290  efg_tensor(i, j, iatom) = -pw_integral_ab(dvr2(ij), structure_factor)
291  efg_tensor(j, i, iatom) = efg_tensor(i, j, iatom)
292  END DO
293  END DO
294  efg_tensor(:, :, iatom) = efg_tensor(:, :, iatom)/structure_factor%pw_grid%vol
295  END IF
296  IF (efg_debug) THEN
297  efg_pw(:, :, iatom) = efg_tensor(:, :, iatom)
298  END IF
299  END DO
300 
301  IF (paw_atom) THEN
302  CALL vlimit_atom(para_env, vh0, rho_atom_set, qs_kind_set(ikind), &
303  atom_list, natomkind, nspins)
304  DO iat = 1, natomkind
305  iatom = atom_list(iat)
306  efg_tensor(1, 1, iatom) = efg_tensor(1, 1, iatom) &
307  + f1*(vh0(iatom, 2)) - f2*(vh0(iatom, 0))
308  efg_tensor(2, 2, iatom) = efg_tensor(2, 2, iatom) &
309  - f1*(vh0(iatom, 2)) - f2*(vh0(iatom, 0))
310  efg_tensor(3, 3, iatom) = efg_tensor(3, 3, iatom) + 2._dp*f2*(vh0(iatom, 0))
311  efg_tensor(1, 2, iatom) = efg_tensor(1, 2, iatom) + f1*(vh0(iatom, -2))
312  efg_tensor(2, 1, iatom) = efg_tensor(2, 1, iatom) + f1*(vh0(iatom, -2))
313  efg_tensor(1, 3, iatom) = efg_tensor(1, 3, iatom) + f1*(vh0(iatom, 1))
314  efg_tensor(3, 1, iatom) = efg_tensor(3, 1, iatom) + f1*(vh0(iatom, 1))
315  efg_tensor(2, 3, iatom) = efg_tensor(2, 3, iatom) + f1*(vh0(iatom, -1))
316  efg_tensor(3, 2, iatom) = efg_tensor(3, 2, iatom) + f1*(vh0(iatom, -1))
317  END DO
318  END IF
319 
320  DO iat = 1, natomkind
321  iatom = atom_list(iat)
322  CALL diagonalise(efg_tensor(:, :, iatom), 3, "UPPER", &
323  eigenvalues, eigenvectors)
324  CALL efgsort(eigenvalues, efg_diagval(:, iatom))
325  END DO
326  END DO ! ikind
327 
328  efg_tensor(:, :, :) = efg_tensor(:, :, :)*efg_units
329  efg_diagval(:, :) = efg_diagval(:, :)*efg_units
330 
331  IF (efg_debug) THEN
332  efg_pw(:, :, :) = efg_pw(:, :, :)*efg_units
333  DO iatom = 1, natom
334  IF (unit_nr > 0) THEN
335  CALL get_atomic_kind(particle_set(iatom)%atomic_kind, &
336  element_symbol=element_symbol)
337  WRITE (unit=unit_nr, fmt="(T2,I5,T8,A,T12,A,T15,6F11.5)") &
338  iatom, element_symbol, "PW", ((efg_pw(i, j, iatom), i=1, j), j=1, 3)
339  WRITE (unit=unit_nr, fmt="(T12,A,T15,6F11.5)") &
340  "AT", ((efg_tensor(i, j, iatom) - efg_pw(i, j, iatom), i=1, j), j=1, 3)
341  END IF
342  END DO
343  IF (unit_nr > 0) THEN
344  WRITE (unit=unit_nr, fmt=*)
345  END IF
346  IF (efg_interpolation) THEN
347  IF (unit_nr > 0) THEN
348  WRITE (unit=unit_nr, fmt="(T2,A,E24.16)") "CheckSum splines =", &
349  chk_spl
350  WRITE (unit=unit_nr, fmt=*)
351  END IF
352  END IF
353  END IF
354 
355  DO iatom = 1, natom
356  IF (unit_nr > 0) THEN
357  CALL get_atomic_kind(particle_set(iatom)%atomic_kind, &
358  element_symbol=element_symbol)
359  WRITE (unit=unit_nr, fmt="(T2,I5,T8,A,T12,A,3(T39,3F14.7,/))") &
360  iatom, element_symbol, "EFG Tensor", (efg_tensor(i, :, iatom), i=1, 3)
361  WRITE (unit=unit_nr, fmt="(T12,A,T39,3F14.7)") &
362  "EFG Tensor eigenvalues", efg_diagval(:, iatom)
363  WRITE (unit=unit_nr, fmt="(T12,A,T67,F14.7)") "EFG Tensor anisotropy", &
364  (efg_diagval(1, iatom) - efg_diagval(2, iatom))/efg_diagval(3, iatom)
365  WRITE (unit=unit_nr, fmt=*)
366  END IF
367  END DO
368 
369  CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
370  IF (.NOT. efg_interpolation) THEN
371  CALL auxbas_pw_pool%give_back_pw(structure_factor)
372  DO i = 1, 6
373  CALL auxbas_pw_pool%give_back_pw(dvr2(i))
374  END DO
375  ELSE
376  DO i = 1, 6
377  CALL auxbas_pw_pool%give_back_pw(dvspl(i))
378  END DO
379  END IF
380 
381  DEALLOCATE (efg_tensor)
382  IF (efg_debug) THEN
383  DEALLOCATE (efg_pw)
384  END IF
385 
386  DEALLOCATE (vh0)
387 
388  CALL timestop(handle)
389 
390  END SUBROUTINE qs_efg_calc
391 
392 ! **************************************************************************************************
393 !> \brief ...
394 !> \param para_env ...
395 !> \param vlimit ...
396 !> \param rho_atom_set ...
397 !> \param qs_kind ...
398 !> \param atom_list ...
399 !> \param natom ...
400 !> \param nspins ...
401 ! **************************************************************************************************
402  SUBROUTINE vlimit_atom(para_env, vlimit, rho_atom_set, qs_kind, &
403  atom_list, natom, nspins)
404 
405  ! calculate : Limit(r->0) V_hartree(r)/r^2
406 
407  TYPE(mp_para_env_type), POINTER :: para_env
408  REAL(dp), DIMENSION(:, -2:), INTENT(inout) :: vlimit
409  TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
410  TYPE(qs_kind_type), INTENT(IN) :: qs_kind
411  INTEGER, DIMENSION(:), INTENT(IN) :: atom_list
412  INTEGER, INTENT(IN) :: natom, nspins
413 
414  INTEGER :: i, i1, i2, iat, iatom, icg, ipgf1, ipgf2, iset1, iset2, iso, iso1, iso1_first, &
415  iso1_last, iso2, iso2_first, iso2_last, l, l_iso, llmax, m1s, m2s, m_iso, max_iso_not0, &
416  max_iso_not0_local, max_s_harm, maxl, maxso, mepos, n1s, n2s, nset, num_pe, size1, size2
417  INTEGER, ALLOCATABLE, DIMENSION(:) :: cg_n_list
418  INTEGER, ALLOCATABLE, DIMENSION(:, :, :) :: cg_list
419  INTEGER, DIMENSION(2) :: bo
420  INTEGER, DIMENSION(:), POINTER :: lmax, lmin, npgf, o2nindex
421  REAL(dp) :: zet12
422  REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: cpc_sphere
423  REAL(dp), DIMENSION(20) :: vgg
424  REAL(dp), DIMENSION(:, :), POINTER :: coeff, zet
425  REAL(dp), DIMENSION(:, :, :), POINTER :: my_cg
426  TYPE(gto_basis_set_type), POINTER :: basis_1c
427  TYPE(harmonics_atom_type), POINTER :: harmonics
428 
429  NULLIFY (basis_1c)
430  NULLIFY (harmonics)
431  NULLIFY (lmin, lmax, npgf, zet, my_cg, coeff)
432 
433  CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_1c, basis_type="GAPW_1C", &
434  harmonics=harmonics)
435 
436  CALL get_gto_basis_set(gto_basis_set=basis_1c, lmax=lmax, lmin=lmin, &
437  maxl=maxl, npgf=npgf, nset=nset, zet=zet, &
438  maxso=maxso)
439  CALL get_paw_basis_info(basis_1c, o2nindex=o2nindex)
440 
441  max_iso_not0 = harmonics%max_iso_not0
442  max_s_harm = harmonics%max_s_harm
443  llmax = harmonics%llmax
444 
445  ! Distribute the atoms of this kind
446  num_pe = para_env%num_pe
447  mepos = para_env%mepos
448  bo = get_limit(natom, num_pe, mepos)
449 
450  my_cg => harmonics%my_CG
451 
452  ALLOCATE (cpc_sphere(nsoset(maxl), nsoset(maxl)))
453  ALLOCATE (cg_list(2, nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm))
454 
455  m1s = 0
456  DO iset1 = 1, nset
457  m2s = 0
458  DO iset2 = 1, nset
459  CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
460  max_s_harm, llmax, cg_list, cg_n_list, max_iso_not0_local)
461  cpassert(max_iso_not0_local .LE. max_iso_not0)
462 
463  n1s = nsoset(lmax(iset1))
464  DO ipgf1 = 1, npgf(iset1)
465  iso1_first = nsoset(lmin(iset1) - 1) + 1 + n1s*(ipgf1 - 1) + m1s
466  iso1_last = nsoset(lmax(iset1)) + n1s*(ipgf1 - 1) + m1s
467  size1 = iso1_last - iso1_first + 1
468  iso1_first = o2nindex(iso1_first)
469  iso1_last = o2nindex(iso1_last)
470  i1 = iso1_last - iso1_first + 1
471  cpassert(size1 == i1)
472  i1 = nsoset(lmin(iset1) - 1) + 1
473 
474  n2s = nsoset(lmax(iset2))
475  DO ipgf2 = 1, npgf(iset2)
476  iso2_first = nsoset(lmin(iset2) - 1) + 1 + n2s*(ipgf2 - 1) + m2s
477  iso2_last = nsoset(lmax(iset2)) + n2s*(ipgf2 - 1) + m2s
478  size2 = iso2_last - iso2_first + 1
479  iso2_first = o2nindex(iso2_first)
480  iso2_last = o2nindex(iso2_last)
481  i2 = iso2_last - iso2_first + 1
482  cpassert(size2 == i2)
483  i2 = nsoset(lmin(iset2) - 1) + 1
484 
485  zet12 = zet(ipgf1, iset1) + zet(ipgf2, iset2)
486 
487  vgg = 0.0_dp
488 
489  DO iso = 1, max_iso_not0_local
490  l_iso = indso(1, iso)
491  IF (l_iso /= 2) cycle
492  DO icg = 1, cg_n_list(iso)
493  iso1 = cg_list(1, icg, iso)
494  iso2 = cg_list(2, icg, iso)
495  l = indso(1, iso1) + indso(1, iso2)
496  IF (mod(l, 2) == 0 .AND. l > 0) THEN
497  vgg(l/2) = fourpi/10._dp*fac(l - 2)/zet12**(l/2)
498  END IF
499  END DO
500  END DO
501 
502  DO iat = bo(1), bo(2)
503  iatom = atom_list(iat)
504 
505  cpc_sphere = 0.0_dp
506  DO i = 1, nspins
507  coeff => rho_atom_set(iatom)%cpc_h(i)%r_coef
508  cpc_sphere(i1:i1 + size1 - 1, i2:i2 + size2 - 1) = &
509  cpc_sphere(i1:i1 + size1 - 1, i2:i2 + size2 - 1) + &
510  coeff(iso1_first:iso1_last, iso2_first:iso2_last)
511  coeff => rho_atom_set(iatom)%cpc_s(i)%r_coef
512  cpc_sphere(i1:i1 + size1 - 1, i2:i2 + size2 - 1) = &
513  cpc_sphere(i1:i1 + size1 - 1, i2:i2 + size2 - 1) - &
514  coeff(iso1_first:iso1_last, iso2_first:iso2_last)
515  END DO ! i
516 
517  DO iso = 1, max_iso_not0_local
518  l_iso = indso(1, iso)
519  m_iso = indso(1, iso)
520  IF (l_iso /= 2) cycle
521  DO icg = 1, cg_n_list(iso)
522  iso1 = cg_list(1, icg, iso)
523  iso2 = cg_list(2, icg, iso)
524  l = indso(1, iso1) + indso(1, iso2)
525  IF (mod(l, 2) == 0 .AND. l > 0) THEN
526  vlimit(iatom, m_iso) = vlimit(iatom, m_iso) + &
527  vgg(l/2)*cpc_sphere(iso1, iso2)*my_cg(iso1, iso2, iso)
528  END IF
529  END DO ! icg
530  END DO ! iso
531 
532  END DO ! iat
533 
534  END DO ! ipgf2
535  END DO ! ipgf1
536  m2s = m2s + maxso
537  END DO ! iset2
538  m1s = m1s + maxso
539  END DO ! iset1
540 
541  CALL para_env%sum(vlimit)
542 
543  DEALLOCATE (o2nindex)
544  DEALLOCATE (cpc_sphere)
545  DEALLOCATE (cg_list, cg_n_list)
546 
547  END SUBROUTINE vlimit_atom
548 
549 ! **************************************************************************************************
550 !> \brief ...
551 !> \param ein ...
552 !> \param eout ...
553 ! **************************************************************************************************
554  SUBROUTINE efgsort(ein, eout)
555  REAL(dp), DIMENSION(3), INTENT(in) :: ein
556  REAL(dp), DIMENSION(3), INTENT(inout) :: eout
557 
558  INTEGER :: i
559  INTEGER, DIMENSION(3) :: ind
560  REAL(dp), DIMENSION(3) :: eab
561 
562  eab = abs(ein)
563  CALL sort(eab, 3, ind)
564  DO i = 1, 3
565  eout(i) = ein(ind(i))
566  END DO
567 
568  END SUBROUTINE efgsort
569 
571 
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
Definition: dumpdcd.F:1203
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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)
...
Provides interfaces to LAPACK eigenvalue/SVD routines.
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
logical function, public section_get_lval(section_vals, keyword_name)
...
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
Definition of mathematical constants and functions.
Definition: mathconstants.F:16
real(kind=dp), parameter, public fourpi
real(kind=dp), dimension(0:maxfac), parameter, public fac
Definition: mathconstants.F:37
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nsoset
integer, dimension(:, :), allocatable, public indso
Define the data structure for the particle information.
subroutine, public get_paw_basis_info(basis_1c, o2nindex, n2oindex, nsatbas)
Return some info on the PAW basis derived from a GTO basis set.
Definition of physical constants:
Definition: physcon.F:68
real(kind=dp), parameter, public a_bohr
Definition: physcon.F:136
real(kind=dp), parameter, public e_charge
Definition: physcon.F:106
real(kind=dp), parameter, public joule
Definition: physcon.F:159
computes preconditioners, and implements methods to apply them currently used in qs_ot
container for various plainwaves related things
Definition: pw_env_types.F:14
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Definition: pw_env_types.F:113
subroutine, public pw_smoothing(pw, ecut, sigma)
Multiplies a G-space function with a smoothing factor of the form f(|G|) = exp((ecut - G^2)/sigma)/(1...
Definition: pw_methods.F:10300
subroutine, public pw_structure_factor(sf, r)
Calculate the structure factor for point r.
Definition: pw_methods.F:10358
subroutine, public pw_dr2(pw, pwdr2, i, j)
Calculate the tensorial 2nd derivative of a plane wave vector.
Definition: pw_methods.F:10204
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Definition: pw_pool_types.F:24
different utils that are useful to manipulate splines on the regular grid of a pw
logical function, public find_coeffs(values, coeffs, linOp, preconditioner, pool, eps_r, eps_x, max_iter, sumtype)
solves iteratively (CG) a systmes of linear equations linOp(coeffs)=values (for example those needed ...
subroutine, public pw_spline_precond_release(preconditioner)
releases the preconditioner
subroutine, public pw_spline_precond_create(preconditioner, precond_kind, pool, pbc, transpose)
...
subroutine, public pw_spline_do_precond(preconditioner, in_v, out_v)
applies the preconditioner to the system of equations to find the coefficients of the spline
subroutine, public pw_spline_precond_set_kind(preconditioner, precond_kind, pbc, transpose)
switches the types of precoditioner to use
real(kind=dp) function, dimension(3), public eval_d_interp_spl3_pbc(vec, pw)
Evaluates the derivatives of the PBC interpolated Spline (pw) function on the generic input vector (v...
real(kind=dp) function, public eval_interp_spl3_pbc(vec, pw)
Evaluates the PBC interpolated Spline (pw) function on the generic input vector (vec)
subroutine, public spl3_pbc(pw_in, pw_out)
...
Calculates electric field gradients H.M. Petrili, P.E. Blochl, P. Blaha, K. Schwarz,...
subroutine, public qs_efg_calc(qs_env)
...
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_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, 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, rhs)
Get the QUICKSTEP environment.
subroutine, public prepare_gapw_den(qs_env, local_rho_set, do_rho0, kind_set_external)
...
Define the quickstep kind type and their sub types.
Definition: qs_kind_types.F:23
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, 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_r3d_rs_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_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
Definition: qs_ks_methods.F:22
subroutine, public calc_rho_tot_gspace(rho_tot_gspace, qs_env, rho, skip_nuclear_density)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
Definition: qs_rho_types.F:18
All kind of helpful little routines.
Definition: util.F:14
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me
Definition: util.F:333