(git:374b731)
Loading...
Searching...
No Matches
atom_set_basis.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
10 USE ai_onecenter, ONLY: sg_overlap
11 USE atom_types, ONLY: cgto_basis,&
12 gto_basis,&
14 lmat
18 USE kinds, ONLY: dp
19 USE mathconstants, ONLY: dfac,&
20 twopi
24#include "./base/base_uses.f90"
25
26 IMPLICIT NONE
27
28 PRIVATE
29
30 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'atom_set_basis'
31
32 INTEGER, PARAMETER :: nua = 40, nup = 20
33 REAL(KIND=dp), DIMENSION(nua), PARAMETER :: ugbs = (/0.007299_dp, 0.013705_dp, 0.025733_dp, &
34 0.048316_dp, 0.090718_dp, 0.170333_dp, 0.319819_dp, 0.600496_dp, 1.127497_dp, 2.117000_dp, &
35 3.974902_dp, 7.463317_dp, 14.013204_dp, 26.311339_dp, 49.402449_dp, 92.758561_dp, &
36 174.164456_dp, 327.013024_dp, 614.003114_dp, 1152.858743_dp, 2164.619772_dp, &
37 4064.312984_dp, 7631.197056_dp, 14328.416324_dp, 26903.186074_dp, 50513.706789_dp, &
38 94845.070265_dp, 178082.107320_dp, 334368.848683_dp, 627814.487663_dp, 1178791.123851_dp, &
39 2213310.684886_dp, 4155735.557141_dp, 7802853.046713_dp, 14650719.428954_dp, &
40 27508345.793637_dp, 51649961.080194_dp, 96978513.342764_dp, 182087882.613702_dp, &
41 341890134.751331_dp/)
42
43 PUBLIC :: set_kind_basis_atomic
44
45! **************************************************************************************************
46
47CONTAINS
48
49! **************************************************************************************************
50!> \brief ...
51!> \param basis ...
52!> \param orb_basis_set ...
53!> \param has_pp ...
54!> \param agrid ...
55!> \param cp2k_norm ...
56! **************************************************************************************************
57 SUBROUTINE set_kind_basis_atomic(basis, orb_basis_set, has_pp, agrid, cp2k_norm)
58 TYPE(atom_basis_type), INTENT(INOUT) :: basis
59 TYPE(gto_basis_set_type), POINTER :: orb_basis_set
60 LOGICAL, INTENT(IN) :: has_pp
61 TYPE(grid_atom_type), OPTIONAL :: agrid
62 LOGICAL, INTENT(IN), OPTIONAL :: cp2k_norm
63
64 INTEGER :: i, ii, ipgf, j, k, l, m, ngp, nj, nr, &
65 ns, nset, nsgf, nu, quadtype
66 INTEGER, DIMENSION(:), POINTER :: lmax, lmin, npgf, nshell
67 INTEGER, DIMENSION(:, :), POINTER :: first_sgf, last_sgf, ls
68 LOGICAL :: has_basis, set_norm
69 REAL(kind=dp) :: al, an, cn, ear, en, rk
70 REAL(kind=dp), DIMENSION(:, :), POINTER :: zet
71 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: gcc
72 TYPE(grid_atom_type), POINTER :: grid
73
74 IF (ASSOCIATED(orb_basis_set)) THEN
75 has_basis = .true.
76 ELSE
77 has_basis = .false.
78 END IF
79
80 IF (PRESENT(cp2k_norm)) THEN
81 set_norm = cp2k_norm
82 ELSE
83 set_norm = .false.
84 END IF
85
86 NULLIFY (grid)
87 IF (PRESENT(agrid)) THEN
88 ngp = agrid%nr
89 quadtype = agrid%quadrature
90 ELSE
91 ngp = 400
92 quadtype = do_gapw_log
93 END IF
94 CALL allocate_grid_atom(grid)
95 CALL create_grid_atom(grid, ngp, 1, 1, 0, quadtype)
96 grid%nr = ngp
97 basis%grid => grid
98
99 NULLIFY (basis%am, basis%cm, basis%as, basis%ns, basis%bf, basis%dbf, basis%ddbf)
100
101 IF (has_basis) THEN
102 ! fill in the basis data structures
103 basis%basis_type = cgto_basis
104 basis%eps_eig = 1.e-12_dp
105 CALL get_gto_basis_set(orb_basis_set, &
106 nset=nset, nshell=nshell, npgf=npgf, lmin=lmin, lmax=lmax, &
107 l=ls, nsgf=nsgf, zet=zet, gcc=gcc, &
108 first_sgf=first_sgf, last_sgf=last_sgf)
109 basis%nprim = 0
110 basis%nbas = 0
111 DO i = 1, nset
112 DO j = lmin(i), min(lmax(i), lmat)
113 basis%nprim(j) = basis%nprim(j) + npgf(i)
114 END DO
115 DO j = 1, nshell(i)
116 l = ls(j, i)
117 IF (l <= lmat) THEN
118 basis%nbas(l) = basis%nbas(l) + 1
119 k = basis%nbas(l)
120 END IF
121 END DO
122 END DO
123
124 nj = maxval(basis%nprim)
125 ns = maxval(basis%nbas)
126 ALLOCATE (basis%am(nj, 0:lmat))
127 basis%am = 0._dp
128 ALLOCATE (basis%cm(nj, ns, 0:lmat))
129 basis%cm = 0._dp
130 DO j = 0, lmat
131 nj = 0
132 ns = 0
133 cn = 2.0_dp**(j + 2)/sqrt(dfac(2*j + 1))/twopi**0.25_dp
134 en = (2*j + 3)*0.25_dp
135 DO i = 1, nset
136 IF (j >= lmin(i) .AND. j <= lmax(i)) THEN
137 DO ipgf = 1, npgf(i)
138 basis%am(nj + ipgf, j) = zet(ipgf, i)
139 END DO
140 DO ii = 1, nshell(i)
141 IF (ls(ii, i) == j) THEN
142 ns = ns + 1
143 IF (set_norm) THEN
144 DO ipgf = 1, npgf(i)
145 an = cn*zet(ipgf, i)**en
146 basis%cm(nj + ipgf, ns, j) = an*gcc(ipgf, ii, i)
147 END DO
148 ELSE
149 DO ipgf = 1, npgf(i)
150 basis%cm(nj + ipgf, ns, j) = gcc(ipgf, ii, i)
151 END DO
152 END IF
153 END IF
154 END DO
155 nj = nj + npgf(i)
156 END IF
157 END DO
158 END DO
159 ! Normalization
160 IF (set_norm) THEN
161 CALL normalize_basis_cp2k(basis)
162 END IF
163 ELSE
164 ! use default basis
165 IF (has_pp) THEN
166 nu = nup
167 ELSE
168 nu = nua
169 END IF
170 basis%geometrical = .false.
171 basis%aval = 0._dp
172 basis%cval = 0._dp
173 basis%start = 0
174 basis%eps_eig = 1.e-12_dp
175
176 basis%basis_type = gto_basis
177 basis%nbas = nu
178 basis%nprim = nu
179 ALLOCATE (basis%am(nu, 0:lmat))
180 DO i = 0, lmat
181 basis%am(1:nu, i) = ugbs(1:nu)
182 END DO
183 END IF
184
185 ! initialize basis function on a radial grid
186 nr = basis%grid%nr
187 m = maxval(basis%nbas)
188 ALLOCATE (basis%bf(nr, m, 0:lmat))
189 ALLOCATE (basis%dbf(nr, m, 0:lmat))
190 ALLOCATE (basis%ddbf(nr, m, 0:lmat))
191
192 basis%bf = 0._dp
193 basis%dbf = 0._dp
194 basis%ddbf = 0._dp
195 DO l = 0, lmat
196 DO i = 1, basis%nprim(l)
197 al = basis%am(i, l)
198 IF (basis%basis_type == gto_basis) THEN
199 DO k = 1, nr
200 rk = basis%grid%rad(k)
201 ear = exp(-al*basis%grid%rad(k)**2)
202 basis%bf(k, i, l) = rk**l*ear
203 basis%dbf(k, i, l) = (real(l, dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear
204 basis%ddbf(k, i, l) = (real(l*(l - 1), dp)*rk**(l - 2) - &
205 2._dp*al*real(2*l + 1, dp)*rk**(l) + 4._dp*al*rk**(l + 2))*ear
206 END DO
207 ELSEIF (basis%basis_type == cgto_basis) THEN
208 DO k = 1, nr
209 rk = basis%grid%rad(k)
210 ear = exp(-al*basis%grid%rad(k)**2)
211 DO j = 1, basis%nbas(l)
212 basis%bf(k, j, l) = basis%bf(k, j, l) + rk**l*ear*basis%cm(i, j, l)
213 basis%dbf(k, j, l) = basis%dbf(k, j, l) &
214 + (real(l, dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear*basis%cm(i, j, l)
215 basis%ddbf(k, j, l) = basis%ddbf(k, j, l) + &
216 (real(l*(l - 1), dp)*rk**(l - 2) - 2._dp*al*real(2*l + 1, dp)*rk**(l) + &
217 4._dp*al*rk**(l + 2))*ear*basis%cm(i, j, l)
218 END DO
219 END DO
220 ELSE
221 cpabort('Atom basis type?')
222 END IF
223 END DO
224 END DO
225
226 END SUBROUTINE set_kind_basis_atomic
227
228! **************************************************************************************************
229!> \brief ...
230!> \param basis ...
231! **************************************************************************************************
232 SUBROUTINE normalize_basis_cp2k(basis)
233 TYPE(atom_basis_type), INTENT(INOUT) :: basis
234
235 INTEGER :: ii, l, n, np
236 REAL(kind=dp) :: fnorm
237 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: smat
238
239 DO l = 0, lmat
240 n = basis%nbas(l)
241 np = basis%nprim(l)
242 IF (n > 0) THEN
243 ALLOCATE (smat(np, np))
244 CALL sg_overlap(smat, l, basis%am(1:np, l), basis%am(1:np, l))
245 DO ii = 1, basis%nbas(l)
246 fnorm = dot_product(basis%cm(1:np, ii, l), matmul(smat, basis%cm(1:np, ii, l)))
247 fnorm = 1._dp/sqrt(fnorm)
248 basis%cm(1:np, ii, l) = fnorm*basis%cm(1:np, ii, l)
249 END DO
250 DEALLOCATE (smat)
251 END IF
252 END DO
253
254 END SUBROUTINE normalize_basis_cp2k
255
256! **************************************************************************************************
257
258END MODULE atom_set_basis
subroutine, public sg_overlap(smat, l, pa, pb)
...
subroutine, public set_kind_basis_atomic(basis, orb_basis_set, has_pp, agrid, cp2k_norm)
...
Define the atom type and its sub types.
Definition atom_types.F:15
integer, parameter, public cgto_basis
Definition atom_types.F:69
integer, parameter, public gto_basis
Definition atom_types.F:69
integer, parameter, public lmat
Definition atom_types.F:67
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)
...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_gapw_log
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), dimension(-1:2 *maxfac+1), parameter, public dfac
real(kind=dp), parameter, public twopi
subroutine, public allocate_grid_atom(grid_atom)
Initialize components of the grid_atom_type structure.
subroutine, public create_grid_atom(grid_atom, nr, na, llmax, ll, quadrature)
...
Provides all information about a basis set.
Definition atom_types.F:78