50#include "./base/base_uses.f90"
56 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .false.
58 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'accint_weights_forces'
76 INTEGER,
INTENT(IN) :: order
78 LOGICAL,
INTENT(IN),
OPTIONAL :: triplet
80 CHARACTER(len=*),
PARAMETER :: routinen =
'accint_weight_force'
82 INTEGER :: atom_a, handle, iatom, ikind, natom, &
84 INTEGER,
DIMENSION(:),
POINTER :: atom_list
85 LOGICAL :: lr_triplet, use_virial
86 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: calpha, cvalue
87 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: aforce
88 REAL(kind=
dp),
DIMENSION(3, 3) :: avirial
98 CALL timeset(routinen, handle)
100 CALL get_qs_env(qs_env, dft_control=dft_control)
102 IF (dft_control%qs_control%gapw_control%accurate_xcint)
THEN
104 CALL get_qs_env(qs_env=qs_env, force=force, virial=virial)
105 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
107 CALL get_qs_env(qs_env, natom=natom, nkind=nkind)
108 ALLOCATE (aforce(3, natom))
109 ALLOCATE (calpha(nkind), cvalue(nkind))
111 calpha(1:nkind) = dft_control%qs_control%gapw_control%aw(1:nkind)
113 CALL get_qs_env(qs_env, ks_env=ks_env, pw_env=pw_env)
114 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
115 CALL auxbas_pw_pool%create_pw(e_rspace)
118 IF (
PRESENT(triplet)) lr_triplet = triplet
120 CALL xc_density(ks_env, rho, rho1, order, xc_section, lr_triplet, e_rspace)
121 CALL pw_scale(e_rspace, e_rspace%pw_grid%dvol)
123 CALL gauss_grid_force(e_rspace, qs_env, calpha, cvalue, aforce, avirial)
125 CALL auxbas_pw_pool%give_back_pw(e_rspace)
127 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
129 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
130 DO iatom = 1, natom_of_kind
131 atom_a = atom_list(iatom)
132 force(ikind)%rho_elec(1:3, iatom) = &
133 force(ikind)%rho_elec(1:3, iatom) + aforce(1:3, atom_a)
137 virial%pv_exc = virial%pv_exc + avirial
138 virial%pv_virial = virial%pv_virial + avirial
145 CALL timestop(handle)
158 SUBROUTINE gauss_grid_force(e_rspace, qs_env, calpha, cvalue, aforce, avirial)
161 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: calpha, cvalue
162 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: aforce
163 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(OUT) :: avirial
165 CHARACTER(len=*),
PARAMETER :: routinen =
'gauss_grid_force'
167 INTEGER :: atom_a, handle, iatom, ikind, j, &
169 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
170 LOGICAL :: use_virial
171 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
172 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
173 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
174 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hab, pab
182 CALL timeset(routinen, handle)
194 atomic_kind_set=atomic_kind_set, &
196 dft_control=dft_control, &
197 particle_set=particle_set)
203 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
205 DO ikind = 1,
SIZE(atomic_kind_set)
207 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
209 alpha = calpha(ikind)
210 pab(1, 1) = -cvalue(ikind)
211 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
217 DO iatom = 1, natom_of_kind
218 atom_a = atom_list(iatom)
219 ra(:) =
pbc(particle_set(atom_a)%r, cell)
220 IF (rs_v%desc%parallel .AND. .NOT. rs_v%desc%distributed)
THEN
222 IF (
modulo(iatom, rs_v%desc%group_size) == rs_v%desc%my_pos)
THEN
235 atom_a = atom_list(iatom)
236 ra(:) =
pbc(particle_set(atom_a)%r, cell)
244 ra=ra, rb=ra, rp=ra, &
245 zetp=alpha, eps=eps_rho_rspace, &
246 pab=pab, o1=0, o2=0, &
247 prefactor=1.0_dp, cutoff=1.0_dp)
250 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], &
251 rs_v, hab, pab=pab, o1=0, o2=0, &
253 calculate_forces=.true., force_a=force_a, &
254 force_b=force_b, use_virial=use_virial, my_virial_a=my_virial_a, &
255 my_virial_b=my_virial_b, use_subpatch=.true., subpatch_pattern=0)
257 aforce(1:3, atom_a) = aforce(1:3, atom_a) + force_a(1:3)
258 avirial = avirial + my_virial_a
264 DEALLOCATE (hab, pab, cores)
266 CALL timestop(handle)
268 END SUBROUTINE gauss_grid_force
284 SUBROUTINE xc_density(ks_env, rho_struct, rho1_struct, order, xc_section, triplet, exc)
287 TYPE(
qs_rho_type),
POINTER :: rho_struct, rho1_struct
288 INTEGER,
INTENT(IN) :: order
290 LOGICAL,
INTENT(IN) :: triplet
293 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_density'
295 INTEGER :: handle, ispin, myfun, nspins
297 REAL(kind=
dp) :: excint, factor
298 REAL(kind=
dp),
DIMENSION(3, 3) :: vdum
304 TYPE(
pw_pool_type),
POINTER :: auxbas_pw_pool, xc_pw_pool
305 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho1_r, rho_r, tau1_r, tau_r, vxc_rho, &
309 CALL timeset(routinen, handle)
315 dft_control=dft_control, &
319 rho_nlcc_g=rho_nlcc_g)
321 CALL qs_rho_get(rho_struct, rho_r=rho_r, rho_g=rho_g, tau_r=tau_r)
323 nspins = dft_control%nspins
327 CALL pw_env_get(pw_env, xc_pw_pool=xc_pw_pool, auxbas_pw_pool=auxbas_pw_pool)
328 uf_grid = .NOT.
pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
330 CALL cp_warn(__location__,
"Fine grid option not possible with energy density")
331 cpabort(
"Fine Grid in xc_density")
338 cpassert(
ASSOCIATED(rho_struct))
339 cpassert(dft_control%sic_method_id ==
sic_none)
342 IF (
ASSOCIATED(rho_nlcc) .AND. order <= 1)
THEN
345 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
346 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
350 NULLIFY (vxc_rho, vxc_tau)
354 CALL xc_exc_pw_create(rho_r, rho_g, tau_r, xc_section, weights, xc_pw_pool, exc)
356 CALL qs_rho_get(rho1_struct, rho_r=rho1_r, tau_r=tau1_r)
358 rho_g=rho_g, tau=tau_r, exc=excint, &
359 xc_section=xc_section, &
360 weights=weights, pw_pool=xc_pw_pool, &
361 compute_virial=.false., &
364 CALL qs_rho_get(rho1_struct, rho_r=rho1_r, tau_r=tau1_r)
365 CALL qs_fxc_analytic(rho_struct, rho1_r, tau1_r, xc_section, weights, xc_pw_pool, &
366 triplet, vxc_rho, vxc_tau)
368 cpabort(
"Derivative order not available in xc_density")
372 IF (
ASSOCIATED(rho_nlcc) .AND. order <= 1)
THEN
374 DO ispin = 1, dft_control%nspins
375 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
376 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
385 IF (
ASSOCIATED(vxc_rho))
THEN
388 CALL pw_axpy(vxc_rho(ispin), exc, 1.0_dp)
389 CALL vxc_rho(ispin)%release()
393 IF (
ASSOCIATED(vxc_tau))
THEN
396 CALL pw_axpy(vxc_tau(ispin), exc, 1.0_dp)
397 CALL vxc_tau(ispin)%release()
402 cpabort(
"Derivative order not available in xc_density")
411 CALL timestop(handle)
413 END SUBROUTINE xc_density
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
subroutine, public accint_weight_force(qs_env, rho, rho1, order, xc_section, triplet)
...
All kind of helpful little routines.
real(kind=dp) function, public exp_radius_very_extended(la_min, la_max, lb_min, lb_max, pab, o1, o2, ra, rb, rp, zetp, eps, prefactor, cutoff, epsabs)
computes the radius of the Gaussian outside of which it is smaller than eps
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.
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Fortran API for the grid package, which is written in C.
subroutine, public integrate_pgf_product(la_max, zeta, la_min, lb_max, zetb, lb_min, ra, rab, rsgrid, hab, pab, o1, o2, radius, calculate_forces, force_a, force_b, compute_tau, use_virial, my_virial_a, my_virial_b, hdab, hadb, a_hdab, use_subpatch, subpatch_pattern)
low level function to compute matrix elements of primitive gaussian functions
Defines the basic variable types.
integer, parameter, public dp
Utility routines for the memory handling.
Define the data structure for the particle information.
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
This module defines the grid data type and some basic operations on it.
logical function, public pw_grid_compare(grida, gridb)
Check if two pw_grids are equal.
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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, 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.
https://en.wikipedia.org/wiki/Finite_difference_coefficient
subroutine, public qs_fxc_analytic(rho0, rho1_r, tau1_r, xc_section, weights, auxbas_pw_pool, is_triplet, v_xc, v_xc_tau, spinflip)
...
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
subroutine, public transfer_pw2rs(rs, pw)
...
Exchange and Correlation functional calculations.
subroutine, public xc_vxc_pw_create(vxc_rho, vxc_tau, exc, rho_r, rho_g, tau, xc_section, weights, pw_pool, compute_virial, virial_xc, exc_r)
Exchange and Correlation functional calculations.
subroutine, public xc_exc_pw_create(rho_r, rho_g, tau, xc_section, weights, pw_pool, exc)
calculates just the exchange and correlation energy density
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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.