67 log10_pmax, log10_eps_schwarz, neighbor_cells, &
68 cell, potential_parameter, m_max, do_periodic)
72 DIMENSION(:),
INTENT(INOUT) :: product_list
73 INTEGER,
INTENT(OUT) :: nproducts
74 REAL(
dp),
INTENT(IN) :: log10_pmax, log10_eps_schwarz
78 INTEGER,
INTENT(IN) :: m_max
79 LOGICAL,
INTENT(IN) :: do_periodic
81 INTEGER :: i, j, k, l, nimages1, nimages2, tmp_i4
83 REAL(
dp) :: c11(3), den, eta, etainv, factor, fm(
prim_data_f_size), g(3), num, omega2, &
84 omega_corr, omega_corr2, p(3), pgf_max_1, pgf_max_2, pq(3), q(3), r, r1, r2, ra(3), &
85 rb(3), rc(3), rd(3), rho, rhoinv, rpq2, s1234, s1234a, s1234b, shift(3), ssss, t, &
86 temp(3), temp_cc(3), temp_dd(3), tmp, tmp_d(3), w(3), zeta1, zeta_c, zeta_d, zetapetainv
88 DIMENSION(:) :: tmp_product_list
90 nimages1 = list1%nimages
91 nimages2 = list2%nimages
93 zeta1 = list1%zetapzetb
95 etainv = list2%ZetaInv
101 p = list1%image_list(i)%P
102 r1 = list1%image_list(i)%R
103 s1234a = list1%image_list(i)%S1234
104 pgf_max_1 = list1%image_list(i)%pgf_max
105 ra = list1%image_list(i)%ra
106 rb = list1%image_list(i)%rb
108 pgf_max_2 = list2%image_list(j)%pgf_max
109 IF (pgf_max_1 + pgf_max_2 + log10_pmax < log10_eps_schwarz) cycle
110 q = list2%image_list(j)%P
111 r2 = list2%image_list(j)%R
112 s1234b = list2%image_list(j)%S1234
113 rc = list2%image_list(j)%ra
114 rd = list2%image_list(j)%rb
116 zetapetainv = zeta1 + eta
117 zetapetainv = 1.0_dp/zetapetainv
118 rho = zeta1*eta*zetapetainv
120 s1234 = exp(s1234a + s1234b)
121 IF (do_periodic)
THEN
129 DO k = 1,
SIZE(neighbor_cells)
130 IF (do_periodic)
THEN
131 c11 = temp_cc + neighbor_cells(k)%cell_r(:)
132 tmp_d = temp_dd + neighbor_cells(k)%cell_r(:)
137 q = (zeta_c*c11 + zeta_d*tmp_d)*etainv
138 rpq2 = (p(1) - q(1))**2 + (p(2) - q(2))**2 + (p(3) - q(3))**2
142 IF (rpq2 > (r1 + r2 + potential_parameter%cutoff_radius)**2) cycle
145 IF (rpq2 > (r1 + r2 + potential_parameter%cutoff_radius*2.0_dp)**2) cycle
147 nproducts = nproducts + 1
151 IF (nproducts >
SIZE(product_list))
THEN
157 ALLOCATE (tmp_product_list(
SIZE(product_list)))
158 tmp_product_list(:) = product_list
159 DEALLOCATE (product_list)
160 ALLOCATE (product_list(tmp_i4))
161 product_list(1:
SIZE(tmp_product_list)) = tmp_product_list
162 DEALLOCATE (tmp_product_list)
166 SELECT CASE (potential_parameter%potential_type)
168 r = potential_parameter%cutoff_radius*sqrt(rho)
169 CALL t_c_g0_n(product_list(nproducts)%Fm(1), use_gamma, r, t, m_max)
170 IF (use_gamma)
CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
171 factor = 2.0_dp*
pi*rhoinv
173 r = potential_parameter%cutoff_radius*sqrt(rho)
174 product_list(nproducts)%Fm = 0.0_dp
176 factor = 2.0_dp*
pi*rhoinv
178 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
179 factor = 2.0_dp*
pi*rhoinv
181 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
182 omega2 = potential_parameter%omega**2
183 omega_corr2 = omega2/(omega2 + rho)
184 omega_corr = sqrt(omega_corr2)
186 CALL fgamma(m_max, t, fm)
189 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l) + fm(l)*tmp
190 tmp = tmp*omega_corr2
192 factor = 2.0_dp*
pi*rhoinv
194 omega2 = potential_parameter%omega**2
195 omega_corr2 = omega2/(omega2 + rho)
196 omega_corr = sqrt(omega_corr2)
198 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
201 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l)*tmp
202 tmp = tmp*omega_corr2
204 factor = 2.0_dp*
pi*rhoinv
206 CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
207 omega2 = potential_parameter%omega**2
208 omega_corr2 = omega2/(omega2 + rho)
209 omega_corr = sqrt(omega_corr2)
211 CALL fgamma(m_max, t, fm)
214 product_list(nproducts)%Fm(l) = &
215 product_list(nproducts)%Fm(l)*potential_parameter%scale_coulomb &
216 + fm(l)*tmp*potential_parameter%scale_longrange
217 tmp = tmp*omega_corr2
219 factor = 2.0_dp*
pi*rhoinv
223 r = potential_parameter%cutoff_radius*sqrt(rho)
224 CALL t_c_g0_n(product_list(nproducts)%Fm(1), use_gamma, r, t, m_max)
225 IF (use_gamma)
CALL fgamma(m_max, t, product_list(nproducts)%Fm(1))
228 CALL fgamma(m_max, t, fm)
231 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l)* &
232 (potential_parameter%scale_coulomb + potential_parameter%scale_longrange) - &
233 fm(l)*potential_parameter%scale_longrange
237 omega2 = potential_parameter%omega**2
238 omega_corr2 = omega2/(omega2 + rho)
239 omega_corr = sqrt(omega_corr2)
241 CALL fgamma(m_max, t, fm)
244 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l) + fm(l)*tmp*potential_parameter%scale_longrange
245 tmp = tmp*omega_corr2
247 factor = 2.0_dp*
pi*rhoinv
250 omega2 = potential_parameter%omega**2
251 t = -omega2*t/(rho + omega2)
254 product_list(nproducts)%Fm(l) = exp(t)*tmp
255 tmp = tmp*omega2/(rho + omega2)
257 factor = (
pi/(rho + omega2))**(1.5_dp)
259 omega2 = potential_parameter%omega**2
260 omega_corr2 = omega2/(omega2 + rho)
261 omega_corr = sqrt(omega_corr2)
263 CALL fgamma(m_max, t, fm)
264 tmp = omega_corr*2.0_dp*
pi*rhoinv*potential_parameter%scale_longrange
267 tmp = tmp*omega_corr2
270 t = -omega2*t/(rho + omega2)
271 tmp = (
pi/(rho + omega2))**(1.5_dp)*potential_parameter%scale_gaussian
273 product_list(nproducts)%Fm(l) = exp(t)*tmp + fm(l)
274 tmp = tmp*omega2/(rho + omega2)
278 num = list1%zeta*list1%zetb
279 den = list1%zeta + list1%zetb
280 ssss = -num/den*sum((ra - rb)**2)
284 ssss = ssss - num/den*sum((p - rc)**2)
286 g(:) = (list1%zeta*ra(:) + list1%zetb*rb(:) + zeta_c*rc(:))/den
289 ssss = ssss - num/den*sum((g - rd)**2)
291 product_list(nproducts)%Fm(:) = exp(ssss)
293 IF (s1234 > epsilon(0.0_dp)) factor = 1.0_dp/s1234
296 tmp = (
pi*zetapetainv)**3
297 factor = factor*s1234*sqrt(tmp)
300 product_list(nproducts)%Fm(l) = product_list(nproducts)%Fm(l)*factor
303 w = (zeta1*p + eta*q)*zetapetainv
304 product_list(nproducts)%ra = ra
305 product_list(nproducts)%rb = rb
306 product_list(nproducts)%rc = c11
307 product_list(nproducts)%rd = tmp_d
308 product_list(nproducts)%ZetapEtaInv = zetapetainv
309 product_list(nproducts)%Rho = rho
310 product_list(nproducts)%RhoInv = rhoinv
311 product_list(nproducts)%P = p
312 product_list(nproducts)%Q = q
313 product_list(nproducts)%W = w
314 product_list(nproducts)%AB = ra - rb
315 product_list(nproducts)%CD = c11 - tmp_d
343 log10_pmax, log10_eps_schwarz, ra, rb, nelements, &
344 neighbor_cells, nimages, do_periodic)
345 INTEGER,
INTENT(IN) :: npgfa, npgfb
347 REAL(
dp),
DIMENSION(1:npgfa),
INTENT(IN) :: zeta
348 REAL(
dp),
DIMENSION(1:npgfb),
INTENT(IN) :: zetb
349 REAL(
dp),
INTENT(IN) :: screen1(2), screen2(2)
351 POINTER :: pgf, r_pgf
352 REAL(
dp),
INTENT(IN) :: log10_pmax, log10_eps_schwarz, ra(3), &
354 INTEGER,
INTENT(OUT) :: nelements
356 INTEGER :: nimages(npgfa*npgfb)
357 LOGICAL,
INTENT(IN) :: do_periodic
359 INTEGER :: element_counter, i, ipgf, j, jpgf
360 REAL(
dp) :: ab(3), im_b(3), pgf_max, rab2, zeta1, &
361 zeta_a, zeta_b, zetainv
365 nelements = npgfa*npgfb
366 DO i = 1,
SIZE(neighbor_cells)
367 IF (do_periodic)
THEN
368 im_b = rb + neighbor_cells(i)%cell_r(:)
373 rab2 = ab(1)**2 + ab(2)**2 + ab(3)**2
374 IF (screen1(1)*rab2 + screen1(2) + screen2(2) + log10_pmax < log10_eps_schwarz) cycle
378 element_counter = element_counter + 1
379 pgf_max = pgf(jpgf, ipgf)%x(1)*rab2 + pgf(jpgf, ipgf)%x(2)
380 IF (pgf_max + screen2(2) + log10_pmax < log10_eps_schwarz)
THEN
383 nimages(element_counter) = nimages(element_counter) + 1
384 list(element_counter)%image_list(nimages(element_counter))%pgf_max = pgf_max
385 list(element_counter)%image_list(nimages(element_counter))%ra = ra
386 list(element_counter)%image_list(nimages(element_counter))%rb = im_b
387 list(element_counter)%image_list(nimages(element_counter))%rab2 = rab2
391 zeta1 = zeta_a + zeta_b
392 zetainv = 1.0_dp/zeta1
394 IF (nimages(element_counter) == 1)
THEN
395 list(element_counter)%ipgf = ipgf
396 list(element_counter)%jpgf = jpgf
397 list(element_counter)%zetaInv = zetainv
398 list(element_counter)%zetapzetb = zeta1
399 list(element_counter)%zeta = zeta_a
400 list(element_counter)%zetb = zeta_b
403 list(element_counter)%image_list(nimages(element_counter))%S1234 = (-zeta_a*zeta_b*zetainv*rab2)
404 list(element_counter)%image_list(nimages(element_counter))%P = (zeta_a*ra + zeta_b*im_b)*zetainv
405 list(element_counter)%image_list(nimages(element_counter))%R = &
406 max(0.0_dp, r_pgf(jpgf, ipgf)%x(1)*rab2 + r_pgf(jpgf, ipgf)%x(2))
407 list(element_counter)%image_list(nimages(element_counter))%ra = ra
408 list(element_counter)%image_list(nimages(element_counter))%rb = im_b
409 list(element_counter)%image_list(nimages(element_counter))%rab2 = rab2
410 list(element_counter)%image_list(nimages(element_counter))%bcell = neighbor_cells(i)%cell
413 nelements = max(nelements, element_counter)
416 list(j)%nimages = nimages(j)
422 IF (
list(j)%nimages == 0) cycle
423 element_counter = element_counter + 1
424 list(element_counter)%nimages =
list(j)%nimages
425 list(element_counter)%zetapzetb =
list(j)%zetapzetb
426 list(element_counter)%ZetaInv =
list(j)%ZetaInv
427 list(element_counter)%zeta =
list(j)%zeta
428 list(element_counter)%zetb =
list(j)%zetb
429 list(element_counter)%ipgf =
list(j)%ipgf
430 list(element_counter)%jpgf =
list(j)%jpgf
431 DO i = 1,
list(j)%nimages
432 list(element_counter)%image_list(i) =
list(j)%image_list(i)
436 nelements = element_counter
461 SUBROUTINE build_pair_list(natom, list, set_list, i_start, i_end, j_start, j_end, kind_of, basis_parameter, particle_set, &
462 do_periodic, coeffs_set, coeffs_kind, coeffs_kind_max0, log10_eps_schwarz, cell, &
463 pmax_blocks, atomic_pair_list)
465 INTEGER,
INTENT(IN) :: natom
468 INTENT(OUT) :: set_list
469 INTEGER,
INTENT(IN) :: i_start, i_end, j_start, j_end, &
472 POINTER :: basis_parameter
474 POINTER :: particle_set
475 LOGICAL,
INTENT(IN) :: do_periodic
477 DIMENSION(:, :, :, :),
INTENT(IN),
POINTER :: coeffs_set
479 INTENT(IN) :: coeffs_kind
480 REAL(kind=
dp),
INTENT(IN) :: coeffs_kind_max0, log10_eps_schwarz
482 REAL(
dp),
INTENT(IN) :: pmax_blocks
483 LOGICAL,
DIMENSION(natom, natom),
INTENT(IN) :: atomic_pair_list
485 INTEGER :: iatom, ikind, iset, jatom, jkind, jset, &
486 n_element, nset_ij, nseta, nsetb
487 REAL(kind=
dp) :: rab2
488 REAL(kind=
dp),
DIMENSION(3) :: b11, pbc_b, ra, rb, temp
493 DO iatom = i_start, i_end
494 DO jatom = j_start, j_end
495 IF (atomic_pair_list(jatom, iatom) .EQV. .false.) cycle
497 ikind = kind_of(iatom)
498 nseta = basis_parameter(ikind)%nset
499 ra = particle_set(iatom)%r(:)
501 IF (jatom < iatom) cycle
502 jkind = kind_of(jatom)
503 nsetb = basis_parameter(jkind)%nset
504 rb = particle_set(jatom)%r(:)
506 IF (do_periodic)
THEN
508 pbc_b =
pbc(temp, cell)
510 rab2 = (ra(1) - b11(1))**2 + (ra(2) - b11(2))**2 + (ra(3) - b11(3))**2
512 rab2 = (ra(1) - rb(1))**2 + (ra(2) - rb(2))**2 + (ra(3) - rb(3))**2
515 IF ((coeffs_kind(jkind, ikind)%x(1)*rab2 + &
516 coeffs_kind(jkind, ikind)%x(2)) + coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
518 n_element = n_element + 1
519 list%elements(n_element)%pair = (/iatom, jatom/)
520 list%elements(n_element)%kind_pair = (/ikind, jkind/)
521 list%elements(n_element)%r1 = ra
522 list%elements(n_element)%r2 = b11
523 list%elements(n_element)%dist2 = rab2
525 list%elements(n_element)%set_bounds(1) = nset_ij + 1
528 IF (coeffs_set(jset, iset, jkind, ikind)%x(1)*rab2 + coeffs_set(jset, iset, jkind, ikind)%x(2) + &
529 coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
530 nset_ij = nset_ij + 1
531 set_list(nset_ij)%pair = (/iset, jset/)
534 list%elements(n_element)%set_bounds(2) = nset_ij
538 list%n_element = n_element
557 do_periodic, coeffs_kind, coeffs_kind_max0, log10_eps_schwarz, cell, &
559 INTEGER,
INTENT(IN) :: natom
560 LOGICAL,
DIMENSION(natom, natom) :: atomic_pair_list
561 INTEGER,
INTENT(IN) :: kind_of(*)
563 POINTER :: basis_parameter
565 POINTER :: particle_set
566 LOGICAL,
INTENT(IN) :: do_periodic
568 INTENT(IN) :: coeffs_kind
569 REAL(kind=
dp),
INTENT(IN) :: coeffs_kind_max0, log10_eps_schwarz
572 INTENT(IN),
POINTER :: blocks
574 INTEGER :: iatom, iatom_end, iatom_start, iblock, &
575 ikind, jatom, jatom_end, jatom_start, &
576 jblock, jkind, nseta, nsetb
577 REAL(kind=
dp) :: rab2
578 REAL(kind=
dp),
DIMENSION(3) :: b11, pbc_b, ra, rb, temp
580 atomic_pair_list = .false.
582 DO iblock = 1,
SIZE(blocks)
583 iatom_start = blocks(iblock)%istart
584 iatom_end = blocks(iblock)%iend
585 DO jblock = 1,
SIZE(blocks)
586 jatom_start = blocks(jblock)%istart
587 jatom_end = blocks(jblock)%iend
589 DO iatom = iatom_start, iatom_end
590 ikind = kind_of(iatom)
591 nseta = basis_parameter(ikind)%nset
592 ra = particle_set(iatom)%r(:)
593 DO jatom = jatom_start, jatom_end
594 IF (jatom < iatom) cycle
595 jkind = kind_of(jatom)
596 nsetb = basis_parameter(jkind)%nset
597 rb = particle_set(jatom)%r(:)
599 IF (do_periodic)
THEN
601 pbc_b =
pbc(temp, cell)
603 rab2 = (ra(1) - b11(1))**2 + (ra(2) - b11(2))**2 + (ra(3) - b11(3))**2
605 rab2 = (ra(1) - rb(1))**2 + (ra(2) - rb(2))**2 + (ra(3) - rb(3))**2
608 IF ((coeffs_kind(jkind, ikind)%x(1)*rab2 + &
609 coeffs_kind(jkind, ikind)%x(2)) + coeffs_kind_max0 < log10_eps_schwarz) cycle
611 atomic_pair_list(jatom, iatom) = .true.
612 atomic_pair_list(iatom, jatom) = .true.
642 SUBROUTINE build_pair_list_mp2(natom, list, set_list, i_start, i_end, j_start, j_end, kind_of, basis_parameter, particle_set, &
643 do_periodic, coeffs_set, coeffs_kind, coeffs_kind_max0, log10_eps_schwarz, cell, &
644 pmax_blocks, atomic_pair_list, skip_atom_symmetry)
646 INTEGER,
INTENT(IN) :: natom
649 INTENT(OUT) :: set_list
650 INTEGER,
INTENT(IN) :: i_start, i_end, j_start, j_end, &
653 POINTER :: basis_parameter
655 POINTER :: particle_set
656 LOGICAL,
INTENT(IN) :: do_periodic
658 DIMENSION(:, :, :, :),
INTENT(IN),
POINTER :: coeffs_set
660 INTENT(IN) :: coeffs_kind
661 REAL(kind=
dp),
INTENT(IN) :: coeffs_kind_max0, log10_eps_schwarz
663 REAL(
dp),
INTENT(IN) :: pmax_blocks
664 LOGICAL,
DIMENSION(natom, natom),
INTENT(IN) :: atomic_pair_list
665 LOGICAL,
INTENT(IN),
OPTIONAL :: skip_atom_symmetry
667 INTEGER :: iatom, ikind, iset, jatom, jkind, jset, &
668 n_element, nset_ij, nseta, nsetb
669 LOGICAL :: my_skip_atom_symmetry
670 REAL(kind=
dp) :: rab2
671 REAL(kind=
dp),
DIMENSION(3) :: b11, pbc_b, ra, rb, temp
676 my_skip_atom_symmetry = .false.
677 IF (
PRESENT(skip_atom_symmetry)) my_skip_atom_symmetry = skip_atom_symmetry
679 DO iatom = i_start, i_end
680 DO jatom = j_start, j_end
681 IF (atomic_pair_list(jatom, iatom) .EQV. .false.) cycle
683 ikind = kind_of(iatom)
684 nseta = basis_parameter(ikind)%nset
685 ra = particle_set(iatom)%r(:)
687 IF (jatom < iatom .AND. (.NOT. my_skip_atom_symmetry)) cycle
688 jkind = kind_of(jatom)
689 nsetb = basis_parameter(jkind)%nset
690 rb = particle_set(jatom)%r(:)
692 IF (do_periodic)
THEN
694 pbc_b =
pbc(temp, cell)
696 rab2 = (ra(1) - b11(1))**2 + (ra(2) - b11(2))**2 + (ra(3) - b11(3))**2
698 rab2 = (ra(1) - rb(1))**2 + (ra(2) - rb(2))**2 + (ra(3) - rb(3))**2
701 IF ((coeffs_kind(jkind, ikind)%x(1)*rab2 + &
702 coeffs_kind(jkind, ikind)%x(2)) + coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
704 n_element = n_element + 1
705 list%elements(n_element)%pair = (/iatom, jatom/)
706 list%elements(n_element)%kind_pair = (/ikind, jkind/)
707 list%elements(n_element)%r1 = ra
708 list%elements(n_element)%r2 = b11
709 list%elements(n_element)%dist2 = rab2
711 list%elements(n_element)%set_bounds(1) = nset_ij + 1
714 IF (coeffs_set(jset, iset, jkind, ikind)%x(1)*rab2 + coeffs_set(jset, iset, jkind, ikind)%x(2) + &
715 coeffs_kind_max0 + pmax_blocks < log10_eps_schwarz) cycle
716 nset_ij = nset_ij + 1
717 set_list(nset_ij)%pair = (/iset, jset/)
720 list%elements(n_element)%set_bounds(2) = nset_ij
724 list%n_element = n_element