(git:1f285aa)
gapw_1c_basis_set.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 ! **************************************************************************************************
9 !> \par History
10 !> none
11 !> \author JHU (9.2022)
12 ! **************************************************************************************************
14 
21  gto_basis_set_type
22  USE kinds, ONLY: dp
24 #include "base/base_uses.f90"
25 
26  IMPLICIT NONE
27 
28  PRIVATE
29 
30 ! *** Global parameters (only in this module)
31 
32  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gapw_1c_basis_set'
33 
34  INTEGER, PARAMETER :: max_name_length = 60
35 
36 ! *** Public subroutines ***
37 
38  PUBLIC :: create_1c_basis
39 
40 CONTAINS
41 
42 ! **************************************************************************************************
43 !> \brief create the one center basis from the orbital basis
44 !> \param orb_basis ...
45 !> \param soft_basis ...
46 !> \param gapw_1c_basis ...
47 !> \param basis_1c_level ...
48 !> \version 1.0
49 ! **************************************************************************************************
50  SUBROUTINE create_1c_basis(orb_basis, soft_basis, gapw_1c_basis, basis_1c_level)
51 
52  TYPE(gto_basis_set_type), POINTER :: orb_basis, soft_basis, gapw_1c_basis
53  INTEGER, INTENT(IN) :: basis_1c_level
54 
55  INTEGER :: i, ipgf, iset, j, l, lbas, maxl, maxlo, &
56  maxls, mp, n1, n2, nn, nseto, nsets
57  INTEGER, ALLOCATABLE, DIMENSION(:) :: nps
58  INTEGER, DIMENSION(:), POINTER :: lmaxo, lmaxs, lmino, lmins, npgfo, npgfs
59  REAL(kind=dp) :: fmin, fr1, fr2, fz, rr, xz, yz, zmall, &
60  zms, zz
61  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: z1, z2, zmaxs
62  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: zeta, zexs
63  REAL(kind=dp), DIMENSION(:, :), POINTER :: zeto, zets
64  TYPE(gto_basis_set_type), POINTER :: ext_basis, p_basis
65 
66  cpassert(.NOT. ASSOCIATED(gapw_1c_basis))
67 
68  IF (basis_1c_level == 0) THEN
69  ! we use the orbital basis set
70  CALL copy_gto_basis_set(orb_basis, gapw_1c_basis)
71  ELSE
72  CALL copy_gto_basis_set(orb_basis, gapw_1c_basis)
73  NULLIFY (ext_basis)
74  CALL allocate_gto_basis_set(ext_basis)
75  ! get information on orbital basis and soft basis
76  CALL get_gto_basis_set(gto_basis_set=orb_basis, maxl=maxlo, nset=nseto, &
77  lmin=lmino, lmax=lmaxo, npgf=npgfo, zet=zeto)
78  CALL get_gto_basis_set(gto_basis_set=soft_basis, maxl=maxls, nset=nsets, &
79  lmin=lmins, lmax=lmaxs, npgf=npgfs, zet=zets)
80  ! determine max soft exponent per l-qn
81  maxl = max(maxls, maxlo)
82  ALLOCATE (zmaxs(0:maxl), nps(0:maxl))
83  zmaxs = 0.0_dp
84  DO iset = 1, nsets
85  zms = maxval(zets(:, iset))
86  DO l = lmins(iset), lmaxs(iset)
87  zmaxs(l) = max(zmaxs(l), zms)
88  END DO
89  END DO
90  zmall = maxval(zmaxs)
91  ! in case of missing soft basis!
92  zmall = max(zmall, 0.20_dp)
93  ! create pools of exponents for each l-qn
94  nps = 0
95  DO iset = 1, nsets
96  DO l = lmins(iset), lmaxs(iset)
97  nps(l) = nps(l) + npgfs(iset)
98  END DO
99  END DO
100  mp = maxval(nps)
101  ALLOCATE (zexs(1:mp, 0:maxl))
102  zexs = 0.0_dp
103  nps = 0
104  DO iset = 1, nsets
105  DO ipgf = 1, npgfs(iset)
106  DO l = lmins(iset), lmaxs(iset)
107  nps(l) = nps(l) + 1
108  zexs(nps(l), l) = zets(ipgf, iset)
109  END DO
110  END DO
111  END DO
112 
113  SELECT CASE (basis_1c_level)
114  CASE (1)
115  lbas = maxl
116  fr1 = 2.50_dp
117  fr2 = 2.50_dp
118  CASE (2)
119  lbas = maxl
120  fr1 = 2.00_dp
121  fr2 = 2.50_dp
122  CASE (3)
123  lbas = maxl + 1
124  fr1 = 1.75_dp
125  fr2 = 2.50_dp
126  CASE (4)
127  lbas = maxl + 2
128  fr1 = 1.50_dp
129  fr2 = 2.50_dp
130  CASE DEFAULT
131  cpabort("unknown case")
132  END SELECT
133  lbas = min(lbas, 5)
134  !
135  CALL init_spherical_harmonics(lbas, 0)
136  !
137  rr = log(zmall/0.05_dp)/log(fr1)
138  n1 = int(rr) + 1
139  rr = log(zmall/0.05_dp)/log(fr2)
140  n2 = int(rr) + 1
141  ALLOCATE (z1(n1), z2(n2))
142  z1 = 0.0_dp
143  zz = zmall*sqrt(fr1)
144  DO i = 1, n1
145  z1(i) = zz/(fr1**(i - 1))
146  END DO
147  z2 = 0.0_dp
148  zz = zmall
149  DO i = 1, n2
150  z2(i) = zz/(fr2**(i - 1))
151  END DO
152  ALLOCATE (zeta(max(n1, n2), lbas + 1))
153  zeta = 0.0_dp
154  !
155  ext_basis%nset = lbas + 1
156  ALLOCATE (ext_basis%lmin(lbas + 1), ext_basis%lmax(lbas + 1))
157  ALLOCATE (ext_basis%npgf(lbas + 1))
158  DO l = 0, lbas
159  ext_basis%lmin(l + 1) = l
160  ext_basis%lmax(l + 1) = l
161  IF (l <= maxl) THEN
162  fmin = 10.0_dp
163  nn = 0
164  DO i = 1, n1
165  xz = z1(i)
166  DO j = 1, nps(l)
167  yz = zexs(j, l)
168  fz = max(xz, yz)/min(xz, yz)
169  fmin = min(fmin, fz)
170  END DO
171  IF (fmin > fr1**0.25) THEN
172  nn = nn + 1
173  zeta(nn, l + 1) = xz
174  END IF
175  END DO
176  cpassert(nn > 0)
177  ext_basis%npgf(l + 1) = nn
178  ELSE
179  ext_basis%npgf(l + 1) = n2
180  zeta(1:n2, l + 1) = z2(1:n2)
181  END IF
182  END DO
183  nn = maxval(ext_basis%npgf)
184  ALLOCATE (ext_basis%zet(nn, lbas + 1))
185  DO i = 1, lbas + 1
186  nn = ext_basis%npgf(i)
187  ext_basis%zet(1:nn, i) = zeta(1:nn, i)
188  END DO
189  ext_basis%name = "extbas"
190  ext_basis%kind_radius = orb_basis%kind_radius
191  ext_basis%short_kind_radius = orb_basis%short_kind_radius
192  ext_basis%norm_type = orb_basis%norm_type
193 
194  NULLIFY (p_basis)
195  CALL create_primitive_basis_set(ext_basis, p_basis)
196  CALL combine_basis_sets(gapw_1c_basis, p_basis)
197 
198  CALL deallocate_gto_basis_set(ext_basis)
199  CALL deallocate_gto_basis_set(p_basis)
200  DEALLOCATE (zmaxs, zexs, nps, z1, z2, zeta)
201  END IF
202 
203  END SUBROUTINE create_1c_basis
204 
205 END MODULE gapw_1c_basis_set
subroutine, public create_primitive_basis_set(basis_set, pbasis)
...
subroutine, public deallocate_gto_basis_set(gto_basis_set)
...
subroutine, public allocate_gto_basis_set(gto_basis_set)
...
subroutine, public copy_gto_basis_set(basis_set_in, basis_set_out)
...
subroutine, public combine_basis_sets(basis_set, basis_set_add)
...
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)
...
subroutine, public create_1c_basis(orb_basis, soft_basis, gapw_1c_basis, basis_1c_level)
create the one center basis from the orbital basis
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
Calculation of the spherical harmonics and the corresponding orbital transformation matrices.
subroutine, public init_spherical_harmonics(maxl, output_unit)
Initialize or update the orbital transformation matrices.