69#include "./base/base_uses.f90"
77 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_energy_init'
94 LOGICAL,
INTENT(IN) :: calc_forces
96 INTEGER :: img, ispin, nimg, nspin
97 LOGICAL :: has_unit_metric, ks_is_complex, &
99 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s, matrix_w
104 NULLIFY (ks_env, matrix_w, matrix_s, dft_control)
106 CALL get_qs_env(qs_env, dft_control=dft_control, ks_env=ks_env)
107 IF (dft_control%qs_control%do_kg)
THEN
108 molecule_only = .true.
109 CALL qs_energies_init_kg(qs_env)
111 molecule_only = .false.
113 CALL qs_energies_init_hamiltonians(qs_env, calc_forces, molecule_only)
114 CALL get_ks_env(ks_env, complex_ks=ks_is_complex)
118 CALL get_qs_env(qs_env, has_unit_metric=has_unit_metric)
119 IF (calc_forces .AND. .NOT. has_unit_metric)
THEN
122 matrix_s_kp=matrix_s)
123 nspin = dft_control%nspins
124 nimg = dft_control%nimages
125 matrix => matrix_s(1, 1)%matrix
129 ALLOCATE (matrix_w(ispin, img)%matrix)
130 CALL dbcsr_copy(matrix_w(ispin, img)%matrix, matrix, name=
"W MATRIX")
131 CALL dbcsr_set(matrix_w(ispin, img)%matrix, 0.0_dp)
147 SUBROUTINE qs_energies_init_kg(qs_env)
150 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_energies_init_kg'
152 INTEGER :: handle, isubset, natom
158 POINTER :: soo_list, soo_list1
160 CALL timeset(routinen, handle)
162 CALL get_qs_env(qs_env, dft_control=dft_control, para_env=para_env)
163 cpassert(dft_control%qs_control%do_kg)
165 kg_env => qs_env%kg_env
168 CALL get_qs_env(qs_env=qs_env, molecule_set=molecule_set, natom=natom)
171 kg_env%molecule_set => molecule_set
175 IF (.NOT.
ALLOCATED(kg_env%atom_to_molecule))
THEN
176 ALLOCATE (kg_env%atom_to_molecule(natom))
181 SELECT CASE (kg_env%tnadd_method)
184 IF (.NOT.
ASSOCIATED(kg_env%subset_of_mol))
THEN
185 ALLOCATE (kg_env%subset_of_mol(
SIZE(molecule_set)))
190 DO isubset = 1, kg_env%nsubsets
193 subset_of_mol=kg_env%subset_of_mol, current_subset=isubset)
198 IF (.NOT.
ASSOCIATED(kg_env%subset_of_mol))
THEN
199 ALLOCATE (kg_env%subset_of_mol(
SIZE(molecule_set)))
204 DO isubset = 1, kg_env%nsubsets
207 subset_of_mol=kg_env%subset_of_mol, current_subset=isubset)
213 kg_env%lri_env%soo_list => soo_list
215 IF (qs_env%energy_correction)
THEN
218 kg_env%lri_env1%soo_list => soo_list1
229 cpabort(
"KG:TNADD METHOD")
232 CALL timestop(handle)
234 END SUBROUTINE qs_energies_init_kg
247 SUBROUTINE qs_energies_init_hamiltonians(qs_env, calc_forces, molecule_only)
249 LOGICAL,
INTENT(IN) :: calc_forces
250 LOGICAL :: molecule_only
252 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_energies_init_hamiltonians'
255 LOGICAL :: do_kpoints
261 POINTER :: sab_nl, sab_nl_nosym
267 CALL timeset(routinen, handle)
271 dft_control=dft_control, &
274 do_kpoints=do_kpoints)
278 force_env_section=input)
282 CALL get_qs_env(qs_env, sab_kp=sab_nl, sab_kp_nosym=sab_nl_nosym)
286 IF (dft_control%qs_control%cdft)
THEN
287 IF (.NOT. (dft_control%qs_control%cdft_control%external_control))
THEN
288 dft_control%qs_control%cdft_control%need_pot = .true.
290 IF (
ASSOCIATED(dft_control%qs_control%cdft_control%group))
THEN
292 IF (
ASSOCIATED(dft_control%qs_control%cdft_control%group(1)%weight))
THEN
293 dft_control%qs_control%cdft_control%need_pot = .false.
299 IF (dft_control%qs_control%semi_empirical)
THEN
301 calculate_forces=.false.)
304 CALL get_qs_env(qs_env=qs_env, dispersion_env=dispersion_env, energy=energy)
306 ELSE IF (dft_control%qs_control%dftb)
THEN
308 calculate_forces=.false.)
310 calculate_forces=.false.)
312 ELSE IF (dft_control%qs_control%xtb)
THEN
313 IF (dft_control%qs_control%xtb_control%do_tblite)
THEN
329 IF (.NOT. dft_control%qs_control%gapw)
THEN
333 IF (dft_control%qs_control%lrigpw)
THEN
334 CALL get_qs_env(qs_env=qs_env, lri_env=lri_env)
336 ELSE IF (dft_control%qs_control%rigpw)
THEN
337 CALL get_qs_env(qs_env=qs_env, lri_env=lri_env)
346 CALL get_qs_env(qs_env=qs_env, dispersion_env=dispersion_env, energy=energy)
350 CALL get_qs_env(qs_env=qs_env, gcp_env=gcp_env, energy=energy)
351 IF (
ASSOCIATED(gcp_env))
THEN
357 IF (dft_control%qs_control%dfet_embedded)
THEN
358 dft_control%apply_embed_pot = .true.
362 IF (dft_control%qs_control%dmfet_embedded)
THEN
363 dft_control%apply_dmfet_pot = .true.
366 CALL timestop(handle)
368 END SUBROUTINE qs_energies_init_hamiltonians
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.
all routins needed for a nonperiodic electric field
subroutine, public calculate_ecore_efield(qs_env, calculate_forces)
Computes the force and the energy due to a efield on the cores Note: In the velocity gauge,...
Types needed for a Kim-Gordon-like partitioning into molecular subunits.
Routines for a Kim-Gordon-like partitioning into molecular subunits.
subroutine, public kg_build_neighborlist(qs_env, sab_orb, sac_kin, molecular, subset_of_mol, current_subset)
builds either the full neighborlist or neighborlists of molecular
subroutine, public kg_build_subsets(kg_env, para_env)
...
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public kpoint_init_cell_index(kpoint, sab_nl, para_env, nimages)
Generates the mapping of cell indices and linear RS index CELL (0,0,0) is always mapped to index 1.
Types and basic routines needed for a kpoint calculation.
subroutine, public set_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered)
Set information in a kpoint environment.
Calculates integral matrices for LRIGPW method lri : local resolution of the identity.
subroutine, public calculate_lri_integrals(lri_env, qs_env)
calculates integrals needed for the LRI density fitting, integrals are calculated once,...
subroutine, public build_lri_matrices(lri_env, qs_env)
creates and initializes an lri_env
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
Interface to the message passing library MPI.
Define the data structure for the molecule information.
subroutine, public molecule_of_atom(molecule_set, atom_to_mol)
finds for each atom the molecule it belongs to
subroutine, public given_embed_pot(qs_env)
Read the external embedding potential, not to be optimized.
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.
Calculation of the core Hamiltonian integral matrix <a|H|b> over Cartesian Gaussian-type functions.
subroutine, public build_core_hamiltonian_matrix(qs_env, calculate_forces)
Cosntruction of the QS Core Hamiltonian Matrix.
Calculation of dispersion in DFTB.
subroutine, public calculate_dftb_dispersion(qs_env, para_env, calculate_forces)
...
Calculation of Overlap and Hamiltonian matrices in DFTB.
subroutine, public build_dftb_matrices(qs_env, para_env, calculate_forces)
...
Calculation of dispersion using pair potentials.
subroutine, public calculate_dispersion_pairpot(qs_env, dispersion_env, energy, calculate_forces, atevdw)
...
Definition of disperson types for DFT calculations.
Utility subroutine for qs energy calculation.
subroutine, public qs_energies_init(qs_env, calc_forces)
Refactoring of qs_energies_scf. Driver routine for the initial setup and calculations for a qs energy...
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, matrix_vhxc, 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 to handle an external density The external density can be generic and is provided by user in...
subroutine, public external_read_density(qs_env)
Computes the external density on the grid.
Routines to handle an external electrostatic field The external field can be generic and is provided ...
subroutine, public external_c_potential(qs_env, calculate_forces)
Computes the force and the energy due to the external potential on the cores.
subroutine, public external_e_potential(qs_env)
Computes the external potential on the grid.
Calculation of gCP pair potentials.
subroutine, public calculate_gcp_pairpot(qs_env, gcp_env, energy, calculate_forces, ategcp)
...
Definition of gCP types for DFT calculations.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_allocate_basics(qs_env, is_complex)
Allocate ks_matrix if necessary, take current overlap matrix as template.
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_vhxc, 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)
...
subroutine, public get_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_vhxc, 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, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, 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, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
Define the neighbor list data types and the corresponding functionality.
Generate the atomic neighbor lists.
subroutine, public build_qs_neighbor_lists(qs_env, para_env, molecular, force_env_section)
Build all the required neighbor lists for Quickstep.
qs_environment methods that use many other modules
subroutine, public qs_env_update_s_mstruct(qs_env)
updates the s_mstruct to reflect the new overlap structure, and also updates rho_core distribution....
Calculates integral matrices for RIGPW method.
subroutine, public build_ri_matrices(lri_env, qs_env, calculate_forces)
creates and initializes an lri_env
Split and build its own idependent core_core SE interaction module.
subroutine, public se_core_core_interaction(qs_env, para_env, calculate_forces)
Evaluates the core-core interactions for NDDO methods.
Calculation of the Hamiltonian integral matrix <a|H|b> for semi-empirical methods.
subroutine, public build_se_core_matrix(qs_env, para_env, calculate_forces)
...
subroutine, public tb_init_ham(qs_env, calculate_forces)
Prepare geometry-dependent data once, before SCF, including requested core forces.
subroutine, public build_tblite_matrices(qs_env, calculate_forces)
...
Calculation of Overlap and Hamiltonian matrices in xTB Reference: Stefan Grimme, Christoph Bannwarth,...
subroutine, public build_xtb_matrices(qs_env, calculate_forces)
...
Contains all the info needed for KG runs...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...