71 integer,
parameter :: MAX_NPROJECTIONS = 4
72 integer,
parameter :: MAX_L = 5
89 integer :: nprojections
90 integer,
public :: lmax
91 integer,
public :: lloc
95 type(submesh_t),
public :: sphere
100 type(hgh_projector_t),
allocatable,
public :: hgh_p(:, :)
101 type(kb_projector_t),
allocatable,
public :: kb_p(:, :)
102 type(rkb_projector_t),
allocatable,
public :: rkb_p(:, :)
103 real(real64),
allocatable,
public :: uspp_dij(:, :, :)
104 real(real64),
allocatable,
public :: uspp_qij(:, :, :)
105 real(real64),
allocatable,
public :: uspp_qfunc(:, :, :)
106 integer,
public :: uspp_qfunc_lmax = -1
107 integer,
public :: uspp_qfunc_nbeta = 0
108 complex(real64),
allocatable,
public :: phase(:, :, :)
114 logical elemental function projector_is_null(p)
115 type(projector_t),
intent(in) :: p
117 projector_is_null = (p%type ==
proj_none)
121 logical elemental function projector_is(p, type)
122 type(projector_t),
intent(in) :: p
123 integer,
intent(in) :: type
129 type(projector_t),
intent(inout) :: p
130 type(pseudopotential_t),
target,
intent(in) :: pseudo
131 type(namespace_t),
intent(in) :: namespace
132 integer,
intent(in) :: dim
133 integer,
intent(in) :: reltype
135 type(ps_t),
pointer :: ps
152 p%type = ps%projector_type
156 if (p%type == proj_kb .and. reltype == 1)
then
157 if (ps%relativistic_treatment == proj_j_dependent)
then
160 call messages_write(
"Spin-orbit coupling for species '"//trim(pseudo%get_label())//
" is not available.")
161 call messages_warning(namespace=namespace)
166 case (proj_kb, proj_rkb, proj_uspp)
167 p%nprojections = ps%kbc
180 type(projector_t),
intent(inout) :: this
181 integer,
intent(in) :: dim
182 type(states_elec_dim_t),
intent(in) :: std
183 type(boundaries_t),
intent(in) :: bnd
184 type(kpoints_t),
intent(in) :: kpoints
185 real(real64),
optional,
allocatable,
intent(in) :: vec_pot(:)
186 real(real64),
optional,
allocatable,
intent(in) :: vec_pot_var(:, :)
188 integer :: ns, iq, is, ikpoint
189 real(real64) :: kr, kpoint(dim)
190 integer :: nphase, iphase
191 real(real64),
allocatable :: diff(:,:)
197 if (bnd%spiralBC) nphase = 3
199 if (.not.
allocated(this%phase) .and. ns > 0)
then
200 safe_allocate(this%phase(1:ns, 1:nphase, std%kpt%start:std%kpt%end))
207 safe_allocate(diff(1:dim, 1:ns))
211 diff(:, is) = this%sphere%rel_x(:,is) + this%sphere%center - this%sphere%mesh%x(:, this%sphere%map(is))
214 do iq = std%kpt%start, std%kpt%end
215 ikpoint = std%get_kpoint_index(iq)
218 assert(ikpoint <= kpoints_number(kpoints))
221 kpoint(1:dim) = kpoints%get_point(ikpoint)
223 do iphase = 1, nphase
229 kr = sum(kpoint(1:dim)*diff(1:dim, is))
231 if (
present(vec_pot))
then
232 if (
allocated(vec_pot)) kr = kr + sum(vec_pot(1:dim)*diff(1:dim, is))
235 if (
present(vec_pot_var))
then
236 if (
allocated(vec_pot_var)) kr = kr + sum(vec_pot_var(1:dim, this%sphere%map(is)) &
237 *(this%sphere%rel_x(:, is)+this%sphere%center))
240 if (bnd%spiralBC .and. iphase > 1)
then
241 kr = kr + (2*(iphase-1)-3)*sum(bnd%spiral_q(1:dim)*diff(1:dim, is))
244 this%phase(is, iphase, iq) =
exp(-m_zi*kr)
251 safe_deallocate_a(diff)
260 class(pseudopotential_t),
intent(in) :: ps
261 real(real64),
intent(in) :: so_strength
263 integer :: ll, mm, ic, ip
270 safe_allocate(p%hgh_p(0:p%lmax, -p%lmax:p%lmax))
272 if (ll == p%lloc) cycle
274 call hgh_projector_init(p%hgh_p(ll, mm), p%sphere, p%reltype, ps, ll, mm, so_strength)
278 case (proj_kb, proj_uspp)
279 safe_allocate(p%kb_p(0:p%lmax, -p%lmax:p%lmax))
280 if (p%type == proj_uspp)
then
281 safe_allocate(p%uspp_dij(0:p%lmax, 1:ps%ps%kbc, 1:ps%ps%kbc))
282 safe_allocate(p%uspp_qij(0:p%lmax, 1:ps%ps%kbc, 1:ps%ps%kbc))
284 p%uspp_qij = ps%ps%qij
285 if (
allocated(ps%ps%radial_augmentation))
then
286 p%uspp_qfunc_lmax = ps%ps%radial_augmentation_lmax
287 p%uspp_qfunc_nbeta = ps%ps%radial_augmentation_nprojectors
288 safe_allocate(p%uspp_qfunc(1:p%sphere%np, 1:p%uspp_qfunc_nbeta*p%uspp_qfunc_nbeta, 0:p%uspp_qfunc_lmax))
289 do ll = 0, p%uspp_qfunc_lmax
290 do ic = 1, p%uspp_qfunc_nbeta*p%uspp_qfunc_nbeta
291 do ip = 1, p%sphere%np
292 if (p%sphere%r(ip) < spline_range_max(ps%ps%radial_augmentation(ic, ll)))
then
293 p%uspp_qfunc(ip, ic, ll) = spline_eval(ps%ps%radial_augmentation(ic, ll), p%sphere%r(ip))
295 p%uspp_qfunc(ip, ic, ll) = m_zero
303 if (ll == p%lloc) cycle
305 call kb_projector_init(p%kb_p(ll, mm), p%sphere, ps, ll, mm)
310 safe_allocate(p%rkb_p(1:p%lmax, -p%lmax:p%lmax))
312 if (ll == p%lloc) cycle
314 call rkb_projector_init(p%rkb_p(ll, mm), p%sphere, ps, ll, mm, so_strength)
318 if (p%lloc /= 0)
then
319 safe_allocate(p%kb_p(1, 1))
320 call kb_projector_init(p%kb_p(1, 1), p%sphere, ps, 0, 0)
336 class(pseudopotential_t),
target,
intent(in) :: pseudo
337 type(submesh_t),
intent(in) :: sm
338 type(namespace_t),
intent(in) :: namespace
340 integer :: ll, mm, ic, ir, nc
341 real(real64) :: rc, dr, rr, norm_rad, norm_grid, dev
342 real(real64),
allocatable :: uv(:)
343 type(ps_t),
pointer :: ps
345 integer,
parameter :: quad_points = 2000
347 real(real64),
parameter :: norm_dev_warning = 0.05_real64
354 safe_allocate(uv(1:max(sm%np, 1)))
357 if (ll == ps%llocal) cycle
360 if (ps%projector_type == proj_kb) nc = min(nc, ps%projectors_per_l(ll+1))
364 rc = ps%kb(ll, ic)%x_threshold
365 if (rc <= m_epsilon) cycle
368 do ir = 1, quad_points
369 rr = (ir - m_half)*dr
370 norm_rad = norm_rad + spline_eval(ps%kb(ll, ic), rr)**2 * rr**2
372 norm_rad = norm_rad*dr
373 if (norm_rad <= 1.0e-10_real64) cycle
377 call pseudopotential_real_nl_projector(pseudo, sm%np, sm%rel_x, sm%r, ll, mm, ic, uv)
378 norm_grid = dsm_nrm2(sm, uv)**2
379 dev = max(dev, abs(norm_grid - norm_rad)/norm_rad)
384 safe_deallocate_a(uv)
386 write(message(1),
'(a,es9.2)')
"Debug: projector discretization error for species '" &
387 //trim(pseudo%get_label())//
"' = ", dev
388 call messages_info(1, namespace=namespace, debug_only=.
true.)
390 if (dev > norm_dev_warning)
then
391 write(message(1),
'(a)')
"The nonlocal projectors of species '"//trim(pseudo%get_label())//
"'"
392 write(message(2),
'(a)')
"are not well resolved on the real-space grid: at least one projector norm"
393 write(message(3),
'(a,f8.1,a)')
"deviates by ", dev*100,
"% from its radial-grid value."
394 write(message(4),
'(a)')
"This can produce spurious (ghost) states. Please reduce the grid Spacing."
395 call messages_warning(4, namespace=namespace)
409 call submesh_end(p%sphere)
414 if (ll == p%lloc) cycle
416 call hgh_projector_end(p%hgh_p(ll, mm))
419 safe_deallocate_a(p%hgh_p)
421 case (proj_kb, proj_uspp)
423 if (ll == p%lloc) cycle
425 call kb_projector_end(p%kb_p(ll, mm))
428 safe_deallocate_a(p%kb_p)
429 safe_deallocate_a(p%uspp_dij)
430 safe_deallocate_a(p%uspp_qij)
431 safe_deallocate_a(p%uspp_qfunc)
435 if (ll == p%lloc) cycle
437 call rkb_projector_end(p%rkb_p(ll, mm))
440 safe_deallocate_a(p%rkb_p)
441 if (p%lloc /= 0)
then
442 call kb_projector_end(p%kb_p(1, 1))
443 safe_deallocate_a(p%kb_p)
450 safe_deallocate_a(p%phase)
457#include "projector_inc.F90"
460#include "complex.F90"
461#include "projector_inc.F90"
double exp(double __x) __attribute__((__nothrow__
This module implements batches of mesh functions.
This module implements common operations on batches of mesh functions.
Module implementing boundary conditions in Octopus.
This module implements the underlying real-space grid.
This module defines the meshes, which are used in Octopus.
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
real(real64) function, public dprojector_matrix_element(pj, bnd, dim, ik, psia, psib)
dprojector_matrix_element calculates <psia|projector|psib>
subroutine, public projector_build(p, ps, so_strength)
subroutine, public dprojector_commute_r(pj, mesh, bnd, dim, idir, ik, psi, cpsi)
This function calculates |cpsi> += [x, V_nl] |psi>
logical elemental function, public projector_is(p, type)
subroutine, public dproject_psi(mesh, bnd, pj, npj, dim, psi, ppsi, ik)
dproject_psi calculates the action of a projector on the psi wavefunction. The result is summed up to...
subroutine, public projector_init(p, pseudo, namespace, dim, reltype)
subroutine, public projector_init_phases(this, dim, std, bnd, kpoints, vec_pot, vec_pot_var)
subroutine, public dproject_psi_batch(mesh, bnd, pj, npj, dim, psib, ppsib)
To optimize the application of the non-local operator in parallel, the projectors are applied in step...
complex(real64) function, public zprojector_matrix_element(pj, bnd, dim, ik, psia, psib)
zprojector_matrix_element calculates <psia|projector|psib>
subroutine, public zprojector_commute_r_allatoms_alldir(pj, ions, mesh, dim, bnd, ik, psi, cpsi)
This function calculates |cpsi> += [x, V_nl] |psi>
subroutine, public projector_end(p)
subroutine, public zproject_psi(mesh, bnd, pj, npj, dim, psi, ppsi, ik)
zproject_psi calculates the action of a projector on the psi wavefunction. The result is summed up to...
subroutine, public zproject_psi_batch(mesh, bnd, pj, npj, dim, psib, ppsib)
To optimize the application of the non-local operator in parallel, the projectors are applied in step...
subroutine, public projector_check_discretization(pseudo, sm, namespace)
Check how well the nonlocal projectors are resolved on the real-space grid.
subroutine, public dprojector_commute_r_allatoms_alldir(pj, ions, mesh, dim, bnd, ik, psi, cpsi)
This function calculates |cpsi> += [x, V_nl] |psi>
subroutine, public zprojector_commute_r(pj, mesh, bnd, dim, idir, ik, psi, cpsi)
This function calculates |cpsi> += [x, V_nl] |psi>
logical elemental function, public projector_is_null(p)
integer, parameter, public proj_none
This module handles spin dimensions of the states and the k-point distribution.
The projector data type is intended to hold the local and non-local parts of the pseudopotentials....