63#include "./base/base_uses.f90"
71 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_ks_reference'
93 SUBROUTINE ks_ref_potential(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, &
94 ehartree, exc, h_stress)
97 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: vxc_rspace, vtau_rspace, vadmm_rspace
98 REAL(kind=
dp),
INTENT(OUT) :: ehartree, exc
99 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT), &
102 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ks_ref_potential'
104 INTEGER :: handle, iab, ispin, nspins
105 REAL(
dp) :: eadmm, eovrl, eself
106 REAL(kind=
dp),
DIMENSION(3, 3) :: virial_xc
117 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_admm_rspace, v_admm_tau_rspace, &
118 v_rspace, v_tau_rspace
124 CALL timeset(routinen, handle)
127 NULLIFY (rho, ks_env)
128 CALL get_qs_env(qs_env=qs_env, rho=rho, dft_control=dft_control, &
129 para_env=para_env, ks_env=ks_env, rho_core=rho_core)
131 nspins = dft_control%nspins
135 cpassert(
ASSOCIATED(pw_env))
137 NULLIFY (auxbas_pw_pool, poisson_env)
139 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
140 poisson_env=poisson_env)
143 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
144 CALL auxbas_pw_pool%create_pw(v_hartree_rspace)
145 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
151 v_hartree_gspace, h_stress=h_stress, rho_core=rho_core)
152 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
153 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
155 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
156 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
160 ehartree = ehartree + eovrl + eself
163 IF (dft_control%do_admm)
THEN
165 xc_section => admm_env%xc_section_primary
169 NULLIFY (v_rspace, v_tau_rspace)
170 IF (dft_control%qs_control%gapw_xc)
THEN
172 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho_xc, xc_section=xc_section, &
173 vxc_rho=v_rspace, vxc_tau=v_tau_rspace, exc=exc, just_energy=.false.)
175 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho, xc_section=xc_section, &
176 vxc_rho=v_rspace, vxc_tau=v_tau_rspace, exc=exc, just_energy=.false.)
179 NULLIFY (v_admm_rspace, v_admm_tau_rspace)
180 IF (dft_control%do_admm)
THEN
183 IF (
PRESENT(h_stress))
THEN
185 virial_xc = virial%pv_xc
188 xc_section => admm_env%xc_section_aux
189 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho, xc_section=xc_section, &
190 vxc_rho=v_admm_rspace, vxc_tau=v_admm_tau_rspace, exc=eadmm, just_energy=.false.)
191 IF (
PRESENT(h_stress)) virial%pv_xc = virial%pv_xc + virial_xc
196 IF (
ASSOCIATED(vh_rspace%pw_grid))
THEN
197 CALL vh_rspace%release()
199 IF (
ASSOCIATED(vxc_rspace))
THEN
200 DO iab = 1,
SIZE(vxc_rspace)
201 CALL vxc_rspace(iab)%release()
204 ALLOCATE (vxc_rspace(nspins))
206 IF (
ASSOCIATED(v_tau_rspace))
THEN
207 IF (
ASSOCIATED(vtau_rspace))
THEN
208 DO iab = 1,
SIZE(vtau_rspace)
209 CALL vtau_rspace(iab)%release()
212 ALLOCATE (vtau_rspace(nspins))
215 NULLIFY (vtau_rspace)
217 IF (
ASSOCIATED(v_admm_rspace))
THEN
218 IF (
ASSOCIATED(vadmm_rspace))
THEN
219 DO iab = 1,
SIZE(vadmm_rspace)
220 CALL vadmm_rspace(iab)%release()
223 ALLOCATE (vadmm_rspace(nspins))
226 NULLIFY (vadmm_rspace)
229 pw_grid => v_hartree_rspace%pw_grid
230 CALL vh_rspace%create(pw_grid)
232 CALL vxc_rspace(ispin)%create(pw_grid)
233 IF (
ASSOCIATED(vtau_rspace))
THEN
234 CALL vtau_rspace(ispin)%create(pw_grid)
236 IF (
ASSOCIATED(vadmm_rspace))
THEN
237 CALL vadmm_rspace(ispin)%create(pw_grid)
242 IF (
ASSOCIATED(v_rspace))
THEN
244 CALL pw_transfer(v_rspace(ispin), vxc_rspace(ispin))
245 CALL pw_scale(vxc_rspace(ispin), v_rspace(ispin)%pw_grid%dvol)
246 IF (
ASSOCIATED(v_tau_rspace))
THEN
247 CALL pw_transfer(v_tau_rspace(ispin), vtau_rspace(ispin))
248 CALL pw_scale(vtau_rspace(ispin), v_tau_rspace(ispin)%pw_grid%dvol)
253 CALL pw_zero(vxc_rspace(ispin))
256 IF (
ASSOCIATED(v_admm_rspace))
THEN
258 CALL pw_transfer(v_admm_rspace(ispin), vadmm_rspace(ispin))
259 CALL pw_scale(vadmm_rspace(ispin), vadmm_rspace(ispin)%pw_grid%dvol)
264 CALL auxbas_pw_pool%give_back_pw(v_hartree_rspace)
265 IF (
ASSOCIATED(v_rspace))
THEN
267 CALL auxbas_pw_pool%give_back_pw(v_rspace(ispin))
268 IF (
ASSOCIATED(v_tau_rspace))
THEN
269 CALL auxbas_pw_pool%give_back_pw(v_tau_rspace(ispin))
272 DEALLOCATE (v_rspace)
274 IF (
ASSOCIATED(v_tau_rspace))
DEALLOCATE (v_tau_rspace)
275 IF (
ASSOCIATED(v_admm_rspace))
THEN
277 CALL auxbas_pw_pool%give_back_pw(v_admm_rspace(ispin))
279 DEALLOCATE (v_admm_rspace)
282 CALL timestop(handle)
298 TYPE(
local_rho_type),
POINTER :: local_rho_set, local_rho_set_admm
301 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ks_ref_potential_atom'
303 INTEGER :: handle, natom, nspins
304 LOGICAL :: gapw, gapw_xc
305 REAL(kind=
dp) :: eh1c, exc1, exc1_admm
308 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_aux, rho_ao_kp
316 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
320 CALL timeset(routinen, handle)
323 CALL get_qs_env(qs_env=qs_env, rho=rho, pw_env=pw_env, &
324 dft_control=dft_control, para_env=para_env)
326 nspins = dft_control%nspins
327 gapw = dft_control%qs_control%gapw
328 gapw_xc = dft_control%qs_control%gapw_xc
330 IF (gapw .OR. gapw_xc)
THEN
331 NULLIFY (hartree_local, local_rho_set, local_rho_set_admm)
333 atomic_kind_set=atomic_kind_set, &
334 qs_kind_set=qs_kind_set)
337 qs_kind_set, dft_control, para_env)
340 CALL init_rho0(local_rho_set, qs_env, dft_control%qs_control%gapw_control)
346 CALL get_qs_env(qs_env=qs_env, oce=oce, sab_orb=sab)
349 qs_kind_set, oce, sab, para_env)
353 CALL vh_1c_gg_integrals(qs_env, eh1c, hartree_local%ecoul_1c, local_rho_set, para_env, .false.)
355 local_rho_set=local_rho_set)
357 IF (dft_control%do_admm)
THEN
359 xc_section => admm_env%xc_section_primary
364 rho_atom_set_external=local_rho_set%rho_atom_set)
366 IF (dft_control%do_admm)
THEN
367 IF (admm_env%do_gapw)
THEN
370 admm_env%admm_gapw_env%admm_kind_set, dft_control, para_env)
371 oce => admm_env%admm_gapw_env%oce
372 sab => admm_env%sab_aux_fit
376 admm_env%admm_gapw_env%admm_kind_set, oce, sab, para_env)
378 do_rho0=.false., kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
380 xc_section => admm_env%xc_section_aux
382 kind_set_external=admm_env%admm_gapw_env%admm_kind_set, &
383 xc_section_external=xc_section, &
384 rho_atom_set_external=local_rho_set_admm%rho_atom_set)
393 NULLIFY (local_rho_set, local_rho_set_admm)
397 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, 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, 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, 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)
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(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, ehartree, exc, h_stress)
calculate the Kohn-Sham reference potential
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 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, gradient_atom_set, 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)
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.