33#include "./base/base_uses.f90"
39 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'auto_basis'
59 INTEGER,
INTENT(IN) :: basis_cntrl
60 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
61 INTEGER,
INTENT(IN),
OPTIONAL :: basis_sort
63 CHARACTER(LEN=2) :: element_symbol
64 CHARACTER(LEN=default_string_length) :: bsname, kname
65 INTEGER :: i, j, jj, l, laux, linc, lmax, lval, lx, &
67 INTEGER,
DIMENSION(0:18) :: nval
68 INTEGER,
DIMENSION(0:9, 1:20) :: nl
69 INTEGER,
DIMENSION(1:3) :: ls1, ls2, npgf
70 INTEGER,
DIMENSION(:),
POINTER :: econf
71 REAL(kind=
dp) :: xv, zval
72 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: zet
73 REAL(kind=
dp),
DIMENSION(0:18) :: bv, bval, fv, peff, pend, pmax, pmin
74 REAL(kind=
dp),
DIMENSION(0:9) :: zeff, zmax, zmin
75 REAL(kind=
dp),
DIMENSION(3) :: amax, amin, bmin
81 bv(0:18) = [1.8_dp, 2.0_dp, 2.2_dp, 2.2_dp, 2.3_dp, 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp, &
82 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp, 3.0_dp]
83 fv(0:18) = [20.0_dp, 4.0_dp, 4.0_dp, 3.5_dp, 2.5_dp, 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp, &
84 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp, 2.0_dp]
86 cpassert(.NOT.
ASSOCIATED(ri_aux_basis_set))
87 NULLIFY (orb_basis_set, econf)
88 IF (.NOT.
PRESENT(basis_type))
THEN
89 CALL get_qs_kind(qs_kind, basis_set=orb_basis_set, basis_type=
"ORB")
91 CALL get_qs_kind(qs_kind, basis_set=orb_basis_set, basis_type=basis_type)
93 IF (
ASSOCIATED(orb_basis_set))
THEN
97 IF (sum(orb_basis_set%nsgf_set) == 0)
THEN
98 CALL cp_abort(__location__, &
99 "Cannot autocreate RI_AUX basis set for at least one of the given "// &
100 "primary basis sets due to missing exponents. If you have invoked BASIS_SET NONE, "// &
101 "you should state BASIS_SET RI_AUX NONE explicitly in the input.")
103 CALL get_basis_keyfigures(orb_basis_set, lmax, zmin, zmax, zeff)
107 CALL get_basis_products(lmax, zmin, zmax, zeff, pmin, pmax, peff)
108 CALL get_qs_kind(qs_kind, zeff=zval, elec_conf=econf, element_symbol=element_symbol)
109 IF (.NOT.
ASSOCIATED(econf))
THEN
111 CALL cp_abort(__location__, &
112 "AUTO_BASIS RI_AUX cannot process atom kind "// &
113 "<"//trim(adjustl(kname))//
"> due to missing "// &
114 "definition of potential or electron configuration; "// &
115 "consider setting keyword ELEC_CONF explicitly for "// &
116 "GHOST atom kind that has assigned a basis set")
120 DO l = 0, maxval(ubound(econf))
121 IF (econf(l) > 0) lval = l
123 IF (sum(econf) /= nint(zval))
THEN
124 cpwarn(
"Valence charge and electron configuration not consistent")
129 SELECT CASE (basis_cntrl)
131 laux = max(2*lval, lmax + linc)
133 laux = max(2*lval, lmax + linc)
135 laux = max(2*lval, lmax + linc + 1)
137 laux = max(2*lmax, lmax + linc + 2)
139 cpabort(
"Invalid value of control variable")
142 DO l = 2*lmax + 1, laux
151 IF (l <= 2*lval)
THEN
152 pend(l) = min(fv(l)*peff(l), pmax(l))
158 xv = log(pend(l)/pmin(l))/log(bval(l)) + 1.e-10_dp
159 nval(l) = max(ceiling(xv), 0)
165 DO l = lval + 1, laux
166 IF (nval(l) < nval(lval) - 1)
EXIT
170 IF (laux > ls2(1))
THEN
171 IF (lval == 0 .OR. 2*lval <= ls2(1) + 1)
THEN
178 ls2(2) = min(2*lval, laux)
181 IF (nval(l) < nval(lx) - 1)
EXIT
184 IF (laux > ls2(2))
THEN
196 DO j = ls1(i), ls2(i)
197 amax(i) = max(amax(i), pend(j))
198 amin(i) = min(amin(i), pmin(j))
199 bmin(i) = min(bmin(i), bval(j))
201 xv = log(amax(i)/amin(i))/log(bmin(i)) + 1.e-10_dp
202 npgf(i) = max(ceiling(xv), 0)
204 nx = maxval(npgf(1:nsets))
205 ALLOCATE (zet(nx, nsets))
211 zet(jj, i) = amin(i)*bmin(i)**(j - 1)
213 DO l = ls1(i), ls2(i)
217 bsname = trim(element_symbol)//
"-RI-AUX-"//trim(orb_basis_set%name)
219 CALL create_aux_basis(ri_aux_basis_set, bsname, nsets, ls1, ls2, nl, npgf, zet)
223 IF (
PRESENT(basis_sort))
THEN
241 exact_1c_terms, tda_kernel)
244 INTEGER,
INTENT(IN) :: basis_cntrl
245 LOGICAL,
INTENT(IN),
OPTIONAL :: exact_1c_terms, tda_kernel
247 CHARACTER(LEN=2) :: element_symbol
248 CHARACTER(LEN=default_string_length) :: bsname, kname
249 INTEGER :: i, j, l, laux, linc, lm, lmax, lval, n1, &
251 INTEGER,
DIMENSION(0:18) :: nval
252 INTEGER,
DIMENSION(0:9, 1:50) :: nl
253 INTEGER,
DIMENSION(1:50) :: ls1, ls2, npgf
254 INTEGER,
DIMENSION(:),
POINTER :: econf
255 LOGICAL :: e1terms, kernel_basis
256 REAL(kind=
dp) :: xv, zval
257 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: zet
258 REAL(kind=
dp),
DIMENSION(0:18) :: bval, peff, pend, pmax, pmin
259 REAL(kind=
dp),
DIMENSION(0:9) :: zeff, zmax, zmin
260 REAL(kind=
dp),
DIMENSION(4) :: bv, bx
264 IF (
PRESENT(exact_1c_terms))
THEN
265 e1terms = exact_1c_terms
269 IF (
PRESENT(tda_kernel))
THEN
270 kernel_basis = tda_kernel
272 kernel_basis = .false.
274 IF (kernel_basis .AND. e1terms)
THEN
275 CALL cp_warn(__location__,
"LRI Kernel basis generation will ignore exact 1C term option.")
278 cpassert(.NOT.
ASSOCIATED(lri_aux_basis_set))
279 NULLIFY (orb_basis_set, econf)
280 CALL get_qs_kind(qs_kind, basis_set=orb_basis_set, basis_type=
"ORB")
281 IF (
ASSOCIATED(orb_basis_set))
THEN
282 CALL get_basis_keyfigures(orb_basis_set, lmax, zmin, zmax, zeff)
283 CALL get_basis_products(lmax, zmin, zmax, zeff, pmin, pmax, peff)
284 CALL get_qs_kind(qs_kind, zeff=zval, elec_conf=econf, element_symbol=element_symbol)
285 IF (.NOT.
ASSOCIATED(econf))
THEN
287 CALL cp_abort(__location__, &
288 "AUTO_BASIS LRI_AUX cannot process atom kind "// &
289 "<"//trim(adjustl(kname))//
"> due to missing "// &
290 "definition of potential or electron configuration; "// &
291 "consider setting keyword ELEC_CONF explicitly for "// &
292 "GHOST atom kind that has assigned a basis set")
296 DO l = 0, maxval(ubound(econf))
297 IF (econf(l) > 0) lval = l
299 IF (sum(econf) /= nint(zval))
THEN
300 cpwarn(
"Valence charge and electron configuration not consistent")
306 IF (kernel_basis)
THEN
307 bv(1:4) = [3.20_dp, 2.80_dp, 2.40_dp, 2.00_dp]
308 bx(1:4) = [4.00_dp, 3.50_dp, 3.00_dp, 2.50_dp]
310 SELECT CASE (basis_cntrl)
314 laux = max(lval + 1, lmax)
316 laux = max(lval + 2, lmax + 1)
318 laux = max(lval + 3, lmax + 2)
319 laux = min(laux, 2 + linc)
321 cpabort(
"Invalid value of control variable")
324 bv(1:4) = [2.00_dp, 1.90_dp, 1.80_dp, 1.80_dp]
325 bx(1:4) = [2.60_dp, 2.40_dp, 2.20_dp, 2.20_dp]
327 SELECT CASE (basis_cntrl)
329 laux = max(2*lval, lmax + linc)
330 laux = min(laux, 2 + linc)
332 laux = max(2*lval, lmax + linc)
333 laux = min(laux, 3 + linc)
335 laux = max(2*lval, lmax + linc + 1)
336 laux = min(laux, 4 + linc)
338 laux = max(2*lval, lmax + linc + 1)
339 laux = min(laux, 4 + linc)
341 cpabort(
"Invalid value of control variable")
345 DO l = 2*lmax + 1, laux
346 pmin(l) = pmin(2*lmax)
347 pmax(l) = pmax(2*lmax)
348 peff(l) = peff(2*lmax)
352 IF (exact_1c_terms)
THEN
354 IF (l <= lval + 1)
THEN
355 pend(l) = zmax(l) + 1.0_dp
356 bval(l) = bv(basis_cntrl + 1)
358 pend(l) = 2.0_dp*peff(l)
359 bval(l) = bx(basis_cntrl + 1)
362 xv = log(pend(l)/pmin(l))/log(bval(l)) + 1.e-10_dp
363 nval(l) = max(ceiling(xv), 0)
364 bval(l) = (pend(l)/pmin(l))**(1._dp/nval(l))
368 IF (l <= lval + 1)
THEN
370 bval(l) = bv(basis_cntrl + 1)
373 pend(l) = 4.0_dp*peff(l)
374 bval(l) = bx(basis_cntrl + 1)
376 xv = log(pend(l)/pmin(l))/log(bval(l)) + 1.e-10_dp
377 nval(l) = max(ceiling(xv), 0)
378 bval(l) = (pend(l)/pmin(l))**(1._dp/nval(l))
383 n1 = maxval(nval(0:lm))
384 IF (laux < lm + 1)
THEN
387 n2 = maxval(nval(lm + 1:laux))
391 ALLOCATE (zet(1, nsets))
394 j = maxval(maxloc(nval(0:lm)))
399 zet(1, i) = pmin(j)*bval(j)**(i - 1)
409 zet(1, i) = pmin(j)*bval(j)**(i - n1 - 1)
415 bsname = trim(element_symbol)//
"-LRI-AUX-"//trim(orb_basis_set%name)
417 CALL create_aux_basis(lri_aux_basis_set, bsname, nsets, ls1, ls2, nl, npgf, zet)
433 INTEGER,
INTENT(IN) :: lmax_oce, nbas_oce
435 CHARACTER(LEN=default_string_length) :: bsname
436 INTEGER :: i, l, lmax, lx, nset, nx
437 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: lmin, lset, npgf
438 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: nl
439 INTEGER,
DIMENSION(:),
POINTER :: npgf_orb
440 REAL(kind=
dp) :: cval, x, z0, z1
441 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: zet
442 REAL(kind=
dp),
DIMENSION(0:9) :: zeff, zmax, zmin
444 CALL get_basis_keyfigures(orb_basis, lmax, zmin, zmax, zeff)
445 IF (nbas_oce < 1)
THEN
447 nx = sum(npgf_orb(1:nset))
451 nset = max(nbas_oce, nx)
452 lx = max(lmax_oce, lmax)
454 bsname =
"OCE-"//trim(orb_basis%name)
455 ALLOCATE (lmin(nset), lset(nset), nl(0:9, nset), npgf(nset), zet(1, nset))
462 z0 = minval(zmin(0:lmax))
463 z1 = maxval(zmax(0:lmax))
464 x = 1.0_dp/real(nset - 1, kind=
dp)
467 DO i = nset - 1, 1, -1
468 zet(1, i) = zet(1, i + 1)*cval
474 IF (x < z1) lset(i) = l
476 IF (lset(i) == lmax) lset(i) = lx
481 DEALLOCATE (lmin, lset, nl, npgf, zet)
492 SUBROUTINE get_basis_keyfigures(basis_set, lmax, zmin, zmax, zeff)
494 INTEGER,
INTENT(OUT) :: lmax
495 REAL(kind=
dp),
DIMENSION(0:9),
INTENT(OUT) :: zmin, zmax, zeff
497 INTEGER :: i, ipgf, iset, ishell, j, l, nset
498 INTEGER,
DIMENSION(:),
POINTER :: lm, npgf, nshell
499 INTEGER,
DIMENSION(:, :),
POINTER :: lshell
500 REAL(kind=
dp) :: aeff, gcca, gccb, kval, rexp, rint, rno, &
502 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: zet
503 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: gcc
523 DO ipgf = 1, npgf(iset)
524 DO ishell = 1, nshell(iset)
525 l = lshell(ishell, iset)
526 zeta = zet(ipgf, iset)
527 zmax(l) = max(zmax(l), zeta)
528 zmin(l) = min(zmin(l), zeta)
532 DO ishell = 1, nshell(iset)
533 l = lshell(ishell, iset)
534 kval =
fac(l + 1)**2*2._dp**(2*l + 1)/
fac(2*l + 2)
538 gcca = gcc(i, ishell, iset)
540 zeta = zet(i, iset) + zet(j, iset)
541 gccb = gcc(j, ishell, iset)
542 rint = 0.5_dp*
fac(l + 1)/zeta**(l + 2)
543 rexp = rexp + gcca*gccb*rint
544 rint =
rootpi*0.5_dp**(l + 2)*
dfac(2*l + 1)/zeta**(l + 1.5_dp)
545 rno = rno + gcca*gccb*rint
549 aeff = (
fac(l + 1)/
dfac(2*l + 1))**2*2._dp**(2*l + 1)/(
pi*rexp**2)
550 zeff(l) = max(zeff(l), aeff)
554 END SUBROUTINE get_basis_keyfigures
566 SUBROUTINE get_basis_products(lmax, zmin, zmax, zeff, pmin, pmax, peff)
567 INTEGER,
INTENT(IN) :: lmax
568 REAL(kind=
dp),
DIMENSION(0:9),
INTENT(IN) :: zmin, zmax, zeff
569 REAL(kind=
dp),
DIMENSION(0:18),
INTENT(OUT) :: pmin, pmax, peff
571 INTEGER :: l1, l2, la
579 DO la = l2 - l1, l2 + l1
580 pmax(la) = max(pmax(la), zmax(l1) + zmax(l2))
581 pmin(la) = min(pmin(la), zmin(l1) + zmin(l2))
582 peff(la) = max(peff(la), zeff(l1) + zeff(l2))
587 END SUBROUTINE get_basis_products
600 SUBROUTINE overlap_maximum(lm, npgf, nfun, zet, gcc, nfit, afit, amet, eval)
601 INTEGER,
INTENT(IN) :: lm, npgf, nfun
602 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: zet
603 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: gcc
604 INTEGER,
INTENT(IN) :: nfit
605 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: afit
606 REAL(kind=
dp),
INTENT(IN) :: amet
607 REAL(kind=
dp),
INTENT(OUT) :: eval
609 INTEGER :: i, ia, ib, info
610 REAL(kind=
dp) :: fij, fxij, intab, p, xij
611 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fx, tx, x2, xx
617 p = zet(ia) + zet(ib) + amet
618 intab = 0.5_dp/p**(lm + 1.5_dp)*
gamma1(lm + 1)
620 fij = fij + gcc(ia, i)*gcc(ib, i)*intab
626 ALLOCATE (fx(nfit, nfun), tx(nfit, nfun))
630 p = zet(ia) + afit(ib) + amet
631 intab = 0.5_dp/p**(lm + 1.5_dp)*
gamma1(lm + 1)
633 fx(ib, i) = fx(ib, i) + gcc(ia, i)*intab
639 ALLOCATE (xx(nfit, nfit), x2(nfit, nfit))
642 p = afit(ia) + afit(ib) + amet
643 xx(ia, ib) = 0.5_dp/p**(lm + 1.5_dp)*
gamma1(lm + 1)
648 tx(1:nfit, 1:nfun) = fx(1:nfit, 1:nfun)
649 x2(1:nfit, 1:nfit) = xx(1:nfit, 1:nfit)
650 CALL dposv(
"U", nfit, nfun, x2, nfit, tx, nfit, info)
655 xij = xij + dot_product(tx(:, i), matmul(xx, tx(:, i)))
660 fxij = fxij + dot_product(tx(:, i), fx(:, i))
663 eval = fij - 2.0_dp*fxij + xij
669 DEALLOCATE (fx, xx, x2, tx)
671 END SUBROUTINE overlap_maximum
678 SUBROUTINE neb_potential(x, n, eval)
679 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: x
680 INTEGER,
INTENT(IN) :: n
681 REAL(kind=
dp),
INTENT(INOUT) :: eval
686 IF (x(i) < 1.5_dp)
THEN
687 eval = eval + 10.0_dp*(1.5_dp - x(i))**2
691 END SUBROUTINE neb_potential
701 SUBROUTINE get_basis_functions(basis_set, lin, np, nf, zval, gcval)
703 INTEGER,
INTENT(IN) :: lin
704 INTEGER,
INTENT(OUT) :: np, nf
705 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: zval
706 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: gcval
708 INTEGER :: iset, ishell, j1, j2, jf, jp, l, nset
709 INTEGER,
DIMENSION(:),
POINTER :: lm, npgf, nshell
710 INTEGER,
DIMENSION(:, :),
POINTER :: lshell
712 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: zet
713 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: gcc
728 DO ishell = 1, nshell(iset)
729 l = lshell(ishell, iset)
739 ALLOCATE (zval(np), gcval(np, nf))
747 DO ishell = 1, nshell(iset)
748 l = lshell(ishell, iset)
754 zval(j1:j2) = zet(1:npgf(iset), iset)
758 gcval(j1:j2, jf) = gcc(1:npgf(iset), ishell, iset)
763 END SUBROUTINE get_basis_functions
Automatic generation of auxiliary basis sets of different kind.
subroutine, public create_lri_aux_basis_set(lri_aux_basis_set, qs_kind, basis_cntrl, exact_1c_terms, tda_kernel)
Create a LRI_AUX basis set using some heuristics.
subroutine, public create_ri_aux_basis_set(ri_aux_basis_set, qs_kind, basis_cntrl, basis_type, basis_sort)
Create a RI_AUX basis set using some heuristics.
subroutine, public create_oce_basis(oce_basis, orb_basis, lmax_oce, nbas_oce)
...
subroutine, public create_aux_basis(aux_basis, bsname, nsets, lmin, lmax, nl, npgf, zet)
create a basis in GTO form
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)
...
subroutine, public sort_gto_basis_set(basis_set, sort_method)
sort basis sets w.r.t. radius
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public stoychev2016
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Definition of mathematical constants and functions.
real(kind=dp), dimension(0:maxfac), parameter, public gamma1
real(kind=dp), parameter, public pi
real(kind=dp), dimension(-1:2 *maxfac+1), parameter, public dfac
real(kind=dp), parameter, public rootpi
real(kind=dp), dimension(0:maxfac), parameter, public fac
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
Periodic Table related data definitions.
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.
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.
Provides all information about a quickstep kind.