109 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_vhxc_dbasis
112 INTEGER,
INTENT(IN) :: lambda
114 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_v_dbasis'
116 INTEGER :: bcol, brow, handle, i, iatom, igrid_level, ikind, ikind_old, ilevel, img, ipair, &
117 ipgf, ipgf_new, iset, iset_new, iset_old, itask, ithread, jatom, jkind, jkind_old, jpgf, &
118 jpgf_new, jset, jset_new, jset_old, maxco, maxpgf, maxset, maxsgf_set, na1, na2, natom, &
119 nb1, nb2, ncoa, ncob, nimages, nkind, nseta, nsetb, nthread, offset, sgfa, sgfb
120 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: block_touched
121 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, la_max, la_min, lb_max, &
122 lb_min, npgfa, npgfb, nsgfa, nsgfb, &
124 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
125 LOGICAL :: atom_pair_changed, atom_pair_done, dh_duplicated, found, my_compute_tau, &
126 new_set_pair_coming, pab_required, redistribute_matrices, use_subpatch
127 REAL(kind=
dp) :: eps_rho_rspace, f, prefactor, radius, &
129 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :), &
131 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra, rab, rab_inv, rb, &
133 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
134 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
135 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, hab, p_block, pab, rpgfa, &
136 rpgfb, sphi_a, sphi_b, work, zeta, zetb
137 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: habt, hadb, hdab, pabt, workt
138 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: hadbt, hdabt
139 TYPE(
atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
152 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
157 TYPE(
task_type),
DIMENSION(:),
POINTER :: tasks
159 CALL timeset(routinen, handle)
163 CALL get_qs_env(qs_env=qs_env, task_list=task_list)
164 cpassert(
ASSOCIATED(task_list))
172 gridlevel_info => pw_env%gridlevel_info
176 atomic_kind_set=atomic_kind_set, &
177 qs_kind_set=qs_kind_set, &
180 dft_control=dft_control, &
181 particle_set=particle_set)
184 cpassert(.NOT. dft_control%qs_control%gapw)
186 nimages = dft_control%nimages
187 cpassert(nimages == 1)
190 cpassert(
ASSOCIATED(pw_env))
191 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
192 redistribute_matrices =
ASSOCIATED(task_list%atom_pair_send)
194 group = rs_rho(1)%desc%group
199 nkind =
SIZE(qs_kind_set)
203 maxsgf_set=maxsgf_set, &
207 tasks => task_list%tasks
208 atom_pair_send => task_list%atom_pair_send
209 atom_pair_recv => task_list%atom_pair_recv
212 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
216 ALLOCATE (deltap(dft_control%nimages))
217 IF (redistribute_matrices)
THEN
218 ALLOCATE (deltap(1)%matrix)
221 CALL dbcsr_copy(deltap(1)%matrix, matrix_p, name=
"DeltaP")
223 deltap(1)%matrix => matrix_p
229 NULLIFY (pabt, habt, workt)
230 ALLOCATE (habt(maxco, maxco, 0:nthread))
231 ALLOCATE (workt(maxco, maxsgf_set, 0:nthread))
232 ALLOCATE (hdabt(3, maxco, maxco, 0:nthread))
233 ALLOCATE (hadbt(3, maxco, maxco, 0:nthread))
234 ALLOCATE (pabt(maxco, maxco, 0:nthread))
236 IF (redistribute_matrices)
THEN
238 nimages, scatter=.true.)
240 ALLOCATE (h_buffer(task_list%buffer_size_recv, 3))
241 h_buffer(:, :) = 0.0_dp
242 CALL dbcsr_get_info(matrix_p, row_blk_size=row_blk_size, col_blk_size=col_blk_size)
266 work => workt(:, :, ithread)
267 hab => habt(:, :, ithread)
268 pab => pabt(:, :, ithread)
269 hdab => hdabt(:, :, :, ithread)
270 hadb => hadbt(:, :, :, ithread)
272 iset_old = -1; jset_old = -1
273 ikind_old = -1; jkind_old = -1
279 loop_gridlevels:
DO igrid_level = 1, gridlevel_info%ngrid_levels
282 loop_pairs:
DO ipair = 1, task_list%npairs(igrid_level)
283 loop_tasks:
DO itask = task_list%taskstart(ipair, igrid_level), task_list%taskstop(ipair, igrid_level)
284 ilevel = tasks(itask)%grid_level
285 img = tasks(itask)%image
286 iatom = tasks(itask)%iatom
287 jatom = tasks(itask)%jatom
288 iset = tasks(itask)%iset
289 jset = tasks(itask)%jset
290 ipgf = tasks(itask)%ipgf
291 jpgf = tasks(itask)%jpgf
294 IF (itask == task_list%taskstart(ipair, igrid_level))
THEN
296 ikind = particle_set(iatom)%atomic_kind%kind_number
297 jkind = particle_set(jatom)%atomic_kind%kind_number
299 ra(:) =
pbc(particle_set(iatom)%r, cell)
301 IF (iatom <= jatom)
THEN
309 IF (ikind /= ikind_old)
THEN
311 basis_set=orb_basis_set, basis_type=
"ORB")
314 first_sgf=first_sgfa, &
321 set_radius=set_radius_a, &
326 IF (jkind /= jkind_old)
THEN
328 basis_set=orb_basis_set, basis_type=
"ORB")
330 first_sgf=first_sgfb, &
337 set_radius=set_radius_b, &
344 NULLIFY (vhxc_block(i)%block)
345 IF (redistribute_matrices)
THEN
346 offset = task_list%pair_offsets_recv(tasks(itask)%pair_index)
347 vhxc_block(i)%block(1:row_blk_size(brow), 1:col_blk_size(bcol)) => &
348 h_buffer(offset + 1:offset + row_blk_size(brow)*col_blk_size(bcol), i)
350 CALL dbcsr_get_block_p(matrix_vhxc_dbasis(i)%matrix, brow, bcol, vhxc_block(i)%block, found)
356 row=brow, col=bcol, block=p_block, found=found)
362 atom_pair_changed = .true.
366 atom_pair_changed = .false.
370 IF (atom_pair_changed .OR. iset_old /= iset .OR. jset_old /= jset)
THEN
372 ncoa = npgfa(iset)*
ncoset(la_max(iset))
373 sgfa = first_sgfa(1, iset)
374 ncob = npgfb(jset)*
ncoset(lb_max(jset))
375 sgfb = first_sgfb(1, jset)
377 IF (iatom <= jatom)
THEN
378 work(1:ncoa, 1:nsgfb(jset)) = matmul(sphi_a(1:ncoa, sgfa:sgfa + nsgfa(iset) - 1), &
379 p_block(sgfa:sgfa + nsgfa(iset) - 1, sgfb:sgfb + nsgfb(jset) - 1))
380 pab(1:ncoa, 1:ncob) = matmul(work(1:ncoa, 1:nsgfb(jset)), transpose(sphi_b(1:ncob, sgfb:sgfb + nsgfb(jset) - 1)))
382 work(1:ncob, 1:nsgfa(iset)) = matmul(sphi_b(1:ncob, sgfb:sgfb + nsgfb(jset) - 1), &
383 p_block(sgfb:sgfb + nsgfb(jset) - 1, sgfa:sgfa + nsgfa(iset) - 1))
384 pab(1:ncob, 1:ncoa) = matmul(work(1:ncob, 1:nsgfa(iset)), transpose(sphi_a(1:ncoa, sgfa:sgfa + nsgfa(iset) - 1)))
387 IF (iatom <= jatom)
THEN
388 hab(1:ncoa, 1:ncob) = 0._dp
389 hdab(:, 1:ncoa, 1:ncob) = 0._dp
390 hadb(:, 1:ncoa, 1:ncob) = 0._dp
392 hab(1:ncob, 1:ncoa) = 0._dp
393 hdab(:, 1:ncob, 1:ncoa) = 0._dp
394 hadb(:, 1:ncob, 1:ncoa) = 0._dp
402 rab = tasks(itask)%rab
403 rb(:) = ra(:) + rab(:)
404 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
406 f = zetb(jpgf, jset)/zetp
407 rp(:) = ra(:) + f*rab(:)
408 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
410 lb_min=lb_min(jset), lb_max=lb_max(jset), &
411 ra=ra, rb=rb, rp=rp, &
412 zetp=zetp, eps=eps_rho_rspace, &
413 prefactor=prefactor, cutoff=1.0_dp)
415 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
416 na2 = ipgf*
ncoset(la_max(iset))
417 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
418 nb2 = jpgf*
ncoset(lb_max(jset))
421 IF (rs_rho(igrid_level)%desc%distributed)
THEN
423 IF (tasks(itask)%dist_type == 2)
THEN
424 use_subpatch = .true.
426 use_subpatch = .false.
429 use_subpatch = .false.
432 IF (iatom <= jatom)
THEN
433 IF (iatom == lambda)
THEN
435 la_max(iset), zeta(ipgf, iset), la_min(iset), &
436 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
437 ra, rab, rs_rho(igrid_level), &
438 hab, o1=na1 - 1, o2=nb1 - 1, &
440 calculate_forces=.true., &
441 compute_tau=.false., &
442 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern, &
445 IF (jatom == lambda)
THEN
447 la_max(iset), zeta(ipgf, iset), la_min(iset), &
448 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
449 ra, rab, rs_rho(igrid_level), &
450 hab, o1=na1 - 1, o2=nb1 - 1, &
452 calculate_forces=.true., &
453 compute_tau=.false., &
454 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern, &
459 IF (iatom == lambda)
THEN
461 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
462 la_max(iset), zeta(ipgf, iset), la_min(iset), &
463 rb, rab_inv, rs_rho(igrid_level), &
464 hab, o1=nb1 - 1, o2=na1 - 1, &
466 calculate_forces=.true., &
467 force_a=force_b, force_b=force_a, &
468 compute_tau=.false., &
469 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern, &
472 IF (jatom == lambda)
THEN
474 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
475 la_max(iset), zeta(ipgf, iset), la_min(iset), &
476 rb, rab_inv, rs_rho(igrid_level), &
477 hab, o1=nb1 - 1, o2=na1 - 1, &
479 calculate_forces=.true., &
480 force_a=force_b, force_b=force_a, &
481 compute_tau=.false., &
482 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern, &
487 new_set_pair_coming = .false.
488 atom_pair_done = .false.
489 IF (itask < task_list%taskstop(ipair, igrid_level))
THEN
490 ilevel = tasks(itask + 1)%grid_level
491 img = tasks(itask + 1)%image
492 iatom = tasks(itask + 1)%iatom
493 jatom = tasks(itask + 1)%jatom
494 iset_new = tasks(itask + 1)%iset
495 jset_new = tasks(itask + 1)%jset
496 ipgf_new = tasks(itask + 1)%ipgf
497 jpgf_new = tasks(itask + 1)%jpgf
498 IF (iset_new /= iset .OR. jset_new /= jset)
THEN
499 new_set_pair_coming = .true.
503 new_set_pair_coming = .true.
504 atom_pair_done = .true.
507 IF (new_set_pair_coming)
THEN
510 hdab(i, :, :) = hdab(i, :, :) + hadb(i, :, :)
511 IF (iatom <= jatom)
THEN
512 work(1:ncoa, 1:nsgfb(jset)) = matmul(hdab(i, 1:ncoa, 1:ncob), sphi_b(1:ncob, sgfb:sgfb + nsgfb(jset) - 1))
513 vhxc_block(i)%block(sgfa:sgfa + nsgfa(iset) - 1, sgfb:sgfb + nsgfb(jset) - 1) = &
514 vhxc_block(i)%block(sgfa:sgfa + nsgfa(iset) - 1, sgfb:sgfb + nsgfb(jset) - 1) + &
515 matmul(transpose(sphi_a(1:ncoa, sgfa:sgfa + nsgfa(iset) - 1)), work(1:ncoa, 1:nsgfb(jset)))
517 work(1:ncob, 1:nsgfa(iset)) = matmul(hdab(i, 1:ncob, 1:ncoa), sphi_a(1:ncoa, sgfa:sgfa + nsgfa(iset) - 1))
518 vhxc_block(i)%block(sgfb:sgfb + nsgfb(jset) - 1, sgfa:sgfa + nsgfa(iset) - 1) = &
519 vhxc_block(i)%block(sgfb:sgfb + nsgfb(jset) - 1, sgfa:sgfa + nsgfa(iset) - 1) + &
520 matmul(transpose(sphi_b(1:ncob, sgfb:sgfb + nsgfb(jset) - 1)), work(1:ncob, 1:nsgfa(iset)))
529 IF (.NOT. redistribute_matrices)
THEN
535 END DO loop_gridlevels
539 IF (redistribute_matrices)
THEN
541 task_list%hab_buffer%host_buffer(:) = h_buffer(:, i)
542 matrix_image(1)%matrix => matrix_vhxc_dbasis(i)%matrix
547 IF (redistribute_matrices)
THEN
550 DO img = 1, dft_control%nimages
551 NULLIFY (deltap(img)%matrix)
556 DEALLOCATE (pabt, habt, workt, hdabt, hadbt)
558 CALL timestop(handle)
598 qs_env, calculate_forces, force_adm, &
599 compute_tau, gapw, basis_type, pw_env_external, task_list_external)
609 LOGICAL,
INTENT(IN) :: calculate_forces
610 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: force_adm
611 LOGICAL,
INTENT(IN),
OPTIONAL :: compute_tau, gapw
612 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: basis_type
613 TYPE(
pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
616 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_v_rspace'
618 CHARACTER(len=default_string_length) :: my_basis_type
619 INTEGER :: atom_a, handle, iatom, ikind, img, &
620 maxco, maxsgf_set, natoms, nimages, &
622 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of
623 LOGICAL :: calculate_virial, do_kp, my_compute_tau, &
624 my_gapw, pab_required
625 REAL(kind=
dp) :: admm_scal_fac
626 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: forces_array
627 REAL(kind=
dp),
DIMENSION(3, 3) :: virial_matrix
630 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: deltap, dhmat
636 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
641 CALL timeset(routinen, handle)
644 cpassert(
PRESENT(hmat) .OR.
PRESENT(hmat_kp))
646 IF (
PRESENT(hmat_kp)) do_kp = .true.
647 IF (
PRESENT(pmat))
THEN
648 cpassert(
PRESENT(hmat))
649 ELSE IF (
PRESENT(pmat_kp))
THEN
650 cpassert(
PRESENT(hmat_kp))
658 my_compute_tau = .false.
659 IF (
PRESENT(compute_tau)) my_compute_tau = compute_tau
664 IF (
PRESENT(gapw)) my_gapw = gapw
665 IF (
PRESENT(basis_type))
THEN
666 my_basis_type = basis_type
668 my_basis_type =
"ORB"
676 task_list=task_list, &
677 task_list_soft=task_list_soft)
678 IF (.NOT. my_basis_type ==
"ORB")
THEN
679 cpassert(
PRESENT(task_list_external))
681 IF (my_gapw) task_list => task_list_soft
682 IF (
PRESENT(task_list_external)) task_list => task_list_external
683 cpassert(
ASSOCIATED(task_list))
689 IF (
PRESENT(pw_env_external)) pw_env => pw_env_external
693 atomic_kind_set=atomic_kind_set, &
694 qs_kind_set=qs_kind_set, &
697 dft_control=dft_control, &
698 particle_set=particle_set, &
702 admm_scal_fac = 1.0_dp
703 IF (
PRESENT(force_adm)) admm_scal_fac = force_adm
705 cpassert(
ASSOCIATED(pw_env))
709 group = rs_v(1)%desc%group
714 nimages = dft_control%nimages
715 IF (nimages > 1)
THEN
718 nkind =
SIZE(qs_kind_set)
719 calculate_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer) .AND. calculate_forces
720 pab_required = (
PRESENT(pmat) .OR.
PRESENT(pmat_kp)) .AND. calculate_forces
724 maxsgf_set=maxsgf_set, &
725 basis_type=my_basis_type)
727 ALLOCATE (forces_array(3, natoms))
729 IF (pab_required)
THEN
731 ALLOCATE (deltap(nimages))
734 deltap(img)%matrix => pmat_kp(img)%matrix
737 deltap(1)%matrix => pmat%matrix
747 compute_tau=my_compute_tau, &
748 calculate_forces=calculate_forces, &
749 calculate_virial=calculate_virial, &
750 pab_blocks=task_list%pab_buffer, &
752 hab_blocks=task_list%hab_buffer, &
753 forces=forces_array, &
754 virial=virial_matrix)
756 IF (calculate_forces)
THEN
761 atom_a = atom_of_kind(iatom)
762 ikind = kind_of(iatom)
763 force(ikind)%rho_elec(:, atom_a) = force(ikind)%rho_elec(:, atom_a) + admm_scal_fac*forces_array(:, iatom)
766 DEALLOCATE (atom_of_kind, kind_of)
769 IF (calculate_virial)
THEN
770 virial%pv_virial = virial%pv_virial + admm_scal_fac*virial_matrix
774 ALLOCATE (dhmat(nimages))
775 IF (
PRESENT(hmat_kp))
THEN
776 cpassert(.NOT.
PRESENT(hmat))
778 dhmat(img)%matrix => hmat_kp(img)%matrix
781 cpassert(
PRESENT(hmat) .AND. nimages == 1)
782 dhmat(1)%matrix => hmat%matrix
789 CALL timestop(handle)
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.
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, hund_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, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, 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.