57#include "./base/base_uses.f90"
63 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_local_properties'
83 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_local_energy'
85 INTEGER :: handle, img, iounit, ispin, nimages, &
87 LOGICAL :: gapw, gapw_xc, local_soft_only
88 REAL(kind=
dp) :: eban, eband, eh, exc, ovol
91 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s, matrix_w, rho_ao_kp
107 CALL timeset(routinen, handle)
111 cpassert(
ASSOCIATED(qs_env))
116 CALL get_qs_env(qs_env, nkind=nkind, dft_control=dft_control)
117 gapw = dft_control%qs_control%gapw
118 gapw_xc = dft_control%qs_control%gapw_xc
119 local_soft_only = dft_control%do_admm .OR. gapw .OR. gapw_xc
121 nimages = dft_control%nimages
122 nspins = dft_control%nspins
126 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
127 CALL auxbas_pw_pool%create_pw(band_density)
128 CALL auxbas_pw_pool%create_pw(hartree_density)
129 CALL auxbas_pw_pool%create_pw(xc_density)
133 IF (.NOT.
ASSOCIATED(matrix_w))
THEN
136 matrix_s_kp=matrix_s)
137 matrix => matrix_s(1, 1)%matrix
141 ALLOCATE (matrix_w(ispin, img)%matrix)
142 CALL dbcsr_copy(matrix_w(ispin, img)%matrix, matrix, name=
"W MATRIX")
143 CALL dbcsr_set(matrix_w(ispin, img)%matrix, 0.0_dp)
150 CALL get_qs_env(qs_env, ks_env=ks_env, matrix_w_kp=matrix_w)
151 CALL auxbas_pw_pool%create_pw(edens_r)
152 CALL auxbas_pw_pool%create_pw(edens_g)
155 rho_ao => matrix_w(ispin, :)
158 rho_gspace=edens_g, &
159 ks_env=ks_env, soft_valid=(gapw .OR. gapw_xc))
160 CALL pw_axpy(edens_r, band_density)
162 CALL auxbas_pw_pool%give_back_pw(edens_r)
163 CALL auxbas_pw_pool%give_back_pw(edens_g)
166 ALLOCATE (rho_tot_gspace, rho_tot_rspace)
167 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
168 CALL auxbas_pw_pool%create_pw(rho_tot_rspace)
171 v_hartree_rspace=v_hartree_rspace, &
172 rho_core=rho_core, rho=rho)
174 IF (
ASSOCIATED(rho_core))
THEN
181 CALL pw_axpy(rho_r(ispin), rho_tot_rspace, alpha=-1.0_dp)
184 ovol = 0.5_dp/hartree_density%pw_grid%dvol
185 CALL pw_multiply(hartree_density, v_hartree_rspace, rho_tot_rspace, alpha=ovol)
186 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
187 CALL auxbas_pw_pool%give_back_pw(rho_tot_rspace)
188 DEALLOCATE (rho_tot_gspace, rho_tot_rspace)
190 IF (dft_control%do_admm)
THEN
191 CALL cp_warn(__location__, &
192 "ADMM local energy density contains only the regular-grid contribution")
194 IF (gapw_xc .OR. gapw)
THEN
195 CALL cp_warn(__location__, &
196 "GAPW/GAPW_XC local energy density contains only the soft regular-grid part")
201 CALL get_qs_env(qs_env=qs_env, rho=rho_struct)
203 CALL qs_xc_density(ks_env, rho_struct, xc_section, xc_ener=xc_density)
212 CALL get_qs_env(qs_env, matrix_ks_kp=matrix_ks)
217 CALL pw_copy(band_density, energy_density)
218 CALL pw_axpy(hartree_density, energy_density)
219 CALL pw_axpy(xc_density, energy_density)
222 WRITE (unit=iounit, fmt=
"(/,T3,A)") repeat(
"=", 78)
223 IF (local_soft_only)
THEN
224 WRITE (unit=iounit, fmt=
"(T4,A)") &
225 "Local Energy Calculation (regular-grid contribution only)"
226 WRITE (unit=iounit, fmt=
"(T4,A,T52,A,T68,A)")
"Energy Component",
"Reference",
"Local Grid"
228 WRITE (unit=iounit, fmt=
"(T4,A,T52,A,T75,A)")
"Local Energy Calculation",
"GPW/GAPW",
"Local"
230 WRITE (unit=iounit, fmt=
"(T4,A,T45,F15.8,T65,F15.8)")
"Band Energy", eband, eban
231 WRITE (unit=iounit, fmt=
"(T4,A,T65,F15.8)")
"Hartree Energy Correction", eh
232 WRITE (unit=iounit, fmt=
"(T4,A,T65,F15.8)")
"XC Energy Correction", exc
233 IF (local_soft_only)
THEN
234 WRITE (unit=iounit, fmt=
"(T4,A,T45,F15.8)")
"Reference Total Energy", energy%total
235 WRITE (unit=iounit, fmt=
"(T4,A,T65,F15.8)")
"Local Grid Energy Sum", &
236 eban + eh + exc + energy%core_overlap + energy%core_self + energy%dispersion
238 WRITE (unit=iounit, fmt=
"(T4,A,T45,F15.8,T65,F15.8)")
"Total Energy", &
239 energy%total, eban + eh + exc + energy%core_overlap + energy%core_self + energy%dispersion
241 WRITE (unit=iounit, fmt=
"(T3,A)") repeat(
"=", 78)
245 CALL auxbas_pw_pool%give_back_pw(band_density)
246 CALL auxbas_pw_pool%give_back_pw(hartree_density)
247 CALL auxbas_pw_pool%give_back_pw(xc_density)
249 CALL timestop(handle)
265 INTENT(INOUT),
OPTIONAL :: stress_tensor
266 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: beta
268 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_local_stress'
270 INTEGER :: handle, i, iounit, j, nimages, nkind, &
272 LOGICAL :: do_stress, gapw, gapw_xc, use_virial
273 REAL(kind=
dp) :: my_beta
274 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_loc
288 CALL cp_warn(__location__,
"Local Stress Tensor code is not working, skipping")
291 CALL timeset(routinen, handle)
296 cpassert(
ASSOCIATED(qs_env))
298 IF (
PRESENT(stress_tensor))
THEN
303 IF (
PRESENT(beta))
THEN
313 CALL cp_warn(__location__,
"Local Stress Tensor code is not tested")
317 CALL get_qs_env(qs_env, nkind=nkind, dft_control=dft_control)
318 gapw = dft_control%qs_control%gapw
319 gapw_xc = dft_control%qs_control%gapw_xc
321 nimages = dft_control%nimages
322 nspins = dft_control%nspins
326 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
327 CALL auxbas_pw_pool%create_pw(xc_density)
333 CALL pw_zero(stress_tensor(i, j))
338 IF (dft_control%do_admm)
THEN
339 CALL cp_warn(__location__, &
340 "ADMM local stress density contains only the regular-grid contribution")
342 IF (gapw_xc .OR. gapw)
THEN
343 CALL cp_warn(__location__, &
344 "GAPW/GAPW_XC local stress density contains only the soft regular-grid part")
347 CALL get_qs_env(qs_env, ks_env=ks_env, input=input, rho=rho_struct)
350 CALL qs_xc_density(ks_env, rho_struct, xc_section, xc_ener=xc_density)
353 CALL get_qs_env(qs_env, v_hartree_rspace=v_hartree_rspace)
354 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
355 CALL pw_transfer(v_hartree_rspace, v_hartree_gspace)
357 CALL auxbas_pw_pool%create_pw(efield(i))
358 CALL pw_copy(v_hartree_gspace, efield(i))
363 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
365 CALL auxbas_pw_pool%give_back_pw(efield(i))
371 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
372 IF (.NOT. use_virial)
THEN
373 CALL cp_warn(__location__,
"Local stress should be used with standard stress calculation.")
375 IF (iounit > 0 .AND. use_virial)
THEN
376 WRITE (unit=iounit, fmt=
"(/,T3,A)") repeat(
"=", 78)
377 WRITE (unit=iounit, fmt=
"(T4,A)")
"Local Stress Calculation"
378 WRITE (unit=iounit, fmt=
"(T42,A,T64,A)")
" 1/3 Trace",
" Determinant"
379 WRITE (unit=iounit, fmt=
"(T4,A,T42,F16.8,T64,F16.8)")
"Total Stress", &
380 (pv_loc(1, 1) + pv_loc(2, 2) + pv_loc(3, 3))/3.0_dp,
det_3x3(pv_loc)
381 WRITE (unit=iounit, fmt=
"(T3,A)") repeat(
"=", 78)
384 CALL timestop(handle)
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public filippetti2000
integer, save, public cohen2000
integer, save, public rogers2002
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_set(matrix, alpha)
...
DBCSR operations in CP2K.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Defines the basic variable types.
integer, parameter, public dp
Collection of simple mathematical functions and subroutines.
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
subroutine, public pw_derive(pw, n)
Calculate the derivative of a plane wave vector.
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
Calculation of the energies concerning 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.
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)
...
subroutine, public set_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, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, 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, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
Routines for calculating local energy and stress tensor.
subroutine, public qs_local_stress(qs_env, stress_tensor, beta)
Routine to calculate the local stress.
subroutine, public qs_local_energy(qs_env, energy_density)
Routine to calculate the local energy.
Utility subroutine for qs energy calculation.
subroutine, public compute_matrix_w(qs_env, calc_forces)
Refactoring of qs_energies_scf. Moves computation of matrix_w into separate subroutine.
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 qs_xc_density(ks_env, rho_struct, xc_section, dispersion_env, xc_ener, xc_den, exc, vxc, vtau)
calculates the XC density: E_xc(r) - V_xc(r)*rho(r) or E_xc(r)/rho(r)
type of a logger, at the moment it contains just a print level starting at which level it should be l...
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.