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
150 if (p%type == proj_kb .and. reltype == 1)
then
151 if (ps%relativistic_treatment == proj_j_dependent)
then
154 call messages_write(
"Spin-orbit coupling for species '"//trim(pseudo%get_label())//
" is not available.")
155 call messages_warning(namespace=namespace)
160 case (proj_kb, proj_rkb)
161 p%nprojections = ps%kbc
175 integer,
intent(in) :: dim
176 type(states_elec_dim_t),
intent(in) :: std
177 type(boundaries_t),
intent(in) :: bnd
178 type(kpoints_t),
intent(in) :: kpoints
179 real(real64),
optional,
allocatable,
intent(in) :: vec_pot(:)
180 real(real64),
optional,
allocatable,
intent(in) :: vec_pot_var(:, :)
182 integer :: ns, iq, is, ikpoint
183 real(real64) :: kr, kpoint(dim)
184 integer :: nphase, iphase
185 real(real64),
allocatable :: diff(:,:)
191 if (bnd%spiralBC) nphase = 3
193 if (.not.
allocated(this%phase) .and. ns > 0)
then
194 safe_allocate(this%phase(1:ns, 1:nphase, std%kpt%start:std%kpt%end))
201 safe_allocate(diff(1:dim, 1:ns))
205 diff(:, is) = this%sphere%rel_x(:,is) + this%sphere%center - this%sphere%mesh%x(:, this%sphere%map(is))
208 do iq = std%kpt%start, std%kpt%end
209 ikpoint = std%get_kpoint_index(iq)
212 assert(ikpoint <= kpoints_number(kpoints))
215 kpoint(1:dim) = kpoints%get_point(ikpoint)
217 do iphase = 1, nphase
223 kr = sum(kpoint(1:dim)*diff(1:dim, is))
225 if (
present(vec_pot))
then
226 if (
allocated(vec_pot)) kr = kr + sum(vec_pot(1:dim)*diff(1:dim, is))
229 if (
present(vec_pot_var))
then
230 if (
allocated(vec_pot_var)) kr = kr + sum(vec_pot_var(1:dim, this%sphere%map(is)) &
231 *(this%sphere%rel_x(:, is)+this%sphere%center))
234 if (bnd%spiralBC .and. iphase > 1)
then
235 kr = kr + (2*(iphase-1)-3)*sum(bnd%spiral_q(1:dim)*diff(1:dim, is))
238 this%phase(is, iphase, iq) =
exp(-m_zi*kr)
245 safe_deallocate_a(diff)
254 class(pseudopotential_t),
intent(in) :: ps
255 real(real64),
intent(in) :: so_strength
264 safe_allocate(p%hgh_p(0:p%lmax, -p%lmax:p%lmax))
266 if (ll == p%lloc) cycle
268 call hgh_projector_init(p%hgh_p(ll, mm), p%sphere, p%reltype, ps, ll, mm, so_strength)
273 safe_allocate(p%kb_p(0:p%lmax, -p%lmax:p%lmax))
275 if (ll == p%lloc) cycle
277 call kb_projector_init(p%kb_p(ll, mm), p%sphere, ps, ll, mm)
282 safe_allocate(p%rkb_p(1:p%lmax, -p%lmax:p%lmax))
284 if (ll == p%lloc) cycle
286 call rkb_projector_init(p%rkb_p(ll, mm), p%sphere, ps, ll, mm, so_strength)
290 if (p%lloc /= 0)
then
291 safe_allocate(p%kb_p(1, 1))
292 call kb_projector_init(p%kb_p(1, 1), p%sphere, ps, 0, 0)
308 class(pseudopotential_t),
target,
intent(in) :: pseudo
309 type(submesh_t),
intent(in) :: sm
310 type(namespace_t),
intent(in) :: namespace
312 integer :: ll, mm, ic, ir, nc
313 real(real64) :: rc, dr, rr, norm_rad, norm_grid, dev
314 real(real64),
allocatable :: uv(:)
315 type(ps_t),
pointer :: ps
317 integer,
parameter :: quad_points = 2000
319 real(real64),
parameter :: norm_dev_warning = 0.05_real64
326 safe_allocate(uv(1:max(sm%np, 1)))
329 if (ll == ps%llocal) cycle
332 if (ps%projector_type == proj_kb) nc = min(nc, ps%projectors_per_l(ll+1))
336 rc = ps%kb(ll, ic)%x_threshold
337 if (rc <= m_epsilon) cycle
340 do ir = 1, quad_points
341 rr = (ir - m_half)*dr
342 norm_rad = norm_rad + spline_eval(ps%kb(ll, ic), rr)**2 * rr**2
344 norm_rad = norm_rad*dr
345 if (norm_rad <= 1.0e-10_real64) cycle
349 call pseudopotential_real_nl_projector(pseudo, sm%np, sm%rel_x, sm%r, ll, mm, ic, uv)
350 norm_grid = dsm_nrm2(sm, uv)**2
351 dev = max(dev, abs(norm_grid - norm_rad)/norm_rad)
356 safe_deallocate_a(uv)
358 write(message(1),
'(a,es9.2)')
"Debug: projector discretization error for species '" &
359 //trim(pseudo%get_label())//
"' = ", dev
360 call messages_info(1, namespace=namespace, debug_only=.
true.)
362 if (dev > norm_dev_warning)
then
363 write(message(1),
'(a)')
"The nonlocal projectors of species '"//trim(pseudo%get_label())//
"'"
364 write(message(2),
'(a)')
"are not well resolved on the real-space grid: at least one projector norm"
365 write(message(3),
'(a,f8.1,a)')
"deviates by ", dev*100,
"% from its radial-grid value."
366 write(message(4),
'(a)')
"This can produce spurious (ghost) states. Please reduce the grid Spacing."
367 call messages_warning(4, namespace=namespace)
381 call submesh_end(p%sphere)
386 if (ll == p%lloc) cycle
388 call hgh_projector_end(p%hgh_p(ll, mm))
391 safe_deallocate_a(p%hgh_p)
395 if (ll == p%lloc) cycle
397 call kb_projector_end(p%kb_p(ll, mm))
400 safe_deallocate_a(p%kb_p)
404 if (ll == p%lloc) cycle
406 call rkb_projector_end(p%rkb_p(ll, mm))
409 safe_deallocate_a(p%rkb_p)
410 if (p%lloc /= 0)
then
411 call kb_projector_end(p%kb_p(1, 1))
412 safe_deallocate_a(p%kb_p)
419 safe_deallocate_a(p%phase)
426#include "projector_inc.F90"
429#include "complex.F90"
430#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....