(git:cccd2f3)
Loading...
Searching...
No Matches
qs_basis_rotation_methods.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! **************************************************************************************************
12 USE cell_types, ONLY: cell_type
15 USE kinds, ONLY: dp
16 USE kpoint_types, ONLY: kpoint_sym_type,&
18 USE orbital_pointers, ONLY: nso
26 USE qs_kind_types, ONLY: get_qs_kind,&
29#include "./base/base_uses.f90"
30
31 IMPLICIT NONE
32
33 PRIVATE
34
35 ! Global parameters (only in this module)
36
37 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_basis_rotation_methods'
38
39 ! Public subroutines
40
41 PUBLIC :: qs_basis_rotation
42
43CONTAINS
44
45! **************************************************************************************************
46!> \brief Construct basis set rotation matrices
47!> \param qs_env ...
48!> \param kpoints ...
49!> \param basis_type ...
50! **************************************************************************************************
51 SUBROUTINE qs_basis_rotation(qs_env, kpoints, basis_type)
52
53 TYPE(qs_environment_type), POINTER :: qs_env
54 TYPE(kpoint_type), POINTER :: kpoints
55 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: basis_type
56
57 CHARACTER(LEN=12) :: my_basis
58 INTEGER :: ik, ikind, ir, ira, irot, jr, lval, &
59 nkind, nrot
60 REAL(kind=dp), DIMENSION(3, 3) :: rotmat
61 TYPE(cell_type), POINTER :: cell
62 TYPE(dft_control_type), POINTER :: dft_control
63 TYPE(gto_basis_set_type), POINTER :: orb_basis
64 TYPE(kpoint_sym_type), POINTER :: kpsym
65 TYPE(orbrotmat_type), DIMENSION(:), POINTER :: orbrot
66 TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
67 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
68
69 cpassert(ASSOCIATED(qs_env))
70 cpassert(ASSOCIATED(kpoints))
71 IF (PRESENT(basis_type)) THEN
72 my_basis = basis_type
73 ELSE
74 my_basis = "ORB"
75 END IF
76 IF (ASSOCIATED(kpoints%kind_rotmat)) THEN
77 CALL get_qs_env(qs_env, cell=cell)
78 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
79 CALL get_qs_kind_set(qs_kind_set, maxlgto=lval)
80 nrot = SIZE(kpoints%kind_rotmat, 1)
81 nkind = SIZE(kpoints%kind_rotmat, 2)
82 ! remove possible old rotation matrices
83 DO irot = 1, nrot
84 DO ikind = 1, nkind
85 IF (ASSOCIATED(kpoints%kind_rotmat(irot, ikind)%rmat)) THEN
86 DEALLOCATE (kpoints%kind_rotmat(irot, ikind)%rmat)
87 END IF
88 END DO
89 END DO
90 ! check all rotations needed
91 NULLIFY (orbrot)
92 CALL get_qs_env(qs_env, dft_control=dft_control)
93 DO ik = 1, kpoints%nkp
94 kpsym => kpoints%kp_sym(ik)%kpoint_sym
95 IF (kpsym%apply_symmetry) THEN
96 DO irot = 1, SIZE(kpsym%rotp)
97 ir = abs(kpsym%rotp(irot))
98 ira = 0
99 DO jr = 1, SIZE(kpoints%ibrot)
100 IF (ir == kpoints%ibrot(jr)) ira = jr
101 END DO
102 IF (ira > 0) THEN
103 IF (.NOT. ASSOCIATED(kpoints%kind_rotmat(ira, 1)%rmat)) THEN
104 rotmat(1:3, 1:3) = matmul(cell%h_inv, &
105 matmul(kpsym%rot(:, :, irot), cell%hmat))
106 CALL calculate_rotmat(orbrot, rotmat, lval)
107 IF (dft_control%qs_control%method_id == do_method_dftb) THEN
108 DO ikind = 1, nkind
109 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_parameter)
110 NULLIFY (kpoints%kind_rotmat(ira, ikind)%rmat)
111 CALL set_rotmat_dftb(kpoints%kind_rotmat(ira, ikind)%rmat, &
112 orbrot, dftb_parameter)
113 END DO
114 ELSE
115 DO ikind = 1, nkind
116 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis, basis_type=my_basis)
117 NULLIFY (kpoints%kind_rotmat(ira, ikind)%rmat)
118 CALL set_rotmat_basis(kpoints%kind_rotmat(ira, ikind)%rmat, orbrot, orb_basis)
119 END DO
120 END IF
121 END IF
122 END IF
123 END DO
124 END IF
125 END DO
126 CALL release_rotmat(orbrot)
127 END IF
128
129 END SUBROUTINE qs_basis_rotation
130
131! **************************************************************************************************
132!> \brief Construct DFTB basis-set rotation matrices
133!> \param rmat ...
134!> \param orbrot ...
135!> \param dftb_parameter ...
136! **************************************************************************************************
137 SUBROUTINE set_rotmat_dftb(rmat, orbrot, dftb_parameter)
138 REAL(kind=dp), DIMENSION(:, :), POINTER :: rmat
139 TYPE(orbrotmat_type), DIMENSION(:), POINTER :: orbrot
140 TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
141
142 INTEGER :: first, i, j, l, lmax, n, natorb
143 INTEGER, DIMENSION(5) :: perm
144 LOGICAL :: defined
145
146 CALL get_dftb_atom_param(dftb_parameter, defined=defined, lmax=lmax, natorb=natorb)
147 cpassert(defined)
148
149 ALLOCATE (rmat(natorb, natorb))
150 rmat = 0.0_dp
151
152 first = 1
153 DO l = 0, lmax
154 n = nso(l)
155 SELECT CASE (l)
156 CASE (0)
157 perm(1) = 1
158 CASE (1)
159 perm(1:3) = [3, 1, 2]
160 CASE (2)
161 perm(1:5) = [1, 2, 4, 5, 3]
162 CASE DEFAULT
163 CALL cp_abort(__location__, &
164 "DFTB k-point symmetry is implemented for basis functions up to d orbitals")
165 END SELECT
166 DO i = 1, n
167 DO j = 1, n
168 rmat(first + i - 1, first + j - 1) = orbrot(l)%mat(perm(i), perm(j))
169 END DO
170 END DO
171 first = first + n
172 END DO
173 cpassert(first == natorb + 1)
174
175 END SUBROUTINE set_rotmat_dftb
176
177! **************************************************************************************************
178!> \brief ...
179!> \param rmat ...
180!> \param orbrot ...
181!> \param basis ...
182! **************************************************************************************************
183 SUBROUTINE set_rotmat_basis(rmat, orbrot, basis)
184 REAL(kind=dp), DIMENSION(:, :), POINTER :: rmat
185 TYPE(orbrotmat_type), DIMENSION(:), POINTER :: orbrot
186 TYPE(gto_basis_set_type), POINTER :: basis
187
188 INTEGER :: fs1, fs2, iset, ishell, l, nset, nsgf
189 INTEGER, DIMENSION(:), POINTER :: nshell
190 INTEGER, DIMENSION(:, :), POINTER :: first_sgf, lshell
191
192 CALL get_gto_basis_set(gto_basis_set=basis, nsgf=nsgf)
193 ALLOCATE (rmat(nsgf, nsgf))
194 rmat = 0.0_dp
195
196 CALL get_gto_basis_set(gto_basis_set=basis, nset=nset, nshell=nshell, l=lshell, &
197 first_sgf=first_sgf)
198 DO iset = 1, nset
199 DO ishell = 1, nshell(iset)
200 l = lshell(ishell, iset)
201 fs1 = first_sgf(ishell, iset)
202 fs2 = fs1 + nso(l) - 1
203 rmat(fs1:fs2, fs1:fs2) = orbrot(l)%mat(1:nso(l), 1:nso(l))
204 END DO
205 END DO
206
207 END SUBROUTINE set_rotmat_basis
208
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum)
...
Handles all functions related to the CELL.
Definition cell_types.F:15
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_method_dftb
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Types and basic routines needed for a kpoint calculation.
K-points and crystal symmetry routines based on.
Definition kpsym.F:28
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nso
Calculation of the spherical harmonics and the corresponding orbital transformation matrices.
subroutine, public calculate_rotmat(orbrotmat, rotmat, lval)
Calculate rotation matrices for spherical harmonics up to value l Joseph Ivanic and Klaus Ruedenberg ...
subroutine, public release_rotmat(orbrotmat)
Release rotation matrices.
subroutine, public qs_basis_rotation(qs_env, kpoints, basis_type)
Construct basis set rotation matrices.
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
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.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
Keeps symmetry information about a specific k-point.
Contains information about kpoints.
Provides all information about a quickstep kind.