(git:ba1d7ca)
Loading...
Searching...
No Matches
qs_harris_methods.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 Harris method calculations
10!> \par History
11!> 2026.07 split from qs_harris_utils
12!> \author JGH
13! **************************************************************************************************
15 USE cp_dbcsr_api, ONLY: dbcsr_copy,&
24 USE input_constants, ONLY: hden_cube,&
28 USE kinds, ONLY: dp
30 USE pw_env_types, ONLY: pw_env_get,&
32 USE pw_methods, ONLY: pw_axpy,&
33 pw_copy,&
36 pw_scale,&
41 USE pw_types, ONLY: pw_c1d_gs_type,&
49 USE qs_fxc, ONLY: qs_fxc_create
55 USE qs_integrate_potential, ONLY: integrate_function,&
56 integrate_v_core_rspace,&
57 integrate_v_rspace
59 USE qs_ks_types, ONLY: qs_ks_did_change,&
62 USE qs_rho_types, ONLY: qs_rho_create,&
66#include "./base/base_uses.f90"
67
68 IMPLICIT NONE
69
70 PRIVATE
71
72 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_harris_methods'
73
76
77CONTAINS
78
79! **************************************************************************************************
80!> \brief ...
81!> \param qs_env ...
82!> \param calculate_forces ...
83! **************************************************************************************************
84 SUBROUTINE harris_energy_correction(qs_env, calculate_forces)
85 TYPE(qs_environment_type), POINTER :: qs_env
86 LOGICAL, INTENT(IN) :: calculate_forces
87
88 CHARACTER(LEN=*), PARAMETER :: routinen = 'harris_energy_correction'
89
90 INTEGER :: handle, iounit, ispin, nspins
91 REAL(kind=dp) :: dvol, ec, eh, exc, vxc
92 TYPE(cp_logger_type), POINTER :: logger
93 TYPE(harris_energy_type), POINTER :: energy
94 TYPE(harris_type), POINTER :: harris_env
95 TYPE(pw_c1d_gs_type), POINTER :: rho_core
96 TYPE(pw_env_type), POINTER :: pw_env
97 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
98 TYPE(pw_r3d_rs_type) :: core_rspace
99 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
100 TYPE(qs_energy_type), POINTER :: ks_energy
101 TYPE(qs_rho_type), POINTER :: rho
102
103 mark_used(calculate_forces)
104
105 CALL timeset(routinen, handle)
106
107 CALL get_qs_env(qs_env, harris_env=harris_env, energy=ks_energy)
108 energy => harris_env%energy
109 IF (harris_env%direct_density_matrix_energy) THEN
110 IF (calculate_forces) THEN
111 cpabort("Forces are not available for the direct fitted-density-matrix energy")
112 END IF
113 ks_energy%nonscf_correction = energy%direct_harris - ks_energy%total
114 ks_energy%total = energy%direct_harris
115 CALL timestop(handle)
116 RETURN
117 END IF
118 IF (calculate_forces .AND. (harris_env%density_source == hden_cube .OR. &
119 harris_env%density_source == hden_cube_fit)) THEN
120 cpabort("Forces are not available for a Harris energy based on an external cube density")
121 END IF
122 energy%eband = ks_energy%band
123 energy%ewald_correction = ks_energy%core_overlap + ks_energy%core_self
124 energy%dispersion = ks_energy%dispersion
125
126 nspins = harris_env%rhoin%nspin
127
128 CALL get_qs_env(qs_env, rho=rho, rho_core=rho_core)
129 CALL qs_rho_get(rho, rho_r=rho_r)
130
131 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
132 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
133 CALL auxbas_pw_pool%create_pw(core_rspace)
134 CALL pw_transfer(rho_core, core_rspace)
135
136 dvol = harris_env%vh_rspace%pw_grid%dvol
137 eh = 0.0_dp
138 DO ispin = 1, nspins
139 eh = eh + pw_integral_ab(rho_r(ispin), harris_env%vh_rspace)/dvol
140 END DO
141 ec = pw_integral_ab(core_rspace, harris_env%vh_rspace)/dvol
142 eh = 0.5_dp*(eh + ec)
143 energy%eh_correction = ec - eh
144
145 exc = ks_energy%exc
146 vxc = 0.0_dp
147 IF (ASSOCIATED(harris_env%vxc_rspace)) THEN
148 DO ispin = 1, nspins
149 vxc = vxc + pw_integral_ab(rho_r(ispin), harris_env%vxc_rspace(ispin))/ &
150 harris_env%vxc_rspace(ispin)%pw_grid%dvol
151 END DO
152 END IF
153 energy%exc_correction = exc - vxc
154
155 ! Total Harris model energy
156 energy%eharris = energy%eband + energy%eh_correction + energy%exc_correction + &
157 energy%ewald_correction + energy%dispersion
158
159 CALL auxbas_pw_pool%give_back_pw(core_rspace)
160
161 ks_energy%total = ks_energy%total + ks_energy%core
162 ks_energy%nonscf_correction = energy%eharris - ks_energy%total
163 ks_energy%total = energy%eharris
164
165 logger => cp_get_default_logger()
166 iounit = cp_logger_get_default_io_unit(logger)
167
168 CALL harris_print_energy(iounit, energy)
169
170 IF (calculate_forces) THEN
171 CALL harris_forces(qs_env, iounit)
172 END IF
173
174 CALL timestop(handle)
175
176 END SUBROUTINE harris_energy_correction
177
178! **************************************************************************************************
179!> \brief Evaluates the fitted AO density matrix without solving a NONSCF eigenproblem.
180!>
181!> First, the fitted density matrix and its collocated density are used consistently. The second
182!> energy keeps all density-matrix-dependent terms from this evaluation and replaces only the
183!> Hartree and semilocal XC contributions by those obtained from the original cube density. For
184!> GPW this is algebraically equivalent to the Harris expression with P_fit in the band trace.
185!> \param qs_env Quickstep environment
186! **************************************************************************************************
188 TYPE(qs_environment_type), POINTER :: qs_env
189
190 CHARACTER(LEN=*), PARAMETER :: routinen = 'harris_direct_density_matrix_energy'
191
192 INTEGER :: handle, iounit
193 REAL(kind=dp) :: target_density_energy, &
194 trial_density_energy
195 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
196 TYPE(cp_logger_type), POINTER :: logger
197 TYPE(harris_energy_type), POINTER :: energy
198 TYPE(harris_type), POINTER :: harris_env
199 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
200 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
201 TYPE(qs_energy_type), POINTER :: ks_energy
202 TYPE(qs_rho_type), POINTER :: rho
203
204 CALL timeset(routinen, handle)
205 NULLIFY (harris_env, ks_energy, rho, rho_g, rho_r, tot_rho_r)
206
207 CALL get_qs_env(qs_env, harris_env=harris_env, energy=ks_energy, rho=rho)
208 cpassert(harris_env%density_source == hden_cube_fit)
209 cpassert(harris_env%density_fit_ready)
210 cpassert(ASSOCIATED(harris_env%density_target_rspace%pw_grid))
211
212 energy => harris_env%energy
213
214 ! Consistent evaluation: P_fit and the density collocated from P_fit.
215 CALL qs_ks_update_qs_env(qs_env, calculate_forces=.false., just_energy=.true., &
216 print_active=.false.)
217 energy%trial_dm = ks_energy%total
218 trial_density_energy = ks_energy%hartree + ks_energy%hartree_1c + &
219 ks_energy%exc + ks_energy%exc1 + &
220 ks_energy%exc_aux_fit + ks_energy%exc1_aux_fit
221
222 ! Mixed Harris evaluation: retain P_fit but use the original cube density for E_H and E_xc.
223 CALL qs_rho_get(rho, rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
224 cpassert(SIZE(rho_r) == 1 .AND. SIZE(rho_g) == 1)
225 CALL pw_copy(harris_env%density_target_rspace, rho_r(1))
226 CALL pw_transfer(rho_r(1), rho_g(1))
227 tot_rho_r(1) = pw_integrate_function(rho_r(1), isign=-1)
228 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
229 CALL qs_ks_did_change(qs_env%ks_env, rho_changed=.true., potential_changed=.true.)
230 CALL qs_ks_update_qs_env(qs_env, calculate_forces=.false., just_energy=.true., &
231 print_active=.false.)
232 target_density_energy = ks_energy%hartree + ks_energy%hartree_1c + &
233 ks_energy%exc + ks_energy%exc1 + &
234 ks_energy%exc_aux_fit + ks_energy%exc1_aux_fit
235
236 energy%direct_harris = energy%trial_dm + target_density_energy - trial_density_energy
237 energy%direct_difference = energy%trial_dm - energy%direct_harris
238 energy%eharris = energy%direct_harris
239 ks_energy%nonscf_correction = energy%direct_harris - ks_energy%total
240 ks_energy%total = energy%direct_harris
241
242 logger => cp_get_default_logger()
243 iounit = cp_logger_get_default_io_unit(logger)
244 CALL harris_print_direct_energy(iounit, energy)
245
246 CALL timestop(handle)
247
249
250! **************************************************************************************************
251!> \brief Builds H[n_cube] once and reconstructs the AO density matrix by minimizing a
252!> density residual regularized by fermionic relative entropy to its Fermi matrix.
253!> \param qs_env Quickstep environment with the target cube density active
254! **************************************************************************************************
256 TYPE(qs_environment_type), POINTER :: qs_env
257
258 CHARACTER(LEN=*), PARAMETER :: routinen = 'harris_relative_entropy_reconstruction'
259
260 INTEGER :: handle
261 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
262 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks
263 TYPE(harris_type), POINTER :: harris_env
264 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
265 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
266 TYPE(qs_rho_type), POINTER :: rho
267
268 CALL timeset(routinen, handle)
269 NULLIFY (harris_env, matrix_ks, rho, rho_g, rho_r, tot_rho_r)
270
271 CALL get_qs_env(qs_env, harris_env=harris_env, rho=rho)
272 cpassert(harris_env%density_source == hden_cube_fit)
273 cpassert(harris_env%density_target_ready)
274 cpassert(.NOT. harris_env%density_fit_ready)
275
276 ! The active real-space density is n_cube here. Build and freeze its Kohn-Sham matrix
277 ! before changing the AO density matrix.
278 CALL qs_ks_did_change(qs_env%ks_env, rho_changed=.true., potential_changed=.true.)
279 CALL qs_ks_update_qs_env(qs_env, calculate_forces=.false., just_energy=.true., &
280 print_active=.false.)
281 CALL get_qs_env(qs_env, matrix_ks=matrix_ks)
282 cpassert(ASSOCIATED(matrix_ks) .AND. SIZE(matrix_ks) == 1)
283
284 CALL fit_relative_entropy_density(qs_env, rho, matrix_ks(1)%matrix, &
285 harris_env%fit_temperature, &
286 harris_env%fit_relative_entropy_weight, &
287 harris_env%fit_max_iter, harris_env%fit_eps, &
288 harris_env%fit_step_size, harris_env%fit_max_backtrack)
289
290 CALL qs_rho_get(rho, rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
291 cpassert(SIZE(rho_r) == 1 .AND. SIZE(rho_g) == 1)
292 CALL harris_env%density_fit_rspace%create(rho_r(1)%pw_grid)
293 CALL pw_copy(rho_r(1), harris_env%density_fit_rspace)
294 harris_env%density_fit_ready = .true.
295 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
296 CALL qs_ks_did_change(qs_env%ks_env, rho_changed=.true., potential_changed=.true.)
297
298 CALL timestop(handle)
299
301
302! **************************************************************************************************
303!> \brief ...
304!> \param qs_env ...
305!> \param iounit ...
306! **************************************************************************************************
307 SUBROUTINE harris_forces(qs_env, iounit)
308 TYPE(qs_environment_type), POINTER :: qs_env
309 INTEGER, INTENT(IN) :: iounit
310
311 CHARACTER(LEN=*), PARAMETER :: routinen = 'harris_forces'
312 LOGICAL, PARAMETER :: debug_forces = .true.
313
314 INTEGER :: handle, ispin, nspins
315 REAL(kind=dp) :: ehartree
316 REAL(kind=dp), DIMENSION(3) :: fodeb
317 TYPE(dbcsr_p_type) :: scrm
318 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rhoh_ao, smat
319 TYPE(harris_type), POINTER :: harris_env
320 TYPE(mp_para_env_type), POINTER :: para_env
321 TYPE(pw_c1d_gs_type) :: rhoh_tot_gspace, vhout_gspace
322 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g, rhoh_g
323 TYPE(pw_c1d_gs_type), POINTER :: rho_core
324 TYPE(pw_env_type), POINTER :: pw_env
325 TYPE(pw_poisson_type), POINTER :: poisson_env
326 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
327 TYPE(pw_r3d_rs_type) :: vhout_rspace, vhxc_rspace
328 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fhxc_rspace, ftau, fxc, rho_r, rhoh_r, &
329 tauh_r
330 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
331 TYPE(qs_ks_env_type), POINTER :: ks_env
332 TYPE(qs_rho_type), POINTER :: rho, rhoh
333 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set, rho1_atom_set
334 TYPE(section_vals_type), POINTER :: xc_section
335
336 CALL timeset(routinen, handle)
337
338 IF (debug_forces) THEN
339 IF (iounit > 0) WRITE (iounit, "(/,T3,A)") &
340 "DEBUG:: Harris Method Forces (density dependent)"
341 END IF
342
343 CALL get_qs_env(qs_env, harris_env=harris_env, force=force, para_env=para_env)
344 nspins = harris_env%rhoin%nspin
345
346 CALL get_qs_env(qs_env, rho=rho, rho_core=rho_core, matrix_s=smat)
347 ! Warning: rho_ao = output DM; rho_r = rhoin
348 CALL qs_rho_get(rho, rho_ao=rhoh_ao, rho_r=rho_r, rho_g=rho_g)
349 ALLOCATE (scrm%matrix)
350 CALL dbcsr_create(scrm%matrix, template=rhoh_ao(1)%matrix)
351 CALL dbcsr_copy(scrm%matrix, smat(1)%matrix)
352 CALL dbcsr_set(scrm%matrix, 0.0_dp)
353
354 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, ks_env=ks_env)
355 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
356 CALL auxbas_pw_pool%create_pw(vhxc_rspace)
357
358 IF (debug_forces) fodeb(1:3) = force(1)%rho_elec(1:3, 1)
359 DO ispin = 1, nspins
360 CALL pw_copy(harris_env%vh_rspace, vhxc_rspace)
361 CALL pw_axpy(harris_env%vxc_rspace(ispin), vhxc_rspace)
362 CALL integrate_v_rspace(v_rspace=vhxc_rspace, &
363 hmat=scrm, pmat=rhoh_ao(ispin), &
364 qs_env=qs_env, calculate_forces=.true.)
365 END DO
366 IF (debug_forces) THEN
367 fodeb(1:3) = force(1)%rho_elec(1:3, 1) - fodeb(1:3)
368 CALL para_env%sum(fodeb)
369 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: P*(Vh[in]+Vxc)", fodeb
370 END IF
371
372 CALL dbcsr_release(scrm%matrix)
373 DEALLOCATE (scrm%matrix)
374 CALL auxbas_pw_pool%give_back_pw(vhxc_rspace)
375
376 ALLOCATE (rhoh_r(nspins), rhoh_g(nspins))
377 DO ispin = 1, nspins
378 CALL auxbas_pw_pool%create_pw(rhoh_r(ispin))
379 CALL auxbas_pw_pool%create_pw(rhoh_g(ispin))
380 END DO
381 CALL auxbas_pw_pool%create_pw(rhoh_tot_gspace)
382 CALL pw_copy(rho_core, rhoh_tot_gspace)
383 DO ispin = 1, nspins
384 CALL calculate_rho_elec(ks_env=ks_env, matrix_p=rhoh_ao(ispin)%matrix, &
385 rho=rhoh_r(ispin), rho_gspace=rhoh_g(ispin))
386 CALL pw_axpy(rhoh_g(ispin), rhoh_tot_gspace)
387 END DO
388 ! no meta functionals here
389 NULLIFY (tauh_r)
390
391 CALL auxbas_pw_pool%create_pw(vhout_rspace)
392 CALL auxbas_pw_pool%create_pw(vhout_gspace)
393 CALL pw_env_get(pw_env, poisson_env=poisson_env)
394 !
395 CALL pw_poisson_solve(poisson_env, rhoh_tot_gspace, ehartree, vhout_gspace)
396 !
397 CALL pw_transfer(vhout_gspace, vhout_rspace)
398 CALL pw_scale(vhout_rspace, vhout_rspace%pw_grid%dvol)
399
400 IF (debug_forces) fodeb(1:3) = force(1)%rho_core(1:3, 1)
401 CALL integrate_v_core_rspace(vhout_rspace, qs_env)
402 IF (debug_forces) THEN
403 fodeb(1:3) = force(1)%rho_core(1:3, 1) - fodeb(1:3)
404 CALL para_env%sum(fodeb)
405 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Vh[out]*dncore ", fodeb
406 END IF
407
408 ALLOCATE (fhxc_rspace(nspins))
409 DO ispin = 1, nspins
410 CALL auxbas_pw_pool%create_pw(fhxc_rspace(ispin))
411 END DO
412 ! vh = vh[out] - vh[in]
413 CALL pw_axpy(harris_env%vh_rspace, vhout_rspace, alpha=-1._dp, beta=1.0_dp)
414 ! kernel fxc
415 ! drho = rho[out] - rho[in]
416 DO ispin = 1, nspins
417 CALL pw_axpy(rho_r(ispin), rhoh_r(ispin), alpha=-1._dp, beta=1.0_dp)
418 CALL pw_axpy(rho_g(ispin), rhoh_g(ispin), alpha=-1._dp, beta=1.0_dp)
419 END DO
420 xc_section => section_vals_get_subs_vals(qs_env%input, "DFT%XC")
421 NULLIFY (fxc, ftau)
422 NULLIFY (rho0_atom_set, rho1_atom_set)
423 ALLOCATE (rhoh)
424 CALL qs_rho_create(rhoh)
425 IF (ASSOCIATED(rhoh_r)) THEN
426 CALL qs_rho_set(rhoh, rho_r=rhoh_r, rho_r_valid=.true.)
427 END IF
428 IF (ASSOCIATED(rhoh_g)) THEN
429 CALL qs_rho_set(rhoh, rho_g=rhoh_g, rho_g_valid=.true.)
430 END IF
431 IF (ASSOCIATED(tauh_r)) THEN
432 CALL qs_rho_set(rhoh, tau_r=tauh_r, tau_r_valid=.true.)
433 END IF
434 !
435 CALL qs_fxc_create(qs_env, rho, rhoh, rho0_atom_set, xc_section, .false., &
436 fxc, ftau, rho1_atom_set)
437 !
438 DEALLOCATE (rhoh)
439 cpassert(.NOT. ASSOCIATED(ftau))
440
441 DO ispin = 1, nspins
442 CALL pw_copy(vhout_rspace, fhxc_rspace(ispin))
443 IF (ASSOCIATED(fxc)) THEN
444 CALL pw_scale(fxc(ispin), fxc(ispin)%pw_grid%dvol)
445 CALL pw_axpy(fxc(ispin), fhxc_rspace(ispin))
446 END IF
447 END DO
448
449 IF (debug_forces) fodeb(1:3) = force(1)%rho_elec(1:3, 1)
450 CALL calculate_harris_integrals(qs_env, harris_env%rhoin, fhxc_rspace, .true.)
451 IF (debug_forces) THEN
452 fodeb(1:3) = force(1)%rho_elec(1:3, 1) - fodeb(1:3)
453 CALL para_env%sum(fodeb)
454 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: (dVh+fxc)*dn[in] ", fodeb
455 END IF
456
457 IF (ASSOCIATED(fxc)) THEN
458 DO ispin = 1, nspins
459 CALL auxbas_pw_pool%give_back_pw(fxc(ispin))
460 END DO
461 DEALLOCATE (fxc)
462 END IF
463 IF (ASSOCIATED(ftau)) THEN
464 DO ispin = 1, nspins
465 CALL auxbas_pw_pool%give_back_pw(ftau(ispin))
466 END DO
467 DEALLOCATE (ftau)
468 END IF
469
470 CALL auxbas_pw_pool%give_back_pw(rhoh_tot_gspace)
471 CALL auxbas_pw_pool%give_back_pw(vhout_rspace)
472 CALL auxbas_pw_pool%give_back_pw(vhout_gspace)
473
474 DO ispin = 1, nspins
475 CALL auxbas_pw_pool%give_back_pw(rhoh_r(ispin))
476 CALL auxbas_pw_pool%give_back_pw(rhoh_g(ispin))
477 CALL auxbas_pw_pool%give_back_pw(fhxc_rspace(ispin))
478 END DO
479 DEALLOCATE (rhoh_r, rhoh_g, fhxc_rspace)
480
481 CALL timestop(handle)
482
483 END SUBROUTINE harris_forces
484
485! **************************************************************************************************
486!> \brief ...
487!> \param qs_env ...
488!> \param rhoin ...
489!> \param v_rspace ...
490!> \param calculate_forces ...
491! **************************************************************************************************
492 SUBROUTINE calculate_harris_integrals(qs_env, rhoin, v_rspace, calculate_forces)
493 TYPE(qs_environment_type), POINTER :: qs_env
494 TYPE(harris_rhoin_type), INTENT(INOUT) :: rhoin
495 TYPE(pw_r3d_rs_type), DIMENSION(:), INTENT(IN) :: v_rspace
496 LOGICAL, INTENT(IN) :: calculate_forces
497
498 CHARACTER(LEN=*), PARAMETER :: routinen = 'calculate_harris_integrals'
499
500 INTEGER :: handle, i1, i2, iatom, ikind, ilocal, &
501 ispin, n, nkind, nlocal, nspin
502 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: integral, vector
503 TYPE(distribution_1d_type), POINTER :: local_particles
504 TYPE(mp_para_env_type), POINTER :: para_env
505
506 CALL timeset(routinen, handle)
507
508 CALL get_qs_env(qs_env, para_env=para_env, local_particles=local_particles)
509
510 ALLOCATE (vector(rhoin%nbas))
511 ALLOCATE (integral(rhoin%nbas))
512
513 nkind = SIZE(rhoin%rhovec, 1)
514 nspin = SIZE(rhoin%rhovec, 2)
515
516 DO ispin = 1, nspin
517 vector = 0.0_dp
518 integral = 0.0_dp
519 DO ikind = 1, nkind
520 nlocal = local_particles%n_el(ikind)
521 DO ilocal = 1, nlocal
522 iatom = local_particles%list(ikind)%array(ilocal)
523 i1 = rhoin%basptr(iatom, 1)
524 i2 = rhoin%basptr(iatom, 2)
525 n = i2 - i1 + 1
526 vector(i1:i2) = rhoin%rhovec(ikind, ispin)%rvecs(1:n, ilocal)
527 END DO
528 END DO
529 CALL para_env%sum(vector)
530 !
531 CALL integrate_function(qs_env, v_rspace(ispin), vector, integral, &
532 calculate_forces, rhoin%basis_type)
533 DO ikind = 1, nkind
534 nlocal = local_particles%n_el(ikind)
535 DO ilocal = 1, nlocal
536 iatom = local_particles%list(ikind)%array(ilocal)
537 i1 = rhoin%basptr(iatom, 1)
538 i2 = rhoin%basptr(iatom, 2)
539 n = i2 - i1 + 1
540 rhoin%intvec(ikind, ispin)%rvecs(1:n, ilocal) = integral(i1:i2)
541 END DO
542 END DO
543 END DO
544
545 DEALLOCATE (vector, integral)
546
547 CALL timestop(handle)
548
549 END SUBROUTINE calculate_harris_integrals
550
551END MODULE qs_harris_methods
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
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...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public hden_cube
integer, parameter, public hden_cube_fit
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
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
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 ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
Constrained fitting of a real-space density by an AO density matrix. This is a dense reference implem...
subroutine, public fit_relative_entropy_density(qs_env, rho_struct, prior_hamiltonian, temperature, entropy_weight, max_iter, eps_rms, step_size, max_backtrack)
Reconstructs an AO density matrix using the Fermi matrix of H[n_cube] as a fermionic relative-entropy...
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.
Setup Routine for Fxc Potentials.
Definition qs_fxc.F:29
subroutine, public qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, do_onecenter, fxc_rho, fxc_tau, rho1_atom_set, do_scale, is_triplet, spinflip, no_weights, uf_grid_results, pw_env_ext, kind_set_external, para_env_external, compute_virial, virial_xc)
...
Definition qs_fxc.F:118
Harris method calculations.
subroutine, public harris_relative_entropy_reconstruction(qs_env)
Builds H[n_cube] once and reconstructs the AO density matrix by minimizing a density residual regular...
subroutine, public harris_direct_density_matrix_energy(qs_env)
Evaluates the fitted AO density matrix without solving a NONSCF eigenproblem.
subroutine, public harris_energy_correction(qs_env, calculate_forces)
...
Types needed for a for a Harris model calculation.
subroutine, public harris_print_direct_energy(iounit, energy)
Prints the two direct fitted-density-matrix energy evaluations.
subroutine, public harris_print_energy(iounit, energy)
...
Integrate single or product functions over a potential on a RS grid.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
subroutine, public qs_ks_did_change(ks_env, s_mstruct_changed, rho_changed, potential_changed, full_reset)
tells that some of the things relevant to the ks calculation did change. has to be called when change...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
subroutine, public qs_rho_create(rho)
Allocates a new instance of rho.
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
contained for different pw related things
environment for the poisson solver
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Contains information on the Harris method.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.