(git:f7b9015)
Loading...
Searching...
No Matches
four_center_integral_preparation.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! **************************************************************************************************
9!> \brief Gaussian-product geometry and radial seeds shared by four-center evaluation and screening.
10! **************************************************************************************************
12 USE four_center_integral_types, ONLY: eri4_fundamentals_size,&
15 eri4_pgf_product_type
18 USE kinds, ONLY: dp
19 USE mathconstants, ONLY: pi
21#include "./base/base_uses.f90"
22
23 IMPLICIT NONE
24 PRIVATE
26
27CONTAINS
28
29! **************************************************************************************************
30!> \brief Prepare one Gaussian pair, retaining the caller's image topology and screening metadata.
31!> \param ra first center
32!> \param rb second center in the selected image
33!> \param zeta first Gaussian exponent
34!> \param zetb second Gaussian exponent
35!> \param rab2 squared center distance, reusable across primitive pairs
36!> \param pair exponent data; image-list ownership is unchanged
37!> \param image product center and logarithmic Gaussian attenuation for this image
38! **************************************************************************************************
39 SUBROUTINE prepare_eri4_pair(ra, rb, zeta, zetb, rab2, pair, image)
40 REAL(dp), INTENT(IN) :: ra(3), rb(3), zeta, zetb, rab2
41 TYPE(eri4_pgf_pair_type), INTENT(INOUT) :: pair
42 TYPE(eri4_pgf_image_type), INTENT(INOUT) :: image
43
44 pair%zeta = zeta
45 pair%zetb = zetb
46 pair%zetapzetb = zeta + zetb
47 pair%ZetaInv = 1.0_dp/pair%zetapzetb
48 image%ra = ra
49 image%rb = rb
50 image%rab2 = rab2
51 image%S1234 = -zeta*zetb*pair%ZetaInv*rab2
52 image%P = (zeta*ra + zetb*rb)*pair%ZetaInv
53 END SUBROUTINE prepare_eri4_pair
54
55! **************************************************************************************************
56!> \brief Prepare the image-independent quartet data once per combination of Gaussian pairs.
57!> \param pair_a bra Gaussian pair
58!> \param pair_b ket Gaussian pair
59!> \param m_max maximum radial order, including any derivative increment
60!> \param product reusable template; centers and radial seeds are filled for each selected image
61! **************************************************************************************************
62 SUBROUTINE prepare_eri4_product(pair_a, pair_b, m_max, product)
63 TYPE(eri4_pgf_pair_type), INTENT(IN) :: pair_a, pair_b
64 INTEGER, INTENT(IN) :: m_max
65 TYPE(eri4_pgf_product_type), INTENT(INOUT) :: product
66
67 cpassert(m_max < eri4_fundamentals_size)
68
69 product%prepared_max_order = m_max
70 product%exponents = [pair_a%zeta, pair_a%zetb, pair_b%zeta, pair_b%zetb]
71 product%ZetaInv = pair_a%ZetaInv
72 product%EtaInv = pair_b%ZetaInv
73 product%ZetapEtaInv = pair_a%zetapzetb + pair_b%zetapzetb
74 product%ZetapEtaInv = 1.0_dp/product%ZetapEtaInv
75 product%Rho = pair_a%zetapzetb*pair_b%zetapzetb*product%ZetapEtaInv
76 END SUBROUTINE prepare_eri4_product
77
78! **************************************************************************************************
79!> \brief Complete a prepared quartet for one selected image, including normalized radial seeds.
80!> \param product image-independent quartet template
81!> \param image_a bra pair geometry
82!> \param image_b ket pair geometry after the caller's image translation
83!> \param attenuation exponential of the two pair logarithmic attenuations, reusable across translations
84!> \param pq2 squared product-center distance, already available from cutoff screening
85!> \param potential_parameter radial operator parameters
86!> \param params complete primitive in original center order, ready for backend permutation
87! **************************************************************************************************
88 SUBROUTINE prepare_eri4_primitive(product, image_a, image_b, attenuation, pq2, potential_parameter, params)
89 TYPE(eri4_pgf_product_type), INTENT(IN) :: product
90 TYPE(eri4_pgf_image_type), INTENT(IN) :: image_a, image_b
91 REAL(dp), INTENT(IN) :: attenuation, pq2
92 TYPE(coulomb_operator_type), INTENT(IN) :: potential_parameter
93 TYPE(eri4_pgf_product_type), INTENT(INOUT) :: params
94
95 INTEGER :: i, m_max
96 REAL(dp) :: den, fundamentals_work(eri4_fundamentals_size), g(3), normalization, num, &
97 prefactor, ssss, t
98
99 m_max = product%prepared_max_order
100 params%prepared_max_order = m_max
101 params%exponents = product%exponents
102 params%ZetaInv = product%ZetaInv
103 params%EtaInv = product%EtaInv
104 params%ZetapEtaInv = product%ZetapEtaInv
105 params%Rho = product%Rho
106 params%centers(:, 1) = image_a%ra
107 params%centers(:, 2) = image_a%rb
108 params%centers(:, 3) = image_b%ra
109 params%centers(:, 4) = image_b%rb
110 params%P = image_a%P
111 params%Q = image_b%P
112
113 associate(a => image_a%ra, b => image_a%rb, c => image_b%ra, d => image_b%rb, &
114 zeta_a => product%exponents(1), zeta_b => product%exponents(2), &
115 zeta_c => product%exponents(3), zeta_d => product%exponents(4))
116 params%W = ((zeta_a + zeta_b)*params%P + (zeta_c + zeta_d)*params%Q)*params%ZetapEtaInv
117 t = params%Rho*pq2
118 IF (potential_parameter%potential_type == do_potential_id) THEN
119 num = zeta_a*zeta_b
120 den = zeta_a + zeta_b
121 ssss = -num/den*sum((a - b)**2)
122 num = den*zeta_c
123 den = den + zeta_c
124 ssss = ssss - num/den*sum((params%P - c)**2)
125 g = (zeta_a*a + zeta_b*b + zeta_c*c)/den
126 num = den*zeta_d
127 den = den + zeta_d
128 ssss = ssss - num/den*sum((g - d)**2)
129 params%Fm(:) = exp(ssss)
130 ! The ID seed already contains the four-Gaussian attenuation.
131 normalization = 1.0_dp
132 IF (attenuation > epsilon(0.0_dp)) normalization = 1.0_dp/attenuation
133 ELSE
134 CALL compute_r12_fundamentals(params%Fm, normalization, m_max, potential_parameter%potential_type, &
135 params%Rho, t, fundamentals_work, &
136 omega=potential_parameter%omega, &
137 cutoff_radius=potential_parameter%cutoff_radius, &
138 scale_coulomb=potential_parameter%scale_coulomb, &
139 scale_longrange=potential_parameter%scale_longrange, &
140 scale_gaussian=potential_parameter%scale_gaussian)
141 END IF
142 END associate
143
144 prefactor = normalization*attenuation*sqrt((pi*params%ZetapEtaInv)**3)
145 DO i = 1, m_max + 1
146 params%Fm(i) = params%Fm(i)*prefactor
147 END DO
148 END SUBROUTINE prepare_eri4_primitive
149
Gaussian-product geometry and radial seeds shared by four-center evaluation and screening.
subroutine, public prepare_eri4_primitive(product, image_a, image_b, attenuation, pq2, potential_parameter, params)
Complete a prepared quartet for one selected image, including normalized radial seeds.
subroutine, public prepare_eri4_pair(ra, rb, zeta, zetb, rab2, pair, image)
Prepare one Gaussian pair, retaining the caller's image topology and screening metadata.
subroutine, public prepare_eri4_product(pair_a, pair_b, m_max, product)
Prepare the image-independent quartet data once per combination of Gaussian pairs.
Primitive Gaussian pairs and products for four-center integrals. The fixed radial workspace capacity ...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_potential_id
Library choices for electronic integral APIs.
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), parameter, public pi
Radial fundamentals for Gaussian two-electron integrals. Entry m+1 stores order m....
subroutine, public compute_r12_fundamentals(f, normalization, m_max, potential_type, rho, t, work, omega, cutoff_radius, scale_coulomb, scale_longrange, scale_gaussian)
Compose radial kernels before applying their common normalization.