47#include "./base/base_uses.f90"
55 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_core_energies'
62 MODULE PROCEDURE calculate_ptrace_1, calculate_ptrace_gamma, calculate_ptrace_kp
83 SUBROUTINE calculate_ptrace_gamma(hmat, pmat, ecore, nspin, spinmat)
86 REAL(KIND=
dp),
INTENT(OUT) :: ecore
87 INTEGER,
INTENT(IN) :: nspin
88 LOGICAL,
INTENT(IN),
OPTIONAL :: spinmat
90 CHARACTER(len=*),
PARAMETER :: routineN =
'calculate_ptrace_gamma'
92 INTEGER :: handle, ispin
96 CALL timeset(routinen, handle)
99 IF (
PRESENT(spinmat)) lspin = spinmat
105 CALL dbcsr_dot(hmat(ispin)%matrix, pmat(ispin)%matrix, etr)
107 CALL dbcsr_dot(hmat(1)%matrix, pmat(ispin)%matrix, etr)
112 CALL timestop(handle)
114 END SUBROUTINE calculate_ptrace_gamma
129 SUBROUTINE calculate_ptrace_kp(hmat, pmat, ecore, nspin, spinmat)
131 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: hmat, pmat
132 REAL(kind=
dp),
INTENT(OUT) :: ecore
133 INTEGER,
INTENT(IN) :: nspin
134 LOGICAL,
INTENT(IN),
OPTIONAL :: spinmat
136 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ptrace_kp'
138 INTEGER :: handle, ic, ispin, nc
142 CALL timeset(routinen, handle)
145 IF (
PRESENT(spinmat)) lspin = spinmat
154 CALL dbcsr_dot(hmat(ispin, ic)%matrix, pmat(ispin, ic)%matrix, etr)
156 CALL dbcsr_dot(hmat(1, ic)%matrix, pmat(ispin, ic)%matrix, etr)
162 CALL timestop(handle)
164 END SUBROUTINE calculate_ptrace_kp
183 SUBROUTINE calculate_ptrace_1(h, p, ecore)
186 REAL(kind=
dp),
INTENT(OUT) :: ecore
188 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ptrace_1'
192 CALL timeset(routinen, handle)
197 CALL timestop(handle)
199 END SUBROUTINE calculate_ptrace_1
219 E_overlap_core, atecc)
222 LOGICAL,
INTENT(IN) :: calculate_forces
223 LOGICAL,
INTENT(IN),
OPTIONAL :: molecular
224 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: e_overlap_core
225 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: atecc
227 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ecore_overlap'
229 INTEGER :: atom_a, atom_b, handle, iatom, ikind, &
230 jatom, jkind, natom, nkind
231 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
232 LOGICAL :: atenergy, only_molecule, use_virial
233 REAL(kind=
dp) :: aab, dab, eab, ecore_overlap, f, fab, &
235 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: alpha, radius, zeff
236 REAL(kind=
dp),
DIMENSION(3) :: deab, rab
237 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_loc
243 DIMENSION(:),
POINTER :: nl_iterator
249 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
252 CALL timeset(routinen, handle)
254 NULLIFY (atomic_kind_set)
255 NULLIFY (qs_kind_set)
259 NULLIFY (particle_set)
263 only_molecule = .false.
264 IF (
PRESENT(molecular)) only_molecule = molecular
267 atomic_kind_set=atomic_kind_set, &
268 qs_kind_set=qs_kind_set, &
269 particle_set=particle_set, &
277 nkind =
SIZE(atomic_kind_set)
278 natom =
SIZE(particle_set)
280 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
282 ALLOCATE (alpha(nkind), radius(nkind), zeff(nkind))
287 IF (calculate_forces)
THEN
292 IF (
ASSOCIATED(atprop))
THEN
293 IF (atprop%energy)
THEN
301 NULLIFY (cneo_potential)
302 CALL get_qs_kind(qs_kind_set(ikind), cneo_potential=cneo_potential)
303 IF (
ASSOCIATED(cneo_potential))
THEN
304 alpha(ikind) = 1.0_dp
305 radius(ikind) = 1.0_dp
309 alpha_core_charge=alpha(ikind), &
310 core_charge_radius=radius(ikind), &
315 ecore_overlap = 0.0_dp
320 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, iatom=iatom, jatom=jatom, r=rab)
321 zab = zeff(ikind)*zeff(jkind)
322 aab = alpha(ikind)*alpha(jkind)/(alpha(ikind) + alpha(jkind))
325 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
326 IF (rab2 > 1.e-8_dp)
THEN
327 IF (ikind == jkind .AND. iatom == jatom)
THEN
333 eab = zab*erfc(rootaab*dab)/dab
334 ecore_overlap = ecore_overlap + f*eab
336 atprop%atecc(iatom) = atprop%atecc(iatom) + 0.5_dp*f*eab
337 atprop%atecc(jatom) = atprop%atecc(jatom) + 0.5_dp*f*eab
339 IF (
PRESENT(atecc))
THEN
340 atecc(iatom) = atecc(iatom) + 0.5_dp*f*eab
341 atecc(jatom) = atecc(jatom) + 0.5_dp*f*eab
343 IF (calculate_forces)
THEN
344 deab(:) = rab(:)*f*(eab + fab*exp(-aab*rab2))/rab2
345 atom_a = atom_of_kind(iatom)
346 atom_b = atom_of_kind(jatom)
347 force(ikind)%core_overlap(:, atom_a) = force(ikind)%core_overlap(:, atom_a) + deab(:)
348 force(jkind)%core_overlap(:, atom_b) = force(jkind)%core_overlap(:, atom_b) - deab(:)
357 DEALLOCATE (alpha, radius, zeff)
358 IF (calculate_forces)
THEN
359 DEALLOCATE (atom_of_kind)
361 IF (calculate_forces .AND. use_virial)
THEN
362 virial%pv_ecore_overlap = virial%pv_ecore_overlap + pv_loc
363 virial%pv_virial = virial%pv_virial + pv_loc
366 CALL group%sum(ecore_overlap)
368 energy%core_overlap = ecore_overlap
370 IF (
PRESENT(e_overlap_core))
THEN
371 e_overlap_core = energy%core_overlap
374 CALL timestop(handle)
389 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: e_self_core
390 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: atecc
392 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ecore_self'
394 INTEGER :: handle, iatom, ikind, iparticle_local, &
395 natom, nparticle_local
396 REAL(kind=
dp) :: alpha_core_charge, ecore_self, es, zeff
403 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
408 CALL timeset(routinen, handle)
410 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, &
411 qs_kind_set=qs_kind_set, energy=energy, atprop=atprop)
415 DO ikind = 1,
SIZE(atomic_kind_set)
417 NULLIFY (cneo_potential)
418 CALL get_qs_kind(qs_kind_set(ikind), cneo_potential=cneo_potential)
419 IF (
ASSOCIATED(cneo_potential)) cycle
421 CALL get_qs_kind(qs_kind_set(ikind), zeff=zeff, alpha_core_charge=alpha_core_charge)
422 ecore_self = ecore_self - real(natom,
dp)*zeff**2*sqrt(alpha_core_charge)
425 energy%core_self = ecore_self/sqrt(
twopi)
426 IF (
PRESENT(e_self_core))
THEN
427 e_self_core = energy%core_self
430 IF (
ASSOCIATED(atprop))
THEN
431 IF (atprop%energy)
THEN
433 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, &
434 local_particles=local_particles)
435 natom =
SIZE(particle_set)
438 DO ikind = 1,
SIZE(atomic_kind_set)
440 NULLIFY (cneo_potential)
441 CALL get_qs_kind(qs_kind_set(ikind), cneo_potential=cneo_potential)
442 IF (
ASSOCIATED(cneo_potential)) cycle
443 nparticle_local = local_particles%n_el(ikind)
444 CALL get_qs_kind(qs_kind_set(ikind), zeff=zeff, alpha_core_charge=alpha_core_charge)
445 es = zeff**2*sqrt(alpha_core_charge)/sqrt(
twopi)
446 DO iparticle_local = 1, nparticle_local
447 iatom = local_particles%list(ikind)%array(iparticle_local)
448 atprop%ateself(iatom) = atprop%ateself(iatom) - es
453 IF (
PRESENT(atecc))
THEN
455 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, &
456 local_particles=local_particles)
457 natom =
SIZE(particle_set)
458 DO ikind = 1,
SIZE(atomic_kind_set)
459 nparticle_local = local_particles%n_el(ikind)
460 CALL get_qs_kind(qs_kind_set(ikind), zeff=zeff, alpha_core_charge=alpha_core_charge)
461 es = zeff**2*sqrt(alpha_core_charge)/sqrt(
twopi)
462 DO iparticle_local = 1, nparticle_local
463 iatom = local_particles%list(ikind)%array(iparticle_local)
464 atecc(iatom) = atecc(iatom) - es
469 CALL timestop(handle)
484 REAL(kind=
dp),
INTENT(IN) :: alpha
485 REAL(kind=
dp),
DIMENSION(:) :: atecc
487 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ecore_alpha'
489 INTEGER :: handle, iatom, ikind, jatom, jkind, &
491 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of
492 REAL(kind=
dp) :: dab, eab, fab, rootaab, zab
493 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zeff
494 REAL(kind=
dp),
DIMENSION(3) :: rab
498 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
500 CALL timeset(routinen, handle)
504 atomic_kind_set=atomic_kind_set, &
505 qs_kind_set=qs_kind_set, &
506 particle_set=particle_set)
509 nkind =
SIZE(atomic_kind_set)
510 natom =
SIZE(particle_set)
511 ALLOCATE (zeff(nkind))
514 CALL get_qs_kind(qs_kind_set(ikind), zeff=zeff(ikind))
517 rootaab = sqrt(0.5_dp*alpha)
519 ikind = kind_of(iatom)
520 atecc(iatom) = atecc(iatom) - zeff(ikind)**2*sqrt(alpha/
twopi)
521 DO jatom = iatom + 1, natom
522 jkind = kind_of(jatom)
523 zab = zeff(ikind)*zeff(jkind)
525 rab = particle_set(iatom)%r - particle_set(jatom)%r
527 dab = sqrt(sum(rab(:)**2))
528 eab = zab*erfc(rootaab*dab)/dab
529 atecc(iatom) = atecc(iatom) + 0.5_dp*eab
530 atecc(jatom) = atecc(jatom) + 0.5_dp*eab
536 CALL timestop(handle)
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Holds information on atomic properties.
subroutine, public atprop_array_init(atarray, natom)
...
Handles all functions related to the CELL.
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public oorootpi
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
Define the data structure for the particle information.
Types used by CNEO-DFT (see J. Chem. Theory Comput. 2025, 21, 16, 7865–7877)
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 calculate_ecore_alpha(qs_env, alpha, atecc)
Calculate the overlap and self energy of the core charge distribution for a given alpha Use a minimum...
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.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
pure subroutine, public virial_pair_force(pv_virial, f0, force, rab)
Computes the contribution to the stress tensor from two-body pair-wise forces.
Provides all information about an atomic kind.
type for the atomic properties
Type defining parameters related to the simulation cell.
structure to store local (to a processor) ordered lists of integers.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.