54#include "./base/base_uses.f90"
60 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gapw_gspace_reconstruction'
85 rhotot_elec_gspace, q_max, rho_hard, &
86 rho_soft, fsign, compute_tau, rho_source, &
87 allow_nonorthorhombic)
92 REAL(kind=
dp),
INTENT(IN) :: q_max
93 REAL(kind=
dp),
INTENT(OUT) :: rho_hard, rho_soft
94 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: fsign
95 LOGICAL,
INTENT(IN),
OPTIONAL :: compute_tau
97 LOGICAL,
INTENT(IN),
OPTIONAL :: allow_nonorthorhombic
99 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_rhotot_elec_gspace'
101 INTEGER ::
atom, handle, iatom, ico, ico1_pgf, ico1_set, ikind, ipgf, iset, iso, iso1_pgf, &
102 iso1_set, ison, ispin, jco, jco1_pgf, jco1_set, jpgf, jset, jso, jso1_pgf, jso1_set, &
103 json, la, lb, maxco, maxso, na, natom, nb, ncoa, ncob, ncotot, nkind, nsatbas, nset, &
104 nsoa, nsob, nsotot, nspin
105 INTEGER,
DIMENSION(:),
POINTER :: atom_list, lmax, lmin, npgf, o2nindex
106 LOGICAL :: my_compute_tau, orthorhombic, paw_atom, &
107 permit_nonorthorhombic
108 REAL(kind=
dp) :: alpha, eps_rho_gspace, rho_total, scale, &
110 REAL(kind=
dp),
DIMENSION(3) :: ra
111 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: delta_cpc, pab, work, zet
118 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r, source_r, tau_r
119 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
125 cpassert(
ASSOCIATED(qs_env))
126 cpassert(
ASSOCIATED(auxbas_pw_pool))
128 CALL timeset(routinen, handle)
131 NULLIFY (atomic_kind_set)
132 NULLIFY (qs_kind_set)
137 NULLIFY (dft_control)
141 NULLIFY (basis_1c_set)
143 NULLIFY (particle_set)
144 NULLIFY (rho, rho_r, source_r, tau_r)
146 NULLIFY (rho_atom_set)
151 atomic_kind_set=atomic_kind_set, &
152 qs_kind_set=qs_kind_set, &
154 dft_control=dft_control, &
155 particle_set=particle_set, &
156 rho_atom_set=rho_atom_set)
158 IF (
PRESENT(rho_source))
THEN
164 CALL qs_rho_get(rho, rho_r=rho_r, tau_r=tau_r)
165 my_compute_tau = .false.
166 IF (
PRESENT(compute_tau)) my_compute_tau = compute_tau
167 IF (my_compute_tau)
THEN
168 cpassert(
ASSOCIATED(tau_r))
173 eps_rho_gspace = dft_control%qs_control%eps_rho_gspace
174 nkind =
SIZE(atomic_kind_set)
175 nspin = dft_control%nspins
179 CALL auxbas_pw_pool%create_pw(pw=rho_elec_gspace)
181 CALL pw_zero(rhotot_elec_gspace)
186 IF (
PRESENT(fsign) .AND. (ispin == 2))
THEN
191 CALL pw_axpy(rho_elec_gspace, rhotot_elec_gspace, alpha=alpha)
197 CALL auxbas_pw_pool%give_back_pw(rho_elec_gspace)
202 orthorhombic=orthorhombic)
203 permit_nonorthorhombic = .false.
204 IF (
PRESENT(allow_nonorthorhombic)) permit_nonorthorhombic = allow_nonorthorhombic
205 IF (.NOT. orthorhombic .AND. .NOT. permit_nonorthorhombic)
THEN
206 CALL cp_abort(__location__, &
207 "The calculation of XRD spectra for non-orthorhombic cells is not implemented")
210 CALL pw_scale(rhotot_elec_gspace, volume)
220 atom_list=atom_list, &
224 basis_set=basis_1c_set, &
225 basis_type=
"GAPW_1C", &
228 IF (.NOT. paw_atom) cycle
243 CALL reallocate(delta_cpc, 1, nsatbas, 1, nsatbas)
249 atom = atom_list(iatom)
250 rho_atom => rho_atom_set(
atom)
256 ra(:) =
pbc(particle_set(
atom)%r, cell)
261 IF (
PRESENT(fsign) .AND. (ispin == 2))
THEN
266 delta_cpc = delta_cpc + alpha*(cpc_h(ispin)%r_coef - cpc_s(ispin)%r_coef)
272 ico1_set = (iset - 1)*maxco + 1
273 iso1_set = (iset - 1)*maxso + 1
277 jco1_set = (jset - 1)*maxco + 1
278 jso1_set = (jset - 1)*maxso + 1
281 DO ipgf = 1, npgf(iset)
282 ico1_pgf = ico1_set + (ipgf - 1)*ncoa
283 iso1_pgf = iso1_set + (ipgf - 1)*nsoa
284 DO jpgf = 1, npgf(jset)
285 jco1_pgf = jco1_set + (jpgf - 1)*ncob
286 jso1_pgf = jso1_set + (jpgf - 1)*nsob
287 ico = ico1_pgf +
ncoset(lmin(iset) - 1)
288 iso = iso1_pgf +
nsoset(lmin(iset) - 1)
292 DO la = lmin(iset), lmax(iset)
293 jco = jco1_pgf +
ncoset(lmin(jset) - 1)
294 jso = jso1_pgf +
nsoset(lmin(jset) - 1)
295 DO lb = lmin(jset), lmax(jset)
299 delta_cpc(ison:ison +
nso(la) - 1, json),
SIZE(delta_cpc, 1), &
304 0.0_dp, pab(ico:ico +
nco(la) - 1, jco),
SIZE(pab, 1))
317 CALL collocate_pgf_product_gspace( &
319 zeta=zet(ipgf, iset), &
322 zetb=zet(jpgf, jset), &
325 rab=[0.0_dp, 0.0_dp, 0.0_dp], &
331 eps_rho_gspace=eps_rho_gspace, &
332 gsq_max=q_max*q_max, &
333 pw=rhotot_elec_gspace, &
334 compute_tau=my_compute_tau)
341 DEALLOCATE (o2nindex)
346 rho_hard = rho_total - rho_soft
350 IF (
ASSOCIATED(delta_cpc))
THEN
351 DEALLOCATE (delta_cpc)
354 IF (
ASSOCIATED(work))
THEN
358 IF (
ASSOCIATED(pab))
THEN
362 CALL timestop(handle)
379 vxc_rho, vxc_tau, atom_force, strain_virial, &
380 one_center_contraction, one_center_rho_contraction, &
381 one_center_tau_contraction)
385 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
INTENT(IN) :: vxc_rho, vxc_tau
386 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT), &
387 OPTIONAL :: atom_force, strain_virial
388 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: one_center_contraction, &
389 one_center_rho_contraction, &
390 one_center_tau_contraction
392 CHARACTER(LEN=*),
PARAMETER :: routinen =
'integrate_gapw_composite_vxc_gspace'
394 INTEGER ::
atom, handle, iatom, ico, ico1_pgf, ico1_set, ikind, ipgf, iset, iso, iso1_pgf, &
395 iso1_set, ison, ispin, jco, jco1_pgf, jco1_set, jpgf, jset, jso, jso1_pgf, jso1_set, &
396 json, la, lb, maxco, maxso, na, natom, nb, ncoa, ncob, ncotot, nkind, nsatbas, nset, &
397 nsoa, nsob, nsotot, nspin, output_unit
398 INTEGER,
DIMENSION(:),
POINTER :: atom_list, lmax, lmin, npgf, o2nindex
399 LOGICAL :: adjoint_consistent, paw_atom
400 REAL(kind=
dp) :: adjoint_cart, adjoint_rho_cart, &
401 adjoint_spherical, adjoint_tau_cart, &
402 eps_rho_gspace, q_max
403 REAL(kind=
dp),
DIMENSION(3) :: center_force, ra
404 REAL(kind=
dp),
DIMENSION(3, 3) :: atom_strain_virial
405 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: delta_cpc, hab, hab_rho, hab_tau, pab, &
406 v_spherical, work, zet
415 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
416 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: cpc_h, cpc_s, int_h, int_s
424 CALL timeset(routinen, handle)
426 NULLIFY (atom_list, atomic_kind_set, basis_1c_set, cell, cpc_h, cpc_s, delta_cpc, &
427 dft_control, hab, hab_rho, hab_tau, int_h, int_s, lmax, lmin, npgf, o2nindex, &
429 particle_set, qs_kind_set, rho_atom, rho_atom_set, work, zet)
430 NULLIFY (v_spherical)
432 cpassert(
ASSOCIATED(qs_env))
433 cpassert(
ASSOCIATED(auxbas_pw_pool))
434 cpassert(
SIZE(vxc_rho) ==
SIZE(vxc_tau))
435 IF (
PRESENT(one_center_contraction)) one_center_contraction = 0.0_dp
436 IF (
PRESENT(one_center_rho_contraction)) one_center_rho_contraction = 0.0_dp
437 IF (
PRESENT(one_center_tau_contraction)) one_center_tau_contraction = 0.0_dp
438 IF (
PRESENT(atom_force))
THEN
439 cpassert(
SIZE(atom_force, 1) == 3)
441 IF (
PRESENT(strain_virial))
THEN
442 cpassert(
SIZE(strain_virial, 1) == 3)
443 cpassert(
SIZE(strain_virial, 2) == 3)
447 atomic_kind_set=atomic_kind_set, &
448 qs_kind_set=qs_kind_set, &
450 dft_control=dft_control, &
452 particle_set=particle_set, &
453 rho_atom_set=rho_atom_set)
455 eps_rho_gspace = dft_control%qs_control%eps_rho_gspace
456 nkind =
SIZE(atomic_kind_set)
457 nspin =
SIZE(vxc_rho)
459 ALLOCATE (vrho_g(nspin), vtau_g(nspin))
461 CALL auxbas_pw_pool%create_pw(vrho_g(ispin))
462 CALL auxbas_pw_pool%create_pw(vtau_g(ispin))
466 q_max = sqrt(maxval(vrho_g(1)%pw_grid%gsq))
469 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
470 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_1c_set, &
471 basis_type=
"GAPW_1C", paw_atom=paw_atom)
472 IF (.NOT. paw_atom) cycle
476 lmax=lmax, lmin=lmin, maxco=maxco, maxso=maxso, &
477 npgf=npgf, nset=nset, zet=zet)
481 CALL reallocate(hab_rho, 1, ncotot, 1, ncotot)
482 CALL reallocate(hab_tau, 1, ncotot, 1, ncotot)
484 CALL reallocate(delta_cpc, 1, nsatbas, 1, nsatbas)
485 CALL reallocate(v_spherical, 1, nsotot, 1, nsotot)
490 atom = atom_list(iatom)
491 rho_atom => rho_atom_set(
atom)
492 CALL get_rho_atom(rho_atom=rho_atom, cpc_h=cpc_h, cpc_s=cpc_s, &
493 ga_vlocal_gb_h=int_h, ga_vlocal_gb_s=int_s)
494 ra(:) =
pbc(particle_set(
atom)%r, cell)
501 center_force = 0.0_dp
502 atom_strain_virial = 0.0_dp
503 delta_cpc = cpc_h(ispin)%r_coef - cpc_s(ispin)%r_coef
505 ico1_set = (iset - 1)*maxco + 1
506 iso1_set = (iset - 1)*maxso + 1
510 jco1_set = (jset - 1)*maxco + 1
511 jso1_set = (jset - 1)*maxso + 1
514 DO ipgf = 1, npgf(iset)
515 ico1_pgf = ico1_set + (ipgf - 1)*ncoa
516 iso1_pgf = iso1_set + (ipgf - 1)*nsoa
517 DO jpgf = 1, npgf(jset)
518 jco1_pgf = jco1_set + (jpgf - 1)*ncob
519 jso1_pgf = jso1_set + (jpgf - 1)*nsob
520 ico = ico1_pgf +
ncoset(lmin(iset) - 1)
521 iso = iso1_pgf +
nsoset(lmin(iset) - 1)
522 DO la = lmin(iset), lmax(iset)
523 jco = jco1_pgf +
ncoset(lmin(jset) - 1)
524 jso = jso1_pgf +
nsoset(lmin(jset) - 1)
525 DO lb = lmin(jset), lmax(jset)
529 delta_cpc(ison:ison +
nso(la) - 1, json), &
534 pab(ico:ico +
nco(la) - 1, jco),
SIZE(pab, 1))
543 IF (
PRESENT(strain_virial))
THEN
544 CALL collocate_pgf_product_gspace( &
545 la_max=lmax(iset), zeta=zet(ipgf, iset), la_min=lmin(iset), &
546 lb_max=lmax(jset), zetb=zet(jpgf, jset), lb_min=lmin(jset), &
547 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], rab2=0.0_dp, scale=1.0_dp, &
548 pab=pab, na=na, nb=nb, eps_rho_gspace=eps_rho_gspace, &
549 gsq_max=q_max*q_max, pw=vrho_g(ispin), &
550 potential_gspace=vrho_g(ispin), hab=hab_rho, &
551 center_force=center_force, strain_virial=atom_strain_virial)
552 CALL collocate_pgf_product_gspace( &
553 la_max=lmax(iset), zeta=zet(ipgf, iset), la_min=lmin(iset), &
554 lb_max=lmax(jset), zetb=zet(jpgf, jset), lb_min=lmin(jset), &
555 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], rab2=0.0_dp, scale=1.0_dp, &
556 pab=pab, na=na, nb=nb, eps_rho_gspace=eps_rho_gspace, &
557 gsq_max=q_max*q_max, pw=vtau_g(ispin), compute_tau=.true., &
558 potential_gspace=vtau_g(ispin), hab=hab_tau, &
559 center_force=center_force, strain_virial=atom_strain_virial)
560 ELSE IF (
PRESENT(atom_force))
THEN
561 CALL collocate_pgf_product_gspace( &
562 la_max=lmax(iset), zeta=zet(ipgf, iset), la_min=lmin(iset), &
563 lb_max=lmax(jset), zetb=zet(jpgf, jset), lb_min=lmin(jset), &
564 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], rab2=0.0_dp, scale=1.0_dp, &
565 pab=pab, na=na, nb=nb, eps_rho_gspace=eps_rho_gspace, &
566 gsq_max=q_max*q_max, pw=vrho_g(ispin), &
567 potential_gspace=vrho_g(ispin), hab=hab_rho, &
568 center_force=center_force)
569 CALL collocate_pgf_product_gspace( &
570 la_max=lmax(iset), zeta=zet(ipgf, iset), la_min=lmin(iset), &
571 lb_max=lmax(jset), zetb=zet(jpgf, jset), lb_min=lmin(jset), &
572 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], rab2=0.0_dp, scale=1.0_dp, &
573 pab=pab, na=na, nb=nb, eps_rho_gspace=eps_rho_gspace, &
574 gsq_max=q_max*q_max, pw=vtau_g(ispin), compute_tau=.true., &
575 potential_gspace=vtau_g(ispin), hab=hab_tau, &
576 center_force=center_force)
578 CALL collocate_pgf_product_gspace( &
579 la_max=lmax(iset), zeta=zet(ipgf, iset), la_min=lmin(iset), &
580 lb_max=lmax(jset), zetb=zet(jpgf, jset), lb_min=lmin(jset), &
581 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], rab2=0.0_dp, scale=1.0_dp, &
582 pab=pab, na=na, nb=nb, eps_rho_gspace=eps_rho_gspace, &
583 gsq_max=q_max*q_max, pw=vrho_g(ispin), &
584 potential_gspace=vrho_g(ispin), hab=hab_rho)
585 CALL collocate_pgf_product_gspace( &
586 la_max=lmax(iset), zeta=zet(ipgf, iset), la_min=lmin(iset), &
587 lb_max=lmax(jset), zetb=zet(jpgf, jset), lb_min=lmin(jset), &
588 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], rab2=0.0_dp, scale=1.0_dp, &
589 pab=pab, na=na, nb=nb, eps_rho_gspace=eps_rho_gspace, &
590 gsq_max=q_max*q_max, pw=vtau_g(ispin), compute_tau=.true., &
591 potential_gspace=vtau_g(ispin), hab=hab_tau)
597 CALL para_env%sum(hab_rho)
598 CALL para_env%sum(hab_tau)
601 hab = hab_rho + hab_tau
602 adjoint_rho_cart = sum(pab*hab_rho)
603 adjoint_tau_cart = sum(pab*hab_tau)
604 adjoint_cart = adjoint_rho_cart + adjoint_tau_cart
605 IF (
PRESENT(one_center_contraction))
THEN
606 one_center_contraction = one_center_contraction + adjoint_cart
608 IF (
PRESENT(one_center_rho_contraction))
THEN
609 one_center_rho_contraction = one_center_rho_contraction + adjoint_rho_cart
611 IF (
PRESENT(one_center_tau_contraction))
THEN
612 one_center_tau_contraction = one_center_tau_contraction + adjoint_tau_cart
615 IF (
ASSOCIATED(int_h) .AND.
ASSOCIATED(int_s))
THEN
616 IF (
ASSOCIATED(int_h(ispin)%r_coef) .AND.
ASSOCIATED(int_s(ispin)%r_coef))
THEN
619 ico1_set = (iset - 1)*maxco + 1
620 iso1_set = (iset - 1)*maxso + 1
624 jco1_set = (jset - 1)*maxco + 1
625 jso1_set = (jset - 1)*maxso + 1
628 DO ipgf = 1, npgf(iset)
629 ico1_pgf = ico1_set + (ipgf - 1)*ncoa
630 iso1_pgf = iso1_set + (ipgf - 1)*nsoa
631 DO jpgf = 1, npgf(jset)
632 jco1_pgf = jco1_set + (jpgf - 1)*ncob
633 jso1_pgf = jso1_set + (jpgf - 1)*nsob
634 ico = ico1_pgf +
ncoset(lmin(iset) - 1)
635 iso = iso1_pgf +
nsoset(lmin(iset) - 1)
636 DO la = lmin(iset), lmax(iset)
637 jco = jco1_pgf +
ncoset(lmin(jset) - 1)
638 jso = jso1_pgf +
nsoset(lmin(jset) - 1)
639 DO lb = lmin(jset), lmax(jset)
642 hab(ico:ico +
nco(la) - 1, jco), &
643 SIZE(hab, 1), 0.0_dp, work, maxso)
646 v_spherical(iso:iso +
nso(la) - 1, jso), nsotot)
657 int_h(ispin)%r_coef = int_h(ispin)%r_coef + v_spherical
658 int_s(ispin)%r_coef = int_s(ispin)%r_coef + v_spherical
659 adjoint_spherical = 0.0_dp
666 adjoint_spherical = adjoint_spherical + &
667 delta_cpc(ison, json)*v_spherical(iso, jso)
670 adjoint_consistent = abs(adjoint_cart - adjoint_spherical) <= &
671 1.0e-9_dp*max(1.0_dp, abs(adjoint_cart))
672 IF (.NOT. adjoint_consistent)
THEN
673 WRITE (unit=output_unit, fmt=
"(A,3I6,3ES24.15)") &
674 " SKALA_GPW| Composite adjoint mismatch", ikind,
atom, ispin, &
675 adjoint_cart, adjoint_spherical, adjoint_cart - adjoint_spherical
677 cpassert(adjoint_consistent)
680 IF (
PRESENT(atom_force)) atom_force(:,
atom) = atom_force(:,
atom) + center_force
681 IF (
PRESENT(strain_virial)) strain_virial = strain_virial + atom_strain_virial
685 DEALLOCATE (delta_cpc, hab, hab_rho, hab_tau, pab, v_spherical, work, o2nindex)
689 CALL auxbas_pw_pool%give_back_pw(vrho_g(ispin))
690 CALL auxbas_pw_pool%give_back_pw(vtau_g(ispin))
692 DEALLOCATE (vrho_g, vtau_g)
694 CALL timestop(handle)
722 SUBROUTINE collocate_pgf_product_gspace(la_max, zeta, la_min, &
723 lb_max, zetb, lb_min, &
724 ra, rab, rab2, scale, pab, na, nb, &
725 eps_rho_gspace, gsq_max, pw, compute_tau, &
726 potential_gspace, hab, center_force, strain_virial)
728 INTEGER,
INTENT(IN) :: la_max
729 REAL(
dp),
INTENT(IN) :: zeta
730 INTEGER,
INTENT(IN) :: la_min, lb_max
731 REAL(
dp),
INTENT(IN) :: zetb
732 INTEGER,
INTENT(IN) :: lb_min
733 REAL(
dp),
DIMENSION(3),
INTENT(IN) :: ra, rab
734 REAL(
dp),
INTENT(IN) :: rab2, scale
735 REAL(
dp),
DIMENSION(:, :),
POINTER :: pab
736 INTEGER,
INTENT(IN) :: na, nb
737 REAL(
dp),
INTENT(IN) :: eps_rho_gspace, gsq_max
739 LOGICAL,
INTENT(IN),
OPTIONAL :: compute_tau
741 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT),
OPTIONAL :: hab
742 REAL(
dp),
DIMENSION(3),
INTENT(INOUT),
OPTIONAL :: center_force
743 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT),
OPTIONAL :: strain_virial
745 CHARACTER(LEN=*),
PARAMETER :: routinen =
'collocate_pgf_product_gspace'
747 COMPLEX(dp) :: plane_product, rag, rbg, shifted_product, &
749 COMPLEX(dp),
DIMENSION(3) :: plane_gradient
750 COMPLEX(dp),
DIMENSION(:, :, :),
ALLOCATABLE :: cubeaxis
751 INTEGER :: ax, ay, az, bx, by, bz, handle, i, ico, &
752 idir, jco, jdir, la, la_rec_max, lb, &
753 lb_grid, lb_rec_max, ub_grid
754 LOGICAL :: integrate_potential, integrate_strain, &
756 REAL(
dp) :: f, fa, fb, gcoord, pij, potential_term, &
757 prefactor, reciprocal_weight, rzetp, &
759 REAL(
dp),
DIMENSION(3) :: fap, fbp, force_product, gvec, rap, rbp, rp
761 CALL timeset(routinen, handle)
763 my_compute_tau = .false.
764 IF (
PRESENT(compute_tau)) my_compute_tau = compute_tau
765 integrate_potential =
PRESENT(potential_gspace) .OR.
PRESENT(hab)
766 integrate_strain =
PRESENT(strain_virial)
767 cpassert(
PRESENT(potential_gspace) .EQV.
PRESENT(hab))
768 cpassert(.NOT. integrate_strain .OR. integrate_potential)
769 IF (integrate_potential)
THEN
770 cpassert(
ASSOCIATED(pw%pw_grid, potential_gspace%pw_grid))
775 IF (my_compute_tau)
THEN
776 la_rec_max = la_rec_max + 1
777 lb_rec_max = lb_rec_max + 1
779 IF (integrate_strain) la_rec_max = la_rec_max + 1
785 rbp(:) = rap(:) - rab(:)
786 rp(:) = ra(:) + rap(:)
787 twozetp = 2.0_dp*zetp
788 fap(:) = twozetp*rap(:)
789 fbp(:) = twozetp*rbp(:)
790 prefactor = scale*sqrt((
pi*rzetp)**3)*exp(-zeta*f*rab2)
792 ALLOCATE (cubeaxis(3, 0:la_rec_max, 0:lb_rec_max))
793 lb_grid = lbound(pw%array, 1)
794 ub_grid = ubound(pw%array, 1)
796 DO i = lb_grid, ub_grid
797 IF (pw%pw_grid%gsq(i) > gsq_max) cycle
798 gvec = pw%pw_grid%g(:, i)
799 CALL build_cubeaxis(gvec)
800 reciprocal_weight = 1.0_dp
801 IF (pw%pw_grid%grid_span ==
halfspace .AND. pw%pw_grid%gsq(i) > 0.0_dp)
THEN
802 reciprocal_weight = 2.0_dp
814 pij = prefactor*pab(na + ico, nb + jco)
815 IF (.NOT. integrate_potential .AND. abs(pij) < eps_rho_gspace) cycle
817 IF (.NOT. my_compute_tau)
THEN
818 plane_product = cubeaxis(1, ax, bx)*cubeaxis(2, ay, by)*cubeaxis(3, az, bz)
821 tau_product = 2.0_dp*zeta*zetb* &
822 cubeaxis(1, ax + 1, bx + 1)* &
823 cubeaxis(2, ay, by)*cubeaxis(3, az, bz)
825 tau_product = tau_product - real(ax,
dp)*zetb* &
826 cubeaxis(1, ax - 1, bx + 1)* &
827 cubeaxis(2, ay, by)*cubeaxis(3, az, bz)
830 tau_product = tau_product - zeta*real(bx,
dp)* &
831 cubeaxis(1, ax + 1, bx - 1)* &
832 cubeaxis(2, ay, by)*cubeaxis(3, az, bz)
834 IF (ax > 0 .AND. bx > 0)
THEN
835 tau_product = tau_product + 0.5_dp*real(ax*bx,
dp)* &
836 cubeaxis(1, ax - 1, bx - 1)* &
837 cubeaxis(2, ay, by)*cubeaxis(3, az, bz)
840 tau_product = tau_product + 2.0_dp*zeta*zetb* &
841 cubeaxis(1, ax, bx)* &
842 cubeaxis(2, ay + 1, by + 1)*cubeaxis(3, az, bz)
844 tau_product = tau_product - real(ay,
dp)*zetb* &
845 cubeaxis(1, ax, bx)* &
846 cubeaxis(2, ay - 1, by + 1)*cubeaxis(3, az, bz)
849 tau_product = tau_product - zeta*real(by,
dp)* &
850 cubeaxis(1, ax, bx)* &
851 cubeaxis(2, ay + 1, by - 1)*cubeaxis(3, az, bz)
853 IF (ay > 0 .AND. by > 0)
THEN
854 tau_product = tau_product + 0.5_dp*real(ay*by,
dp)* &
855 cubeaxis(1, ax, bx)* &
856 cubeaxis(2, ay - 1, by - 1)*cubeaxis(3, az, bz)
859 tau_product = tau_product + 2.0_dp*zeta*zetb* &
860 cubeaxis(1, ax, bx)*cubeaxis(2, ay, by)* &
861 cubeaxis(3, az + 1, bz + 1)
863 tau_product = tau_product - real(az,
dp)*zetb* &
864 cubeaxis(1, ax, bx)*cubeaxis(2, ay, by)* &
865 cubeaxis(3, az - 1, bz + 1)
868 tau_product = tau_product - zeta*real(bz,
dp)* &
869 cubeaxis(1, ax, bx)*cubeaxis(2, ay, by)* &
870 cubeaxis(3, az + 1, bz - 1)
872 IF (az > 0 .AND. bz > 0)
THEN
873 tau_product = tau_product + 0.5_dp*real(az*bz,
dp)* &
874 cubeaxis(1, ax, bx)*cubeaxis(2, ay, by)* &
875 cubeaxis(3, az - 1, bz - 1)
877 plane_product = tau_product
880 IF (integrate_strain)
THEN
881 IF (.NOT. my_compute_tau)
THEN
882 shifted_product = cubeaxis(1, ax + 1, bx)* &
883 cubeaxis(2, ay, by)*cubeaxis(3, az, bz)
884 plane_gradient(1) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
885 (shifted_product + ra(1)*plane_product)
886 shifted_product = cubeaxis(1, ax, bx)* &
887 cubeaxis(2, ay + 1, by)*cubeaxis(3, az, bz)
888 plane_gradient(2) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
889 (shifted_product + ra(2)*plane_product)
890 shifted_product = cubeaxis(1, ax, bx)* &
891 cubeaxis(2, ay, by)*cubeaxis(3, az + 1, bz)
892 plane_gradient(3) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
893 (shifted_product + ra(3)*plane_product)
896 shifted_product = tau_plane_product_shifted(idir)
897 plane_gradient(idir) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
898 (shifted_product + ra(idir)*plane_product)
903 IF (integrate_potential)
THEN
904 potential_term = reciprocal_weight*prefactor* &
905 REAL(conjg(potential_gspace%array(i))*plane_product, kind=
dp)
906 hab(na + ico, nb + jco) = hab(na + ico, nb + jco) + potential_term
907 IF (
PRESENT(center_force) .OR. integrate_strain)
THEN
908 force_product = reciprocal_weight*pij* &
909 REAL(conjg(potential_gspace%array(i))* &
910 cmplx(0.0_dp, -gvec, kind=
dp)*plane_product, kind=
dp)
911 IF (
PRESENT(center_force)) center_force = center_force + force_product
913 IF (integrate_strain)
THEN
916 strain_virial(idir, jdir) = strain_virial(idir, jdir) - &
917 reciprocal_weight*pij*gvec(idir)* &
918 REAL(conjg(potential_gspace%array(i))*plane_gradient(jdir), kind=
dp) + &
919 force_product(idir)*ra(jdir)
921 strain_virial(idir, idir) = strain_virial(idir, idir) - &
922 pab(na + ico, nb + jco)*potential_term
926 pw%array(i) = pw%array(i) + pij*plane_product
932 DEALLOCATE (cubeaxis)
933 CALL timestop(handle)
941 SUBROUTINE build_cubeaxis(gvector)
942 REAL(
dp),
DIMENSION(3),
INTENT(IN) :: gvector
944 cubeaxis = cmplx(0.0_dp, 0.0_dp, kind=
dp)
946 gcoord = gvector(idir)
947 cubeaxis(idir, 0, 0) = &
948 exp(cmplx(-0.25_dp*rzetp*gcoord*gcoord, -rp(idir)*gcoord, kind=
dp))
950 IF (la_rec_max > 0)
THEN
951 rag = cmplx(fap(idir), -gcoord, kind=
dp)
952 cubeaxis(idir, 1, 0) = rag*cubeaxis(idir, 0, 0)
953 DO la = 2, la_rec_max
954 fa = real(la - 1,
dp)*twozetp
955 cubeaxis(idir, la, 0) = rag*cubeaxis(idir, la - 1, 0) + &
956 fa*cubeaxis(idir, la - 2, 0)
958 IF (lb_rec_max > 0)
THEN
959 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
961 cubeaxis(idir, 0, 1) = rbg*cubeaxis(idir, 0, 0)
962 cubeaxis(idir, 1, 1) = rbg*cubeaxis(idir, 1, 0) + &
963 fa*cubeaxis(idir, 0, 0)
964 DO lb = 2, lb_rec_max
965 fb = real(lb - 1,
dp)*twozetp
966 cubeaxis(idir, 0, lb) = rbg*cubeaxis(idir, 0, lb - 1) + &
967 fb*cubeaxis(idir, 0, lb - 2)
968 cubeaxis(idir, 1, lb) = rbg*cubeaxis(idir, 1, lb - 1) + &
969 fb*cubeaxis(idir, 1, lb - 2) + &
970 fa*cubeaxis(idir, 0, lb - 1)
972 DO la = 2, la_rec_max
973 fa = real(la,
dp)*twozetp
974 cubeaxis(idir, la, 1) = rbg*cubeaxis(idir, la, 0) + &
975 fa*cubeaxis(idir, la - 1, 0)
976 DO lb = 2, lb_rec_max
977 fb = real(lb - 1,
dp)*twozetp
978 cubeaxis(idir, la, lb) = rbg*cubeaxis(idir, la, lb - 1) + &
979 fb*cubeaxis(idir, la, lb - 2) + &
980 fa*cubeaxis(idir, la - 1, lb - 1)
984 ELSE IF (lb_rec_max > 0)
THEN
985 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
986 cubeaxis(idir, 0, 1) = rbg*cubeaxis(idir, 0, 0)
987 DO lb = 2, lb_rec_max
988 fb = real(lb - 1,
dp)*twozetp
989 cubeaxis(idir, 0, lb) = rbg*cubeaxis(idir, 0, lb - 1) + &
990 fb*cubeaxis(idir, 0, lb - 2)
994 DO la = 0, la_rec_max
995 DO lb = 0, lb_rec_max
996 IF (la + lb == 0) cycle
997 fa = (1.0_dp/twozetp)**(la + lb)
998 cubeaxis(idir, la, lb) = fa*cubeaxis(idir, la, lb)
1002 END SUBROUTINE build_cubeaxis
1009 FUNCTION tau_plane_product_shifted(shift_axis)
RESULT(value)
1010 INTEGER,
INTENT(IN) :: shift_axis
1011 COMPLEX(dp) :: value
1013 INTEGER :: sx, sy, sz
1018 IF (shift_axis == 1) sx = 1
1019 IF (shift_axis == 2) sy = 1
1020 IF (shift_axis == 3) sz = 1
1022 value = 2.0_dp*zeta*zetb* &
1023 cubeaxis(1, ax + 1 + sx, bx + 1)* &
1024 cubeaxis(2, ay + sy, by)*cubeaxis(3, az + sz, bz)
1026 value =
value - real(ax,
dp)*zetb* &
1027 cubeaxis(1, ax - 1 + sx, bx + 1)* &
1028 cubeaxis(2, ay + sy, by)*cubeaxis(3, az + sz, bz)
1031 value =
value - zeta*real(bx,
dp)* &
1032 cubeaxis(1, ax + 1 + sx, bx - 1)* &
1033 cubeaxis(2, ay + sy, by)*cubeaxis(3, az + sz, bz)
1035 IF (ax > 0 .AND. bx > 0)
THEN
1036 value =
value + 0.5_dp*real(ax*bx,
dp)* &
1037 cubeaxis(1, ax - 1 + sx, bx - 1)* &
1038 cubeaxis(2, ay + sy, by)*cubeaxis(3, az + sz, bz)
1041 value =
value + 2.0_dp*zeta*zetb* &
1042 cubeaxis(1, ax + sx, bx)* &
1043 cubeaxis(2, ay + 1 + sy, by + 1)*cubeaxis(3, az + sz, bz)
1045 value =
value - real(ay,
dp)*zetb* &
1046 cubeaxis(1, ax + sx, bx)* &
1047 cubeaxis(2, ay - 1 + sy, by + 1)*cubeaxis(3, az + sz, bz)
1050 value =
value - zeta*real(by,
dp)* &
1051 cubeaxis(1, ax + sx, bx)* &
1052 cubeaxis(2, ay + 1 + sy, by - 1)*cubeaxis(3, az + sz, bz)
1054 IF (ay > 0 .AND. by > 0)
THEN
1055 value =
value + 0.5_dp*real(ay*by,
dp)* &
1056 cubeaxis(1, ax + sx, bx)* &
1057 cubeaxis(2, ay - 1 + sy, by - 1)*cubeaxis(3, az + sz, bz)
1060 value =
value + 2.0_dp*zeta*zetb* &
1061 cubeaxis(1, ax + sx, bx)*cubeaxis(2, ay + sy, by)* &
1062 cubeaxis(3, az + 1 + sz, bz + 1)
1064 value =
value - real(az,
dp)*zetb* &
1065 cubeaxis(1, ax + sx, bx)*cubeaxis(2, ay + sy, by)* &
1066 cubeaxis(3, az - 1 + sz, bz + 1)
1069 value =
value - zeta*real(bz,
dp)* &
1070 cubeaxis(1, ax + sx, bx)*cubeaxis(2, ay + sy, by)* &
1071 cubeaxis(3, az + 1 + sz, bz - 1)
1073 IF (az > 0 .AND. bz > 0)
THEN
1074 value =
value + 0.5_dp*real(az*bz,
dp)* &
1075 cubeaxis(1, ax + sx, bx)*cubeaxis(2, ay + sy, by)* &
1076 cubeaxis(3, az - 1 + sz, bz - 1)
1078 END FUNCTION tau_plane_product_shifted
1080 END SUBROUTINE collocate_pgf_product_gspace
1106 SUBROUTINE collocate_pgf_product_gspace_buffered(la_max, zeta, la_min, &
1107 lb_max, zetb, lb_min, &
1108 ra, rab, rab2, scale, pab, na, nb, &
1109 eps_rho_gspace, gsq_max, pw, compute_tau, &
1110 potential_gspace, hab, center_force, strain_virial)
1114 INTEGER,
INTENT(IN) :: la_max
1115 REAL(
dp),
INTENT(IN) :: zeta
1116 INTEGER,
INTENT(IN) :: la_min, lb_max
1117 REAL(
dp),
INTENT(IN) :: zetb
1118 INTEGER,
INTENT(IN) :: lb_min
1119 REAL(
dp),
DIMENSION(3),
INTENT(IN) :: ra, rab
1120 REAL(
dp),
INTENT(IN) :: rab2, scale
1121 REAL(
dp),
DIMENSION(:, :),
POINTER :: pab
1122 INTEGER,
INTENT(IN) :: na, nb
1123 REAL(
dp),
INTENT(IN) :: eps_rho_gspace, gsq_max
1125 LOGICAL,
INTENT(IN),
OPTIONAL :: compute_tau
1127 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT),
OPTIONAL :: hab
1128 REAL(
dp),
DIMENSION(3),
INTENT(INOUT),
OPTIONAL :: center_force
1129 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT),
OPTIONAL :: strain_virial
1131 CHARACTER(LEN=*),
PARAMETER :: routinen =
'collocate_pgf_product_gspace'
1133 COMPLEX(dp) :: plane_product, rag, rbg, shifted_product, &
1135 COMPLEX(dp),
DIMENSION(3) :: plane_gradient
1136 COMPLEX(dp),
DIMENSION(:, :, :, :),
POINTER :: cubeaxis
1137 INTEGER :: ax, ay, az, bx, by, bz, handle, i, ico, &
1138 idir, jco, jdir, la, la_rec_max, lb, &
1139 lb_grid, lb_rec_max, ub_grid
1140 LOGICAL :: integrate_potential, integrate_strain, my_compute_tau
1141 REAL(
dp) :: f, fa, fb, g0_contribution, gcoord, pij, &
1142 potential_product, prefactor, rzetp, &
1144 REAL(
dp),
DIMENSION(3) :: force_product, gvec
1145 REAL(
dp),
DIMENSION(3) :: fap, fbp, rap, rbp, rp
1146 REAL(
dp),
DIMENSION(3, 3) :: strain_product
1148 CALL timeset(routinen, handle)
1150 my_compute_tau = .false.
1151 IF (
PRESENT(compute_tau)) my_compute_tau = compute_tau
1152 integrate_potential =
PRESENT(potential_gspace) .OR.
PRESENT(hab)
1153 integrate_strain =
PRESENT(strain_virial)
1154 cpassert(
PRESENT(potential_gspace) .EQV.
PRESENT(hab))
1155 cpassert(.NOT. integrate_strain .OR. integrate_potential)
1156 IF (integrate_potential)
THEN
1157 cpassert(
ASSOCIATED(pw%pw_grid, potential_gspace%pw_grid))
1161 IF (my_compute_tau)
THEN
1162 la_rec_max = la_rec_max + 1
1163 lb_rec_max = lb_rec_max + 1
1165 IF (integrate_strain) la_rec_max = la_rec_max + 1
1171 rbp(:) = rap(:) - rab(:)
1172 rp(:) = ra(:) + rap(:)
1173 twozetp = 2.0_dp*zetp
1174 fap(:) = twozetp*rap(:)
1175 fbp(:) = twozetp*rbp(:)
1177 prefactor = scale*sqrt((
pi*rzetp)**3)*exp(-zeta*f*rab2)
1178 lb_grid = lbound(pw%array, 1)
1179 ub_grid = ubound(pw%array, 1)
1181 CALL reallocate(cubeaxis, lb_grid, ub_grid, 1, 3, 0, la_rec_max, 0, lb_rec_max)
1184 DO i = lb_grid, ub_grid
1185 gcoord = pw%pw_grid%g(idir, i)
1186 cubeaxis(i, idir, 0, 0) = &
1187 exp(cmplx(-0.25_dp*rzetp*gcoord*gcoord, -rp(idir)*gcoord, kind=
dp))
1190 IF (la_rec_max > 0)
THEN
1191 DO i = lb_grid, ub_grid
1192 gcoord = pw%pw_grid%g(idir, i)
1193 rag = cmplx(fap(idir), -gcoord, kind=
dp)
1194 cubeaxis(i, idir, 1, 0) = rag*cubeaxis(i, idir, 0, 0)
1196 DO la = 2, la_rec_max
1197 fa = real(la - 1,
dp)*twozetp
1198 DO i = lb_grid, ub_grid
1199 gcoord = pw%pw_grid%g(idir, i)
1200 rag = cmplx(fap(idir), -gcoord, kind=
dp)
1201 cubeaxis(i, idir, la, 0) = rag*cubeaxis(i, idir, la - 1, 0) + &
1202 fa*cubeaxis(i, idir, la - 2, 0)
1205 IF (lb_rec_max > 0)
THEN
1207 DO i = lb_grid, ub_grid
1208 gcoord = pw%pw_grid%g(idir, i)
1209 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
1210 cubeaxis(i, idir, 0, 1) = rbg*cubeaxis(i, idir, 0, 0)
1211 cubeaxis(i, idir, 1, 1) = rbg*cubeaxis(i, idir, 1, 0) + &
1212 fa*cubeaxis(i, idir, 0, 0)
1214 DO lb = 2, lb_rec_max
1215 fb = real(lb - 1,
dp)*twozetp
1216 DO i = lb_grid, ub_grid
1217 gcoord = pw%pw_grid%g(idir, i)
1218 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
1219 cubeaxis(i, idir, 0, lb) = rbg*cubeaxis(i, idir, 0, lb - 1) + &
1220 fb*cubeaxis(i, idir, 0, lb - 2)
1221 cubeaxis(i, idir, 1, lb) = rbg*cubeaxis(i, idir, 1, lb - 1) + &
1222 fb*cubeaxis(i, idir, 1, lb - 2) + &
1223 fa*cubeaxis(i, idir, 0, lb - 1)
1226 DO la = 2, la_rec_max
1227 fa = real(la,
dp)*twozetp
1228 DO i = lb_grid, ub_grid
1229 gcoord = pw%pw_grid%g(idir, i)
1230 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
1231 cubeaxis(i, idir, la, 1) = rbg*cubeaxis(i, idir, la, 0) + &
1232 fa*cubeaxis(i, idir, la - 1, 0)
1234 DO lb = 2, lb_rec_max
1235 fb = real(lb - 1,
dp)*twozetp
1236 DO i = lb_grid, ub_grid
1237 gcoord = pw%pw_grid%g(idir, i)
1238 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
1239 cubeaxis(i, idir, la, lb) = rbg*cubeaxis(i, idir, la, lb - 1) + &
1240 fb*cubeaxis(i, idir, la, lb - 2) + &
1241 fa*cubeaxis(i, idir, la - 1, lb - 1)
1247 IF (lb_rec_max > 0)
THEN
1248 DO i = lb_grid, ub_grid
1249 gcoord = pw%pw_grid%g(idir, i)
1250 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
1251 cubeaxis(i, idir, 0, 1) = rbg*cubeaxis(i, idir, 0, 0)
1253 DO lb = 2, lb_rec_max
1254 fb = real(lb - 1,
dp)*twozetp
1255 DO i = lb_grid, ub_grid
1256 gcoord = pw%pw_grid%g(idir, i)
1257 rbg = cmplx(fbp(idir), -gcoord, kind=
dp)
1258 cubeaxis(i, idir, 0, lb) = rbg*cubeaxis(i, idir, 0, lb - 1) + &
1259 fb*cubeaxis(i, idir, 0, lb - 2)
1266 DO la = 0, la_rec_max
1267 DO lb = 0, lb_rec_max
1268 IF (la + lb == 0) cycle
1269 fa = (1.0_dp/twozetp)**(la + lb)
1271 DO i = lb_grid, ub_grid
1272 cubeaxis(i, idir, la, lb) = fa*cubeaxis(i, idir, la, lb)
1288 IF (integrate_potential)
THEN
1289 g0_contribution = 0.0_dp
1290 potential_product = 0.0_dp
1291 force_product = 0.0_dp
1292 strain_product = 0.0_dp
1293 IF (
PRESENT(center_force) .OR. integrate_strain)
THEN
1294 pij = prefactor*pab(na + ico, nb + jco)
1297 pij = prefactor*pab(na + ico, nb + jco)
1298 IF (abs(pij) < eps_rho_gspace) cycle
1305 DO i = lb_grid, ub_grid
1306 IF (pw%pw_grid%gsq(i) > gsq_max) cycle
1307 IF (.NOT. my_compute_tau)
THEN
1308 plane_product = cubeaxis(i, 1, ax, bx)* &
1309 cubeaxis(i, 2, ay, by)* &
1310 cubeaxis(i, 3, az, bz)
1313 tau_product = 2.0_dp*zeta*zetb* &
1314 cubeaxis(i, 1, ax + 1, bx + 1)* &
1315 cubeaxis(i, 2, ay, by)*cubeaxis(i, 3, az, bz)
1317 tau_product = tau_product - real(ax,
dp)*zetb* &
1318 cubeaxis(i, 1, ax - 1, bx + 1)* &
1319 cubeaxis(i, 2, ay, by)*cubeaxis(i, 3, az, bz)
1322 tau_product = tau_product - zeta*real(bx,
dp)* &
1323 cubeaxis(i, 1, ax + 1, bx - 1)* &
1324 cubeaxis(i, 2, ay, by)*cubeaxis(i, 3, az, bz)
1326 IF (ax > 0 .AND. bx > 0)
THEN
1327 tau_product = tau_product + 0.5_dp*real(ax*bx,
dp)* &
1328 cubeaxis(i, 1, ax - 1, bx - 1)* &
1329 cubeaxis(i, 2, ay, by)*cubeaxis(i, 3, az, bz)
1332 tau_product = tau_product + 2.0_dp*zeta*zetb* &
1333 cubeaxis(i, 1, ax, bx)* &
1334 cubeaxis(i, 2, ay + 1, by + 1)*cubeaxis(i, 3, az, bz)
1336 tau_product = tau_product - real(ay,
dp)*zetb* &
1337 cubeaxis(i, 1, ax, bx)* &
1338 cubeaxis(i, 2, ay - 1, by + 1)*cubeaxis(i, 3, az, bz)
1341 tau_product = tau_product - zeta*real(by,
dp)* &
1342 cubeaxis(i, 1, ax, bx)* &
1343 cubeaxis(i, 2, ay + 1, by - 1)*cubeaxis(i, 3, az, bz)
1345 IF (ay > 0 .AND. by > 0)
THEN
1346 tau_product = tau_product + 0.5_dp*real(ay*by,
dp)* &
1347 cubeaxis(i, 1, ax, bx)* &
1348 cubeaxis(i, 2, ay - 1, by - 1)*cubeaxis(i, 3, az, bz)
1351 tau_product = tau_product + 2.0_dp*zeta*zetb* &
1352 cubeaxis(i, 1, ax, bx)*cubeaxis(i, 2, ay, by)* &
1353 cubeaxis(i, 3, az + 1, bz + 1)
1355 tau_product = tau_product - real(az,
dp)*zetb* &
1356 cubeaxis(i, 1, ax, bx)*cubeaxis(i, 2, ay, by)* &
1357 cubeaxis(i, 3, az - 1, bz + 1)
1360 tau_product = tau_product - zeta*real(bz,
dp)* &
1361 cubeaxis(i, 1, ax, bx)*cubeaxis(i, 2, ay, by)* &
1362 cubeaxis(i, 3, az + 1, bz - 1)
1364 IF (az > 0 .AND. bz > 0)
THEN
1365 tau_product = tau_product + 0.5_dp*real(az*bz,
dp)* &
1366 cubeaxis(i, 1, ax, bx)*cubeaxis(i, 2, ay, by)* &
1367 cubeaxis(i, 3, az - 1, bz - 1)
1369 plane_product = tau_product
1371 IF (integrate_strain)
THEN
1372 IF (.NOT. my_compute_tau)
THEN
1373 shifted_product = cubeaxis(i, 1, ax + 1, bx)* &
1374 cubeaxis(i, 2, ay, by)*cubeaxis(i, 3, az, bz)
1375 plane_gradient(1) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
1376 (shifted_product + ra(1)*plane_product)
1377 shifted_product = cubeaxis(i, 1, ax, bx)* &
1378 cubeaxis(i, 2, ay + 1, by)*cubeaxis(i, 3, az, bz)
1379 plane_gradient(2) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
1380 (shifted_product + ra(2)*plane_product)
1381 shifted_product = cubeaxis(i, 1, ax, bx)* &
1382 cubeaxis(i, 2, ay, by)*cubeaxis(i, 3, az + 1, bz)
1383 plane_gradient(3) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
1384 (shifted_product + ra(3)*plane_product)
1387 shifted_product = tau_plane_product_shifted(idir)
1388 plane_gradient(idir) = cmplx(0.0_dp, -1.0_dp, kind=
dp)* &
1389 (shifted_product + ra(idir)*plane_product)
1393 IF (integrate_potential)
THEN
1394 potential_product = potential_product + prefactor* &
1395 REAL(conjg(potential_gspace%array(i))*plane_product, kind=
dp)
1396 IF (
PRESENT(center_force) .OR. integrate_strain)
THEN
1397 gvec = pw%pw_grid%g(:, i)
1398 force_product = force_product + pij* &
1399 REAL(conjg(potential_gspace%array(i))* &
1400 cmplx(0.0_dp, -gvec, kind=
dp)*plane_product, kind=
dp)
1402 IF (integrate_strain)
THEN
1405 strain_product(idir, jdir) = strain_product(idir, jdir) - &
1406 pij*gvec(idir)*real(conjg(potential_gspace%array(i))* &
1407 plane_gradient(jdir), kind=
dp)
1411 IF (pw%pw_grid%have_g0 .AND. i == 1)
THEN
1412 g0_contribution = prefactor* &
1413 REAL(conjg(potential_gspace%array(i))*plane_product, kind=
dp)
1416 pw%array(i) = pw%array(i) + pij*plane_product
1420 IF (integrate_potential)
THEN
1421 IF (pw%pw_grid%grid_span ==
halfspace)
THEN
1422 potential_product = 2.0_dp*potential_product - g0_contribution
1423 force_product = 2.0_dp*force_product
1424 strain_product = 2.0_dp*strain_product
1426 hab(na + ico, nb + jco) = hab(na + ico, nb + jco) + potential_product
1427 IF (
PRESENT(center_force)) center_force = center_force + force_product
1428 IF (integrate_strain)
THEN
1431 strain_product(idir, jdir) = strain_product(idir, jdir) + &
1432 force_product(idir)*ra(jdir)
1434 strain_product(idir, idir) = strain_product(idir, idir) - &
1435 pab(na + ico, nb + jco)*potential_product
1437 strain_virial = strain_virial + strain_product
1445 DEALLOCATE (cubeaxis)
1447 CALL timestop(handle)
1456 FUNCTION tau_plane_product_shifted(shift_axis)
RESULT(value)
1457 INTEGER,
INTENT(IN) :: shift_axis
1458 COMPLEX(dp) :: value
1460 INTEGER :: sx, sy, sz
1465 IF (shift_axis == 1) sx = 1
1466 IF (shift_axis == 2) sy = 1
1467 IF (shift_axis == 3) sz = 1
1469 value = 2.0_dp*zeta*zetb* &
1470 cubeaxis(i, 1, ax + 1 + sx, bx + 1)* &
1471 cubeaxis(i, 2, ay + sy, by)*cubeaxis(i, 3, az + sz, bz)
1473 value =
value - real(ax,
dp)*zetb* &
1474 cubeaxis(i, 1, ax - 1 + sx, bx + 1)* &
1475 cubeaxis(i, 2, ay + sy, by)*cubeaxis(i, 3, az + sz, bz)
1478 value =
value - zeta*real(bx,
dp)* &
1479 cubeaxis(i, 1, ax + 1 + sx, bx - 1)* &
1480 cubeaxis(i, 2, ay + sy, by)*cubeaxis(i, 3, az + sz, bz)
1482 IF (ax > 0 .AND. bx > 0)
THEN
1483 value =
value + 0.5_dp*real(ax*bx,
dp)* &
1484 cubeaxis(i, 1, ax - 1 + sx, bx - 1)* &
1485 cubeaxis(i, 2, ay + sy, by)*cubeaxis(i, 3, az + sz, bz)
1488 value =
value + 2.0_dp*zeta*zetb* &
1489 cubeaxis(i, 1, ax + sx, bx)* &
1490 cubeaxis(i, 2, ay + 1 + sy, by + 1)*cubeaxis(i, 3, az + sz, bz)
1492 value =
value - real(ay,
dp)*zetb* &
1493 cubeaxis(i, 1, ax + sx, bx)* &
1494 cubeaxis(i, 2, ay - 1 + sy, by + 1)*cubeaxis(i, 3, az + sz, bz)
1497 value =
value - zeta*real(by,
dp)* &
1498 cubeaxis(i, 1, ax + sx, bx)* &
1499 cubeaxis(i, 2, ay + 1 + sy, by - 1)*cubeaxis(i, 3, az + sz, bz)
1501 IF (ay > 0 .AND. by > 0)
THEN
1502 value =
value + 0.5_dp*real(ay*by,
dp)* &
1503 cubeaxis(i, 1, ax + sx, bx)* &
1504 cubeaxis(i, 2, ay - 1 + sy, by - 1)*cubeaxis(i, 3, az + sz, bz)
1507 value =
value + 2.0_dp*zeta*zetb* &
1508 cubeaxis(i, 1, ax + sx, bx)*cubeaxis(i, 2, ay + sy, by)* &
1509 cubeaxis(i, 3, az + 1 + sz, bz + 1)
1511 value =
value - real(az,
dp)*zetb* &
1512 cubeaxis(i, 1, ax + sx, bx)*cubeaxis(i, 2, ay + sy, by)* &
1513 cubeaxis(i, 3, az - 1 + sz, bz + 1)
1516 value =
value - zeta*real(bz,
dp)* &
1517 cubeaxis(i, 1, ax + sx, bx)*cubeaxis(i, 2, ay + sy, by)* &
1518 cubeaxis(i, 3, az + 1 + sz, bz - 1)
1520 IF (az > 0 .AND. bz > 0)
THEN
1521 value =
value + 0.5_dp*real(az*bz,
dp)* &
1522 cubeaxis(i, 1, ax + sx, bx)*cubeaxis(i, 2, ay + sy, by)* &
1523 cubeaxis(i, 3, az - 1 + sz, bz - 1)
1526 END FUNCTION tau_plane_product_shifted
1528 END SUBROUTINE collocate_pgf_product_gspace_buffered
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
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)
...
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
GAPW reciprocal-space reconstruction and its discrete adjoint.
subroutine, public integrate_gapw_composite_vxc_gspace(qs_env, auxbas_pw_pool, vxc_rho, vxc_tau, atom_force, strain_virial, one_center_contraction, one_center_rho_contraction, one_center_tau_contraction)
Apply the discrete adjoint of the common-grid GAPW hard-minus-soft reconstruction.
subroutine, public calculate_rhotot_elec_gspace(qs_env, auxbas_pw_pool, rhotot_elec_gspace, q_max, rho_hard, rho_soft, fsign, compute_tau, rho_source, allow_nonorthorhombic)
The total electronic density in reciprocal space (g-space) is calculated.
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public nsoset
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :), allocatable, public indco
integer, dimension(:), allocatable, public nso
Define the data structure for the particle information.
subroutine, public get_paw_basis_info(basis_1c, o2nindex, n2oindex, nsatbas)
Return some info on the PAW basis derived from a GTO basis set.
integer, parameter, public halfspace
This module defines the grid data type and some basic operations on it.
subroutine, public get_pw_grid_info(pw_grid, id_nr, mode, vol, dvol, npts, ngpts, ngpts_cut, dr, cutoff, orthorhombic, gvectors, gsquare)
Access to information stored in the pw_grid_type.
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
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.
subroutine, public get_rho_atom(rho_atom, cpc_h, cpc_s, rho_rad_h, rho_rad_s, drho_rad_h, drho_rad_s, vrho_rad_h, vrho_rad_s, rho_rad_h_d, rho_rad_s_d, ga_vlocal_gb_h, ga_vlocal_gb_s, int_scr_h, int_scr_s)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.