21 USE dbcsr_api,
ONLY: dbcsr_copy,&
69 #include "./base/base_uses.f90"
77 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_energy_utils'
93 TYPE(qs_environment_type),
POINTER :: qs_env
94 LOGICAL,
INTENT(IN) :: calc_forces
96 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_energies_properties'
98 INTEGER :: handle, natom
99 LOGICAL :: do_et, do_et_proj, &
100 do_post_scf_bandstructure, do_tip_scan
101 REAL(kind=
dp) :: ekts
102 TYPE(atprop_type),
POINTER :: atprop
103 TYPE(dft_control_type),
POINTER :: dft_control
104 TYPE(mp_para_env_type),
POINTER :: para_env
105 TYPE(pw_env_type),
POINTER :: pw_env
106 TYPE(pw_r3d_rs_type),
POINTER :: v_hartree_rspace
107 TYPE(qs_energy_type),
POINTER :: energy
108 TYPE(section_vals_type),
POINTER :: input, post_scf_bands_section, &
109 proj_section, rest_b_section, &
112 NULLIFY (atprop, energy, pw_env)
113 CALL timeset(routinen, handle)
117 dft_control=dft_control, &
121 v_hartree_rspace=v_hartree_rspace, &
124 IF (atprop%energy)
THEN
125 CALL qs_energies_mulliken(qs_env)
127 IF (.NOT. dft_control%qs_control%semi_empirical .AND. &
128 .NOT. dft_control%qs_control%xtb .AND. &
129 .NOT. dft_control%qs_control%dftb)
THEN
131 CALL integrate_v_core_rspace(v_hartree_rspace, qs_env)
132 IF (.NOT.
ASSOCIATED(atprop%ateb))
THEN
136 CALL ks_xc_correction(qs_env)
147 ekts = energy%kts/real(natom, kind=
dp)/real(para_env%num_pe, kind=
dp)
148 atprop%atener(:) = atprop%atener(:) + ekts
152 NULLIFY (proj_section)
162 do_et = dft_control%qs_control%et_coupling_calc
164 qs_env%et_coupling%energy = energy%total
165 qs_env%et_coupling%keep_matrix = .true.
166 qs_env%et_coupling%first_run = .true.
168 qs_env%et_coupling%first_run = .false.
169 IF (dft_control%qs_control%ddapc_restraint)
THEN
172 ddapc_restraint_section=rest_b_section)
174 CALL scf(qs_env=qs_env)
175 qs_env%et_coupling%keep_matrix = .true.
182 IF (dft_control%do_xas_calculation)
THEN
183 CALL xas(qs_env, dft_control)
186 IF (dft_control%do_xas_tdp_calculation)
THEN
191 IF (.NOT. qs_env%linres_run)
THEN
195 IF (dft_control%tddfpt2_control%enabled)
THEN
196 CALL tddfpt(qs_env, calc_forces)
200 NULLIFY (post_scf_bands_section)
202 CALL section_vals_get(post_scf_bands_section, explicit=do_post_scf_bandstructure)
203 IF (do_post_scf_bandstructure)
THEN
208 NULLIFY (tip_scan_section)
211 IF (do_tip_scan)
THEN
215 CALL timestop(handle)
226 SUBROUTINE qs_energies_mulliken(qs_env)
228 TYPE(qs_environment_type),
POINTER :: qs_env
231 TYPE(atprop_type),
POINTER :: atprop
232 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_h, matrix_ks, rho_ao
233 TYPE(qs_rho_type),
POINTER :: rho
235 NULLIFY (atprop, matrix_h, matrix_ks, rho, rho_ao)
236 CALL get_qs_env(qs_env=qs_env, matrix_ks=matrix_ks, matrix_h=matrix_h, &
237 rho=rho, atprop=atprop)
240 IF (atprop%energy)
THEN
242 atprop%atener = 0._dp
243 DO ispin = 1,
SIZE(rho_ao)
244 CALL atom_trace(matrix_h(1)%matrix, rho_ao(ispin)%matrix, &
245 0.5_dp, atprop%atener)
246 CALL atom_trace(matrix_ks(ispin)%matrix, rho_ao(ispin)%matrix, &
247 0.5_dp, atprop%atener)
251 END SUBROUTINE qs_energies_mulliken
257 SUBROUTINE ks_xc_correction(qs_env)
258 TYPE(qs_environment_type),
POINTER :: qs_env
260 CHARACTER(len=*),
PARAMETER :: routinen =
'ks_xc_correction'
262 INTEGER :: handle, iatom, ispin, natom, nspins
263 LOGICAL :: gapw, gapw_xc
264 REAL(kind=
dp) :: eh1, exc1
265 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
266 TYPE(atprop_type),
POINTER :: atprop
267 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, rho_ao, xcmat
268 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p
269 TYPE(dft_control_type),
POINTER :: dft_control
270 TYPE(ecoul_1center_type),
DIMENSION(:),
POINTER :: ecoul_1c
271 TYPE(local_rho_type),
POINTER :: local_rho_set
272 TYPE(mp_para_env_type),
POINTER :: para_env
273 TYPE(pw_env_type),
POINTER :: pw_env
274 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
275 TYPE(pw_r3d_rs_type) :: xc_den
276 TYPE(pw_r3d_rs_type),
ALLOCATABLE,
DIMENSION(:) :: vtau, vxc
277 TYPE(pw_r3d_rs_type),
POINTER :: v_hartree_rspace
278 TYPE(qs_dispersion_type),
POINTER :: dispersion_env
279 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
280 TYPE(qs_ks_env_type),
POINTER :: ks_env
281 TYPE(qs_rho_type),
POINTER :: rho_struct
282 TYPE(rho_atom_type),
DIMENSION(:),
POINTER :: rho_atom_set
283 TYPE(section_vals_type),
POINTER :: xc_fun_section, xc_section
284 TYPE(xc_rho_cflags_type) :: needs
286 CALL timeset(routinen, handle)
288 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=pw_env, atprop=atprop)
290 IF (atprop%energy)
THEN
292 nspins = dft_control%nspins
296 gapw = dft_control%qs_control%gapw
297 gapw_xc = dft_control%qs_control%gapw_xc
300 CALL get_qs_env(qs_env, v_hartree_rspace=v_hartree_rspace)
301 IF (gapw .OR. gapw_xc)
THEN
302 CALL get_qs_env(qs_env=qs_env, local_rho_set=local_rho_set, &
303 rho_atom_set=rho_atom_set, ecoul_1c=ecoul_1c, &
304 natom=natom, para_env=para_env)
308 CALL vh_1c_gg_integrals(qs_env, eh1, ecoul_1c, local_rho_set, para_env, tddft=.false.)
309 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
311 local_rho_set=local_rho_set, atener=atprop%ateb)
315 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
316 CALL auxbas_pw_pool%create_pw(xc_den)
317 ALLOCATE (vxc(nspins))
319 CALL auxbas_pw_pool%create_pw(vxc(ispin))
321 IF (needs%tau .OR. needs%tau_spin)
THEN
322 ALLOCATE (vtau(nspins))
324 CALL auxbas_pw_pool%create_pw(vtau(ispin))
329 CALL get_qs_env(qs_env, rho_xc=rho_struct, dispersion_env=dispersion_env)
331 CALL get_qs_env(qs_env, rho=rho_struct, dispersion_env=dispersion_env)
333 IF (needs%tau .OR. needs%tau_spin)
THEN
334 CALL qs_xc_density(ks_env, rho_struct, xc_section, dispersion_env=dispersion_env, &
335 xc_den=xc_den, vxc=vxc, vtau=vtau)
337 CALL qs_xc_density(ks_env, rho_struct, xc_section, dispersion_env=dispersion_env, &
338 xc_den=xc_den, vxc=vxc)
342 CALL get_qs_env(qs_env, natom=natom, matrix_s=matrix_s)
344 ALLOCATE (xcmat(nspins))
346 ALLOCATE (xcmat(ispin)%matrix)
347 CALL dbcsr_create(xcmat(ispin)%matrix, template=matrix_s(1)%matrix)
348 CALL dbcsr_copy(xcmat(ispin)%matrix, matrix_s(1)%matrix)
349 CALL dbcsr_set(xcmat(ispin)%matrix, 0.0_dp)
350 CALL pw_scale(vxc(ispin), -0.5_dp)
351 CALL pw_axpy(xc_den, vxc(ispin))
352 CALL pw_scale(vxc(ispin), vxc(ispin)%pw_grid%dvol)
353 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=vxc(ispin), hmat=xcmat(ispin), &
354 calculate_forces=.false., gapw=(gapw .OR. gapw_xc))
355 IF (needs%tau .OR. needs%tau_spin)
THEN
356 CALL pw_scale(vtau(ispin), -0.5_dp*vtau(ispin)%pw_grid%dvol)
357 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=vtau(ispin), &
358 hmat=xcmat(ispin), calculate_forces=.false., &
359 gapw=(gapw .OR. gapw_xc), compute_tau=.true.)
362 IF (gapw .OR. gapw_xc)
THEN
364 CALL qs_rho_get(rho_struct, rho_ao_kp=matrix_p)
365 CALL update_ks_atom(qs_env, xcmat, matrix_p, forces=.false., kscale=-0.5_dp)
366 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom_set)
368 atprop%ate1c = 0.0_dp
370 atprop%ate1c(iatom) = atprop%ate1c(iatom) + &
371 rho_atom_set(iatom)%exc_h - rho_atom_set(iatom)%exc_s
374 CALL get_qs_env(qs_env=qs_env, ecoul_1c=ecoul_1c)
376 atprop%ate1c(iatom) = atprop%ate1c(iatom) + &
377 ecoul_1c(iatom)%ecoul_1_h - ecoul_1c(iatom)%ecoul_1_s + &
378 ecoul_1c(iatom)%ecoul_1_z - ecoul_1c(iatom)%ecoul_1_0
383 CALL atom_trace(xcmat(ispin)%matrix, rho_ao(ispin)%matrix, 1.0_dp, atprop%atexc)
384 CALL dbcsr_release(xcmat(ispin)%matrix)
385 DEALLOCATE (xcmat(ispin)%matrix)
389 CALL auxbas_pw_pool%give_back_pw(xc_den)
391 CALL auxbas_pw_pool%give_back_pw(vxc(ispin))
393 IF (needs%tau .OR. needs%tau_spin)
THEN
395 CALL auxbas_pw_pool%give_back_pw(vtau(ispin))
401 CALL timestop(handle)
403 END SUBROUTINE ks_xc_correction
Define the atomic kind types and their sub types.
Holds information on atomic properties.
subroutine, public atprop_array_add(array_a, array_b)
...
subroutine, public atprop_array_init(atarray, natom)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Utilities to set up the control types.
subroutine, public read_ddapc_section(qs_control, qs_section, ddapc_restraint_section)
reads the input parameters needed for ddapc.
calculates the electron transfer coupling elements by projection-operator approach Kondov et al....
subroutine, public calc_et_coupling_proj(qs_env)
calculates the electron transfer coupling elements by projection-operator approach Kondov et al....
calculates the electron transfer coupling elements Wu, Van Voorhis, JCP 125, 164105 (2006)
subroutine, public calc_et_coupling(qs_env)
...
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...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
subroutine, public atom_trace(amat, bmat, factor, atrace)
Compute partial trace of product of two matrices.
subroutine, public post_scf_bandstructure(qs_env, post_scf_bandstructure_section)
Perform post-SCF band structure calculations from higher level methods.
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
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Definition of disperson types for DFT calculations.
Utility subroutine for qs energy calculation.
subroutine, public qs_energies_properties(qs_env, calc_forces)
Refactoring of qs_energies_scf. Moves computation of properties into separate subroutine.
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_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, 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, rhs)
Get the QUICKSTEP environment.
Integrate single or product functions over a potential on a RS grid.
Define the quickstep kind type and their sub types.
routines that build the Kohn-Sham matrix contributions coming from local atomic densities
subroutine, public update_ks_atom(qs_env, ksmat, pmat, forces, tddft, rho_atom_external, kind_set_external, oce_external, sab_external, kscale, kintegral, kforce, fscale)
The correction to the KS matrix due to the GAPW local terms to the hartree and XC contributions is he...
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)
Contains the setup for the calculation of properties by linear response by the application of second ...
subroutine, public linres_calculation_low(qs_env)
Linear response can be called as run type or as post scf calculation Initialize the perturbation envi...
subroutine, public integrate_vhg0_rspace(qs_env, v_rspace, para_env, calculate_forces, local_rho_set, local_rho_set_2nd, atener, kforce)
...
subroutine, public zero_rho_atom_integrals(rho_atom_set)
...
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 for the Quickstep SCF run.
subroutine, public scf(qs_env, has_converged, total_scf_steps)
perform an scf procedure in the given qs_env
subroutine, public tddfpt(qs_env, calc_forces)
Perform TDDFPT calculation.
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_xc_density(ks_env, rho_struct, xc_section, dispersion_env, xc_ener, xc_den, vxc, vtau)
calculates the XC density: E_xc(r) - V_xc(r)*rho(r) or E_xc(r)/rho(r)
subroutine, public tip_scanning(qs_env, input_section)
Perform tip scanning calculation.
driver for the xas calculation and xas_scf for the tp method
subroutine, public xas(qs_env, dft_control)
Driver for xas calculations The initial mos are prepared A loop on the atoms to be excited is started...
Methods for X-Ray absorption spectroscopy (XAS) using TDDFPT.
subroutine, public xas_tdp(qs_env)
Driver for XAS TDDFT calculations.
type(xc_rho_cflags_type) function, public xc_functionals_get_needs(functionals, lsd, calc_potential)
...