Octopus
nonlocal_pseudopotential.F90
Go to the documentation of this file.
1!! Copyright (C) 2009 X. Andrade
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use accel_oct_m
23 use batch_oct_m
25 use blas_oct_m
26 use comm_oct_m
27 use debug_oct_m
29 use epot_oct_m
30 use global_oct_m
34 use math_oct_m
35 use mesh_oct_m
37 use mpi_oct_m
41 use ps_oct_m
43 use space_oct_m
47 use types_oct_m
49
50 implicit none
51
52 private
53
54 public :: &
57
61 private
62 type(projector_matrix_t), allocatable, public :: projector_matrices(:)
63 integer, public :: nprojector_matrices
64 logical, public :: apply_projector_matrices
65 logical, public :: has_non_local_potential
66 integer :: full_projection_size
67 integer, public :: max_npoints
68 integer, public :: total_points
69 integer :: max_nprojs
70 logical :: projector_mix
71 complex(real64), allocatable, public :: projector_phases(:, :, :, :)
72 integer, allocatable, public :: projector_to_atom(:)
73 integer :: nregions
74 integer, allocatable :: regions(:)
75 integer, public :: nphase
80 type(accel_mem_t) :: buff_offsets
81 type(accel_mem_t) :: buff_matrices
82 type(accel_mem_t) :: buff_maps
83 type(accel_mem_t) :: buff_scals
84 type(accel_mem_t) :: buff_position
85 type(accel_mem_t) :: buff_pos
86 type(accel_mem_t) :: buff_invmap
87 type(accel_mem_t), public :: buff_projector_phases
88 type(accel_mem_t) :: buff_mix
89 logical :: projector_self_overlap
90 real(real64), pointer, public :: spin(:,:,:) => null()
91 contains
92
93 procedure :: init => nonlocal_pseudopotential_init
94
95 procedure :: build => nonlocal_pseudopotential_build_proj
96
98
99 procedure :: has_self_overlap => nonlocal_pseudopotential_self_overlap
100
101 procedure :: dstart => dnonlocal_pseudopotential_start
102
103 procedure :: zstart => znonlocal_pseudopotential_start
104
105 procedure :: dfinish => dnonlocal_pseudopotential_finish
106
107 procedure :: zfinish => znonlocal_pseudopotential_finish
108
109 procedure :: dforce => dnonlocal_pseudopotential_force
110
111 procedure :: zforce => znonlocal_pseudopotential_force
112
113 procedure :: dposition_commutator => dnonlocal_pseudopotential_position_commutator
115 procedure :: zposition_commutator => znonlocal_pseudopotential_position_commutator
116
117 procedure :: dr_vn_local => dnonlocal_pseudopotential_r_vnlocal
118
119 procedure :: zr_vn_local => znonlocal_pseudopotential_r_vnlocal
120
122
124 !
125 type projection_t
126 private
127 real(real64), allocatable :: dprojection(:, :)
128 complex(real64), allocatable :: zprojection(:, :)
129 type(accel_mem_t) :: buff_projection
130 type(accel_mem_t) :: buff_spin_to_phase
131 end type projection_t
132
133contains
134
135 ! ---------------------------------------------------------
138 subroutine nonlocal_pseudopotential_init(this)
139 class(nonlocal_pseudopotential_t), intent(inout) :: this
140
142
143 this%apply_projector_matrices = .false.
144 this%has_non_local_potential = .false.
145 this%nprojector_matrices = 0
146
147 this%projector_self_overlap = .false.
148
150 end subroutine nonlocal_pseudopotential_init
151
152
153 !--------------------------------------------------------
156 class(nonlocal_pseudopotential_t), intent(inout) :: this
158 integer :: iproj
162 if (allocated(this%projector_matrices)) then
165 call accel_release_buffer(this%buff_offsets)
166 call accel_release_buffer(this%buff_matrices)
167 call accel_release_buffer(this%buff_maps)
168 call accel_release_buffer(this%buff_scals)
169 call accel_release_buffer(this%buff_position)
170 call accel_release_buffer(this%buff_pos)
171 call accel_release_buffer(this%buff_invmap)
172 if (this%projector_mix) call accel_release_buffer(this%buff_mix)
173 if (allocated(this%projector_phases)) call accel_release_buffer(this%buff_projector_phases)
174 end if
176 do iproj = 1, this%nprojector_matrices
177 call projector_matrix_deallocate(this%projector_matrices(iproj))
178 end do
179 safe_deallocate_a(this%regions)
180 safe_deallocate_a(this%projector_matrices)
181 safe_deallocate_a(this%projector_phases)
182 safe_deallocate_a(this%projector_to_atom)
183 end if
184
187
188 !-----------------------------------------------------------------
195 subroutine nonlocal_pseudopotential_build_proj(this, space, mesh, epot)
196 class(nonlocal_pseudopotential_t), target, intent(inout) :: this
197 class(space_t), intent(in) :: space
198 class(mesh_t), intent(in) :: mesh
199 type(epot_t), target, intent(in) :: epot
201 integer :: iatom, iproj, ll, lmax, lloc, mm, ic, jc
202 integer :: nmat, imat, ip, iorder
203 integer :: nregion, jatom, katom, iregion
204 integer, allocatable :: order(:), head(:), region_count(:)
205 logical, allocatable :: atom_counted(:)
206 logical :: overlap
207 type(projector_matrix_t), pointer :: pmat
208 type(kb_projector_t), pointer :: kb_p
209 type(rkb_projector_t), pointer :: rkb_p
210 type(hgh_projector_t), pointer :: hgh_p
211
213
214 call profiling_in("ATOM_COLORING")
215
216 ! this is most likely a very inefficient algorithm, O(natom**2) or
217 ! O(natom**3), probably it should be replaced by something better.
219 safe_allocate(order(1:epot%natoms)) ! order(iregion) = ?
220 safe_allocate(head(1:epot%natoms + 1)) ! head(iregion) points to the first atom in region iregion
221 safe_allocate(region_count(1:epot%natoms)) ! region_count(iregion): number of atoms in that region
222 safe_allocate(atom_counted(1:epot%natoms))
224 this%projector_self_overlap = .false.
225 atom_counted = .false.
226 order = -1
227
228 head(1) = 1
229 nregion = 0
230 do
231 nregion = nregion + 1
232 assert(nregion <= epot%natoms)
233
234 region_count(nregion) = 0
235
236 do iatom = 1, epot%natoms
237 if (atom_counted(iatom)) cycle
238
239 overlap = .false.
240
241 if (.not. projector_is(epot%proj(iatom), proj_none)) then
242 assert(associated(epot%proj(iatom)%sphere%mesh))
243 do jatom = 1, region_count(nregion)
244 katom = order(head(nregion) + jatom - 1)
245 if (projector_is(epot%proj(katom), proj_none)) cycle
246 overlap = submesh_overlap(epot%proj(iatom)%sphere, epot%proj(katom)%sphere, space)
247 if (overlap) exit
248 end do
249 end if
250
251 if (.not. overlap) then
252 ! iatom did not overlap with any previously counted atoms:
253 ! iatom will be added to the current region
254 region_count(nregion) = region_count(nregion) + 1
255 order(head(nregion) - 1 + region_count(nregion)) = iatom
256 atom_counted(iatom) = .true.
257 end if
258
259 end do
260
261 head(nregion + 1) = head(nregion) + region_count(nregion)
262
263 if (all(atom_counted)) exit
264 end do
265
266 safe_deallocate_a(atom_counted)
267 safe_deallocate_a(region_count)
268
269 call messages_write('The atoms can be separated in ')
270 call messages_write(nregion)
271 call messages_write(' non-overlapping groups.')
272 call messages_info(debug_only=.true.)
273
274 do iregion = 1, nregion
275 do iatom = head(iregion), head(iregion + 1) - 1
276 if (.not. projector_is(epot%proj(order(iatom)), proj_kb)) cycle
277 do jatom = head(iregion), iatom - 1
278 if (.not. projector_is(epot%proj(order(jatom)), proj_kb)) cycle
279 assert(.not. submesh_overlap(epot%proj(order(iatom))%sphere, epot%proj(order(jatom))%sphere, space))
280 end do
281 end do
282 end do
283
284 call profiling_out("ATOM_COLORING")
285
286 ! deallocate previous projectors
287 call this%end()
289 ! count projectors
290 this%nprojector_matrices = 0
291 this%apply_projector_matrices = .false.
292 this%has_non_local_potential = .false.
293 this%nregions = nregion
294
295 !We determine if we have only local potential or not.
296 do iorder = 1, epot%natoms
297 iatom = order(iorder)
298
299 if (.not. projector_is_null(epot%proj(iatom))) then
300 this%has_non_local_potential = .true.
301 exit
302 end if
303 end do
304
305 do iorder = 1, epot%natoms
306 iatom = order(iorder)
307
308 if (.not. projector_is_null(epot%proj(iatom))) then
309 this%nprojector_matrices = this%nprojector_matrices + 1
310 this%apply_projector_matrices = .true.
311 !The HGH pseudopotentials are now supporting the SOC
312 if (epot%reltype /= norel .and. projector_is(epot%proj(iatom), proj_kb)) then
313 this%apply_projector_matrices = .false.
314 exit
315 end if
316 end if
317 end do
318
319 if (mesh%use_curvilinear) this%apply_projector_matrices = .false.
320
321 if (.not. this%apply_projector_matrices) then
322 safe_deallocate_a(order)
323 safe_deallocate_a(head)
324
326 return
327 end if
328
329
330 safe_allocate(this%projector_matrices(1:this%nprojector_matrices))
331 safe_allocate(this%regions(1:this%nprojector_matrices + 1))
332 safe_allocate(this%projector_to_atom(1:epot%natoms))
333
334 this%full_projection_size = 0
335 this%regions(this%nregions + 1) = this%nprojector_matrices + 1
336
337 this%projector_mix = .false.
338
339 iproj = 0
340 do iregion = 1, this%nregions
341 this%regions(iregion) = iproj + 1
342 do iorder = head(iregion), head(iregion + 1) - 1
343
344 iatom = order(iorder)
345
346 if (projector_is(epot%proj(iatom), proj_none)) cycle
347
348 iproj = iproj + 1
349
350 pmat => this%projector_matrices(iproj)
351
352 this%projector_to_atom(iproj) = iatom
353
354 lmax = epot%proj(iatom)%lmax
355 lloc = epot%proj(iatom)%lloc
356
357 if (projector_is(epot%proj(iatom), proj_kb)) then
358
359 ! count the number of projectors for this matrix
360 nmat = 0
361 do ll = 0, lmax
362 if (ll == lloc) cycle
363 do mm = -ll, ll
364 nmat = nmat + epot%proj(iatom)%kb_p(ll, mm)%n_c
365 end do
366 end do
367
368 call projector_matrix_allocate(pmat, nmat, epot%proj(iatom)%sphere, has_mix_matrix = .false.)
369
370 ! generate the matrix
371 pmat%dprojectors = m_zero
372 imat = 1
373 do ll = 0, lmax
374 if (ll == lloc) cycle
375 do mm = -ll, ll
376 kb_p => epot%proj(iatom)%kb_p(ll, mm)
377 do ic = 1, kb_p%n_c
378 do ip = 1, pmat%npoints
379 pmat%dprojectors(ip, imat) = kb_p%p(ip, ic)
380 end do
381 pmat%scal(imat) = kb_p%e(ic)*mesh%vol_pp(1)
382 imat = imat + 1
383 end do
384 end do
385 end do
386
387 this%projector_self_overlap = this%projector_self_overlap .or. epot%proj(iatom)%sphere%overlap
388
389 else if (projector_is(epot%proj(iatom), proj_hgh)) then
390
391 this%projector_mix = .true.
392
393 ! count the number of projectors for this matrix
394 nmat = 0
395 do ll = 0, lmax
396 if (ll == lloc) cycle
397 do mm = -ll, ll
398 nmat = nmat + 3
399 end do
400 end do
401
402 call projector_matrix_allocate(pmat, nmat, epot%proj(iatom)%sphere, &
403 has_mix_matrix = .true., is_cmplx = (epot%reltype == spin_orbit))
404
405 ! generate the matrix
406 if (epot%reltype == spin_orbit) then
407 pmat%zprojectors = m_zero
408 pmat%zmix = m_zero
409 else
410 pmat%dprojectors = m_zero
411 pmat%dmix = m_zero
412 end if
413
414 imat = 1
415 do ll = 0, lmax
416 if (ll == lloc) cycle
417 do mm = -ll, ll
418 hgh_p => epot%proj(iatom)%hgh_p(ll, mm)
419
420 ! HGH pseudos mix different components, so we need to
421 ! generate a matrix that mixes the projections
422 if (epot%reltype == spin_orbit .or. epot%reltype == fully_relativistic_zora) then
423 do ic = 1, 3
424 do jc = 1, 3
425 pmat%zmix(imat - 1 + ic, imat - 1 + jc, 1) = hgh_p%h(ic, jc) + m_half*mm*hgh_p%k(ic, jc)
426 pmat%zmix(imat - 1 + ic, imat - 1 + jc, 2) = hgh_p%h(ic, jc) - m_half*mm*hgh_p%k(ic, jc)
427
428 if (mm < ll) then
429 pmat%zmix(imat - 1 + ic, imat + 3 - 1 + jc, 3) = m_half*hgh_p%k(ic, jc) * &
430 sqrt(real(ll*(ll+1)-mm*(mm+1), real64))
431 end if
432
433 if (-mm < ll) then
434 pmat%zmix(imat - 1 + ic, imat - 3 - 1 + jc, 4) = m_half*hgh_p%k(ic, jc) * &
435 sqrt(real(ll*(ll+1)-mm*(mm-1), real64))
436 end if
437 end do
438 end do
439 else
440 do ic = 1, 3
441 do jc = 1, 3
442 pmat%dmix(imat - 1 + ic, imat - 1 + jc) = hgh_p%h(ic, jc)
443 end do
444 end do
445 end if
446
447 do ic = 1, 3
448 if (epot%reltype == spin_orbit .or. epot%reltype == fully_relativistic_zora) then
449 do ip = 1, pmat%npoints
450 pmat%zprojectors(ip, imat) = hgh_p%zp(ip, ic)
451 end do
452 else
453 do ip = 1, pmat%npoints
454 pmat%dprojectors(ip, imat) = hgh_p%dp(ip, ic)
455 end do
456 end if
457 pmat%scal(imat) = mesh%volume_element
458 imat = imat + 1
459 end do
460
461 end do
462 end do
463
464 this%projector_self_overlap = this%projector_self_overlap .or. epot%proj(iatom)%sphere%overlap
465
466 else if (projector_is(epot%proj(iatom), proj_rkb)) then
467 assert(epot%reltype == spin_orbit)
468
469 this%projector_mix = .true.
470
471 ! count the number of projectors for this matrix
472 nmat = 0
473 if (lloc /= 0) nmat = nmat + epot%proj(iatom)%kb_p(1, 1)%n_c
474
475 do ll = 1, lmax
476 if (ll == lloc) cycle
477 do mm = -ll, ll
478 nmat = nmat + epot%proj(iatom)%rkb_p(ll, mm)%n_c
479 end do
480 end do
481
482 call projector_matrix_allocate(pmat, nmat, epot%proj(iatom)%sphere, &
483 has_mix_matrix = .true., is_cmplx = .true.)
484
485 pmat%zprojectors = m_zero
486 pmat%zmix = m_zero
487
488 imat = 1
489 if (lloc /= 0) then
490 kb_p => epot%proj(iatom)%kb_p(1, 1)
491
492 do ic = 1, kb_p%n_c
493 pmat%zmix(ic, ic, 1:2) = kb_p%e(ic)
494 do ip = 1, pmat%npoints
495 pmat%zprojectors(ip, ic) = kb_p%p(ip, ic)
496 end do
497 pmat%scal(ic) = mesh%volume_element
498 end do
499 imat = kb_p%n_c + 1
500 nullify(kb_p)
501 end if
502
503 do ll = 1, lmax
504 if (ll == lloc) cycle
505 do mm = -ll, ll
506 rkb_p => epot%proj(iatom)%rkb_p(ll, mm)
507
508 ! See rkb_projector.F90 for understanding the indices
509 do ic = 0, rkb_p%n_c/2-1
510 pmat%zmix(imat + ic*2, imat + ic*2, 1) = rkb_p%f(ic*2+1, 1, 1)
511 pmat%zmix(imat + ic*2, imat + ic*2, 2) = rkb_p%f(ic*2+1, 2, 2)
512
513 pmat%zmix(imat + ic*2+1, imat + ic*2+1, 1) = rkb_p%f(ic*2+2, 1, 1)
514 pmat%zmix(imat + ic*2+1, imat + ic*2+1, 2) = rkb_p%f(ic*2+2, 2, 2)
515
516 if (mm < ll) then
517 pmat%zmix(imat + ic*2+rkb_p%n_c, imat + ic*2, 4) = rkb_p%f(ic*2+1, 2, 1)
518 pmat%zmix(imat + ic*2+1+rkb_p%n_c, imat + ic*2+1, 4) = rkb_p%f(ic*2+2, 2, 1)
519 end if
520
521 if (-mm < ll) then
522 pmat%zmix(imat + ic*2-rkb_p%n_c, imat + ic*2, 3) = rkb_p%f(ic*2+1, 1, 2)
523 pmat%zmix(imat + ic*2+1-rkb_p%n_c, imat + ic*2+1, 3) = rkb_p%f(ic*2+2, 1, 2)
524 end if
525 end do
526
527 do ic = 1, rkb_p%n_c
528 do ip = 1, pmat%npoints
529 pmat%zprojectors(ip, imat) = rkb_p%ket(ip, ic, 1, 1)
530 end do
531 pmat%scal(imat) = mesh%volume_element
532 imat = imat + 1
533 end do
534 end do
535
536 nullify(rkb_p)
537 end do
538
539 this%projector_self_overlap = this%projector_self_overlap .or. epot%proj(iatom)%sphere%overlap
540
541 else
542 cycle
543 end if
544
545 pmat%map => epot%proj(iatom)%sphere%map
546 pmat%position => epot%proj(iatom)%sphere%rel_x
547
548 pmat%regions = epot%proj(iatom)%sphere%regions
549
550 this%full_projection_size = this%full_projection_size + pmat%nprojs
551
552 end do
553 end do
554
555 if (mesh%parallel_in_domains) then
556 call mesh%mpi_grp%allreduce_inplace(this%projector_self_overlap, 1, mpi_logical, mpi_lor)
557 end if
558
559 safe_deallocate_a(order)
560 safe_deallocate_a(head)
561
562 this%total_points = 0
563 this%max_npoints = 0
564 this%max_nprojs = 0
565 do imat = 1, this%nprojector_matrices
566 pmat => this%projector_matrices(imat)
567
568 this%max_npoints = max(this%max_npoints, pmat%npoints)
569 this%max_nprojs = max(this%max_nprojs, pmat%nprojs)
570 this%total_points = this%total_points + pmat%npoints
571 end do
572
573 if (accel_is_enabled()) call build_accel()
574
576
577 contains
578
579 subroutine build_accel()
580
581 integer :: matrix_size, scal_size
582 integer, allocatable :: cnt(:), invmap(:, :), invmap2(:), pos(:)
583 integer, allocatable :: offsets(:, :)
584 integer, parameter :: OFFSET_SIZE = 6 ! also defined in share/opencl/projectors.cl
585 integer, parameter :: POINTS = 1, projs = 2, matrix = 3, map = 4, scal = 5, mix = 6 ! update OFFSET_SIZE
586 integer :: ip, is, ii, ipos, mix_offset
587
589
590 safe_allocate(offsets(1:offset_size, 1:this%nprojector_matrices))
591 safe_allocate(cnt(1:mesh%np))
592
593 cnt = 0
594
595 ! Here we construct the offsets for accessing various arrays within the GPU kernels.
596 ! The offset(:,:) array contains a number of sizes and offsets, describing how to address the arrays.
597 ! This allows to transfer all these numbers to the GPU in one memory transfer.
598 !
599 ! For each projection matrix (addressed by imap), we have:
600 !
601 ! offset(POINTS, imap) : number of points of the sphere imap
602 ! offset(PROJS, imap) : number of projectors for imap
603 ! offset(MATRIX, imap) : address offset: cumulative of pmat%npoints * pmat%nprojs
604 ! offset(MAP, imap) : address offset: cumulative of pmat%npoints for each imap
605 ! offset(SCAL, imap) : address_offset: cumulative of pmat%nprojs
606 ! offset(MIX, imap) : address_offset: cumulative of pmat%nprojs**2 or 4*pmat%nprojs**2 for complex mixing
607
608 ! first we count
609 matrix_size = 0
610 this%total_points = 0
611 scal_size = 0
612 this%max_npoints = 0
613 this%max_nprojs = 0
614 mix_offset = 0
615 do imat = 1, this%nprojector_matrices
616 pmat => this%projector_matrices(imat)
617
618 this%max_npoints = max(this%max_npoints, pmat%npoints)
619 this%max_nprojs = max(this%max_nprojs, pmat%nprojs)
620
621 offsets(points, imat) = pmat%npoints
622 offsets(projs, imat) = pmat%nprojs
623
624 offsets(matrix, imat) = matrix_size
625 matrix_size = matrix_size + pmat%npoints*pmat%nprojs
626
627 offsets(map, imat) = this%total_points
628 this%total_points = this%total_points + pmat%npoints
629
630 offsets(scal, imat) = scal_size
631 scal_size = scal_size + pmat%nprojs
632
633 offsets(mix, imat) = mix_offset
634 if (allocated(pmat%dmix)) then
635 mix_offset = mix_offset + pmat%nprojs**2
636 else if (allocated(pmat%zmix)) then
637 mix_offset = mix_offset + 4 * pmat%nprojs**2
638 else
639 offsets(mix, imat) = -1
640 end if
641
642 do is = 1, pmat%npoints
643 ip = pmat%map(is)
644 cnt(ip) = cnt(ip) + 1
645 end do
646 end do
647
648 safe_allocate(invmap(1:max(maxval(cnt), 1), 1:mesh%np))
649 safe_allocate(invmap2(1:max(maxval(cnt)*mesh%np, 1)))
650 safe_allocate(pos(1:mesh%np + 1))
651
652 cnt = 0
653 ii = 0
654 do imat = 1, this%nprojector_matrices
655 pmat => this%projector_matrices(imat)
656 do is = 1, pmat%npoints
657 ip = pmat%map(is)
658 cnt(ip) = cnt(ip) + 1
659 invmap(cnt(ip), ip) = ii
660 ii = ii + 1
661 end do
662 end do
663
664 ipos = 0
665 pos(1) = 0
666 do ip = 1, mesh%np
667 do ii = 1, cnt(ip)
668 ipos = ipos + 1
669 invmap2(ipos) = invmap(ii, ip)
670 end do
671 pos(ip + 1) = ipos
672 end do
673
674 ! allocate
675 if (this%projector_matrices(1)%is_cmplx) then
676 call accel_create_buffer(this%buff_matrices, accel_mem_read_only, type_cmplx, matrix_size)
677 else
678 call accel_create_buffer(this%buff_matrices, accel_mem_read_only, type_float, matrix_size)
679 end if
680 call accel_create_buffer(this%buff_maps, accel_mem_read_only, type_integer, this%total_points)
681 call accel_create_buffer(this%buff_position, accel_mem_read_only, type_float, 3*this%total_points)
682 call accel_create_buffer(this%buff_scals, accel_mem_read_only, type_float, scal_size)
683
684 if (mix_offset > 0) then
685 if (allocated(this%projector_matrices(1)%zmix)) then
686 call accel_create_buffer(this%buff_mix, accel_mem_read_only, type_cmplx, mix_offset)
687 else
688 call accel_create_buffer(this%buff_mix, accel_mem_read_only, type_float, mix_offset)
689 end if
690 end if
691
692 ! now copy
693 do imat = 1, this%nprojector_matrices
694 pmat => this%projector_matrices(imat)
695 ! in parallel some spheres might not have points
696 if (pmat%npoints > 0) then
697 if (pmat%is_cmplx) then
698 call accel_write_buffer(this%buff_matrices, pmat%nprojs*pmat%npoints, pmat%zprojectors, offset = offsets(matrix, imat))
699 else
700 call accel_write_buffer(this%buff_matrices, pmat%nprojs*pmat%npoints, pmat%dprojectors, offset = offsets(matrix, imat))
701 end if
702 call accel_write_buffer(this%buff_maps, pmat%npoints, pmat%map, offset = offsets(map, imat))
703 call accel_write_buffer(this%buff_position, 3*pmat%npoints, pmat%position, offset = 3*offsets(map, imat))
704 end if
705 call accel_write_buffer(this%buff_scals, pmat%nprojs, pmat%scal, offset = offsets(scal, imat))
706 if (offsets(mix, imat) /= -1) then
707 if (allocated(pmat%zmix)) then
708 call accel_write_buffer(this%buff_mix, 4*pmat%nprojs**2, pmat%zmix, offset = offsets(mix, imat))
709 else
710 call accel_write_buffer(this%buff_mix, pmat%nprojs**2, pmat%dmix, offset = offsets(mix, imat))
711 end if
712 end if
713 end do
714
715 ! write the offsets
716 call accel_create_buffer(this%buff_offsets, accel_mem_read_only, type_integer, offset_size*this%nprojector_matrices)
717 call accel_write_buffer(this%buff_offsets, offset_size*this%nprojector_matrices, offsets)
718
719 ! the inverse map
720 call accel_create_buffer(this%buff_pos, accel_mem_read_only, type_integer, mesh%np + 1)
721 call accel_write_buffer(this%buff_pos, mesh%np + 1, pos)
722
723 call accel_create_buffer(this%buff_invmap, accel_mem_read_only, type_integer, ipos)
724 call accel_write_buffer(this%buff_invmap, ipos, invmap2)
725
726 safe_deallocate_a(offsets)
727 safe_deallocate_a(cnt)
728 safe_deallocate_a(invmap)
729 safe_deallocate_a(invmap2)
730 safe_deallocate_a(pos)
731
733 end subroutine build_accel
734
736
737 ! ----------------------------------------------------------------------------------
739 !
740 logical pure function nonlocal_pseudopotential_self_overlap(this) result(projector_self_overlap)
741 class(nonlocal_pseudopotential_t), intent(in) :: this
742
743 projector_self_overlap = this%projector_self_overlap
745
746#include "undef.F90"
747#include "real.F90"
748#include "nonlocal_pseudopotential_inc.F90"
749
750#include "undef.F90"
751#include "complex.F90"
752#include "nonlocal_pseudopotential_inc.F90"
753
755
756!! Local Variables:
757!! mode: f90
758!! coding: utf-8
759!! End:
double sqrt(double __x) __attribute__((__nothrow__
subroutine, public accel_release_buffer(this)
Definition: accel.F90:1246
pure logical function, public accel_is_enabled()
Definition: accel.F90:400
integer, parameter, public accel_mem_read_only
Definition: accel.F90:183
type(accel_kernel_t), pointer head
Definition: accel.F90:394
This module implements batches of mesh functions.
Definition: batch.F90:133
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:116
This module contains interfaces for BLAS routines You should not use these routines directly....
Definition: blas.F90:118
integer, parameter, public norel
Definition: epot.F90:166
integer, parameter, public spin_orbit
Definition: epot.F90:166
integer, parameter, public fully_relativistic_zora
Definition: epot.F90:166
real(real64), parameter, public m_zero
Definition: global.F90:187
real(real64), parameter, public m_half
Definition: global.F90:193
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:115
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:624
subroutine nonlocal_pseudopotential_destroy_proj(this)
Destroy the data of nonlocal_pseudopotential_t.
subroutine dnonlocal_pseudopotential_force(this, mesh, st, spiral_bnd, iqn, ndim, psi1b, psi2b, force)
calculate contribution to forces, from non-local potentials
subroutine znonlocal_pseudopotential_position_commutator(this, mesh, std, spiral_bnd, psib, commpsib, async)
apply the commutator between the non-local potential and the position to the wave functions.
subroutine znonlocal_pseudopotential_force(this, mesh, st, spiral_bnd, iqn, ndim, psi1b, psi2b, force)
calculate contribution to forces, from non-local potentials
subroutine dnonlocal_pseudopotential_start(this, mesh, std, spiral_bnd, psib, projection, async)
Start application of non-local potentials (stored in the Hamiltonian) to the wave functions.
subroutine dnonlocal_pseudopotential_finish(this, mesh, spiral_bnd, std, projection, vpsib)
finish the application of non-local potentials.
subroutine dnonlocal_pseudopotential_position_commutator(this, mesh, std, spiral_bnd, psib, commpsib, async)
apply the commutator between the non-local potential and the position to the wave functions.
subroutine znonlocal_pseudopotential_r_vnlocal(this, mesh, std, spiral_bnd, psib, commpsib)
Accumulates to commpsib the result of x V_{nl} | psib >
logical pure function nonlocal_pseudopotential_self_overlap(this)
Returns .true. if the Hamiltonian contains projectors, which overlap with themself.
subroutine nonlocal_pseudopotential_init(this)
initialize the nonlocal_pseudopotential_t object
subroutine dnonlocal_pseudopotential_r_vnlocal(this, mesh, std, spiral_bnd, psib, commpsib)
Accumulates to commpsib the result of x V_{nl} | psib >
subroutine znonlocal_pseudopotential_start(this, mesh, std, spiral_bnd, psib, projection, async)
Start application of non-local potentials (stored in the Hamiltonian) to the wave functions.
subroutine nonlocal_pseudopotential_build_proj(this, space, mesh, epot)
build the projectors for the application of pseudo-potentials
subroutine znonlocal_pseudopotential_finish(this, mesh, spiral_bnd, std, projection, vpsib)
finish the application of non-local potentials.
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:623
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:552
subroutine, public projector_matrix_deallocate(this)
subroutine, public projector_matrix_allocate(this, nprojs, sphere, has_mix_matrix, is_cmplx)
logical elemental function, public projector_is(p, type)
Definition: projector.F90:210
logical elemental function, public projector_is_null(p)
Definition: projector.F90:203
Definition: ps.F90:114
integer, parameter, public proj_hgh
Definition: ps.F90:165
integer, parameter, public proj_rkb
Definition: ps.F90:165
integer, parameter, public proj_none
Definition: ps.F90:165
integer, parameter, public proj_kb
Definition: ps.F90:165
This module handles spin dimensions of the states and the k-point distribution.
logical function, public submesh_overlap(sm1, sm2, space)
Definition: submesh.F90:776
type(type_t), public type_float
Definition: types.F90:133
type(type_t), public type_cmplx
Definition: types.F90:134
type(type_t), public type_integer
Definition: types.F90:135
subroutine build_accel()
Describes mesh distribution to nodes.
Definition: mesh.F90:186
Class for projections of wave functions.
A set of projectors defined on a submesh.
The rkb_projector data type holds the KB projectors build with total angular momentum eigenfunctions....
int true(void)