(git:27c966b)
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
19 USE orbital_pointers, ONLY: nso
27 USE qs_kind_types, ONLY: get_qs_kind,&
30#include "./base/base_uses.f90"
31
32 IMPLICIT NONE
33
34 PRIVATE
35
36 ! Global parameters (only in this module)
37
38 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_basis_rotation_methods'
39
40 ! Public subroutines
41
42 PUBLIC :: qs_basis_rotation
43
44CONTAINS
45
46! **************************************************************************************************
47!> \brief Construct basis set rotation matrices
48!> \param qs_env ...
49!> \param kpoints ...
50!> \param basis_type ...
51!> \param storage_type ...
52! **************************************************************************************************
53 SUBROUTINE qs_basis_rotation(qs_env, kpoints, basis_type, storage_type)
54
55 TYPE(qs_environment_type), POINTER :: qs_env
56 TYPE(kpoint_type), POINTER :: kpoints
57 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: basis_type, storage_type
58
59 CHARACTER(LEN=12) :: my_basis, my_storage
60 INTEGER :: ik, ikind, ir, ira, irot, jr, lval, &
61 nkind, nrot
62 REAL(kind=dp), DIMENSION(3, 3) :: rotmat
63 TYPE(cell_type), POINTER :: cell
64 TYPE(dft_control_type), POINTER :: dft_control
65 TYPE(gto_basis_set_type), POINTER :: orb_basis
66 TYPE(kind_rotmat_type), DIMENSION(:, :), POINTER :: rotmat_store
67 TYPE(kpoint_sym_type), POINTER :: kpsym
68 TYPE(orbrotmat_type), DIMENSION(:), POINTER :: orbrot
69 TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
70 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
71
72 cpassert(ASSOCIATED(qs_env))
73 cpassert(ASSOCIATED(kpoints))
74 IF (PRESENT(basis_type)) THEN
75 my_basis = basis_type
76 ELSE
77 my_basis = "ORB"
78 END IF
79 IF (PRESENT(storage_type)) THEN
80 my_storage = storage_type
81 ELSE
82 my_storage = "ORB"
83 END IF
84 IF (trim(my_storage) == "AUX_FIT") THEN
85 rotmat_store => kpoints%kind_rotmat_aux
86 ELSE
87 rotmat_store => kpoints%kind_rotmat
88 END IF
89 IF (ASSOCIATED(rotmat_store)) THEN
90 CALL get_qs_env(qs_env, cell=cell)
91 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
92 CALL get_qs_kind_set(qs_kind_set, maxlgto=lval, basis_type=my_basis)
93 nrot = SIZE(rotmat_store, 1)
94 nkind = SIZE(rotmat_store, 2)
95 ! remove possible old rotation matrices
96 DO irot = 1, nrot
97 DO ikind = 1, nkind
98 IF (ASSOCIATED(rotmat_store(irot, ikind)%rmat)) THEN
99 DEALLOCATE (rotmat_store(irot, ikind)%rmat)
100 END IF
101 END DO
102 END DO
103 ! check all rotations needed
104 NULLIFY (orbrot)
105 CALL get_qs_env(qs_env, dft_control=dft_control)
106 DO ik = 1, kpoints%nkp
107 kpsym => kpoints%kp_sym(ik)%kpoint_sym
108 IF (kpsym%apply_symmetry) THEN
109 DO irot = 1, SIZE(kpsym%rotp)
110 ir = abs(kpsym%rotp(irot))
111 ira = 0
112 DO jr = 1, SIZE(kpoints%ibrot)
113 IF (ir == kpoints%ibrot(jr)) ira = jr
114 END DO
115 IF (ira > 0) THEN
116 IF (.NOT. ASSOCIATED(rotmat_store(ira, 1)%rmat)) THEN
117 rotmat(1:3, 1:3) = kpsym%rot(1:3, 1:3, irot)
118 CALL calculate_rotmat(orbrot, rotmat, lval)
119 IF (dft_control%qs_control%method_id == do_method_dftb) THEN
120 DO ikind = 1, nkind
121 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_parameter)
122 NULLIFY (rotmat_store(ira, ikind)%rmat)
123 CALL set_rotmat_dftb(rotmat_store(ira, ikind)%rmat, &
124 orbrot, dftb_parameter)
125 END DO
126 ELSE
127 DO ikind = 1, nkind
128 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis, basis_type=my_basis)
129 NULLIFY (rotmat_store(ira, ikind)%rmat)
130 CALL set_rotmat_basis(rotmat_store(ira, ikind)%rmat, orbrot, orb_basis)
131 END DO
132 END IF
133 END IF
134 END IF
135 END DO
136 END IF
137 END DO
138 CALL release_rotmat(orbrot)
139 END IF
140
141 END SUBROUTINE qs_basis_rotation
142
143! **************************************************************************************************
144!> \brief Construct DFTB basis-set rotation matrices
145!> \param rmat ...
146!> \param orbrot ...
147!> \param dftb_parameter ...
148! **************************************************************************************************
149 SUBROUTINE set_rotmat_dftb(rmat, orbrot, dftb_parameter)
150 REAL(kind=dp), DIMENSION(:, :), POINTER :: rmat
151 TYPE(orbrotmat_type), DIMENSION(:), POINTER :: orbrot
152 TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
153
154 INTEGER :: first, i, j, l, lmax, n, natorb
155 INTEGER, DIMENSION(5) :: perm
156 LOGICAL :: defined
157
158 CALL get_dftb_atom_param(dftb_parameter, defined=defined, lmax=lmax, natorb=natorb)
159 cpassert(defined)
160
161 ALLOCATE (rmat(natorb, natorb))
162 rmat = 0.0_dp
163
164 first = 1
165 DO l = 0, lmax
166 n = nso(l)
167 SELECT CASE (l)
168 CASE (0)
169 perm(1) = 1
170 CASE (1)
171 perm(1:3) = [3, 1, 2]
172 CASE (2)
173 perm(1:5) = [1, 2, 4, 5, 3]
174 CASE DEFAULT
175 CALL cp_abort(__location__, &
176 "DFTB k-point symmetry is implemented for basis functions up to d orbitals")
177 END SELECT
178 DO i = 1, n
179 DO j = 1, n
180 rmat(first + i - 1, first + j - 1) = orbrot(l)%mat(perm(i), perm(j))
181 END DO
182 END DO
183 first = first + n
184 END DO
185 cpassert(first == natorb + 1)
186
187 END SUBROUTINE set_rotmat_dftb
188
189! **************************************************************************************************
190!> \brief ...
191!> \param rmat ...
192!> \param orbrot ...
193!> \param basis ...
194! **************************************************************************************************
195 SUBROUTINE set_rotmat_basis(rmat, orbrot, basis)
196 REAL(kind=dp), DIMENSION(:, :), POINTER :: rmat
197 TYPE(orbrotmat_type), DIMENSION(:), POINTER :: orbrot
198 TYPE(gto_basis_set_type), POINTER :: basis
199
200 INTEGER :: fs1, fs2, iset, ishell, l, nset, nsgf
201 INTEGER, DIMENSION(:), POINTER :: nshell
202 INTEGER, DIMENSION(:, :), POINTER :: first_sgf, lshell
203
204 CALL get_gto_basis_set(gto_basis_set=basis, nsgf=nsgf)
205 ALLOCATE (rmat(nsgf, nsgf))
206 rmat = 0.0_dp
207
208 CALL get_gto_basis_set(gto_basis_set=basis, nset=nset, nshell=nshell, l=lshell, &
209 first_sgf=first_sgf)
210 DO iset = 1, nset
211 DO ishell = 1, nshell(iset)
212 l = lshell(ishell, iset)
213 fs1 = first_sgf(ishell, iset)
214 fs2 = fs1 + nso(l) - 1
215 rmat(fs1:fs2, fs1:fs2) = orbrot(l)%mat(1:nso(l), 1:nso(l))
216 END DO
217 END DO
218
219 END SUBROUTINE set_rotmat_basis
220
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, ccon)
...
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.
Crystal-symmetry routines originating from the K290/ACMI code.
Definition kpsym.F:14
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, storage_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, 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.
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, do_mtlr_present, 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
Rotation matrices for basis sets.
Keeps symmetry information about a specific k-point.
Contains information about kpoints.
Provides all information about a quickstep kind.