(git:ed6f26b)
Loading...
Searching...
No Matches
min_basis_set.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief generate or use from input minimal basis set
10!> \par History
11!> 03.2023 created [JGH]
12!> \author JGH
13! **************************************************************************************************
16 USE basis_set_types, ONLY: &
21 USE kinds, ONLY: default_string_length,&
22 dp
24 ptable
28 USE qs_kind_types, ONLY: get_qs_kind,&
30#include "./base/base_uses.f90"
31
32 IMPLICIT NONE
33 PRIVATE
34
35 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'min_basis_set'
36
37 PUBLIC :: create_minbas_set
38
39! **************************************************************************************************
40
41CONTAINS
42
43! **************************************************************************************************
44!> \brief ...
45!> \param qs_env ...
46!> \param unit_nr ...
47!> \param basis_type ...
48!> \param primitive ...
49! **************************************************************************************************
50 SUBROUTINE create_minbas_set(qs_env, unit_nr, basis_type, primitive)
51 TYPE(qs_environment_type), POINTER :: qs_env
52 INTEGER, INTENT(IN) :: unit_nr
53 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: basis_type
54 INTEGER, INTENT(IN), OPTIONAL :: primitive
55
56 CHARACTER(LEN=2) :: element_symbol
57 CHARACTER(LEN=default_string_length) :: bname, btype
58 INTEGER :: ikind, lb, mao, ne, ngau, nkind, nprim, &
59 nsgf, ub, z
60 INTEGER, DIMENSION(0:3) :: elcon
61 INTEGER, DIMENSION(:), POINTER :: econf
62 REAL(kind=dp) :: zval
63 TYPE(dft_control_type), POINTER :: dft_control
64 TYPE(gto_basis_set_type), POINTER :: pbasis, refbasis
65 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
66 TYPE(qs_kind_type), POINTER :: qs_kind
67
68 IF (PRESENT(basis_type)) THEN
69 btype = trim(basis_type)
70 ELSE
71 btype = "MIN"
72 END IF
73 IF (PRESENT(primitive)) THEN
74 nprim = primitive
75 ELSE
76 nprim = -1
77 END IF
78
79 IF (unit_nr > 0) THEN
80 WRITE (unit_nr, '(T2,A,T60,A21)') "Generate MINBAS set", adjustr(trim(btype))
81 END IF
82 ! check for or generate reference basis
83 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set)
84 CALL get_qs_env(qs_env, dft_control=dft_control)
85 nkind = SIZE(qs_kind_set)
86 DO ikind = 1, nkind
87 qs_kind => qs_kind_set(ikind)
88 CALL get_qs_kind(qs_kind, zeff=zval, elec_conf=econf, element_symbol=element_symbol)
89 CALL get_ptable_info(element_symbol, ielement=z)
90 NULLIFY (refbasis, pbasis)
91 CALL get_qs_kind(qs_kind=qs_kind, basis_set=refbasis, basis_type=btype)
92 IF (.NOT. ASSOCIATED(refbasis)) THEN
93 CALL get_qs_kind(qs_kind=qs_kind, mao=mao)
94 ! generate a minimal basis set
95 elcon = 0
96 lb = lbound(econf, 1)
97 ub = ubound(econf, 1)
98 ne = ub - lb
99 elcon(0:ne) = econf(lb:ub)
100 IF (nprim > 0) THEN
101 ngau = nprim
102 CALL create_min_basis(refbasis, z, elcon, mao, ngau)
103 CALL create_primitive_basis_set(refbasis, pbasis)
104 CALL init_interaction_radii_orb_basis(pbasis, dft_control%qs_control%eps_pgf_orb)
105 CALL add_basis_set_to_container(qs_kind%basis_sets, pbasis, btype)
106 CALL deallocate_gto_basis_set(refbasis)
107 ELSE
108 ! STO-3G
109 ngau = 3
110 CALL create_min_basis(refbasis, z, elcon, mao, ngau)
111 CALL init_interaction_radii_orb_basis(refbasis, dft_control%qs_control%eps_pgf_orb)
112 CALL add_basis_set_to_container(qs_kind%basis_sets, refbasis, btype)
113 END IF
114 CALL get_qs_kind(qs_kind=qs_kind, basis_set=refbasis, basis_type=btype)
115 END IF
116 IF (unit_nr > 0) THEN
117 CALL get_gto_basis_set(refbasis, name=bname, nsgf=nsgf)
118 WRITE (unit_nr, '(T2,A,A,T14,A,I4,T40,A,A24)') "Kind: ", element_symbol, "NBasFun: ", nsgf, &
119 "Reference Basis: ", adjustl(trim(bname))
120 END IF
121 END DO
122
123 END SUBROUTINE create_minbas_set
124
125! **************************************************************************************************
126!> \brief Creates a minimal basis set based on Slater rules
127!> \param min_basis_set ...
128!> \param zval ...
129!> \param econf ...
130!> \param mao ...
131!> \param ngau ...
132!> \par History
133!> 03.2023 created [JGH]
134! **************************************************************************************************
135 SUBROUTINE create_min_basis(min_basis_set, zval, econf, mao, ngau)
136 TYPE(gto_basis_set_type), POINTER :: min_basis_set
137 INTEGER, INTENT(IN) :: zval
138 INTEGER, DIMENSION(0:3) :: econf
139 INTEGER, INTENT(IN) :: mao, ngau
140
141 CHARACTER(len=1), DIMENSION(0:3), PARAMETER :: lnam = (/"S", "P", "D", "F"/)
142
143 CHARACTER(len=6) :: str
144 CHARACTER(len=6), DIMENSION(:), POINTER :: sym
145 CHARACTER(LEN=default_string_length) :: bname
146 INTEGER :: i, iss, l, lm, n, nmao, nn, nss
147 INTEGER, DIMENSION(0:3) :: nae, nco, npe
148 INTEGER, DIMENSION(4, 7) :: ne
149 INTEGER, DIMENSION(:), POINTER :: lq, nq
150 REAL(kind=dp), DIMENSION(:), POINTER :: zet
151 TYPE(sto_basis_set_type), POINTER :: sto_basis_set
152
153 cpassert(.NOT. ASSOCIATED(min_basis_set))
154 NULLIFY (sto_basis_set)
155
156 ! electronic configuration
157 ne = 0
158 DO l = 1, 4
159 nn = 2*(l - 1) + 1
160 DO i = l, 7
161 ne(l, i) = ptable(zval)%e_conv(l - 1) - 2*nn*(i - l)
162 ne(l, i) = max(ne(l, i), 0)
163 ne(l, i) = min(ne(l, i), 2*nn)
164 END DO
165 END DO
166 ! STO definition
167 nae = 0
168 npe = 0
169 DO l = 0, 3
170 nn = 2*(2*l + 1)
171 nae(l) = ptable(zval)%e_conv(l)/nn
172 IF (mod(ptable(zval)%e_conv(l), nn) /= 0) nae(l) = nae(l) + 1
173 npe(l) = econf(l)/nn
174 IF (mod(econf(l), nn) /= 0) npe(l) = npe(l) + 1
175 END DO
176 cpassert(all(nae - npe >= 0))
177 nco = nae - npe
178 ! MAO count
179 nmao = 0
180 DO l = 0, 3
181 nmao = nmao + npe(l)*(2*l + 1)
182 END DO
183
184 IF (mao > nmao) THEN
185 nmao = mao - nmao
186 SELECT CASE (nmao)
187 CASE (1)
188 npe(0) = npe(0) + 1
189 CASE (2)
190 npe(0) = npe(0) + 2
191 CASE (3)
192 npe(1) = npe(1) + 1
193 CASE (4)
194 npe(0) = npe(0) + 1
195 npe(1) = npe(1) + 1
196 CASE (5)
197 IF (npe(2) == 0) THEN
198 npe(2) = npe(2) + 1
199 ELSE
200 npe(0) = npe(0) + 2
201 npe(1) = npe(1) + 1
202 END IF
203 CASE (6)
204 npe(0) = npe(0) + 1
205 npe(2) = npe(2) + 1
206 CASE (7)
207 npe(0) = npe(0) + 2
208 npe(2) = npe(2) + 1
209 CASE (8)
210 npe(0) = npe(0) + 3
211 npe(2) = npe(2) + 1
212 CASE (9)
213 npe(0) = npe(0) + 1
214 npe(1) = npe(1) + 1
215 npe(2) = npe(2) + 1
216 CASE DEFAULT
217 cpabort("Default setting of minimal basis failed")
218 END SELECT
219 CALL cp_warn(__location__, "Reference basis has been adjusted according to MAO value.")
220 END IF
221
222 ! All shells should have at least 1 function
223 lm = 0
224 DO l = 0, 3
225 IF (npe(l) > 0) lm = l
226 END DO
227 DO l = 0, lm
228 IF (npe(l) == 0) npe(l) = 1
229 END DO
230
231 nss = sum(npe)
232 ALLOCATE (sym(nss), lq(nss), nq(nss), zet(nss))
233 iss = 0
234 DO l = 0, 3
235 DO i = 1, npe(l)
236 iss = iss + 1
237 lq(iss) = l
238 n = nco(l) + l
239 nq(iss) = n + i
240 str = " "
241 WRITE (str(5:5), fmt='(I1)') nq(iss)
242 str(6:6) = lnam(l)
243 sym(iss) = str
244 zet(iss) = srules(zval, ne, nq(iss), lq(iss))
245 END DO
246 END DO
247
248 bname = adjustr(ptable(zval)%symbol)//"_MBas"
249 CALL allocate_sto_basis_set(sto_basis_set)
250 CALL set_sto_basis_set(sto_basis_set, name=bname, nshell=nss, nq=nq, &
251 lq=lq, zet=zet, symbol=sym)
252 CALL create_gto_from_sto_basis(sto_basis_set, min_basis_set, ngau)
253 min_basis_set%norm_type = 2
255 CALL deallocate_sto_basis_set(sto_basis_set)
256
257 DEALLOCATE (sym, lq, nq, zet)
258
259 END SUBROUTINE create_min_basis
260
261! **************************************************************************************************
262
263END MODULE min_basis_set
subroutine, public add_basis_set_to_container(container, basis_set, basis_set_type)
...
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)
...
subroutine, public deallocate_gto_basis_set(gto_basis_set)
...
pure real(dp) function, public srules(z, ne, n, l)
...
subroutine, public deallocate_sto_basis_set(sto_basis_set)
...
subroutine, public allocate_sto_basis_set(sto_basis_set)
...
subroutine, public create_primitive_basis_set(basis_set, pbasis, lmax)
...
subroutine, public create_gto_from_sto_basis(sto_basis_set, gto_basis_set, ngauss, ortho)
...
subroutine, public set_sto_basis_set(sto_basis_set, name, nshell, symbol, nq, lq, zet)
...
subroutine, public init_orb_basis_set(gto_basis_set)
Initialise a Gaussian-type orbital (GTO) basis set data set.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
generate or use from input minimal basis set
subroutine, public create_minbas_set(qs_env, unit_nr, basis_type, primitive)
...
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
subroutine, public get_ptable_info(symbol, number, amass, ielement, covalent_radius, metallic_radius, vdw_radius, found)
Pass information about the kind given the element symbol.
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, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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)
Get the QUICKSTEP environment.
Calculate the interaction radii for the operator matrix calculation.
subroutine, public init_interaction_radii_orb_basis(orb_basis_set, eps_pgf_orb, eps_pgf_short)
...
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, 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, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Provides all information about a quickstep kind.