LCOV - code coverage report
Current view: top level - src - four_center_integral_methods.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1be8651) Lines: 98.7 % 153 151
Test Date: 2026-11-24 01:22:08 Functions: 100.0 % 3 3

            Line data    Source code
       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 Prepare and evaluate screened four-center Gaussian integrals and derivatives.
      10              : ! **************************************************************************************************
      11              : MODULE four_center_integral_methods
      12              :    USE cell_types,                      ONLY: cell_type
      13              :    USE four_center_integral_interface,  ONLY: evaluate_deriv_eri,&
      14              :                                               evaluate_eri,&
      15              :                                               four_center_integral_context_type,&
      16              :                                               prepare_four_center_batch
      17              :    USE four_center_integral_preparation,ONLY: min_image_gap_sq,&
      18              :                                               prepare_eri4_pair
      19              :    USE four_center_integral_types,      ONLY: eri4_cell_type,&
      20              :                                               eri4_contraction_type,&
      21              :                                               eri4_pgf_pair_type,&
      22              :                                               eri4_screen_coeff_type
      23              :    USE integral_library_types,          ONLY: coulomb_operator_type
      24              :    USE kinds,                           ONLY: dp,&
      25              :                                               int_8
      26              :    USE orbital_pointers,                ONLY: nco,&
      27              :                                               nso
      28              : #include "./base/base_uses.f90"
      29              : 
      30              :    IMPLICIT NONE
      31              :    PRIVATE
      32              : 
      33              :    PUBLIC :: coulomb4, forces4, min_image_gap_sq
      34              : 
      35              : CONTAINS
      36              : 
      37              : ! **************************************************************************************************
      38              : !> \brief ...
      39              : !> \param npgfa ...
      40              : !> \param npgfb ...
      41              : !> \param list ...
      42              : !> \param zeta ...
      43              : !> \param zetb ...
      44              : !> \param screen1 ...
      45              : !> \param screen2 ...
      46              : !> \param pgf ...
      47              : !> \param R_pgf ...
      48              : !> \param log10_pmax ...
      49              : !> \param log10_eps_schwarz ...
      50              : !> \param ra ...
      51              : !> \param rb ...
      52              : !> \param nelements ...
      53              : !> \param neighbor_cells ...
      54              : !> \param nimages ...
      55              : !> \param do_periodic ...
      56              : !> \param cell ...
      57              : ! **************************************************************************************************
      58     19745292 :    SUBROUTINE build_pair_list_pgf(npgfa, npgfb, list, zeta, zetb, screen1, screen2, pgf, R_pgf, &
      59              :                                   log10_pmax, log10_eps_schwarz, ra, rb, nelements, &
      60     19745292 :                                   neighbor_cells, nimages, do_periodic, cell)
      61              :       INTEGER, INTENT(IN)                                :: npgfa, npgfb
      62              :       TYPE(eri4_pgf_pair_type), DIMENSION(npgfa*npgfb)   :: list
      63              :       REAL(dp), DIMENSION(1:npgfa), INTENT(IN)           :: zeta
      64              :       REAL(dp), DIMENSION(1:npgfb), INTENT(IN)           :: zetb
      65              :       REAL(dp), INTENT(IN)                               :: screen1(2), screen2(2)
      66              :       TYPE(eri4_screen_coeff_type), DIMENSION(:, :), &
      67              :          POINTER                                         :: pgf, R_pgf
      68              :       REAL(dp), INTENT(IN)                               :: log10_pmax, log10_eps_schwarz, ra(3), &
      69              :                                                             rb(3)
      70              :       INTEGER, INTENT(OUT)                               :: nelements
      71              :       TYPE(eri4_cell_type), DIMENSION(:), POINTER        :: neighbor_cells
      72              :       INTEGER                                            :: nimages(npgfa*npgfb)
      73              :       LOGICAL, INTENT(IN)                                :: do_periodic
      74              :       TYPE(cell_type), POINTER                           :: cell
      75              : 
      76              :       REAL(dp), PARAMETER                                :: min_img_eps = 1.0E-12_dp
      77              : 
      78              :       INTEGER                                            :: element_counter, i, i_max, ipgf, j, jpgf
      79              :       REAL(dp)                                           :: AB(3), im_B(3), min_img_delta, pgf_max, &
      80              :                                                             rab2
      81              : 
      82     19745292 :       i_max = SIZE(neighbor_cells)
      83     19745292 :       IF (do_periodic) THEN
      84      7499582 :          IF (cell%orthorhombic .AND. screen1(1) <= 0.0_dp .AND. i_max > 1) THEN
      85     10973790 :             IF (ALL(cell%perd == 1) .AND. ALL(neighbor_cells(1)%cell_r == 0.0_dp)) THEN
      86      6232944 :                AB = ra - rb
      87      1558236 :                rab2 = AB(1)**2 + AB(2)**2 + AB(3)**2
      88      1558236 :                min_img_delta = min_image_gap_sq(AB, cell%hmat)
      89      1558236 :                IF (min_img_delta >= 0.0_dp) THEN
      90      1558236 :                   IF (screen1(1)*rab2 + screen1(2) + screen2(2) + log10_pmax < log10_eps_schwarz) THEN
      91            0 :                      nelements = 0
      92            0 :                      RETURN
      93              :                   END IF
      94      1558236 :                   IF (screen1(1)*(rab2 + min_img_delta)*(1.0_dp - min_img_eps) + &
      95       825064 :                       screen1(2) + screen2(2) + log10_pmax < log10_eps_schwarz) i_max = 1
      96              :                END IF
      97              :             END IF
      98              :          END IF
      99              :       ELSE
     100     12245710 :          i_max = MIN(i_max, 1)
     101              :       END IF
     102     72608271 :       nimages = 0
     103              :       ! ** inner loop may never be reached
     104     19745292 :       nelements = npgfa*npgfb
     105    113098358 :       DO i = 1, i_max
     106     93353066 :          IF (do_periodic) THEN
     107    324429424 :             im_B = rb + neighbor_cells(i)%cell_r(:)
     108              :          ELSE
     109     12245710 :             im_B = rb
     110              :          END IF
     111    373412264 :          AB = ra - im_B
     112     93353066 :          rab2 = AB(1)**2 + AB(2)**2 + AB(3)**2
     113     93353066 :          IF (screen1(1)*rab2 + screen1(2) + screen2(2) + log10_pmax < log10_eps_schwarz) CYCLE
     114              :          element_counter = 0
     115     65732117 :          DO ipgf = 1, npgfa
     116    130378992 :             DO jpgf = 1, npgfb
     117     64646875 :                element_counter = element_counter + 1
     118     64646875 :                pgf_max = pgf(jpgf, ipgf)%x(1)*rab2 + pgf(jpgf, ipgf)%x(2)
     119     64646875 :                IF (pgf_max + screen2(2) + log10_pmax < log10_eps_schwarz) THEN
     120              :                   CYCLE
     121              :                END IF
     122     54456670 :                nimages(element_counter) = nimages(element_counter) + 1
     123     54456670 :                list(element_counter)%image_list(nimages(element_counter))%pgf_max = pgf_max
     124              :                CALL prepare_eri4_pair(ra, im_B, zeta(ipgf), zetb(jpgf), rab2, &
     125     54456670 :                                       list(element_counter), list(element_counter)%image_list(nimages(element_counter)))
     126     54456670 :                IF (nimages(element_counter) == 1) THEN
     127     47042150 :                   list(element_counter)%ipgf = ipgf
     128     47042150 :                   list(element_counter)%jpgf = jpgf
     129              :                END IF
     130              : 
     131              :                list(element_counter)%image_list(nimages(element_counter))%R = &
     132    104858440 :                   MAX(0.0_dp, R_pgf(jpgf, ipgf)%x(1)*rab2 + R_pgf(jpgf, ipgf)%x(2))
     133              :             END DO
     134              :          END DO
     135    113098358 :          nelements = MAX(nelements, element_counter)
     136              :       END DO
     137     72608271 :       DO j = 1, nelements
     138     72608271 :          list(j)%nimages = nimages(j)
     139              :       END DO
     140              :       ! ** Remove unused elements
     141              : 
     142              :       element_counter = 0
     143     72608271 :       DO j = 1, nelements
     144     52862979 :          IF (list(j)%nimages == 0) CYCLE
     145     47042150 :          element_counter = element_counter + 1
     146     47042150 :          list(element_counter)%nimages = list(j)%nimages
     147     47042150 :          list(element_counter)%zetapzetb = list(j)%zetapzetb
     148     47042150 :          list(element_counter)%ZetaInv = list(j)%ZetaInv
     149     47042150 :          list(element_counter)%zeta = list(j)%zeta
     150     47042150 :          list(element_counter)%zetb = list(j)%zetb
     151     47042150 :          list(element_counter)%ipgf = list(j)%ipgf
     152     47042150 :          list(element_counter)%jpgf = list(j)%jpgf
     153    121244112 :          DO i = 1, list(j)%nimages
     154    107319649 :             list(element_counter)%image_list(i) = list(j)%image_list(i)
     155              :          END DO
     156              :       END DO
     157              : 
     158     19745292 :       nelements = element_counter
     159              : 
     160              :    END SUBROUTINE build_pair_list_pgf
     161              : 
     162              : ! **************************************************************************************************
     163              : !> \brief calculates two-electron integrals of a quartet/shell using the library
     164              : !>      lib_int in the periodic case
     165              : !> \param context four-center integral context
     166              : !> \param ra ...
     167              : !> \param rb ...
     168              : !> \param rc ...
     169              : !> \param rd ...
     170              : !> \param npgfa ...
     171              : !> \param npgfb ...
     172              : !> \param npgfc ...
     173              : !> \param npgfd ...
     174              : !> \param la_min ...
     175              : !> \param la_max ...
     176              : !> \param lb_min ...
     177              : !> \param lb_max ...
     178              : !> \param lc_min ...
     179              : !> \param lc_max ...
     180              : !> \param ld_min ...
     181              : !> \param ld_max ...
     182              : !> \param nsgfa ...
     183              : !> \param nsgfb ...
     184              : !> \param nsgfc ...
     185              : !> \param nsgfd ...
     186              : !> \param zeta ...
     187              : !> \param zetb ...
     188              : !> \param zetc ...
     189              : !> \param zetd ...
     190              : !> \param primitive_integrals array of primitive_integrals
     191              : !> \param potential_parameter contains info for libint
     192              : !> \param neighbor_cells Periodic images
     193              : !> \param screen1 set based coefficients for near field screening
     194              : !> \param screen2 set based coefficients for near field screening
     195              : !> \param eps_schwarz threshold
     196              : !> \param max_contraction_val maximum multiplication factor for cart -> sph
     197              : !> \param cart_estimate maximum calculated integral value
     198              : !> \param cell cell
     199              : !> \param neris_tmp counter for calculated cart integrals
     200              : !> \param log10_pmax logarithm of initial p matrix max element
     201              : !> \param log10_eps_schwarz log of threshold
     202              : !> \param R1_pgf coefficients for radii of product distribution function
     203              : !> \param R2_pgf coefficients for radii of product distribution function
     204              : !> \param pgf1 schwarz coefficients pgf basid
     205              : !> \param pgf2 schwarz coefficients pgf basid
     206              : !> \param pgf_list_ij ...
     207              : !> \param pgf_list_kl ...
     208              : !> \param contraction_a angular transforms and radial weights for the shell set on A
     209              : !> \param contraction_b angular transforms and radial weights for the shell set on B
     210              : !> \param contraction_c angular transforms and radial weights for the shell set on C
     211              : !> \param contraction_d angular transforms and radial weights for the shell set on D
     212              : !> \param ee_work2 ...
     213              : !> \param ee_buffer1 ...
     214              : !> \param ee_buffer2 ...
     215              : !> \param nimages ...
     216              : !> \param do_periodic ...
     217              : !> \par History
     218              : !>      11.2006 created [Manuel Guidon]
     219              : !>      02.2009 completely rewritten screening part [Manuel Guidon]
     220              : !> \author Manuel Guidon
     221              : ! **************************************************************************************************
     222      8031583 :    SUBROUTINE coulomb4(context, ra, rb, rc, rd, npgfa, npgfb, npgfc, npgfd, &
     223              :                        la_min, la_max, lb_min, lb_max, &
     224              :                        lc_min, lc_max, ld_min, ld_max, nsgfa, nsgfb, nsgfc, nsgfd, &
     225      8031583 :                        zeta, zetb, zetc, zetd, &
     226      8031583 :                        primitive_integrals, &
     227              :                        potential_parameter, neighbor_cells, &
     228              :                        screen1, screen2, eps_schwarz, max_contraction_val, &
     229              :                        cart_estimate, cell, neris_tmp, log10_pmax, &
     230              :                        log10_eps_schwarz, R1_pgf, R2_pgf, pgf1, pgf2, &
     231              :                        pgf_list_ij, pgf_list_kl, &
     232      8031583 :                        contraction_a, contraction_b, contraction_c, contraction_d, &
     233              :                        ee_work2, ee_buffer1, ee_buffer2, &
     234              :                        nimages, do_periodic)
     235              : 
     236              :       TYPE(four_center_integral_context_type), &
     237              :          INTENT(INOUT)                                   :: context
     238              :       REAL(dp), INTENT(IN)                               :: ra(3), rb(3), rc(3), rd(3)
     239              :       INTEGER, INTENT(IN)                                :: npgfa, npgfb, npgfc, npgfd, la_min, &
     240              :                                                             la_max, lb_min, lb_max, lc_min, &
     241              :                                                             lc_max, ld_min, ld_max, nsgfa, nsgfb, &
     242              :                                                             nsgfc, nsgfd
     243              :       REAL(dp), DIMENSION(1:npgfa), INTENT(IN)           :: zeta
     244              :       REAL(dp), DIMENSION(1:npgfb), INTENT(IN)           :: zetb
     245              :       REAL(dp), DIMENSION(1:npgfc), INTENT(IN)           :: zetc
     246              :       REAL(dp), DIMENSION(1:npgfd), INTENT(IN)           :: zetd
     247              :       REAL(dp), DIMENSION(nsgfa, nsgfb, nsgfc, nsgfd)    :: primitive_integrals
     248              :       TYPE(coulomb_operator_type)                        :: potential_parameter
     249              :       TYPE(eri4_cell_type), DIMENSION(:), POINTER        :: neighbor_cells
     250              :       REAL(dp), INTENT(IN)                               :: screen1(2), screen2(2), eps_schwarz, &
     251              :                                                             max_contraction_val
     252              :       REAL(dp)                                           :: cart_estimate
     253              :       TYPE(cell_type), POINTER                           :: cell
     254              :       INTEGER(int_8)                                     :: neris_tmp
     255              :       REAL(dp), INTENT(IN)                               :: log10_pmax, log10_eps_schwarz
     256              :       TYPE(eri4_screen_coeff_type), DIMENSION(:, :), &
     257              :          POINTER                                         :: R1_pgf, R2_pgf, pgf1, pgf2
     258              :       TYPE(eri4_pgf_pair_type), DIMENSION(*)             :: pgf_list_ij, pgf_list_kl
     259              :       TYPE(eri4_contraction_type), INTENT(IN)            :: contraction_a(0:), contraction_b(0:), &
     260              :                                                             contraction_c(0:), contraction_d(0:)
     261              :       REAL(dp), DIMENSION(*)                             :: ee_work2, ee_buffer1, ee_buffer2
     262              :       INTEGER, DIMENSION(*)                              :: nimages
     263              :       LOGICAL, INTENT(IN)                                :: do_periodic
     264              : 
     265              :       INTEGER :: ipgf, jpgf, kpgf, la, lb, lc, ld, list_ij, list_kl, lpgf, max_l, ncoa, ncob, &
     266              :          ncoc, ncod, nelements_ij, nelements_kl, nproducts, nsgfla, nsgflb, nsgflc, nsgfld, nsoa, &
     267              :          nsob, nsoc, nsod, s_offset_a, s_offset_b, s_offset_c, s_offset_d
     268              :       REAL(dp)                                           :: tmp_max
     269              : 
     270      8031583 :       cart_estimate = 0.0_dp
     271      8031583 :       neris_tmp = 0
     272    484546348 :       primitive_integrals = 0.0_dp
     273              : 
     274              :       CALL build_pair_list_pgf(npgfa, npgfb, pgf_list_ij, zeta, zetb, screen1, screen2, &
     275              :                                pgf1, R1_pgf, log10_pmax, log10_eps_schwarz, ra, rb, &
     276              :                                nelements_ij, &
     277      8031583 :                                neighbor_cells, nimages, do_periodic, cell)
     278      8031583 :       IF (nelements_ij == 0) RETURN
     279              :       CALL build_pair_list_pgf(npgfc, npgfd, pgf_list_kl, zetc, zetd, screen2, screen1, &
     280              :                                pgf2, R2_pgf, log10_pmax, log10_eps_schwarz, rc, rd, &
     281              :                                nelements_kl, &
     282      8031583 :                                neighbor_cells, nimages, do_periodic, cell)
     283      8031583 :       IF (nelements_kl == 0) RETURN
     284              : 
     285      8031583 :       max_l = la_max + lb_max + lc_max + ld_max
     286              : 
     287     27578285 :       DO list_ij = 1, nelements_ij
     288     19546702 :          ipgf = pgf_list_ij(list_ij)%ipgf
     289     19546702 :          jpgf = pgf_list_ij(list_ij)%jpgf
     290              : 
     291    100739713 :          DO list_kl = 1, nelements_kl
     292     73161428 :             kpgf = pgf_list_kl(list_kl)%ipgf
     293     73161428 :             lpgf = pgf_list_kl(list_kl)%jpgf
     294              : 
     295              :             CALL prepare_four_center_batch(context, pgf_list_ij(list_ij), pgf_list_kl(list_kl), &
     296              :                                            nproducts, log10_pmax, log10_eps_schwarz, neighbor_cells, cell, &
     297     73161428 :                                            potential_parameter, max_l, do_periodic, group_images=.TRUE.)
     298     73161428 :             IF (nproducts == 0) CYCLE
     299              : 
     300     65757949 :             s_offset_a = 0
     301    164296428 :             DO la = la_min, la_max
     302     78991777 :                s_offset_b = 0
     303     78991777 :                ncoa = nco(la)
     304     78991777 :                nsgfla = SIZE(contraction_a(la)%weights, 1)
     305     78991777 :                nsoa = nso(la)
     306              : 
     307    169330845 :                DO lb = lb_min, lb_max
     308     90339068 :                   s_offset_c = 0
     309     90339068 :                   ncob = nco(lb)
     310     90339068 :                   nsgflb = SIZE(contraction_b(lb)%weights, 1)
     311     90339068 :                   nsob = nso(lb)
     312              : 
     313    214703493 :                   DO lc = lc_min, lc_max
     314    124364425 :                      s_offset_d = 0
     315    124364425 :                      ncoc = nco(lc)
     316    124364425 :                      nsgflc = SIZE(contraction_c(lc)%weights, 1)
     317    124364425 :                      nsoc = nso(lc)
     318              : 
     319    292142721 :                      DO ld = ld_min, ld_max
     320    167778296 :                         ncod = nco(ld)
     321    167778296 :                         nsgfld = SIZE(contraction_d(ld)%weights, 1)
     322    167778296 :                         nsod = nso(ld)
     323              : 
     324    167778296 :                         tmp_max = 0.0_dp
     325              :                         CALL evaluate_eri(context, &
     326              :                                           la, lb, lc, ld, &
     327              :                                           ncoa, ncob, ncoc, ncod, &
     328              :                                           nsgfa, nsgfb, nsgfc, nsgfd, &
     329              :                                           primitive_integrals, &
     330              :                                           max_contraction_val, tmp_max, eps_schwarz, &
     331              :                                           neris_tmp, &
     332              :                                           s_offset_a, s_offset_b, s_offset_c, s_offset_d, &
     333              :                                           nsgfla, nsgflb, nsgflc, nsgfld, nsoa, nsob, nsoc, nsod, &
     334              :                                           contraction_a(la)%angular, contraction_b(lb)%angular, &
     335              :                                           contraction_c(lc)%angular, contraction_d(ld)%angular, &
     336              :                                           contraction_a(la)%weights(:, ipgf), contraction_b(lb)%weights(:, jpgf), &
     337              :                                           contraction_c(lc)%weights(:, kpgf), contraction_d(ld)%weights(:, lpgf), &
     338    167778296 :                                           ee_work2, ee_buffer1, ee_buffer2)
     339    167778296 :                         cart_estimate = MAX(tmp_max, cart_estimate)
     340    292142721 :                         s_offset_d = s_offset_d + nsod*nsgfld
     341              :                      END DO !ld
     342    214703493 :                      s_offset_c = s_offset_c + nsoc*nsgflc
     343              :                   END DO !lc
     344    169330845 :                   s_offset_b = s_offset_b + nsob*nsgflb
     345              :                END DO !lb
     346    152153205 :                s_offset_a = s_offset_a + nsoa*nsgfla
     347              :             END DO !la
     348              :          END DO
     349              :       END DO
     350              : 
     351              :    END SUBROUTINE coulomb4
     352              : 
     353              : ! **************************************************************************************************
     354              : !> \brief ...
     355              : !> \param context four-center integral context
     356              : !> \param ra ...
     357              : !> \param rb ...
     358              : !> \param rc ...
     359              : !> \param rd ...
     360              : !> \param npgfa ...
     361              : !> \param npgfb ...
     362              : !> \param npgfc ...
     363              : !> \param npgfd ...
     364              : !> \param la_min ...
     365              : !> \param la_max ...
     366              : !> \param lb_min ...
     367              : !> \param lb_max ...
     368              : !> \param lc_min ...
     369              : !> \param lc_max ...
     370              : !> \param ld_min ...
     371              : !> \param ld_max ...
     372              : !> \param nsgfa ...
     373              : !> \param nsgfb ...
     374              : !> \param nsgfc ...
     375              : !> \param nsgfd ...
     376              : !> \param zeta ...
     377              : !> \param zetb ...
     378              : !> \param zetc ...
     379              : !> \param zetd ...
     380              : !> \param primitive_integrals ...
     381              : !> \param potential_parameter ...
     382              : !> \param neighbor_cells ...
     383              : !> \param screen1 ...
     384              : !> \param screen2 ...
     385              : !> \param eps_schwarz ...
     386              : !> \param max_contraction_val ...
     387              : !> \param cart_estimate ...
     388              : !> \param cell ...
     389              : !> \param neris_tmp ...
     390              : !> \param log10_pmax ...
     391              : !> \param log10_eps_schwarz ...
     392              : !> \param R1_pgf ...
     393              : !> \param R2_pgf ...
     394              : !> \param pgf1 ...
     395              : !> \param pgf2 ...
     396              : !> \param pgf_list_ij ...
     397              : !> \param pgf_list_kl ...
     398              : !> \param contraction_a angular transforms and radial weights for the shell set on A
     399              : !> \param contraction_b angular transforms and radial weights for the shell set on B
     400              : !> \param contraction_c angular transforms and radial weights for the shell set on C
     401              : !> \param contraction_d angular transforms and radial weights for the shell set on D
     402              : !> \param ede_work ...
     403              : !> \param ede_work2 ...
     404              : !> \param ede_work_forces ...
     405              : !> \param ede_buffer1 ...
     406              : !> \param ede_buffer2 ...
     407              : !> \param nimages ...
     408              : !> \param do_periodic ...
     409              : !> \param use_virial ...
     410              : !> \param ede_work_virial ...
     411              : !> \param ede_work2_virial ...
     412              : !> \param primitive_integrals_virial ...
     413              : !> \param cart_estimate_virial ...
     414              : ! **************************************************************************************************
     415      1841063 :    SUBROUTINE forces4(context, ra, rb, rc, rd, npgfa, npgfb, npgfc, npgfd, &
     416              :                       la_min, la_max, lb_min, lb_max, &
     417              :                       lc_min, lc_max, ld_min, ld_max, nsgfa, nsgfb, nsgfc, nsgfd, &
     418      1841063 :                       zeta, zetb, zetc, zetd, &
     419      1841063 :                       primitive_integrals, &
     420              :                       potential_parameter, neighbor_cells, &
     421              :                       screen1, screen2, eps_schwarz, max_contraction_val, &
     422              :                       cart_estimate, cell, neris_tmp, log10_pmax, &
     423              :                       log10_eps_schwarz, R1_pgf, R2_pgf, pgf1, pgf2, &
     424              :                       pgf_list_ij, pgf_list_kl, &
     425      1841063 :                       contraction_a, contraction_b, contraction_c, contraction_d, &
     426              :                       ede_work, ede_work2, ede_work_forces, &
     427              :                       ede_buffer1, ede_buffer2, &
     428              :                       nimages, do_periodic, use_virial, ede_work_virial, &
     429      1841063 :                       ede_work2_virial, primitive_integrals_virial, &
     430              :                       cart_estimate_virial)
     431              : 
     432              :       TYPE(four_center_integral_context_type), &
     433              :          INTENT(INOUT)                                   :: context
     434              :       REAL(dp), INTENT(IN)                               :: ra(3), rb(3), rc(3), rd(3)
     435              :       INTEGER, INTENT(IN)                                :: npgfa, npgfb, npgfc, npgfd, la_min, &
     436              :                                                             la_max, lb_min, lb_max, lc_min, &
     437              :                                                             lc_max, ld_min, ld_max, nsgfa, nsgfb, &
     438              :                                                             nsgfc, nsgfd
     439              :       REAL(dp), DIMENSION(1:npgfa), INTENT(IN)           :: zeta
     440              :       REAL(dp), DIMENSION(1:npgfb), INTENT(IN)           :: zetb
     441              :       REAL(dp), DIMENSION(1:npgfc), INTENT(IN)           :: zetc
     442              :       REAL(dp), DIMENSION(1:npgfd), INTENT(IN)           :: zetd
     443              :       REAL(dp), &
     444              :          DIMENSION(nsgfa, nsgfb, nsgfc, nsgfd, 12)       :: primitive_integrals
     445              :       TYPE(coulomb_operator_type)                        :: potential_parameter
     446              :       TYPE(eri4_cell_type), DIMENSION(:), POINTER        :: neighbor_cells
     447              :       REAL(dp), INTENT(IN)                               :: screen1(2), screen2(2), eps_schwarz, &
     448              :                                                             max_contraction_val
     449              :       REAL(dp)                                           :: cart_estimate
     450              :       TYPE(cell_type), POINTER                           :: cell
     451              :       INTEGER(int_8)                                     :: neris_tmp
     452              :       REAL(dp), INTENT(IN)                               :: log10_pmax, log10_eps_schwarz
     453              :       TYPE(eri4_screen_coeff_type), DIMENSION(:, :), &
     454              :          POINTER                                         :: R1_pgf, R2_pgf, pgf1, pgf2
     455              :       TYPE(eri4_pgf_pair_type), DIMENSION(*)             :: pgf_list_ij, pgf_list_kl
     456              :       TYPE(eri4_contraction_type), INTENT(IN)            :: contraction_a(0:), contraction_b(0:), &
     457              :                                                             contraction_c(0:), contraction_d(0:)
     458              :       REAL(dp), DIMENSION(*)                             :: ede_work, ede_work2, ede_work_forces, &
     459              :                                                             ede_buffer1, ede_buffer2
     460              :       INTEGER, DIMENSION(*)                              :: nimages
     461              :       LOGICAL, INTENT(IN)                                :: do_periodic, use_virial
     462              :       REAL(dp), DIMENSION(*)                             :: ede_work_virial, ede_work2_virial
     463              :       REAL(dp), &
     464              :          DIMENSION(nsgfa, nsgfb, nsgfc, nsgfd, 12, 3)    :: primitive_integrals_virial
     465              :       REAL(dp)                                           :: cart_estimate_virial
     466              : 
     467              :       INTEGER :: ipgf, jpgf, kpgf, la, lb, lc, ld, list_ij, list_kl, lpgf, max_l, ncoa, ncob, &
     468              :          ncoc, ncod, nelements_ij, nelements_kl, nproducts, nsgfla, nsgflb, nsgflc, nsgfld, nsoa, &
     469              :          nsob, nsoc, nsod, s_offset_a, s_offset_b, s_offset_c, s_offset_d
     470              :       REAL(dp)                                           :: tmp_max, tmp_max_virial
     471              : 
     472      1841063 :       cart_estimate = 0.0_dp
     473    978201947 :       primitive_integrals = 0.0_dp
     474      1841063 :       IF (use_virial) THEN
     475    288753616 :          primitive_integrals_virial = 0.0_dp
     476       203542 :          cart_estimate_virial = 0.0_dp
     477              :       END IF
     478      1841063 :       neris_tmp = 0_int_8
     479              : 
     480              :       CALL build_pair_list_pgf(npgfa, npgfb, pgf_list_ij, zeta, zetb, screen1, screen2, &
     481              :                                pgf1, R1_pgf, log10_pmax, log10_eps_schwarz, ra, rb, &
     482              :                                nelements_ij, &
     483      1841063 :                                neighbor_cells, nimages, do_periodic, cell)
     484      1841063 :       IF (nelements_ij == 0) RETURN
     485              :       CALL build_pair_list_pgf(npgfc, npgfd, pgf_list_kl, zetc, zetd, screen2, screen1, &
     486              :                                pgf2, R2_pgf, log10_pmax, log10_eps_schwarz, rc, rd, &
     487              :                                nelements_kl, &
     488      1841063 :                                neighbor_cells, nimages, do_periodic, cell)
     489      1841063 :       IF (nelements_kl == 0) RETURN
     490              : 
     491      1841063 :       max_l = la_max + lb_max + lc_max + ld_max + 1
     492      5048129 :       DO list_ij = 1, nelements_ij
     493      3207066 :          ipgf = pgf_list_ij(list_ij)%ipgf
     494      3207066 :          jpgf = pgf_list_ij(list_ij)%jpgf
     495              : 
     496     19897260 :          DO list_kl = 1, nelements_kl
     497     14849131 :             kpgf = pgf_list_kl(list_kl)%ipgf
     498     14849131 :             lpgf = pgf_list_kl(list_kl)%jpgf
     499              : 
     500              :             CALL prepare_four_center_batch(context, pgf_list_ij(list_ij), pgf_list_kl(list_kl), &
     501              :                                            nproducts, log10_pmax, log10_eps_schwarz, neighbor_cells, cell, &
     502     14849131 :                                            potential_parameter, max_l, do_periodic, group_images=.NOT. use_virial)
     503     14849131 :             IF (nproducts == 0) CYCLE
     504     14092855 :             s_offset_a = 0
     505     34312022 :             DO la = la_min, la_max
     506     17012101 :                s_offset_b = 0
     507     17012101 :                ncoa = nco(la)
     508     17012101 :                nsgfla = SIZE(contraction_a(la)%weights, 1)
     509     17012101 :                nsoa = nso(la)
     510              : 
     511     35137170 :                DO lb = lb_min, lb_max
     512     18125069 :                   s_offset_c = 0
     513     18125069 :                   ncob = nco(lb)
     514     18125069 :                   nsgflb = SIZE(contraction_b(lb)%weights, 1)
     515     18125069 :                   nsob = nso(lb)
     516              : 
     517     44642461 :                   DO lc = lc_min, lc_max
     518     26517392 :                      s_offset_d = 0
     519     26517392 :                      ncoc = nco(lc)
     520     26517392 :                      nsgflc = SIZE(contraction_c(lc)%weights, 1)
     521     26517392 :                      nsoc = nso(lc)
     522              : 
     523     60625130 :                      DO ld = ld_min, ld_max
     524     34107738 :                         ncod = nco(ld)
     525     34107738 :                         nsgfld = SIZE(contraction_d(ld)%weights, 1)
     526     34107738 :                         nsod = nso(ld)
     527     34107738 :                         tmp_max = 0.0_dp
     528     34107738 :                         tmp_max_virial = 0.0_dp
     529              :                         CALL evaluate_deriv_eri(context, &
     530              :                                                 la, lb, lc, ld, &
     531              :                                                 ncoa, ncob, ncoc, ncod, &
     532              :                                                 nsgfa, nsgfb, nsgfc, nsgfd, &
     533              :                                                 primitive_integrals, &
     534              :                                                 max_contraction_val, tmp_max, eps_schwarz, neris_tmp, &
     535              :                                                 s_offset_a, s_offset_b, s_offset_c, s_offset_d, &
     536              :                                                 nsgfla, nsgflb, nsgflc, nsgfld, nsoa, nsob, nsoc, nsod, &
     537              :                                                 contraction_a(la)%angular, contraction_b(lb)%angular, &
     538              :                                                 contraction_c(lc)%angular, contraction_d(ld)%angular, &
     539              :                                                 contraction_a(la)%weights(:, ipgf), contraction_b(lb)%weights(:, jpgf), &
     540              :                                                 contraction_c(lc)%weights(:, kpgf), contraction_d(ld)%weights(:, lpgf), &
     541              :                                                 ede_work, ede_work2, ede_work_forces, &
     542              :                                                 ede_buffer1, ede_buffer2, use_virial, &
     543              :                                                 ede_work_virial, ede_work2_virial, &
     544     34107738 :                                                 primitive_integrals_virial, cell, tmp_max_virial)
     545     34107738 :                         cart_estimate = MAX(tmp_max, cart_estimate)
     546     34107738 :                         IF (use_virial) cart_estimate_virial = MAX(tmp_max_virial, cart_estimate_virial)
     547     60625130 :                         s_offset_d = s_offset_d + nsod*nsgfld
     548              :                      END DO !ld
     549     44642461 :                      s_offset_c = s_offset_c + nsoc*nsgflc
     550              :                   END DO !lc
     551     35137170 :                   s_offset_b = s_offset_b + nsob*nsgflb
     552              :                END DO !lb
     553     31861232 :                s_offset_a = s_offset_a + nsoa*nsgfla
     554              :             END DO !la
     555              :          END DO
     556              :       END DO
     557              : 
     558              :    END SUBROUTINE forces4
     559              : 
     560              : END MODULE four_center_integral_methods
        

Generated by: LCOV version 2.0-1