71 integer,
parameter :: MAX_NPROJECTIONS = 4
72 integer,
parameter :: MAX_L = 5
88 integer :: nprojections
89 integer,
public :: lmax
90 integer,
public :: lloc
94 type(submesh_t),
public :: sphere
99 type(hgh_projector_t),
allocatable,
public :: hgh_p(:, :)
100 type(kb_projector_t),
allocatable,
public :: kb_p(:, :)
101 type(rkb_projector_t),
allocatable,
public :: rkb_p(:, :)
102 complex(real64),
allocatable,
public :: phase(:, :, :)
108 logical elemental function projector_is_null(p)
109 type(projector_t),
intent(in) :: p
111 projector_is_null = (p%type ==
proj_none)
115 logical elemental function projector_is(p, type)
116 type(projector_t),
intent(in) :: p
117 integer,
intent(in) :: type
123 type(projector_t),
intent(inout) :: p
124 type(pseudopotential_t),
target,
intent(in) :: pseudo
125 type(namespace_t),
intent(in) :: namespace
126 integer,
intent(in) :: dim
127 integer,
intent(in) :: reltype
129 type(ps_t),
pointer :: ps
146 p%type = ps%projector_type
148 if (p%type == proj_kb .and. reltype == 1)
then
149 if (ps%relativistic_treatment == proj_j_dependent)
then
152 call messages_write(
"Spin-orbit coupling for species '"//trim(pseudo%get_label())//
" is not available.")
153 call messages_warning(namespace=namespace)
158 case (proj_kb, proj_rkb)
159 p%nprojections = ps%kbc
173 integer,
intent(in) :: dim
174 type(states_elec_dim_t),
intent(in) :: std
175 type(boundaries_t),
intent(in) :: bnd
176 type(kpoints_t),
intent(in) :: kpoints
177 real(real64),
optional,
allocatable,
intent(in) :: vec_pot(:)
178 real(real64),
optional,
allocatable,
intent(in) :: vec_pot_var(:, :)
180 integer :: ns, iq, is, ikpoint
181 real(real64) :: kr, kpoint(dim)
182 integer :: nphase, iphase
183 real(real64),
allocatable :: diff(:,:)
189 if (bnd%spiralBC) nphase = 3
191 if (.not.
allocated(this%phase) .and. ns > 0)
then
192 safe_allocate(this%phase(1:ns, 1:nphase, std%kpt%start:std%kpt%end))
199 safe_allocate(diff(1:dim, 1:ns))
203 diff(:, is) = this%sphere%rel_x(:,is) + this%sphere%center - this%sphere%mesh%x(:, this%sphere%map(is))
206 do iq = std%kpt%start, std%kpt%end
207 ikpoint = std%get_kpoint_index(iq)
210 assert(ikpoint <= kpoints_number(kpoints))
213 kpoint(1:dim) = kpoints%get_point(ikpoint)
215 do iphase = 1, nphase
221 kr = sum(kpoint(1:dim)*diff(1:dim, is))
223 if (
present(vec_pot))
then
224 if (
allocated(vec_pot)) kr = kr + sum(vec_pot(1:dim)*diff(1:dim, is))
227 if (
present(vec_pot_var))
then
228 if (
allocated(vec_pot_var)) kr = kr + sum(vec_pot_var(1:dim, this%sphere%map(is)) &
229 *(this%sphere%rel_x(:, is)+this%sphere%center))
232 if (bnd%spiralBC .and. iphase > 1)
then
233 kr = kr + (2*(iphase-1)-3)*sum(bnd%spiral_q(1:dim)*diff(1:dim, is))
236 this%phase(is, iphase, iq) =
exp(-m_zi*kr)
243 safe_deallocate_a(diff)
252 class(pseudopotential_t),
intent(in) :: ps
253 real(real64),
intent(in) :: so_strength
262 safe_allocate(p%hgh_p(0:p%lmax, -p%lmax:p%lmax))
264 if (ll == p%lloc) cycle
266 call hgh_projector_init(p%hgh_p(ll, mm), p%sphere, p%reltype, ps, ll, mm, so_strength)
271 safe_allocate(p%kb_p(0:p%lmax, -p%lmax:p%lmax))
273 if (ll == p%lloc) cycle
275 call kb_projector_init(p%kb_p(ll, mm), p%sphere, ps, ll, mm)
280 safe_allocate(p%rkb_p(1:p%lmax, -p%lmax:p%lmax))
282 if (ll == p%lloc) cycle
284 call rkb_projector_init(p%rkb_p(ll, mm), p%sphere, ps, ll, mm, so_strength)
288 if (p%lloc /= 0)
then
289 safe_allocate(p%kb_p(1, 1))
290 call kb_projector_init(p%kb_p(1, 1), p%sphere, ps, 0, 0)
306 class(pseudopotential_t),
target,
intent(in) :: pseudo
307 type(submesh_t),
intent(in) :: sm
308 type(namespace_t),
intent(in) :: namespace
310 integer :: ll, mm, ic, ir, nc
311 real(real64) :: rc, dr, rr, norm_rad, norm_grid, dev
312 real(real64),
allocatable :: uv(:)
313 type(ps_t),
pointer :: ps
315 integer,
parameter :: quad_points = 2000
317 real(real64),
parameter :: norm_dev_warning = 0.05_real64
324 safe_allocate(uv(1:max(sm%np, 1)))
327 if (ll == ps%llocal) cycle
330 if (ps%projector_type == proj_kb) nc = min(nc, ps%projectors_per_l(ll+1))
334 rc = ps%kb(ll, ic)%x_threshold
335 if (rc <= m_epsilon) cycle
338 do ir = 1, quad_points
339 rr = (ir - m_half)*dr
340 norm_rad = norm_rad + spline_eval(ps%kb(ll, ic), rr)**2 * rr**2
342 norm_rad = norm_rad*dr
343 if (norm_rad <= 1.0e-10_real64) cycle
347 call pseudopotential_real_nl_projector(pseudo, sm%np, sm%rel_x, sm%r, ll, mm, ic, uv)
348 norm_grid = dsm_nrm2(sm, uv)**2
349 dev = max(dev, abs(norm_grid - norm_rad)/norm_rad)
354 safe_deallocate_a(uv)
356 write(message(1),
'(a,es9.2)')
"Debug: projector discretization error for species '" &
357 //trim(pseudo%get_label())//
"' = ", dev
358 call messages_info(1, namespace=namespace, debug_only=.
true.)
360 if (dev > norm_dev_warning)
then
361 write(message(1),
'(a)')
"The nonlocal projectors of species '"//trim(pseudo%get_label())//
"'"
362 write(message(2),
'(a)')
"are not well resolved on the real-space grid: at least one projector norm"
363 write(message(3),
'(a,f8.1,a)')
"deviates by ", dev*100,
"% from its radial-grid value."
364 write(message(4),
'(a)')
"This can produce spurious (ghost) states. Please reduce the grid Spacing."
365 call messages_warning(4, namespace=namespace)
379 call submesh_end(p%sphere)
384 if (ll == p%lloc) cycle
386 call hgh_projector_end(p%hgh_p(ll, mm))
389 safe_deallocate_a(p%hgh_p)
393 if (ll == p%lloc) cycle
395 call kb_projector_end(p%kb_p(ll, mm))
398 safe_deallocate_a(p%kb_p)
402 if (ll == p%lloc) cycle
404 call rkb_projector_end(p%rkb_p(ll, mm))
407 safe_deallocate_a(p%rkb_p)
408 if (p%lloc /= 0)
then
409 call kb_projector_end(p%kb_p(1, 1))
410 safe_deallocate_a(p%kb_p)
417 safe_deallocate_a(p%phase)
424#include "projector_inc.F90"
427#include "complex.F90"
428#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.
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....