34 use,
intrinsic :: iso_fortran_env
75 class(nonlocal_pseudopotential_t),
target,
intent(in) :: this
76 type(epot_t),
target,
intent(in) :: epot
77 class(mesh_t),
intent(in) :: mesh
78 real(real64),
optional,
intent(inout) :: density(:, :)
79 real(real64),
optional,
intent(inout) :: tau(:, :)
80 real(real64),
optional,
intent(inout) :: current(:, :, :)
82 integer :: imat, iatom, is, nsp, nprojs, nlm, ncol, idir, dim
83 integer,
allocatable :: map(:), ll(:), mm(:)
84 real(real64),
allocatable :: rho(:,:,:), arho(:,:,:)
86 type(spline_t),
allocatable :: spl(:)
87 type(projector_matrix_t),
pointer :: pmat
88 type(projector_t),
pointer :: proj
93 if (.not.
allocated(this%onsite_density_matrix) .or. &
94 .not. (
present(density) .or.
present(tau) .or.
present(current)))
then
101 if (
present(current)) dim =
size(current, 2)
103 do imat = 1, this%nprojector_matrices
104 iatom = this%projector_to_atom(imat)
105 proj => epot%proj(iatom)
106 if (.not.
associated(proj%aug%paw)) cycle
107 pmat => this%projector_matrices(imat)
111 assert(nlm == nprojs)
112 assert(
size(this%onsite_density_matrix, 4) >= nsp)
113 if (
present(density))
then
114 assert(
size(density, 2) >= nsp)
116 if (
present(tau))
then
117 assert(
size(tau, 2) >= min(nsp, 2))
122 safe_allocate(map(1:nprojs))
124 safe_allocate(rho(1:nlm, 1:nlm, 1:nsp))
129 if (
present(current))
then
130 assert(
allocated(this%onsite_current_matrix))
131 safe_allocate(arho(1:nlm, 1:nlm, 1:nsp))
138 if (
present(density))
then
141 cache = proj%dg_cache)
143 if (
present(tau) .and. is <= 2)
then
146 cache = proj%dg_cache)
148 if (
present(current))
then
151 call paw_splat_onsite_columns(epot%dgrid, proj%sphere, ncol, spl, ll, mm, rcut, current(:, idir, is), &
152 cache = proj%dg_cache)
157 safe_deallocate_a(map)
158 safe_deallocate_a(rho)
159 safe_deallocate_a(arho)
173 integer,
intent(in) :: ncol
174 type(
spline_t),
allocatable,
intent(inout) :: spl(:)
175 integer,
allocatable,
intent(inout) :: ll(:), mm(:)
176 real(real64),
intent(in) :: rcut
177 real(real64),
intent(inout) :: field_col(:)
180 real(real64),
allocatable :: feff(:,:), sphi(:), rcutv(:), ones(:)
183 if (ncol > 0 .and. sphere%np > 0)
then
184 safe_allocate(rcutv(1:ncol))
186 safe_allocate(feff(1:sphere%np, 1:ncol))
190 safe_allocate(sphi(1:sphere%np))
191 safe_allocate(ones(1:ncol))
195 safe_deallocate_a(ones)
196 safe_deallocate_a(sphi)
197 safe_deallocate_a(feff)
198 safe_deallocate_a(rcutv)
201 safe_deallocate_a(spl)
202 safe_deallocate_a(ll)
203 safe_deallocate_a(mm)
217 type(
epot_t),
target,
intent(in) :: epot
218 integer,
intent(in) :: dim
220 integer :: imat, iatom, nprojs, nlm, iproj, jproj, idir, ncol, pairidx, col, nsph
221 integer :: ngrp, maxcols, ntot, g, base
222 integer,
allocatable :: map(:), ll(:), mm(:), big_ll(:), big_mm(:), grp_start(:), grp_ncol(:)
223 real(real64),
allocatable :: arho(:,:), big_rcut(:), feff(:,:)
225 type(
spline_t),
allocatable :: spl(:), big_spl(:)
231 do imat = 1, this%nprojector_matrices
232 iatom = this%projector_to_atom(imat)
233 proj => epot%proj(iatom)
234 if (.not.
associated(proj%aug%paw)) cycle
235 pmat => this%projector_matrices(imat)
238 assert(nlm == nprojs)
239 nsph = proj%sphere%np
241 safe_allocate(map(1:nprojs))
244 safe_deallocate_a(proj%aug%jbasis)
245 safe_allocate(proj%aug%jbasis(1:nsph, 1:nprojs*nprojs, 1:dim))
247 proj%aug%jbasis_nprojs = nprojs
253 ngrp = nprojs*nprojs*dim
255 safe_allocate(big_spl(1:maxcols))
256 safe_allocate(big_ll(1:maxcols))
257 safe_allocate(big_mm(1:maxcols))
258 safe_allocate(big_rcut(1:maxcols))
259 safe_allocate(grp_start(1:ngrp))
260 safe_allocate(grp_ncol(1:ngrp))
261 safe_allocate(arho(1:nlm, 1:nlm))
265 pairidx = (iproj - 1)*nprojs + jproj
267 arho(map(iproj), map(jproj)) =
m_one
269 g = (idir - 1)*nprojs*nprojs + pairidx
271 grp_start(g) = ntot + 1
275 big_spl(ntot) = spl(col)
276 big_ll(ntot) = ll(col)
277 big_mm(ntot) = mm(col)
278 big_rcut(ntot) = rcut
281 safe_deallocate_a(spl)
282 safe_deallocate_a(ll)
283 safe_deallocate_a(mm)
288 if (ntot > 0 .and. nsph > 0)
then
289 safe_allocate(feff(1:nsph, 1:ntot))
291 big_rcut, feff, cache = proj%dg_cache)
295 pairidx = (iproj - 1)*nprojs + jproj
296 g = (idir - 1)*nprojs*nprojs + pairidx
298 do col = 1, grp_ncol(g)
299 proj%aug%jbasis(1:nsph, pairidx, idir) = proj%aug%jbasis(1:nsph, pairidx, idir) &
300 + feff(1:nsph, base + col - 1)
305 safe_deallocate_a(feff)
308 if (ntot > 0)
call spline_end(big_spl(1:ntot))
309 safe_deallocate_a(big_spl)
310 safe_deallocate_a(big_ll)
311 safe_deallocate_a(big_mm)
312 safe_deallocate_a(big_rcut)
313 safe_deallocate_a(grp_start)
314 safe_deallocate_a(grp_ncol)
315 safe_deallocate_a(arho)
316 safe_deallocate_a(map)
333 type(
epot_t),
target,
intent(in) :: epot
334 real(real64),
intent(inout) :: current(:, :, :)
336 integer :: imat, iatom, nprojs, np, idir, is, nsp, iproj, jproj
337 real(real64),
allocatable :: wcol(:), acc(:)
344 if (.not.
allocated(this%onsite_current_matrix))
then
349 nsp = min(
size(this%onsite_current_matrix, 4),
size(current, 3))
351 do imat = 1, this%nprojector_matrices
352 iatom = this%projector_to_atom(imat)
353 proj => epot%proj(iatom)
354 if (.not.
allocated(proj%aug%jbasis)) cycle
355 pmat => this%projector_matrices(imat)
360 safe_allocate(wcol(1:nprojs*nprojs))
361 safe_allocate(acc(1:np))
363 do idir = 1,
size(current, 2)
366 wcol((iproj - 1)*nprojs + jproj) = this%onsite_current_matrix(iproj, jproj, imat, is)
374 safe_deallocate_a(wcol)
375 safe_deallocate_a(acc)
The Ono-Hirose double-grid technique [T. Ono and K. Hirose, Phys. Rev. Lett. 82, 5016 (1999); Phys....
subroutine, public double_grid_transform(this, sm, nf, spl, ll, mm, rcut, feff, cart_dir, cache)
Evaluate a batch of localized functions f_jf(x) = spl_jf(r) * Y_{ll,mm}(x) (or a purely radial spl_jf...
real(real64), parameter, public m_zero
real(real64), parameter, public m_one
This module defines the meshes, which are used in Octopus.
All-electron reconstruction of mesh fields from the PAW one-center terms.
subroutine, public paw_ae_add_onsite_current(this, epot, current)
Add the time-dependent one-center all-electron current to the current density.
subroutine, public paw_ae_build_current_basis(this, epot, dim)
Tabulate the one-center all-electron current basis on each projector sphere.
subroutine, public paw_ae_reconstruct_field(this, epot, mesh, density, tau, current)
Reconstruct all-electron mesh fields from the PAW one-center terms. Any subset of the supported quant...
subroutine paw_splat_onsite_columns(dgrid, sphere, ncol, spl, ll, mm, rcut, field_col, cache)
Splat the radial x Y_LM columns of a one-center difference (spl/ll/mm from paw_onsite_density_diff / ...
subroutine, public paw_onsite_tau_diff(this, rho, ncol, spl, ll, mm, rcut, tau_integral)
Build the one-center all-electron-minus-pseudo kinetic-energy-density difference for a single colline...
subroutine, public paw_onsite_current_diff(this, arho, idir, ncol, spl, ll, mm, rcut, current_integral)
One-center all-electron current-density correction Delta j^alpha = j^1 - j~^1.
integer pure function, public paw_onsite_nlm(this)
Number of (l,m)-resolved projectors, i.e. the leading dimension of rho_ij.
integer pure function, public paw_onsite_nlm_rho(this)
Number of real-harmonic columns (lmax_rho+1)^2 of the one-center density expansion; the upper bound o...
subroutine, public paw_onsite_reorder_pmat(nprojs, map, src, dst)
Reorder one spin channel of a projector-ordered matrix.
subroutine, public paw_onsite_pmat_map(this, nprojs, pl, pm, pchannel, map)
Map the projector-matrix enumeration (l, m, channel) used by the mesh nonlocal machinery to the one-c...
integer pure function, public paw_onsite_nspin(this)
Number of collinear spin channels (1 or 2) the sphere was built for.
subroutine, public paw_onsite_density_diff(this, rho, ncol, spl, ll, mm, rcut)
Build the one-center all-electron-minus-(pseudo+compensation) density difference for a single colline...
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Persistent, function-independent geometry of the double-grid transpose scatter for one submesh....
nonlocal part of the pseudopotential
A set of projectors defined on a submesh.
The projector data type is intended to hold the local and non-local parts of the pseudopotentials....
the basic spline datatype
A submesh is a type of mesh, used for the projectors in the pseudopotentials It contains points on a ...