20 dbcsr_type_no_symmetry, dbcsr_type_symmetric
41#include "./base/base_uses.f90"
45 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_localizer_torus'
65 INTEGER,
INTENT(IN) :: grid(3), directions(:)
66 LOGICAL,
INTENT(IN) :: do_soc
67 TYPE(
dbcsr_p_type),
POINTER :: h(:), s(:), cosines(:), sines(:), &
70 INTEGER :: axis, j, nimages
79 NULLIFY (qp, berry, cb, sb, soc)
80 cpassert(
SIZE(directions) >= 1 .AND.
SIZE(directions) <= 3)
81 cpassert(all(directions >= 1) .AND. all(directions <= 3))
82 DO j = 1,
SIZE(directions)
83 cpassert(count(directions == directions(j)) == 1)
91 CALL get_qs_env(qp, cell=cell, para_env=para_env, sab_all=all_pairs)
92 CALL lift_electronic_operators(qp, grid, do_soc, h, s, soc)
93 ALLOCATE (cosines(
SIZE(directions)), sines(3))
97 ALLOCATE (sines(axis)%matrix)
98 CALL dbcsr_create(sines(axis)%matrix, template=s(1)%matrix, name=
'TORUS SIN')
101 DO j = 1,
SIZE(directions)
104 ordered=.true., ordered_kpoints=berry)
105 ALLOCATE (cosines(j)%matrix)
106 CALL dbcsr_create(cosines(j)%matrix, template=s(1)%matrix, name=
'TORUS COS')
107 CALL lift_berry(cb, sb, berry%index_to_cell, grid, axis, cosines(j)%matrix, sines(axis)%matrix)
112 IF (.NOT. do_kpoints)
THEN
131 INTEGER,
INTENT(IN) :: grid(3)
132 REAL(
dp),
INTENT(IN) :: shifts(:, :)
133 LOGICAL,
INTENT(IN) :: do_soc
134 TYPE(
dbcsr_p_type),
POINTER :: h(:), s(:), translations(:), soc(:, :)
136 INTEGER :: ir, it, r(3)
137 LOGICAL :: do_kpoints
138 REAL(
dp),
ALLOCATABLE :: displaced(:, :)
140 TYPE(
dbcsr_p_type),
POINTER :: primitive_s(:, :), residues(:)
143 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
149 CALL get_qs_env(qp, cell=cell, matrix_s_kp=primitive_s)
150 CALL lift_electronic_operators(qp, grid, do_soc, h, s, soc)
151 ALLOCATE (translations(
SIZE(shifts, 2)), displaced(3,
SIZE(shifts, 2)))
152 DO it = 1,
SIZE(translations)
153 ALLOCATE (translations(it)%matrix)
154 CALL create_torus(primitive_s(1, 1)%matrix, product(grid), translations(it)%matrix)
156 DO ir = 1, product(grid)
157 r = cell_coordinates(ir, grid)
158 DO it = 1,
SIZE(translations)
159 displaced(:, it) = shifts(:, it) - matmul(cell%hmat, real(r,
dp))
162 DO it = 1,
SIZE(translations)
163 CALL lift_blocks(residues(it)%matrix, grid, r, 0, .false., translations(it)%matrix)
167 IF (.NOT. do_kpoints)
THEN
182 SUBROUTINE lift_electronic_operators(qp, grid, do_soc, h, s, soc)
184 INTEGER,
INTENT(IN) :: grid(3)
185 LOGICAL,
INTENT(IN) :: do_soc
188 INTEGER :: axis, spin
189 TYPE(
dbcsr_p_type),
POINTER :: hk(:, :), sk(:, :), vk(:, :)
195 CALL get_qs_env(qp, ks_env=ks_env, matrix_ks_kp=hk, matrix_s_kp=sk, sab_orb=pairs)
197 ALLOCATE (h(
SIZE(hk, 1)), s(1))
198 DO spin = 1,
SIZE(hk, 1)
199 ALLOCATE (h(spin)%matrix)
200 CALL lift_fourier(hk, spin, pairs, kpoints, grid, .false., h(spin)%matrix)
202 ALLOCATE (s(1)%matrix)
203 CALL lift_fourier(sk, 1, pairs, kpoints, grid, .false., s(1)%matrix)
208 ALLOCATE (soc(axis, 1)%matrix)
209 CALL lift_fourier(vk, axis, pairs, kpoints, grid, .true., soc(axis, 1)%matrix)
213 END SUBROUTINE lift_electronic_operators
221 SUBROUTINE create_torus(source, copies, matrix)
223 INTEGER,
INTENT(IN) :: copies
227 INTEGER,
POINTER :: cols(:), ec(:), er(:), es(:), rows(:), &
231 CALL dbcsr_get_info(source, distribution=distribution, row_blk_size=sizes)
233 n =
SIZE(sizes)*copies
234 ALLOCATE (es(n), er(n), ec(n))
235 es = reshape(spread(sizes, 2, copies), [n])
236 er = reshape(spread(rows, 2, copies), [n])
237 ec = reshape(spread(cols, 2, copies), [n])
239 CALL dbcsr_create(matrix,
'TORUS AO', expanded, dbcsr_type_no_symmetry, es, es)
241 DEALLOCATE (es, er, ec)
242 END SUBROUTINE create_torus
256 SUBROUTINE lift_fourier(images, spin, pairs, kpoints, grid, antisymmetric, matrix)
258 INTEGER,
INTENT(IN) :: spin
261 INTEGER,
INTENT(IN) :: grid(3)
262 LOGICAL,
INTENT(IN) :: antisymmetric
265 INTEGER :: ik, ir, n, r(3)
266 REAL(
dp) :: k(3), phase
271 CALL create_torus(images(spin, 1)%matrix, n, matrix)
272 CALL dbcsr_create(re, template=images(spin, 1)%matrix, matrix_type=dbcsr_type_symmetric)
273 CALL dbcsr_create(im, template=images(spin, 1)%matrix, matrix_type=dbcsr_type_antisymmetric)
276 CALL dbcsr_create(full_re, template=re, matrix_type=dbcsr_type_no_symmetry)
277 CALL dbcsr_create(full_im, template=re, matrix_type=dbcsr_type_no_symmetry)
278 ALLOCATE (residues(n))
280 ALLOCATE (residues(ir)%matrix)
281 CALL dbcsr_create(residues(ir)%matrix, template=full_re)
285 k = real(cell_coordinates(ik, grid),
dp)/real(grid,
dp)
288 IF (antisymmetric)
THEN
291 CALL rskp_transform(im, re, images, spin, k, kpoints%cell_to_index, pairs)
295 CALL rskp_transform(re, im, images, spin, k, kpoints%cell_to_index, pairs)
300 r = cell_coordinates(ir, grid)
301 phase =
twopi*dot_product(k, real(r,
dp))
302 CALL dbcsr_add(residues(ir)%matrix, full_re, 1.0_dp, cos(phase)/real(n,
dp))
303 CALL dbcsr_add(residues(ir)%matrix, full_im, 1.0_dp, sin(phase)/real(n,
dp))
307 r = cell_coordinates(ir, grid)
308 CALL lift_blocks(residues(ir)%matrix, grid, r, 0, .false., matrix)
316 END SUBROUTINE lift_fourier
328 SUBROUTINE lift_berry(cosmat, sinmat, cells, grid, axis, cosine, sine)
329 TYPE(
dbcsr_p_type),
INTENT(INOUT) :: cosmat(:, :), sinmat(:, :)
330 INTEGER,
INTENT(IN) :: cells(:, :), grid(3), axis
331 TYPE(
dbcsr_type),
INTENT(INOUT) :: cosine, sine
335 DO ir = 1,
SIZE(cells, 2)
336 CALL lift_blocks(cosmat(1, ir)%matrix, grid, cells(:, ir), axis, .false., cosine)
337 CALL lift_blocks(sinmat(1, ir)%matrix, grid, cells(:, ir), -axis, .true., cosine)
338 CALL lift_blocks(cosmat(1, ir)%matrix, grid, cells(:, ir), axis, .true., sine)
339 CALL lift_blocks(sinmat(1, ir)%matrix, grid, cells(:, ir), axis, .false., sine)
343 END SUBROUTINE lift_berry
354 SUBROUTINE lift_blocks(source, grid, displacement, axis, sine, destination)
356 INTEGER,
INTENT(IN) :: grid(3), displacement(3), axis
357 LOGICAL,
INTENT(IN) :: sine
358 TYPE(
dbcsr_type),
INTENT(INOUT) :: destination
360 INTEGER :: blocks, col, it, iu, row, t(3), u(3)
361 LOGICAL :: transposed
362 REAL(
dp) :: factor, phase
363 REAL(
dp),
POINTER :: block(:, :)
370 cpassert(.NOT. transposed)
371 IF (all(block == 0.0_dp)) cycle
372 DO it = 1, product(grid)
373 t = cell_coordinates(it, grid)
374 u =
modulo(t + displacement, grid)
375 iu = 1 + u(1) + grid(1)*(u(2) + grid(2)*u(3))
378 phase =
twopi*real(t(abs(axis)),
dp)/real(grid(abs(axis)),
dp)
384 IF (axis < 0) factor = -factor
386 IF (factor == 0.0_dp) cycle
387 CALL dbcsr_put_block(destination, row + (it - 1)*blocks, col + (iu - 1)*blocks, &
388 factor*block, summation=.true.)
393 END SUBROUTINE lift_blocks
401 PURE FUNCTION cell_coordinates(index, grid)
RESULT(r)
402 INTEGER,
INTENT(IN) :: index, grid(3)
405 r(1) =
modulo(index - 1, grid(1))
406 r(2) =
modulo((index - 1)/grid(1), grid(2))
407 r(3) = (index - 1)/(grid(1)*grid(2))
408 END FUNCTION cell_coordinates
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Handles all functions related to the CELL.
subroutine, public dbcsr_distribution_release(dist)
...
subroutine, public dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, reuse_arrays)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_finalize(matrix)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_put_block(matrix, row, col, block, summation)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
DBCSR operations in CP2K.
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public rskp_transform(rmatrix, cmatrix, rsmat, ispin, xkp, cell_to_index, sab_nl, is_complex, rs_sign)
Transformation of real space matrices to a kpoint.
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 kpoint_release(kpoint)
Release a kpoint environment, deallocate all data.
subroutine, public kpoint_create(kpoint)
Create a kpoint environment.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
Analytic translations of finite or periodized Gaussian AO functions.
subroutine, public ao_translation_matrices(qs_env, shifts, translations, periodic_grid)
Overlaps with translated ket Gaussians, U(a) psi(r) = psi(r+a).
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 qs_env_release(qs_env)
releases the given qs_env (see doc/ReferenceCounting.html)
Shared finite-system AO position and SOC operators for post-SCF analyses.
subroutine, public finite_ao_soc(qs_env, soc_matrices)
Validate and construct post-SCF GTH SOC components shared by finite AO analyses.
Initialize a qs_env for kpoint calculations starting from a gamma point qs_env.
subroutine, public create_kp_from_gamma(qs_env, qs_env_kp, with_xc_terms)
...
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)
...
Full Born-von-Karman AO operators at a frozen SCF potential.
subroutine, public torus_translation_operators(qs_env, grid, shifts, do_soc, h, s, translations, soc)
Full AO torus with translated, periodized Gaussians instead of position coordinates.
subroutine, public localizer_torus_operators(qs_env, grid, directions, do_soc, h, s, cosines, sines, soc)
Lift scalar image operators and ordered Berry integrals to a full real-cell torus.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>.
subroutine, public build_berry_kpoint_matrix(qs_env, cosmat, sinmat, kvec, basis_type, ordered, ordered_kpoints)
...
Define the neighbor list data types and the corresponding functionality.
Type defining parameters related to the simulation cell.
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 ...