116 log10_pmax, log10_eps_schwarz, ra, rb, nelements, &
117 neighbor_cells, do_periodic)
119 INTEGER,
INTENT(IN) :: npgfa, npgfb
120 TYPE(
bra_t),
POINTER :: bra
121 REAL(
dp),
INTENT(IN) :: screen1(2), screen2(2)
124 REAL(
dp),
INTENT(IN) :: log10_pmax, log10_eps_schwarz, ra(3), &
126 INTEGER,
INTENT(OUT) :: nelements
128 LOGICAL,
INTENT(IN) :: do_periodic
130 INTEGER :: cell_cnt, cell_idx, element_cnt, &
131 element_idx, element_off, ipgf, jpgf
132 REAL(
dp) :: ab(3), im_b(3), pgf_max, rab2
137 DO cell_idx = 1,
SIZE(neighbor_cells)
141 IF (do_periodic)
THEN
142 im_b = rb + neighbor_cells(cell_idx)%cell_r(:)
147 rab2 = ab(1)**2 + ab(2)**2 + ab(3)**2
149 IF (screen1(1)*rab2 + screen1(2) + screen2(2) + log10_pmax < log10_eps_schwarz) cycle
156 pgf_max = pgf(jpgf, ipgf)%x(1)*rab2 + pgf(jpgf, ipgf)%x(2)
157 IF (pgf_max + screen2(2) + log10_pmax < log10_eps_schwarz) cycle
159 element_idx = element_idx + 1
160 bra%pgf_idx(:, element_idx) = [ipgf, jpgf, cell_idx]
161 bra%pgf_scr(1, element_idx) = pgf_max
162 element_cnt = element_cnt + 1
167 IF (element_cnt == 0) cycle
168 cell_cnt = cell_cnt + 1
169 bra%cell_idx(:, cell_cnt) = [cell_idx, element_cnt, element_off]
170 element_off = element_off + element_cnt
173 bra%cell_cnt = cell_cnt
174 nelements = element_idx
175 bra%pgf_cnt = nelements
194 log10_pmax, log10_eps_schwarz, neighbor_cells, &
195 cell, potential_parameter, m_max, do_periodic)
199 DIMENSION(:),
INTENT(INOUT) :: product_list
200 INTEGER,
INTENT(OUT) :: nproducts
201 REAL(
dp),
INTENT(IN) :: log10_pmax, log10_eps_schwarz
205 INTEGER,
INTENT(IN) :: m_max
206 LOGICAL,
INTENT(IN) :: do_periodic
208 INTEGER :: i, j, k, l, nimages1, nimages2, tmp_i4
210 REAL(
dp) :: c11(3), den, eta, etainv, factor, fm(
prim_data_f_size), g(3), num, omega2, &
211 omega_corr, omega_corr2, p(3), pgf_max_1, pgf_max_2, pq(3), q(3), r, r1, r2, ra(3), &
212 rb(3), rc(3), rd(3), rho, rhoinv, rpq2, s1234, s1234a, s1234b, shift(3), ssss, t, &
213 temp(3), temp_cc(3), temp_dd(3), tmp, tmp_d(3), w(3), zeta1, zeta_c, zeta_d, zetapetainv
215 DIMENSION(:) :: tmp_product_list
217 nimages1 = list1%nimages
218 nimages2 = list2%nimages
220 zeta1 = list1%zetapzetb
221 eta = list2%zetapzetb
222 etainv = list2%ZetaInv
228 p = list1%image_list(i)%P
229 r1 = list1%image_list(i)%R
230 s1234a = list1%image_list(i)%S1234
231 pgf_max_1 = list1%image_list(i)%pgf_max
232 ra = list1%image_list(i)%ra
233 rb = list1%image_list(i)%rb
235 pgf_max_2 = list2%image_list(j)%pgf_max
236 IF (pgf_max_1 + pgf_max_2 + log10_pmax < log10_eps_schwarz) cycle
237 q = list2%image_list(j)%P
238 r2 = list2%image_list(j)%R
239 s1234b = list2%image_list(j)%S1234
240 rc = list2%image_list(j)%ra
241 rd = list2%image_list(j)%rb
243 zetapetainv = zeta1 + eta
244 zetapetainv = 1.0_dp/zetapetainv
245 rho = zeta1*eta*zetapetainv
247 s1234 = exp(s1234a + s1234b)
248 IF (do_periodic)
THEN
256 DO k = 1,
SIZE(neighbor_cells)
257 IF (do_periodic)
THEN
258 c11 = temp_cc + neighbor_cells(k)%cell_r(:)
259 tmp_d = temp_dd + neighbor_cells(k)%cell_r(:)
264 q = (zeta_c*c11 + zeta_d*tmp_d)*etainv
265 rpq2 = (p(1) - q(1))**2 + (p(2) - q(2))**2 + (p(3) - q(3))**2
269 IF (rpq2 > (r1 + r2 + potential_parameter%cutoff_radius)**2) cycle
272 IF (rpq2 > (r1 + r2 + potential_parameter%cutoff_radius*2.0_dp)**2) cycle
274 nproducts = nproducts + 1
278 IF (nproducts >
SIZE(product_list))
THEN
284 ALLOCATE (tmp_product_list(
SIZE(product_list)))
285 tmp_product_list(:) = product_list
286 DEALLOCATE (product_list)
287 ALLOCATE (product_list(tmp_i4))
288 product_list(1:
SIZE(tmp_product_list)) = tmp_product_list
289 DEALLOCATE (tmp_product_list)
293 SELECT CASE (potential_parameter%potential_type)
295 r = potential_parameter%cutoff_radius*sqrt(rho)
296 CALL t_c_g0_n(product_list(nproducts)%Fm(1), use_gamma, r, t, m_max)
297 IF (use_gamma)
CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
298 factor = 2.0_dp*
pi*rhoinv
300 r = potential_parameter%cutoff_radius*sqrt(rho)
301 product_list(nproducts)%Fm = 0.0_dp
303 factor = 2.0_dp*
pi*rhoinv
305 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
306 factor = 2.0_dp*
pi*rhoinv
308 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
309 omega2 = potential_parameter%omega**2
310 omega_corr2 = omega2/(omega2 + rho)
311 omega_corr = sqrt(omega_corr2)
313 CALL fgamma(m_max, t, fm)
316 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l) + fm(l)*tmp
317 tmp = tmp*omega_corr2
319 factor = 2.0_dp*
pi*rhoinv
321 omega2 = potential_parameter%omega**2
322 omega_corr2 = omega2/(omega2 + rho)
323 omega_corr = sqrt(omega_corr2)
325 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
328 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l)*tmp
329 tmp = tmp*omega_corr2
331 factor = 2.0_dp*
pi*rhoinv
333 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
334 omega2 = potential_parameter%omega**2
335 omega_corr2 = omega2/(omega2 + rho)
336 omega_corr = sqrt(omega_corr2)
338 CALL fgamma(m_max, t, fm)
341 product_list(nproducts)%Fm(l) = &
342 product_list(nproducts)%Fm(l)*potential_parameter%scale_coulomb &
343 + fm(l)*tmp*potential_parameter%scale_longrange
344 tmp = tmp*omega_corr2
346 factor = 2.0_dp*
pi*rhoinv
350 r = potential_parameter%cutoff_radius*sqrt(rho)
351 CALL t_c_g0_n(product_list(nproducts)%Fm(1), use_gamma, r, t, m_max)
352 IF (use_gamma)
CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
355 CALL fgamma(m_max, t, fm)
358 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l)* &
359 (potential_parameter%scale_coulomb + potential_parameter%scale_longrange) - &
360 fm(l)*potential_parameter%scale_longrange
364 omega2 = potential_parameter%omega**2
365 omega_corr2 = omega2/(omega2 + rho)
366 omega_corr = sqrt(omega_corr2)
368 CALL fgamma(m_max, t, fm)
371 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l) + fm(l)*tmp*potential_parameter%scale_longrange
372 tmp = tmp*omega_corr2
374 factor = 2.0_dp*
pi*rhoinv
377 omega2 = potential_parameter%omega**2
378 t = -omega2*t/(rho + omega2)
381 product_list(nproducts)%Fm(l) = exp(t)*tmp
382 tmp = tmp*omega2/(rho + omega2)
384 factor = (
pi/(rho + omega2))**(1.5_dp)
386 omega2 = potential_parameter%omega**2
387 omega_corr2 = omega2/(omega2 + rho)
388 omega_corr = sqrt(omega_corr2)
390 CALL fgamma(m_max, t, fm)
391 tmp = omega_corr*2.0_dp*
pi*rhoinv*potential_parameter%scale_longrange
394 tmp = tmp*omega_corr2
397 t = -omega2*t/(rho + omega2)
398 tmp = (
pi/(rho + omega2))**(1.5_dp)*potential_parameter%scale_gaussian
400 product_list(nproducts)%Fm(l) = exp(t)*tmp + fm(l)
401 tmp = tmp*omega2/(rho + omega2)
405 num = list1%zeta*list1%zetb
406 den = list1%zeta + list1%zetb
407 ssss = -num/den*sum((ra - rb)**2)
411 ssss = ssss - num/den*sum((p - rc)**2)
413 g(:) = (list1%zeta*ra(:) + list1%zetb*rb(:) + zeta_c*rc(:))/den
416 ssss = ssss - num/den*sum((g - rd)**2)
418 product_list(nproducts)%Fm(:) = exp(ssss)
420 IF (s1234 > epsilon(0.0_dp)) factor = 1.0_dp/s1234
423 tmp = (
pi*zetapetainv)**3
424 factor = factor*s1234*sqrt(tmp)
427 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l)*factor
430 w = (zeta1*p + eta*q)*zetapetainv
431 product_list(nproducts)%ra = ra
432 product_list(nproducts)%rb = rb
433 product_list(nproducts)%rc = c11
434 product_list(nproducts)%rd = tmp_d
435 product_list(nproducts)%ZetapEtaInv = zetapetainv
436 product_list(nproducts)%Rho = rho
437 product_list(nproducts)%RhoInv = rhoinv
438 product_list(nproducts)%P = p
439 product_list(nproducts)%Q = q
440 product_list(nproducts)%W = w
441 product_list(nproducts)%AB = ra - rb
442 product_list(nproducts)%CD = c11 - tmp_d
470 log10_pmax, log10_eps_schwarz, ra, rb, nelements, &
471 neighbor_cells, nimages, do_periodic)
472 INTEGER,
INTENT(IN) :: npgfa, npgfb
474 REAL(
dp),
DIMENSION(1:npgfa),
INTENT(IN) :: zeta
475 REAL(
dp),
DIMENSION(1:npgfb),
INTENT(IN) :: zetb
476 REAL(
dp),
INTENT(IN) :: screen1(2), screen2(2)
478 POINTER :: pgf, r_pgf
479 REAL(
dp),
INTENT(IN) :: log10_pmax, log10_eps_schwarz, ra(3), &
481 INTEGER,
INTENT(OUT) :: nelements
483 INTEGER :: nimages(npgfa*npgfb)
484 LOGICAL,
INTENT(IN) :: do_periodic
486 INTEGER :: element_counter, i, ipgf, j, jpgf
487 REAL(
dp) :: ab(3), im_b(3), pgf_max, rab2, zeta1, &
488 zeta_a, zeta_b, zetainv
492 nelements = npgfa*npgfb
493 DO i = 1,
SIZE(neighbor_cells)
494 IF (do_periodic)
THEN
495 im_b = rb + neighbor_cells(i)%cell_r(:)
500 rab2 = ab(1)**2 + ab(2)**2 + ab(3)**2
501 IF (screen1(1)*rab2 + screen1(2) + screen2(2) + log10_pmax < log10_eps_schwarz) cycle
505 element_counter = element_counter + 1
506 pgf_max = pgf(jpgf, ipgf)%x(1)*rab2 + pgf(jpgf, ipgf)%x(2)
507 IF (pgf_max + screen2(2) + log10_pmax < log10_eps_schwarz)
THEN
510 nimages(element_counter) = nimages(element_counter) + 1
511 list(element_counter)%image_list(nimages(element_counter))%pgf_max = pgf_max
512 list(element_counter)%image_list(nimages(element_counter))%ra = ra
513 list(element_counter)%image_list(nimages(element_counter))%rb = im_b
514 list(element_counter)%image_list(nimages(element_counter))%rab2 = rab2
518 zeta1 = zeta_a + zeta_b
519 zetainv = 1.0_dp/zeta1
521 IF (nimages(element_counter) == 1)
THEN
522 list(element_counter)%ipgf = ipgf
523 list(element_counter)%jpgf = jpgf
524 list(element_counter)%zetaInv = zetainv
525 list(element_counter)%zetapzetb = zeta1
526 list(element_counter)%zeta = zeta_a
527 list(element_counter)%zetb = zeta_b
530 list(element_counter)%image_list(nimages(element_counter))%S1234 = (-zeta_a*zeta_b*zetainv*rab2)
531 list(element_counter)%image_list(nimages(element_counter))%P = (zeta_a*ra + zeta_b*im_b)*zetainv
532 list(element_counter)%image_list(nimages(element_counter))%R = &
533 max(0.0_dp, r_pgf(jpgf, ipgf)%x(1)*rab2 + r_pgf(jpgf, ipgf)%x(2))
534 list(element_counter)%image_list(nimages(element_counter))%ra = ra
535 list(element_counter)%image_list(nimages(element_counter))%rb = im_b
536 list(element_counter)%image_list(nimages(element_counter))%rab2 = rab2
537 list(element_counter)%image_list(nimages(element_counter))%bcell = neighbor_cells(i)%cell
540 nelements = max(nelements, element_counter)
543 list(j)%nimages = nimages(j)
549 IF (
list(j)%nimages == 0) cycle
550 element_counter = element_counter + 1
551 list(element_counter)%nimages =
list(j)%nimages
552 list(element_counter)%zetapzetb =
list(j)%zetapzetb
553 list(element_counter)%ZetaInv =
list(j)%ZetaInv
554 list(element_counter)%zeta =
list(j)%zeta
555 list(element_counter)%zetb =
list(j)%zetb
556 list(element_counter)%ipgf =
list(j)%ipgf
557 list(element_counter)%jpgf =
list(j)%jpgf
558 DO i = 1,
list(j)%nimages
559 list(element_counter)%image_list(i) =
list(j)%image_list(i)
563 nelements = element_counter
588 SUBROUTINE build_pair_list(natom, list, set_list, i_start, i_end, j_start, j_end, kind_of, basis_parameter, particle_set, &
589 do_periodic, coeffs_set, coeffs_kind, coeffs_kind_max0, log10_eps_schwarz, cell, &
590 pmax_blocks, atomic_pair_list)
592 INTEGER,
INTENT(IN) :: natom
595 INTENT(OUT) :: set_list
596 INTEGER,
INTENT(IN) :: i_start, i_end, j_start, j_end, &
599 POINTER :: basis_parameter
601 POINTER :: particle_set
602 LOGICAL,
INTENT(IN) :: do_periodic
604 DIMENSION(:, :, :, :),
INTENT(IN),
POINTER :: coeffs_set
606 INTENT(IN) :: coeffs_kind
607 REAL(kind=
dp),
INTENT(IN) :: coeffs_kind_max0, log10_eps_schwarz
609 REAL(
dp),
INTENT(IN) :: pmax_blocks
610 LOGICAL,
DIMENSION(natom, natom),
INTENT(IN) :: atomic_pair_list
612 INTEGER :: iatom, ikind, iset, jatom, jkind, jset, &
613 n_element, nset_ij, nseta, nsetb
614 REAL(kind=
dp) :: rab2
615 REAL(kind=
dp),
DIMENSION(3) :: b11, pbc_b, ra, rb, temp
620 DO iatom = i_start, i_end
621 DO jatom = j_start, j_end
622 IF (atomic_pair_list(jatom, iatom) .EQV. .false.) cycle
624 ikind = kind_of(iatom)
625 nseta = basis_parameter(ikind)%nset
626 ra = particle_set(iatom)%r(:)
628 IF (jatom < iatom) cycle
629 jkind = kind_of(jatom)
630 nsetb = basis_parameter(jkind)%nset
631 rb = particle_set(jatom)%r(:)
633 IF (do_periodic)
THEN
635 pbc_b =
pbc(temp, cell)
637 rab2 = (ra(1) - b11(1))**2 + (ra(2) - b11(2))**2 + (ra(3) - b11(3))**2
639 rab2 = (ra(1) - rb(1))**2 + (ra(2) - rb(2))**2 + (ra(3) - rb(3))**2
642 IF ((coeffs_kind(jkind, ikind)%x(1)*rab2 + &
643 coeffs_kind(jkind, ikind)%x(2)) + coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
645 n_element = n_element + 1
646 list%elements(n_element)%pair = [iatom, jatom]
647 list%elements(n_element)%kind_pair = [ikind, jkind]
648 list%elements(n_element)%r1 = ra
649 list%elements(n_element)%r2 = b11
650 list%elements(n_element)%dist2 = rab2
652 list%elements(n_element)%set_bounds(1) = nset_ij + 1
655 IF (coeffs_set(jset, iset, jkind, ikind)%x(1)*rab2 + coeffs_set(jset, iset, jkind, ikind)%x(2) + &
656 coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
657 nset_ij = nset_ij + 1
658 set_list(nset_ij)%pair = [iset, jset]
661 list%elements(n_element)%set_bounds(2) = nset_ij
665 list%n_element = n_element
684 do_periodic, coeffs_kind, coeffs_kind_max0, log10_eps_schwarz, cell, &
686 INTEGER,
INTENT(IN) :: natom
687 LOGICAL,
DIMENSION(natom, natom) :: atomic_pair_list
688 INTEGER,
INTENT(IN) :: kind_of(*)
690 POINTER :: basis_parameter
692 POINTER :: particle_set
693 LOGICAL,
INTENT(IN) :: do_periodic
695 INTENT(IN) :: coeffs_kind
696 REAL(kind=
dp),
INTENT(IN) :: coeffs_kind_max0, log10_eps_schwarz
699 INTENT(IN),
POINTER :: blocks
701 INTEGER :: iatom, iatom_end, iatom_start, iblock, &
702 ikind, jatom, jatom_end, jatom_start, &
703 jblock, jkind, nseta, nsetb
704 REAL(kind=
dp) :: rab2
705 REAL(kind=
dp),
DIMENSION(3) :: b11, pbc_b, ra, rb, temp
707 atomic_pair_list = .false.
709 DO iblock = 1,
SIZE(blocks)
710 iatom_start = blocks(iblock)%istart
711 iatom_end = blocks(iblock)%iend
712 DO jblock = 1,
SIZE(blocks)
713 jatom_start = blocks(jblock)%istart
714 jatom_end = blocks(jblock)%iend
716 DO iatom = iatom_start, iatom_end
717 ikind = kind_of(iatom)
718 nseta = basis_parameter(ikind)%nset
719 ra = particle_set(iatom)%r(:)
720 DO jatom = jatom_start, jatom_end
721 IF (jatom < iatom) cycle
722 jkind = kind_of(jatom)
723 nsetb = basis_parameter(jkind)%nset
724 rb = particle_set(jatom)%r(:)
726 IF (do_periodic)
THEN
728 pbc_b =
pbc(temp, cell)
730 rab2 = (ra(1) - b11(1))**2 + (ra(2) - b11(2))**2 + (ra(3) - b11(3))**2
732 rab2 = (ra(1) - rb(1))**2 + (ra(2) - rb(2))**2 + (ra(3) - rb(3))**2
735 IF ((coeffs_kind(jkind, ikind)%x(1)*rab2 + &
736 coeffs_kind(jkind, ikind)%x(2)) + coeffs_kind_max0 < log10_eps_schwarz) cycle
738 atomic_pair_list(jatom, iatom) = .true.
739 atomic_pair_list(iatom, jatom) = .true.
769 SUBROUTINE build_pair_list_mp2(natom, list, set_list, i_start, i_end, j_start, j_end, kind_of, basis_parameter, particle_set, &
770 do_periodic, coeffs_set, coeffs_kind, coeffs_kind_max0, log10_eps_schwarz, cell, &
771 pmax_blocks, atomic_pair_list, skip_atom_symmetry)
773 INTEGER,
INTENT(IN) :: natom
776 INTENT(OUT) :: set_list
777 INTEGER,
INTENT(IN) :: i_start, i_end, j_start, j_end, &
780 POINTER :: basis_parameter
782 POINTER :: particle_set
783 LOGICAL,
INTENT(IN) :: do_periodic
785 DIMENSION(:, :, :, :),
INTENT(IN),
POINTER :: coeffs_set
787 INTENT(IN) :: coeffs_kind
788 REAL(kind=
dp),
INTENT(IN) :: coeffs_kind_max0, log10_eps_schwarz
790 REAL(
dp),
INTENT(IN) :: pmax_blocks
791 LOGICAL,
DIMENSION(natom, natom),
INTENT(IN) :: atomic_pair_list
792 LOGICAL,
INTENT(IN),
OPTIONAL :: skip_atom_symmetry
794 INTEGER :: iatom, ikind, iset, jatom, jkind, jset, &
795 n_element, nset_ij, nseta, nsetb
796 LOGICAL :: my_skip_atom_symmetry
797 REAL(kind=
dp) :: rab2
798 REAL(kind=
dp),
DIMENSION(3) :: b11, pbc_b, ra, rb, temp
803 my_skip_atom_symmetry = .false.
804 IF (
PRESENT(skip_atom_symmetry)) my_skip_atom_symmetry = skip_atom_symmetry
806 DO iatom = i_start, i_end
807 DO jatom = j_start, j_end
808 IF (atomic_pair_list(jatom, iatom) .EQV. .false.) cycle
810 ikind = kind_of(iatom)
811 nseta = basis_parameter(ikind)%nset
812 ra = particle_set(iatom)%r(:)
814 IF (jatom < iatom .AND. (.NOT. my_skip_atom_symmetry)) cycle
815 jkind = kind_of(jatom)
816 nsetb = basis_parameter(jkind)%nset
817 rb = particle_set(jatom)%r(:)
819 IF (do_periodic)
THEN
821 pbc_b =
pbc(temp, cell)
823 rab2 = (ra(1) - b11(1))**2 + (ra(2) - b11(2))**2 + (ra(3) - b11(3))**2
825 rab2 = (ra(1) - rb(1))**2 + (ra(2) - rb(2))**2 + (ra(3) - rb(3))**2
828 IF ((coeffs_kind(jkind, ikind)%x(1)*rab2 + &
829 coeffs_kind(jkind, ikind)%x(2)) + coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
831 n_element = n_element + 1
832 list%elements(n_element)%pair = [iatom, jatom]
833 list%elements(n_element)%kind_pair = [ikind, jkind]
834 list%elements(n_element)%r1 = ra
835 list%elements(n_element)%r2 = b11
836 list%elements(n_element)%dist2 = rab2
838 list%elements(n_element)%set_bounds(1) = nset_ij + 1
841 IF (coeffs_set(jset, iset, jkind, ikind)%x(1)*rab2 + coeffs_set(jset, iset, jkind, ikind)%x(2) + &
842 coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
843 nset_ij = nset_ij + 1
844 set_list(nset_ij)%pair = [iset, jset]
847 list%elements(n_element)%set_bounds(2) = nset_ij
851 list%n_element = n_element