(git:f2099e5)
Loading...
Searching...
No Matches
topology_inversion.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Inversion action on CP2K Gaussian Bloch coefficients, including lattice phases.
10! **************************************************************************************************
14 USE cell_types, ONLY: cell_type,&
15 pbc
16 USE ieee_arithmetic, ONLY: ieee_is_finite
17 USE kinds, ONLY: dp
18 USE mathconstants, ONLY: twopi
22 USE qs_kind_types, ONLY: get_qs_kind,&
24
25 IMPLICIT NONE
26 PRIVATE
28CONTAINS
29
30! **************************************************************************************************
31!> \brief Construct sparse AO inversion at a TRIM for the operation r -> 2*center-r.
32!> \param qs_env Electronic environment
33!> \param k Fractional reciprocal coordinate at a TRIM
34!> \param center Fractional inversion center in the user's cell setting
35!> \param mapping Target AO row for every source row
36!> \param phase AO parity times exp(+2*pi*i*k.L), with 2c-r_a=r_b+L
37!> \param tolerance Geometry tolerance in Bohr
38!> \param status Zero on success, negative if geometry/basis/periodicity is incompatible
39! **************************************************************************************************
40 SUBROUTINE gaussian_inversion_action(qs_env, k, center, mapping, phase, tolerance, status)
41 TYPE(qs_environment_type), POINTER :: qs_env
42 REAL(kind=dp), INTENT(IN) :: k(3), center(3)
43 INTEGER, INTENT(OUT) :: mapping(:)
44 COMPLEX(KIND=dp), INTENT(OUT) :: phase(:)
45 REAL(kind=dp), INTENT(IN) :: tolerance
46 INTEGER, INTENT(OUT) :: status
47
48 INTEGER :: a, b, found, i, iset, l, n, shell, total
49 INTEGER, ALLOCATABLE :: kind(:), offset(:), TARGET(:)
50 REAL(kind=dp) :: angle, delta(3), image(3)
51 REAL(kind=dp), ALLOCATABLE :: position(:, :)
52 TYPE(cell_type), POINTER :: cell
53 TYPE(gto_basis_set_type), POINTER :: basis
54 TYPE(particle_type), POINTER :: particles(:)
55 TYPE(qs_kind_type), POINTER :: kinds_set(:)
56
57 status = -1
58 mapping = 0
59 phase = cmplx(0, 0, dp)
60 IF (tolerance <= 0.0_dp .OR. SIZE(phase) /= SIZE(mapping)) RETURN
61 IF (.NOT. ieee_is_finite(tolerance) .OR. .NOT. all(ieee_is_finite(center))) RETURN
62 IF (.NOT. all(ieee_is_finite(k))) RETURN
63 IF (maxval(abs(2*k - nint(2*k))) > 1.e-8_dp) RETURN
64 CALL get_qs_env(qs_env, cell=cell, particle_set=particles, qs_kind_set=kinds_set)
65 IF (any(cell%perd /= 1)) RETURN
66 n = SIZE(particles)
67 ALLOCATE (kind(n), offset(n), target(n), position(3, n))
68 total = 0
69 DO a = 1, n
70 CALL get_atomic_kind(particles(a)%atomic_kind, kind_number=kind(a))
71 CALL get_qs_kind(kinds_set(kind(a)), basis_set=basis)
72 IF (.NOT. ASSOCIATED(basis)) RETURN
73 offset(a) = total
74 total = total + basis%nsgf
75 position(:, a) = matmul(cell%h_inv, pbc(particles(a)%r, cell))
76 END DO
77 IF (total /= SIZE(mapping)) RETURN
78 DO a = 1, n
79 found = 0
80 DO b = 1, n
81 IF (kind(a) /= kind(b)) cycle
82 delta = 2*center - position(:, a) - position(:, b)
83 IF (sqrt(sum(matmul(cell%hmat, delta - nint(delta))**2)) > tolerance) cycle
84 found = found + 1
85 target(a) = b
86 END DO
87 IF (found /= 1) RETURN
88 END DO
89 DO a = 1, n
90 b = target(a)
91 IF (target(b) /= a) RETURN
92 image = real(nint(2*center - position(:, a) - position(:, b)), dp)
93 angle = twopi*dot_product(k, image)
94 CALL get_qs_kind(kinds_set(kind(a)), basis_set=basis)
95 DO iset = 1, basis%nset
96 DO shell = 1, basis%nshell(iset)
97 l = basis%l(shell, iset)
98 DO i = basis%first_sgf(shell, iset), basis%last_sgf(shell, iset)
99 mapping(offset(a) + i) = offset(b) + i
100 phase(offset(a) + i) = (-1)**l*cmplx(cos(angle), sin(angle), dp)
101 END DO
102 END DO
103 END DO
104 END DO
105 IF (any(mapping == 0)) RETURN
106 status = 0
107 END SUBROUTINE gaussian_inversion_action
108END MODULE topology_inversion
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.
Definition cell_types.F:15
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
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, 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.
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, 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.
Inversion action on CP2K Gaussian Bloch coefficients, including lattice phases.
subroutine, public gaussian_inversion_action(qs_env, k, center, mapping, phase, tolerance, status)
Construct sparse AO inversion at a TRIM for the operation r -> 2*center-r.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
Provides all information about a quickstep kind.