29#include "./base/base_uses.f90"
35 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pao_linpot_rotinv'
49 INTEGER,
INTENT(IN) :: ikind
50 INTEGER,
INTENT(OUT) :: nterms
52 CHARACTER(len=*),
PARAMETER :: routinen =
'linpot_rotinv_count_terms'
54 INTEGER :: handle, ipot, iset, ishell, ishell_abs, &
55 lmax, lmin, lpot, max_shell, &
56 min_shell, npots, nshells, pot_maxl
57 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: shell_l
62 CALL timeset(routinen, handle)
64 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
67 nshells = sum(basis_set%nshell)
70 cpwarn_if(npots == 0,
"Found no PAO_POTENTIAL section")
73 ALLOCATE (shell_l(nshells))
74 DO iset = 1, basis_set%nset
75 DO ishell = 1, basis_set%nshell(iset)
76 ishell_abs = sum(basis_set%nshell(1:iset - 1)) + ishell
77 shell_l(ishell_abs) = basis_set%l(ishell, iset)
87 cpabort(
"ROTINV parametrization requires non-negative PAO_POTENTIAL%MAXL")
88 IF (mod(pot_maxl, 2) /= 0) &
89 cpabort(
"ROTINV parametrization requires even-numbered PAO_POTENTIAL%MAXL")
90 DO max_shell = 1, nshells
91 DO min_shell = 1, max_shell
92 DO lpot = 0, pot_maxl, 2
93 lmin = shell_l(min_shell)
94 lmax = shell_l(max_shell)
95 IF (lmin == 0 .AND. lmax == 0) cycle
103 DO max_shell = 1, nshells
104 DO min_shell = 1, max_shell
105 IF (shell_l(min_shell) /= shell_l(max_shell)) cycle
110 CALL timestop(handle)
122 INTEGER,
INTENT(IN) :: iatom
123 REAL(
dp),
DIMENSION(:, :, :),
INTENT(OUT),
TARGET :: v_blocks
125 CHARACTER(len=*),
PARAMETER :: routinen =
'linpot_rotinv_calc_terms'
127 INTEGER :: handle, i, ic, ikind, ipot, iset, ishell, ishell_abs, jatom, jkind, jset, jshell, &
128 jshell_abs, kterm, la1_max, la1_min, la2_max, la2_min, lb_max, lb_min, lpot, n, na1, na2, &
129 natoms, nb, ncfga1, ncfga2, ncfgb, npgfa1, npgfa2, npgfb, npots, pot_maxl, sgfa1, sgfa2, &
131 REAL(
dp) :: coeff, norm2, pot_beta, pot_weight, &
133 REAL(
dp),
DIMENSION(3) :: ra, rab, rb
134 REAL(
dp),
DIMENSION(:),
POINTER :: rpgfa1, rpgfa2, rpgfb, zeta1, zeta2, zetb
135 REAL(
dp),
DIMENSION(:, :),
POINTER :: t1, t2, v12, v21
136 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: block_v_full, saab, saal
141 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
143 CALL timeset(routinen, handle)
148 particle_set=particle_set, &
149 qs_kind_set=qs_kind_set)
151 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
153 npots =
SIZE(ipao_potentials)
155 cpassert(
SIZE(v_blocks, 1) == n .AND.
SIZE(v_blocks, 2) == n)
159 pot_maxl = ipao_potentials(ipot)%maxl
167 ALLOCATE (rpgfb(npgfb), zetb(npgfb))
170 ALLOCATE (block_v_full(n, n, pot_maxl/2 + 1))
171 block_v_full = 0.0_dp
173 DO iset = 1, basis_set%nset
177 la1_max = basis_set%lmax(iset)
178 la1_min = basis_set%lmin(iset)
179 npgfa1 = basis_set%npgf(iset)
182 zeta1 => basis_set%zet(:, iset)
183 rpgfa1 => basis_set%pgf_radius(:, iset)
186 la2_max = basis_set%lmax(jset)
187 la2_min = basis_set%lmin(jset)
188 npgfa2 = basis_set%npgf(jset)
191 zeta2 => basis_set%zet(:, jset)
192 rpgfa2 => basis_set%pgf_radius(:, jset)
195 rpgfa_max = max(maxval(rpgfa1), maxval(rpgfa2))
198 ALLOCATE (saab(na1, na2, nb), saal(na1, na2, pot_maxl/2 + 1))
203 IF (jatom == iatom) cycle
204 CALL get_atomic_kind(particle_set(jatom)%atomic_kind, kind_number=jkind)
206 IF (
SIZE(jpao_potentials) /= npots) &
207 cpabort(
"Not all KINDs have the same number of PAO_POTENTIAL sections")
210 pot_weight = jpao_potentials(ipot)%weight
211 pot_beta = jpao_potentials(ipot)%beta
212 rpgfb(1) = jpao_potentials(ipot)%beta_radius
216 ra = particle_set(iatom)%r
217 rb = particle_set(jatom)%r
218 rab =
pbc(ra, rb, cell)
221 tab = sqrt(sum(rab**2))
222 IF (rpgfa_max + rpgfb(1) < tab) cycle
226 CALL overlap_aab(la1_max=la1_max, la1_min=la1_min, npgfa1=npgfa1, rpgfa1=rpgfa1, zeta1=zeta1, &
227 la2_max=la2_max, la2_min=la2_min, npgfa2=npgfa2, rpgfa2=rpgfa2, zeta2=zeta2, &
228 lb_max=lb_max, lb_min=lb_min, npgfb=npgfb, rpgfb=rpgfb, zetb=zetb, &
232 DO lpot = 0, pot_maxl, 2
233 norm2 = (2.0_dp*pot_beta)**(-0.5_dp - lpot)*
gamma1(lpot)
237 saal(:, :, lpot/2 + 1) = saal(:, :, lpot/2 + 1) + saab(:, :, ic)*coeff*pot_weight/sqrt(norm2)
243 sgfa1 = basis_set%first_sgf(1, iset)
244 sgla1 = sgfa1 + basis_set%nsgf_set(iset) - 1
245 sgfa2 = basis_set%first_sgf(1, jset)
246 sgla2 = sgfa2 + basis_set%nsgf_set(jset) - 1
247 t1 => basis_set%scon(1:na1, sgfa1:sgla1)
248 t2 => basis_set%scon(1:na2, sgfa2:sgla2)
251 DO lpot = 0, pot_maxl, 2
252 v12 => block_v_full(sgfa1:sgla1, sgfa2:sgla2, lpot/2 + 1)
253 v21 => block_v_full(sgfa2:sgla2, sgfa1:sgla1, lpot/2 + 1)
254 v12 = matmul(transpose(t1), matmul(saal(:, :, lpot/2 + 1), t2))
257 DEALLOCATE (saab, saal)
260 DEALLOCATE (rpgfb, zetb)
264 DO iset = 1, basis_set%nset
266 DO ishell = 1, basis_set%nshell(iset)
267 DO jshell = 1, basis_set%nshell(jset)
268 IF (basis_set%l(ishell, iset) == 0 .AND. basis_set%l(jshell, jset) == 0) cycle
269 ishell_abs = sum(basis_set%nshell(1:iset - 1)) + ishell
270 jshell_abs = sum(basis_set%nshell(1:jset - 1)) + jshell
271 IF (ishell_abs < jshell_abs) cycle
274 sgfa1 = basis_set%first_sgf(ishell, iset)
275 sgla1 = basis_set%last_sgf(ishell, iset)
276 sgfa2 = basis_set%first_sgf(jshell, jset)
277 sgla2 = basis_set%last_sgf(jshell, jset)
279 DO lpot = 0, pot_maxl, 2
281 v_blocks(:, :, kterm) = 0.0_dp
282 v_blocks(sgfa1:sgla1, sgfa2:sgla2, kterm) = block_v_full(sgfa1:sgla1, sgfa2:sgla2, lpot/2 + 1)
283 v_blocks(sgfa2:sgla2, sgfa1:sgla1, kterm) = block_v_full(sgfa2:sgla2, sgfa1:sgla1, lpot/2 + 1)
289 DEALLOCATE (block_v_full)
294 DO iset = 1, basis_set%nset
296 DO ishell = 1, basis_set%nshell(iset)
297 DO jshell = 1, basis_set%nshell(jset)
298 IF (basis_set%l(ishell, iset) /= basis_set%l(jshell, jset)) cycle
299 ishell_abs = sum(basis_set%nshell(1:iset - 1)) + ishell
300 jshell_abs = sum(basis_set%nshell(1:jset - 1)) + jshell
301 IF (ishell_abs < jshell_abs) cycle
303 sgfa1 = basis_set%first_sgf(ishell, iset)
304 sgla1 = basis_set%last_sgf(ishell, iset)
305 sgfa2 = basis_set%first_sgf(jshell, jset)
306 sgla2 = basis_set%last_sgf(jshell, jset)
307 cpassert((sgla1 - sgfa1) == (sgla2 - sgfa2))
308 v_blocks(:, :, kterm) = 0.0_dp
309 DO i = 1, sgla1 - sgfa1 + 1
310 v_blocks(sgfa1 - 1 + i, sgfa2 - 1 + i, kterm) = 1.0_dp
311 v_blocks(sgfa2 - 1 + i, sgfa1 - 1 + i, kterm) = 1.0_dp
313 norm2 = sum(v_blocks(:, :, kterm)**2)
314 v_blocks(:, :, kterm) = v_blocks(:, :, kterm)/sqrt(norm2)
320 cpassert(
SIZE(v_blocks, 3) == kterm)
322 CALL timestop(handle)
334 INTEGER,
INTENT(IN) :: iatom
335 REAL(
dp),
DIMENSION(:, :, :),
INTENT(IN) :: m_blocks
336 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: forces
338 CHARACTER(len=*),
PARAMETER :: routinen =
'linpot_rotinv_calc_forces'
340 INTEGER :: handle, i, ic, ikind, ipot, iset, ishell, ishell_abs, jatom, jkind, jset, jshell, &
341 jshell_abs, kterm, la1_max, la1_min, la2_max, la2_min, lb_max, lb_min, lpot, n, na1, na2, &
342 natoms, nb, ncfga1, ncfga2, ncfgb, npgfa1, npgfa2, npgfb, npots, nshells, pot_maxl, &
343 sgfa1, sgfa2, sgla1, sgla2
344 REAL(
dp) :: coeff, f, norm2, pot_beta, pot_weight, &
346 REAL(
dp),
DIMENSION(3) :: ra, rab, rb
347 REAL(
dp),
DIMENSION(:),
POINTER :: rpgfa1, rpgfa2, rpgfb, zeta1, zeta2, zetb
348 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_d, t1, t2
349 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: block_m_full, dab
350 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: daab
355 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
357 CALL timeset(routinen, handle)
362 particle_set=particle_set, &
363 qs_kind_set=qs_kind_set)
365 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
367 npots =
SIZE(ipao_potentials)
368 nshells = sum(basis_set%nshell)
370 cpassert(
SIZE(m_blocks, 1) == n .AND.
SIZE(m_blocks, 2) == n)
372 ALLOCATE (block_d(n, n))
375 pot_maxl = ipao_potentials(ipot)%maxl
378 ALLOCATE (block_m_full(n, n, pot_maxl/2 + 1))
379 block_m_full = 0.0_dp
380 DO iset = 1, basis_set%nset
382 DO ishell = 1, basis_set%nshell(iset)
383 DO jshell = 1, basis_set%nshell(jset)
384 IF (basis_set%l(ishell, iset) == 0 .AND. basis_set%l(jshell, jset) == 0) cycle
385 ishell_abs = sum(basis_set%nshell(1:iset - 1)) + ishell
386 jshell_abs = sum(basis_set%nshell(1:jset - 1)) + jshell
387 IF (ishell_abs < jshell_abs) cycle
389 sgfa1 = basis_set%first_sgf(ishell, iset)
390 sgla1 = basis_set%last_sgf(ishell, iset)
391 sgfa2 = basis_set%first_sgf(jshell, jset)
392 sgla2 = basis_set%last_sgf(jshell, jset)
393 DO lpot = 0, pot_maxl, 2
395 block_m_full(sgfa1:sgla1, sgfa2:sgla2, lpot/2 + 1) = m_blocks(sgfa1:sgla1, sgfa2:sgla2, kterm)
396 block_m_full(sgfa2:sgla2, sgfa1:sgla1, lpot/2 + 1) = m_blocks(sgfa2:sgla2, sgfa1:sgla1, kterm)
409 ALLOCATE (rpgfb(npgfb), zetb(npgfb))
411 DO iset = 1, basis_set%nset
415 la1_max = basis_set%lmax(iset)
416 la1_min = basis_set%lmin(iset)
417 npgfa1 = basis_set%npgf(iset)
420 zeta1 => basis_set%zet(:, iset)
421 rpgfa1 => basis_set%pgf_radius(:, iset)
424 la2_max = basis_set%lmax(jset)
425 la2_min = basis_set%lmin(jset)
426 npgfa2 = basis_set%npgf(jset)
429 zeta2 => basis_set%zet(:, jset)
430 rpgfa2 => basis_set%pgf_radius(:, jset)
433 rpgfa_max = max(maxval(rpgfa1), maxval(rpgfa2))
436 sgfa1 = basis_set%first_sgf(1, iset)
437 sgla1 = sgfa1 + basis_set%nsgf_set(iset) - 1
438 sgfa2 = basis_set%first_sgf(1, jset)
439 sgla2 = sgfa2 + basis_set%nsgf_set(jset) - 1
440 t1 => basis_set%scon(1:na1, sgfa1:sgla1)
441 t2 => basis_set%scon(1:na2, sgfa2:sgla2)
444 ALLOCATE (daab(na1, na2, nb, 3), dab(na1, na2, 3))
448 IF (jatom == iatom) cycle
449 CALL get_atomic_kind(particle_set(jatom)%atomic_kind, kind_number=jkind)
451 IF (
SIZE(jpao_potentials) /= npots) &
452 cpabort(
"Not all KINDs have the same number of PAO_POTENTIAL sections")
455 pot_weight = jpao_potentials(ipot)%weight
456 pot_beta = jpao_potentials(ipot)%beta
457 rpgfb(1) = jpao_potentials(ipot)%beta_radius
461 ra = particle_set(iatom)%r
462 rb = particle_set(jatom)%r
463 rab =
pbc(ra, rb, cell)
466 tab = sqrt(sum(rab**2))
467 IF (rpgfa_max + rpgfb(1) < tab) cycle
471 CALL overlap_aab(la1_max=la1_max, la1_min=la1_min, npgfa1=npgfa1, rpgfa1=rpgfa1, zeta1=zeta1, &
472 la2_max=la2_max, la2_min=la2_min, npgfa2=npgfa2, rpgfa2=rpgfa2, zeta2=zeta2, &
473 lb_max=lb_max, lb_min=lb_min, npgfb=npgfb, rpgfb=rpgfb, zetb=zetb, &
477 DO lpot = 0, pot_maxl, 2
481 norm2 = (2.0_dp*pot_beta)**(-0.5_dp - lpot)*
gamma1(lpot)
483 dab = dab + coeff*daab(:, :, ic, :)*pot_weight/sqrt(norm2)
488 block_d(sgfa1:sgla1, sgfa2:sgla2) = matmul(transpose(t1), matmul(dab(:, :, i), t2))
489 block_d(sgfa2:sgla2, sgfa1:sgla1) = transpose(block_d(sgfa1:sgla1, sgfa2:sgla2))
491 f = sum(block_m_full(:, :, lpot/2 + 1)*block_d)
492 forces(iatom, i) = forces(iatom, i) - f
493 forces(jatom, i) = forces(jatom, i) + f
497 DEALLOCATE (dab, daab)
500 DEALLOCATE (rpgfb, zetb, block_m_full)
504 CALL timestop(handle)
Calculation of the overlap integrals over Cartesian Gaussian-type functions.
subroutine, public overlap_aab(la1_max, la1_min, npgfa1, rpgfa1, zeta1, la2_max, la2_min, npgfa2, rpgfa2, zeta2, lb_max, lb_min, npgfb, rpgfb, zetb, rab, saab, daab, saba, daba)
Calculation of the two-center overlap integrals [aa|b] over Cartesian Gaussian-type functions.
Define the atomic kind types and their sub types.
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 the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), dimension(0:maxfac), parameter, public gamma1
Collection of simple mathematical functions and subroutines.
pure real(kind=dp) function, public multinomial(n, k)
Calculates the multinomial coefficients.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :), allocatable, public indco
Rotationally invariant parametrization of Fock matrix.
subroutine, public linpot_rotinv_calc_forces(qs_env, iatom, m_blocks, forces)
Calculate force contribution from rotinv parametrization.
subroutine, public linpot_rotinv_calc_terms(qs_env, iatom, v_blocks)
Calculate all potential terms of the rotinv parametrization.
subroutine, public linpot_rotinv_count_terms(qs_env, ikind, nterms)
Count number of terms for given atomic kind.
Factory routines for potentials used e.g. by pao_param_exp and pao_ml.
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.
Type defining parameters related to the simulation cell.
Holds information about a PAO potential.
Provides all information about a quickstep kind.