56#include "./base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'se_fock_matrix_exchange'
62 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
81 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ks_matrix, matrix_p
82 LOGICAL,
INTENT(in) :: calculate_forces
85 CHARACTER(len=*),
PARAMETER :: routinen =
'build_fock_matrix_exchange'
87 INTEGER :: atom_a, atom_b, handle, iatom, icol, &
88 ikind, integral_screening, irow, &
89 jatom, jkind, natorb_a, nkind, nspins
90 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
91 INTEGER,
DIMENSION(2) :: size_p_block_a
92 LOGICAL :: anag, check, defined, found, switch, &
94 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: se_defined
95 REAL(kind=
dp) :: delta, dr
96 REAL(kind=
dp),
DIMENSION(3) :: force_ab, rij
97 REAL(kind=
dp),
DIMENSION(45, 45) :: p_block_tot
98 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: ks_block_a, ks_block_b, p_block_a, &
105 DIMENSION(:),
POINTER :: nl_iterator
110 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
118 CALL timeset(routinen, handle)
120 NULLIFY (dft_control, cell, force, particle_set, se_control, se_taper)
121 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, cell=cell, se_taper=se_taper, &
122 para_env=para_env, virial=virial)
125 se_control => dft_control%qs_control%se_control
126 anag = se_control%analytical_gradients
127 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
128 nspins = dft_control%nspins
130 cpassert(
ASSOCIATED(matrix_p))
131 cpassert(
SIZE(ks_matrix) > 0)
134 integral_screening = se_control%integral_screening
135 IF ((integral_screening ==
do_se_is_kdso_d) .AND. (.NOT. se_control%force_kdsod_EX))
THEN
139 do_ewald_r3=.false., do_ewald_gks=.false., integral_screening=integral_screening, &
142 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb, &
143 atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
145 nkind =
SIZE(atomic_kind_set)
146 IF (calculate_forces)
THEN
147 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, force=force)
148 delta = se_control%delta
152 ALLOCATE (se_defined(nkind), se_kind_list(nkind))
154 CALL get_qs_kind(qs_kind_set(ikind), se_parameter=se_kind_a)
155 se_kind_list(ikind)%se_param => se_kind_a
156 CALL get_se_param(se_kind_a, defined=defined, natorb=natorb_a)
157 se_defined(ikind) = (defined .AND. natorb_a >= 1)
162 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, iatom=iatom, jatom=jatom, r=rij)
163 IF (.NOT. se_defined(ikind)) cycle
164 IF (.NOT. se_defined(jkind)) cycle
165 se_kind_a => se_kind_list(ikind)%se_param
166 se_kind_b => se_kind_list(jkind)%se_param
168 IF (iatom <= jatom)
THEN
179 row=irow, col=icol, block=ks_block_a, found=found)
180 cpassert(
ASSOCIATED(ks_block_a))
182 row=irow, col=icol, block=p_block_a, found=found)
183 cpassert(
ASSOCIATED(p_block_a))
184 size_p_block_a(1) =
SIZE(p_block_a, 1)
185 size_p_block_a(2) =
SIZE(p_block_a, 2)
186 p_block_tot(1:size_p_block_a(1), 1:size_p_block_a(2)) = 2.0_dp*p_block_a
189 IF (nspins == 2)
THEN
191 row=irow, col=icol, block=ks_block_b, found=found)
192 cpassert(
ASSOCIATED(ks_block_b))
194 row=irow, col=icol, block=p_block_b, found=found)
195 cpassert(
ASSOCIATED(p_block_b))
196 check = (size_p_block_a(1) ==
SIZE(p_block_b, 1)) .AND. (size_p_block_a(2) ==
SIZE(p_block_b, 2))
198 p_block_tot(1:
SIZE(p_block_a, 1), 1:
SIZE(p_block_a, 2)) = p_block_a + p_block_b
201 dr = dot_product(rij, rij)
204 IF (nspins == 1)
THEN
205 CALL fock1_2el(se_kind_a, p_block_tot, p_block_a, ks_block_a, factor=0.5_dp)
206 ELSE IF (nspins == 2)
THEN
207 CALL fock1_2el(se_kind_a, p_block_tot, p_block_a, ks_block_a, factor=1.0_dp)
208 CALL fock1_2el(se_kind_a, p_block_tot, p_block_b, ks_block_b, factor=1.0_dp)
212 IF (nspins == 1)
THEN
213 CALL fock2e(se_kind_a, se_kind_b, rij, switch, size_p_block_a, p_block_a, ks_block_a, &
214 factor=0.5_dp, anag=anag, se_int_control=se_int_control, se_taper=se_taper, &
215 store_int_env=store_int_env)
216 ELSE IF (nspins == 2)
THEN
217 CALL fock2e(se_kind_a, se_kind_b, rij, switch, size_p_block_a, p_block_a, ks_block_a, &
218 factor=1.0_dp, anag=anag, se_int_control=se_int_control, se_taper=se_taper, &
219 store_int_env=store_int_env)
221 CALL fock2e(se_kind_a, se_kind_b, rij, switch, size_p_block_a, p_block_b, ks_block_b, &
222 factor=1.0_dp, anag=anag, se_int_control=se_int_control, se_taper=se_taper, &
223 store_int_env=store_int_env)
225 IF (calculate_forces)
THEN
226 atom_a = atom_of_kind(iatom)
227 atom_b = atom_of_kind(jatom)
229 IF (nspins == 1)
THEN
230 CALL dfock2e(se_kind_a, se_kind_b, rij, switch, size_p_block_a, p_block_a, &
231 factor=0.5_dp, anag=anag, se_int_control=se_int_control, se_taper=se_taper, force=force_ab, &
233 ELSE IF (nspins == 2)
THEN
234 CALL dfock2e(se_kind_a, se_kind_b, rij, switch, size_p_block_a, p_block_a, &
235 factor=1.0_dp, anag=anag, se_int_control=se_int_control, se_taper=se_taper, force=force_ab, &
238 CALL dfock2e(se_kind_a, se_kind_b, rij, switch, size_p_block_a, p_block_b, &
239 factor=1.0_dp, anag=anag, se_int_control=se_int_control, se_taper=se_taper, force=force_ab, &
243 force_ab(1) = -force_ab(1)
244 force_ab(2) = -force_ab(2)
245 force_ab(3) = -force_ab(3)
251 force(ikind)%rho_elec(1, atom_a) = force(ikind)%rho_elec(1, atom_a) - force_ab(1)
252 force(jkind)%rho_elec(1, atom_b) = force(jkind)%rho_elec(1, atom_b) + force_ab(1)
254 force(ikind)%rho_elec(2, atom_a) = force(ikind)%rho_elec(2, atom_a) - force_ab(2)
255 force(jkind)%rho_elec(2, atom_b) = force(jkind)%rho_elec(2, atom_b) + force_ab(2)
257 force(ikind)%rho_elec(3, atom_a) = force(ikind)%rho_elec(3, atom_a) - force_ab(3)
258 force(jkind)%rho_elec(3, atom_b) = force(jkind)%rho_elec(3, atom_b) + force_ab(3)
264 DEALLOCATE (se_kind_list, se_defined)
268 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.
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Multipole structure: for multipole (fixed and induced) in FF based MD.
integer, parameter, public do_multipole_none
Define the data structure for the particle information.
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.
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, 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, 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)
...
Construction of the Exchange part of the Fock Matrix.
subroutine, public build_fock_matrix_exchange(qs_env, ks_matrix, matrix_p, calculate_forces, store_int_env)
Construction of the Exchange part of the Fock matrix.
Provides the low level routines to build both the exchange and the Coulomb Fock matrices....
subroutine, public dfock2e(sepi, sepj, rij, switch, isize, pi_mat, factor, anag, se_int_control, se_taper, force, delta)
Derivatives of 2-center Fock Matrix - General Driver.
subroutine, public fock1_2el(sep, p_tot, p_mat, f_mat, factor)
Construction of 1-center 2-electron Fock Matrix.
subroutine, public fock2e(sepi, sepj, rij, switch, isize, pi_mat, fi_mat, factor, anag, se_int_control, se_taper, store_int_env)
Construction of 2-center Fock Matrix - General Driver.
Arrays of parameters used in the semi-empirical calculations \References Everywhere in this module TC...
real(kind=dp), parameter, public rij_threshold
Type to store integrals for semi-empirical calculations.
Definition of the semi empirical parameter types.
subroutine, public setup_se_int_control_type(se_int_control, shortrange, do_ewald_r3, do_ewald_gks, integral_screening, max_multipole, pc_coulomb_int)
Setup the Semiempirical integral control type.
subroutine, public get_se_param(sep, name, typ, defined, z, zeff, natorb, eheat, beta, sto_exponents, uss, upp, udd, uff, alp, eisol, gss, gsp, gpp, gp2, acoul, nr, de, ass, asp, app, hsp, gsd, gpd, gdd, ppddg, dpddg, ngauss)
Get info from the semi-empirical type.
Working with the semi empirical parameter types.
subroutine, public finalize_se_taper(se_taper)
Finalizes the semi-empirical taper for a chunk calculation.
subroutine, public initialize_se_taper(se_taper, coulomb, exchange, lr_corr)
Initializes the semi-empirical taper for a chunk calculation.
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 defining parameters related to the simulation cell.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
Semi-empirical store integrals type.
Taper type use in semi-empirical calculations.