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, 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, just_energy=.false.)
178 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho, xc_section=xc_section, &
179 vxc_rho=v_rspace, vxc_tau=v_tau_rspace, exc=exc, just_energy=.false.)
182 NULLIFY (v_admm_rspace, v_admm_tau_rspace)
183 IF (dft_control%do_admm)
THEN
186 IF (
PRESENT(h_stress))
THEN
188 virial_xc = virial%pv_xc
191 xc_section => admm_env%xc_section_aux
192 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho, xc_section=xc_section, &
193 vxc_rho=v_admm_rspace, vxc_tau=v_admm_tau_rspace, exc=eadmm, just_energy=.false.)
194 IF (
PRESENT(h_stress)) virial%pv_xc = virial%pv_xc + virial_xc
199 IF (
ASSOCIATED(vh_rspace%pw_grid))
THEN
200 CALL vh_rspace%release()
202 IF (
ASSOCIATED(vxc_rspace))
THEN
203 DO iab = 1,
SIZE(vxc_rspace)
204 CALL vxc_rspace(iab)%release()
207 ALLOCATE (vxc_rspace(nspins))
209 IF (
ASSOCIATED(v_tau_rspace))
THEN
210 IF (
ASSOCIATED(vtau_rspace))
THEN
211 DO iab = 1,
SIZE(vtau_rspace)
212 CALL vtau_rspace(iab)%release()
215 ALLOCATE (vtau_rspace(nspins))
218 NULLIFY (vtau_rspace)
220 IF (
ASSOCIATED(v_admm_rspace))
THEN
221 IF (
ASSOCIATED(vadmm_rspace))
THEN
222 DO iab = 1,
SIZE(vadmm_rspace)
223 CALL vadmm_rspace(iab)%release()
226 ALLOCATE (vadmm_rspace(nspins))
229 NULLIFY (vadmm_rspace)
231 IF (
PRESENT(vadmm_tau_rspace))
THEN
232 IF (
ASSOCIATED(vadmm_tau_rspace))
THEN
233 DO iab = 1,
SIZE(vadmm_tau_rspace)
234 CALL vadmm_tau_rspace(iab)%release()
237 IF (
ASSOCIATED(v_admm_tau_rspace))
THEN
238 IF (.NOT.
ASSOCIATED(vadmm_tau_rspace))
ALLOCATE (vadmm_tau_rspace(nspins))
240 IF (
ASSOCIATED(vadmm_tau_rspace))
DEALLOCATE (vadmm_tau_rspace)
241 NULLIFY (vadmm_tau_rspace)
245 pw_grid => v_hartree_rspace%pw_grid
246 CALL vh_rspace%create(pw_grid)
248 CALL vxc_rspace(ispin)%create(pw_grid)
249 IF (
ASSOCIATED(vtau_rspace))
THEN
250 CALL vtau_rspace(ispin)%create(pw_grid)
252 IF (
ASSOCIATED(vadmm_rspace))
THEN
253 CALL vadmm_rspace(ispin)%create(pw_grid)
255 IF (
PRESENT(vadmm_tau_rspace))
THEN
256 IF (
ASSOCIATED(vadmm_tau_rspace))
CALL vadmm_tau_rspace(ispin)%create(pw_grid)
261 IF (
ASSOCIATED(v_rspace))
THEN
263 CALL pw_transfer(v_rspace(ispin), vxc_rspace(ispin))
264 CALL pw_scale(vxc_rspace(ispin), v_rspace(ispin)%pw_grid%dvol)
265 IF (
ASSOCIATED(v_tau_rspace))
THEN
266 CALL pw_transfer(v_tau_rspace(ispin), vtau_rspace(ispin))
267 CALL pw_scale(vtau_rspace(ispin), v_tau_rspace(ispin)%pw_grid%dvol)
272 CALL pw_zero(vxc_rspace(ispin))
275 IF (
ASSOCIATED(v_admm_rspace))
THEN
277 CALL pw_transfer(v_admm_rspace(ispin), vadmm_rspace(ispin))
278 CALL pw_scale(vadmm_rspace(ispin), vadmm_rspace(ispin)%pw_grid%dvol)
281 IF (
PRESENT(vadmm_tau_rspace))
THEN
282 IF (
ASSOCIATED(v_admm_tau_rspace))
THEN
284 CALL pw_transfer(v_admm_tau_rspace(ispin), vadmm_tau_rspace(ispin))
285 CALL pw_scale(vadmm_tau_rspace(ispin), vadmm_tau_rspace(ispin)%pw_grid%dvol)
291 CALL auxbas_pw_pool%give_back_pw(v_hartree_rspace)
292 IF (
ASSOCIATED(v_rspace))
THEN
294 CALL auxbas_pw_pool%give_back_pw(v_rspace(ispin))
295 IF (
ASSOCIATED(v_tau_rspace))
THEN
296 CALL auxbas_pw_pool%give_back_pw(v_tau_rspace(ispin))
299 DEALLOCATE (v_rspace)
301 IF (
ASSOCIATED(v_tau_rspace))
DEALLOCATE (v_tau_rspace)
302 IF (
ASSOCIATED(v_admm_rspace))
THEN
304 CALL auxbas_pw_pool%give_back_pw(v_admm_rspace(ispin))
306 DEALLOCATE (v_admm_rspace)
308 IF (
ASSOCIATED(v_admm_tau_rspace))
THEN
310 CALL auxbas_pw_pool%give_back_pw(v_admm_tau_rspace(ispin))
312 DEALLOCATE (v_admm_tau_rspace)
315 CALL timestop(handle)
331 TYPE(
local_rho_type),
POINTER :: local_rho_set, local_rho_set_admm
334 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ks_ref_potential_atom'
336 INTEGER :: handle, natom, nspins
337 LOGICAL :: gapw, gapw_xc
338 REAL(kind=
dp) :: eh1c, exc1, exc1_admm
341 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_aux, rho_ao_kp
349 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
353 CALL timeset(routinen, handle)
356 CALL get_qs_env(qs_env=qs_env, rho=rho, pw_env=pw_env, &
357 dft_control=dft_control, para_env=para_env)
359 nspins = dft_control%nspins
360 gapw = dft_control%qs_control%gapw
361 gapw_xc = dft_control%qs_control%gapw_xc
363 IF (gapw .OR. gapw_xc)
THEN
364 NULLIFY (hartree_local, local_rho_set, local_rho_set_admm)
366 atomic_kind_set=atomic_kind_set, &
367 qs_kind_set=qs_kind_set)
370 qs_kind_set, dft_control, para_env)
373 CALL init_rho0(local_rho_set, qs_env, dft_control%qs_control%gapw_control)
379 CALL get_qs_env(qs_env=qs_env, oce=oce, sab_orb=sab)
382 qs_kind_set, oce, sab, para_env)
385 IF (dft_control%do_admm)
THEN
387 xc_section => admm_env%xc_section_primary
392 rho_atom_set_external=local_rho_set%rho_atom_set)
395 CALL vh_1c_gg_integrals(qs_env, eh1c, hartree_local%ecoul_1c, local_rho_set, para_env, .false.)
397 local_rho_set=local_rho_set)
400 IF (dft_control%do_admm)
THEN
401 IF (admm_env%do_gapw)
THEN
404 admm_env%admm_gapw_env%admm_kind_set, dft_control, para_env)
405 oce => admm_env%admm_gapw_env%oce
406 sab => admm_env%sab_aux_fit
410 admm_env%admm_gapw_env%admm_kind_set, oce, sab, para_env)
412 do_rho0=.false., kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
414 xc_section => admm_env%xc_section_aux
416 kind_set_external=admm_env%admm_gapw_env%admm_kind_set, &
417 xc_section_external=xc_section, &
418 rho_atom_set_external=local_rho_set_admm%rho_atom_set)
427 NULLIFY (local_rho_set, local_rho_set_admm)
431 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, 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)
...
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)
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.