63#include "./base/base_uses.f90"
71 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_ks_reference'
94 SUBROUTINE ks_ref_potential(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, &
95 ehartree, exc, h_stress, vadmm_tau_rspace)
98 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: vxc_rspace, vtau_rspace, vadmm_rspace
99 REAL(kind=
dp),
INTENT(OUT) :: ehartree, exc
100 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT), &
103 POINTER :: vadmm_tau_rspace
105 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ks_ref_potential'
107 INTEGER :: handle, iab, ispin, nspins
108 REAL(
dp) :: eadmm, edisp, eovrl, eself
109 REAL(kind=
dp),
DIMENSION(3, 3) :: virial_xc
120 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_admm_rspace, v_admm_tau_rspace, &
121 v_rspace, v_tau_rspace
127 CALL timeset(routinen, handle)
130 NULLIFY (rho, ks_env)
131 CALL get_qs_env(qs_env=qs_env, rho=rho, dft_control=dft_control, &
132 para_env=para_env, ks_env=ks_env, rho_core=rho_core)
134 nspins = dft_control%nspins
138 cpassert(
ASSOCIATED(pw_env))
140 NULLIFY (auxbas_pw_pool, poisson_env)
142 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
143 poisson_env=poisson_env)
146 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
147 CALL auxbas_pw_pool%create_pw(v_hartree_rspace)
148 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
154 v_hartree_gspace, h_stress=h_stress, rho_core=rho_core)
155 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
156 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
158 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
159 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
163 ehartree = ehartree + eovrl + eself
166 IF (dft_control%do_admm)
THEN
168 xc_section => admm_env%xc_section_primary
172 NULLIFY (v_rspace, v_tau_rspace)
173 IF (dft_control%qs_control%gapw_xc)
THEN
175 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho_xc, xc_section=xc_section, &
176 vxc_rho=v_rspace, vxc_tau=v_tau_rspace, exc=exc, &
177 edisp=edisp, dispersion_env=qs_env%dispersion_env, just_energy=.false.)
179 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho, xc_section=xc_section, &
180 vxc_rho=v_rspace, vxc_tau=v_tau_rspace, exc=exc, &
181 edisp=edisp, dispersion_env=qs_env%dispersion_env, just_energy=.false.)
184 NULLIFY (v_admm_rspace, v_admm_tau_rspace)
185 IF (dft_control%do_admm)
THEN
188 IF (
PRESENT(h_stress))
THEN
190 virial_xc = virial%pv_xc
193 xc_section => admm_env%xc_section_aux
194 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho, xc_section=xc_section, &
195 vxc_rho=v_admm_rspace, vxc_tau=v_admm_tau_rspace, exc=eadmm, just_energy=.false.)
196 IF (
PRESENT(h_stress)) virial%pv_xc = virial%pv_xc + virial_xc
201 IF (
ASSOCIATED(vh_rspace%pw_grid))
THEN
202 CALL vh_rspace%release()
204 IF (
ASSOCIATED(vxc_rspace))
THEN
205 DO iab = 1,
SIZE(vxc_rspace)
206 CALL vxc_rspace(iab)%release()
209 ALLOCATE (vxc_rspace(nspins))
211 IF (
ASSOCIATED(v_tau_rspace))
THEN
212 IF (
ASSOCIATED(vtau_rspace))
THEN
213 DO iab = 1,
SIZE(vtau_rspace)
214 CALL vtau_rspace(iab)%release()
217 ALLOCATE (vtau_rspace(nspins))
220 NULLIFY (vtau_rspace)
222 IF (
ASSOCIATED(v_admm_rspace))
THEN
223 IF (
ASSOCIATED(vadmm_rspace))
THEN
224 DO iab = 1,
SIZE(vadmm_rspace)
225 CALL vadmm_rspace(iab)%release()
228 ALLOCATE (vadmm_rspace(nspins))
231 NULLIFY (vadmm_rspace)
233 IF (
PRESENT(vadmm_tau_rspace))
THEN
234 IF (
ASSOCIATED(vadmm_tau_rspace))
THEN
235 DO iab = 1,
SIZE(vadmm_tau_rspace)
236 CALL vadmm_tau_rspace(iab)%release()
239 IF (
ASSOCIATED(v_admm_tau_rspace))
THEN
240 IF (.NOT.
ASSOCIATED(vadmm_tau_rspace))
ALLOCATE (vadmm_tau_rspace(nspins))
242 IF (
ASSOCIATED(vadmm_tau_rspace))
DEALLOCATE (vadmm_tau_rspace)
243 NULLIFY (vadmm_tau_rspace)
247 pw_grid => v_hartree_rspace%pw_grid
248 CALL vh_rspace%create(pw_grid)
250 CALL vxc_rspace(ispin)%create(pw_grid)
251 IF (
ASSOCIATED(vtau_rspace))
THEN
252 CALL vtau_rspace(ispin)%create(pw_grid)
254 IF (
ASSOCIATED(vadmm_rspace))
THEN
255 CALL vadmm_rspace(ispin)%create(pw_grid)
257 IF (
PRESENT(vadmm_tau_rspace))
THEN
258 IF (
ASSOCIATED(vadmm_tau_rspace))
CALL vadmm_tau_rspace(ispin)%create(pw_grid)
263 IF (
ASSOCIATED(v_rspace))
THEN
265 CALL pw_transfer(v_rspace(ispin), vxc_rspace(ispin))
266 CALL pw_scale(vxc_rspace(ispin), v_rspace(ispin)%pw_grid%dvol)
267 IF (
ASSOCIATED(v_tau_rspace))
THEN
268 CALL pw_transfer(v_tau_rspace(ispin), vtau_rspace(ispin))
269 CALL pw_scale(vtau_rspace(ispin), v_tau_rspace(ispin)%pw_grid%dvol)
274 CALL pw_zero(vxc_rspace(ispin))
277 IF (
ASSOCIATED(v_admm_rspace))
THEN
279 CALL pw_transfer(v_admm_rspace(ispin), vadmm_rspace(ispin))
280 CALL pw_scale(vadmm_rspace(ispin), vadmm_rspace(ispin)%pw_grid%dvol)
283 IF (
PRESENT(vadmm_tau_rspace))
THEN
284 IF (
ASSOCIATED(v_admm_tau_rspace))
THEN
286 CALL pw_transfer(v_admm_tau_rspace(ispin), vadmm_tau_rspace(ispin))
287 CALL pw_scale(vadmm_tau_rspace(ispin), vadmm_tau_rspace(ispin)%pw_grid%dvol)
293 CALL auxbas_pw_pool%give_back_pw(v_hartree_rspace)
294 IF (
ASSOCIATED(v_rspace))
THEN
296 CALL auxbas_pw_pool%give_back_pw(v_rspace(ispin))
297 IF (
ASSOCIATED(v_tau_rspace))
THEN
298 CALL auxbas_pw_pool%give_back_pw(v_tau_rspace(ispin))
301 DEALLOCATE (v_rspace)
303 IF (
ASSOCIATED(v_tau_rspace))
DEALLOCATE (v_tau_rspace)
304 IF (
ASSOCIATED(v_admm_rspace))
THEN
306 CALL auxbas_pw_pool%give_back_pw(v_admm_rspace(ispin))
308 DEALLOCATE (v_admm_rspace)
310 IF (
ASSOCIATED(v_admm_tau_rspace))
THEN
312 CALL auxbas_pw_pool%give_back_pw(v_admm_tau_rspace(ispin))
314 DEALLOCATE (v_admm_tau_rspace)
317 CALL timestop(handle)
333 TYPE(
local_rho_type),
POINTER :: local_rho_set, local_rho_set_admm
336 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ks_ref_potential_atom'
338 INTEGER :: handle, natom, nspins
339 LOGICAL :: gapw, gapw_xc
340 REAL(kind=
dp) :: eh1c, exc1, exc1_admm
343 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_aux, rho_ao_kp
351 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
355 CALL timeset(routinen, handle)
358 CALL get_qs_env(qs_env=qs_env, rho=rho, pw_env=pw_env, &
359 dft_control=dft_control, para_env=para_env)
361 nspins = dft_control%nspins
362 gapw = dft_control%qs_control%gapw
363 gapw_xc = dft_control%qs_control%gapw_xc
365 IF (gapw .OR. gapw_xc)
THEN
366 NULLIFY (hartree_local, local_rho_set, local_rho_set_admm)
368 atomic_kind_set=atomic_kind_set, &
369 qs_kind_set=qs_kind_set)
372 qs_kind_set, dft_control, para_env)
375 CALL init_rho0(local_rho_set, qs_env, dft_control%qs_control%gapw_control)
381 CALL get_qs_env(qs_env=qs_env, oce=oce, sab_orb=sab)
384 qs_kind_set, oce, sab, para_env)
387 IF (dft_control%do_admm)
THEN
389 xc_section => admm_env%xc_section_primary
394 rho_atom_set_external=local_rho_set%rho_atom_set)
397 CALL vh_1c_gg_integrals(qs_env, eh1c, hartree_local%ecoul_1c, local_rho_set, para_env, .false.)
399 local_rho_set=local_rho_set)
402 IF (dft_control%do_admm)
THEN
403 IF (admm_env%do_gapw)
THEN
406 admm_env%admm_gapw_env%admm_kind_set, dft_control, para_env)
407 oce => admm_env%admm_gapw_env%oce
408 sab => admm_env%sab_aux_fit
412 admm_env%admm_gapw_env%admm_kind_set, oce, sab, para_env)
414 do_rho0=.false., kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
416 xc_section => admm_env%xc_section_aux
418 kind_set_external=admm_env%admm_gapw_env%admm_kind_set, &
419 xc_section_external=xc_section, &
420 rho_atom_set_external=local_rho_set_admm%rho_atom_set)
429 NULLIFY (local_rho_set, local_rho_set_admm)
433 CALL timestop(handle)
Types and set/get functions for auxiliary density matrix methods.
subroutine, public get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, rho_aux_fit_buffer, admm_dm)
Get routine for the ADMM env.
Define the atomic kind types and their sub types.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public init_coulomb_local(hartree_local, natom)
...
subroutine, public vh_1c_gg_integrals(qs_env, energy_hartree_1c, ecoul_1c, local_rho_set, para_env, tddft, local_rho_set_2nd, core_2nd)
Calculates one center GAPW Hartree energies and matrix elements Hartree potentials are input Takes po...
subroutine, public hartree_local_release(hartree_local)
...
subroutine, public hartree_local_create(hartree_local)
...
Defines the basic variable types.
integer, parameter, public dp
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 ...
Calculation of the energies concerning the core charge distribution.
subroutine, public calculate_ecore_overlap(qs_env, para_env, calculate_forces, molecular, e_overlap_core, atecc)
Calculate the overlap energy of the core charge distribution.
subroutine, public calculate_ecore_self(qs_env, e_self_core, atecc)
Calculate the self energy of the core charge distribution.
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 prepare_gapw_den(qs_env, local_rho_set, do_rho0, kind_set_external, pw_env_sub)
...
Define the quickstep kind type and their sub types.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public calc_rho_tot_gspace(rho_tot_gspace, qs_env, rho, skip_nuclear_density)
...
Calculate the KS reference potentials.
subroutine, public ks_ref_potential_atom(qs_env, local_rho_set, local_rho_set_admm, v_hartree_rspace)
calculate the Kohn-Sham GAPW reference potentials
subroutine, public ks_ref_potential(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, ehartree, exc, h_stress, vadmm_tau_rspace)
calculate the Kohn-Sham reference potential
subroutine, public local_rho_set_create(local_rho_set)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public rho0_s_grid_create(pw_env, rho0_mpole)
...
subroutine, public integrate_vhg0_rspace(qs_env, v_rspace, para_env, calculate_forces, local_rho_set, local_rho_set_2nd, atener, kforce, my_pools, my_rs_descs)
...
subroutine, public init_rho0(local_rho_set, qs_env, gapw_control, zcore)
...
subroutine, public allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
subroutine, public calculate_rho_atom_coeff(qs_env, rho_ao, rho_atom_set, qs_kind_set, oce, sab, para_env)
...
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...
routines that build the integrals of the Vxc potential calculated for the atomic density in the basis...
subroutine, public calculate_vxc_atom(qs_env, energy_only, exc1, adiabatic_rescale_factor, kind_set_external, rho_atom_set_external, xc_section_external, calculate_forces, composite_vxc_rho, composite_vxc_tau, composite_reference_active, direct_valence_atom_grid, atom_composite_grid)
...
subroutine, public qs_vxc_create(ks_env, rho_struct, xc_section, vxc_rho, vxc_tau, exc, just_energy, edisp, dispersion_env, adiabatic_rescale_factor, pw_env_external, native_skala_atom_force, qs_env_external, native_gapw_composite_override, native_skala_defer_to_atom_composite)
calculates and allocates the xc potential, already reducing it to the dependence on rho and the one o...
stores some data used in wavefunction fitting
Provides all information about an atomic kind.
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 ...
Provides all information about a quickstep kind.
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.