51#include "./base/base_uses.f90"
57 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'ec_efield_local'
79 LOGICAL,
INTENT(IN) :: calculate_forces
81 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ec_efield_local_operator'
84 REAL(
dp),
DIMENSION(3) :: rpoint
87 CALL timeset(routinen, handle)
90 CALL get_qs_env(qs_env, dft_control=dft_control)
92 IF (dft_control%apply_efield)
THEN
93 cpassert(.NOT. ec_env%do_kpoints)
96 CALL ec_efield_mo_derivatives(qs_env, ec_env, rpoint, calculate_forces)
113 REAL(
dp),
DIMENSION(3),
INTENT(IN) :: rpoint
115 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ec_efield_integrals'
118 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
121 CALL timeset(routinen, handle)
123 CALL get_qs_env(qs_env=qs_env, efield=efieldref)
124 efield => ec_env%efield
126 matrix_s => ec_env%matrix_s(:, 1)
129 ALLOCATE (dipmat(i)%matrix)
130 CALL dbcsr_copy(dipmat(i)%matrix, matrix_s(1)%matrix,
'DIP MAT')
135 ec_env%efield => efield
137 CALL timestop(handle)
148 SUBROUTINE ec_efield_mo_derivatives(qs_env, ec_env, rpoint, calculate_forces)
151 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: rpoint
152 LOGICAL :: calculate_forces
154 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ec_efield_mo_derivatives'
156 INTEGER :: atom_a, atom_b, handle, i, ia, iatom, icol, idir, ikind, irow, iset, ispin, &
157 jatom, jkind, jset, ldab, natom, ncoa, ncob, nkind, nseta, nsetb, sgfa, sgfb
158 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
159 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
161 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
162 LOGICAL :: found, trans
163 REAL(
dp) :: charge, dab, fdir
164 REAL(
dp),
DIMENSION(3) :: ci, fieldpol, ra, rab, rac, rbc, ria
165 REAL(
dp),
DIMENSION(3, 3) :: forcea, forceb
166 REAL(
dp),
DIMENSION(:, :),
POINTER :: p_block_a, p_block_b, pblock, pmat, work
167 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
168 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgfa, rpgfb, sphi_a, sphi_b, zeta, zetb
171 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_ks
178 DIMENSION(:),
POINTER :: nl_iterator
184 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
187 CALL timeset(routinen, handle)
189 CALL get_qs_env(qs_env, dft_control=dft_control, cell=cell, particle_set=particle_set)
190 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
191 energy=energy, para_env=para_env, sab_orb=sab_orb)
193 efield => ec_env%efield
195 fieldpol = dft_control%efield_fields(1)%efield%polarisation* &
196 dft_control%efield_fields(1)%efield%strength
199 natom =
SIZE(particle_set)
200 IF (calculate_forces)
THEN
201 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, force=force)
207 CALL get_qs_kind(qs_kind_set(ikind), core_charge=charge)
208 ria = particle_set(ia)%r - rpoint
210 ci(:) = ci(:) + charge*ria(:)
211 IF (calculate_forces)
THEN
212 IF (para_env%mepos == 0)
THEN
213 iatom = atom_of_kind(ia)
215 force(ikind)%efield(idir, iatom) = force(ikind)%efield(idir, iatom) - fieldpol(idir)*charge
221 IF (ec_env%should_update)
THEN
222 ec_env%efield_nuclear = -sum(ci(:)*fieldpol(:))
224 matrix_ks => ec_env%matrix_h(:, 1)
225 dipmat => efield%dipmat
226 DO ispin = 1,
SIZE(matrix_ks)
228 CALL dbcsr_add(matrix_ks(ispin)%matrix, dipmat(idir)%matrix, &
229 alpha_scalar=1.0_dp, beta_scalar=fieldpol(idir))
235 IF (calculate_forces)
THEN
236 nkind =
SIZE(qs_kind_set)
237 natom =
SIZE(particle_set)
239 ALLOCATE (basis_set_list(nkind))
241 qs_kind => qs_kind_set(ikind)
242 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set_a, basis_type=
"HARRIS")
243 IF (
ASSOCIATED(basis_set_a))
THEN
244 basis_set_list(ikind)%gto_basis_set => basis_set_a
246 NULLIFY (basis_set_list(ikind)%gto_basis_set)
253 iatom=iatom, jatom=jatom, r=rab)
254 basis_set_a => basis_set_list(ikind)%gto_basis_set
255 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
256 basis_set_b => basis_set_list(jkind)%gto_basis_set
257 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
259 first_sgfa => basis_set_a%first_sgf
260 la_max => basis_set_a%lmax
261 la_min => basis_set_a%lmin
262 npgfa => basis_set_a%npgf
263 nseta = basis_set_a%nset
264 nsgfa => basis_set_a%nsgf_set
265 rpgfa => basis_set_a%pgf_radius
266 set_radius_a => basis_set_a%set_radius
267 sphi_a => basis_set_a%sphi
268 zeta => basis_set_a%zet
270 first_sgfb => basis_set_b%first_sgf
271 lb_max => basis_set_b%lmax
272 lb_min => basis_set_b%lmin
273 npgfb => basis_set_b%npgf
274 nsetb = basis_set_b%nset
275 nsgfb => basis_set_b%nsgf_set
276 rpgfb => basis_set_b%pgf_radius
277 set_radius_b => basis_set_b%set_radius
278 sphi_b => basis_set_b%sphi
279 zetb => basis_set_b%zet
281 atom_a = atom_of_kind(iatom)
282 atom_b = atom_of_kind(jatom)
284 ra(:) = particle_set(iatom)%r(:) - rpoint(:)
285 rac(:) =
pbc(ra(:), cell)
286 rbc(:) = rac(:) + rab(:)
287 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
289 IF (iatom <= jatom)
THEN
300 IF (iatom == jatom .AND. dab < 1.e-10_dp) fdir = 1.0_dp
304 CALL dbcsr_get_block_p(ec_env%matrix_p(1, 1)%matrix, irow, icol, p_block_a, found)
305 IF (.NOT. found) cycle
306 IF (
SIZE(ec_env%matrix_p, 1) > 1)
THEN
308 CALL dbcsr_get_block_p(ec_env%matrix_p(2, 1)%matrix, irow, icol, p_block_b, found)
315 ncoa = npgfa(iset)*
ncoset(la_max(iset))
316 sgfa = first_sgfa(1, iset)
318 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
319 ncob = npgfb(jset)*
ncoset(lb_max(jset))
320 sgfb = first_sgfb(1, jset)
322 ldab = max(ncoa, ncob)
323 ALLOCATE (work(ldab, ldab), pmat(ncoa, ncob))
326 DO i = 1,
SIZE(ec_env%matrix_p, 1)
332 IF (.NOT.
ASSOCIATED(pblock)) cycle
334 CALL dgemm(
"N",
"T", ncoa, nsgfb(jset), nsgfa(iset), &
335 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
336 pblock(sgfb, sgfa),
SIZE(pblock, 1), &
337 0.0_dp, work(1, 1), ldab)
339 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
340 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
341 pblock(sgfa, sgfb),
SIZE(pblock, 1), &
342 0.0_dp, work(1, 1), ldab)
344 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
345 1.0_dp, work(1, 1), ldab, &
346 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
347 1.0_dp, pmat(1, 1), ncoa)
350 CALL dipole_force(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
351 lb_max(jset), npgfb(jset), zetb(:, jset), rpgfb(:, jset), lb_min(jset), &
352 1, rac, rbc, pmat, forcea, forceb)
354 DEALLOCATE (work, pmat)
359 force(ikind)%efield(1:3, atom_a) = force(ikind)%efield(1:3, atom_a) &
360 + fdir*fieldpol(idir)*forcea(idir, 1:3)
361 force(jkind)%efield(1:3, atom_b) = force(jkind)%efield(1:3, atom_b) &
362 + fdir*fieldpol(idir)*forceb(idir, 1:3)
367 DEALLOCATE (basis_set_list)
370 CALL timestop(handle)
372 END SUBROUTINE ec_efield_mo_derivatives
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Calculation of the moment integrals over Cartesian Gaussian-type functions.
subroutine, public dipole_force(la_max, npgfa, zeta, rpgfa, la_min, lb_max, npgfb, zetb, rpgfb, lb_min, order, rac, rbc, pab, forcea, forceb)
This returns the derivative of the dipole integrals [a|x|b], with respect to the position of the prim...
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.
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_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
Calculates the energy contribution and the mo_derivative of a static electric field (nonperiodic)
subroutine, public ec_efield_local_operator(qs_env, ec_env, calculate_forces)
...
subroutine, public ec_efield_integrals(qs_env, ec_env, rpoint)
...
Types needed for a for a Energy Correction.
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
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, 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.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>
subroutine, public build_local_moment_matrix(qs_env, moments, nmoments, ref_point, ref_points, basis_type)
...
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)
...
type for berry phase efield matrices. At the moment only used for cosmat and sinmat
subroutine, public set_efield_matrices(efield, sinmat, cosmat, dipmat)
...
subroutine, public init_efield_matrices(efield)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Contains information on the energy correction functional for KG.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.