35 use,
intrinsic :: iso_fortran_env
78 procedure :: delec_dipole_me, zelec_dipole_me
82 procedure :: delec_ks_multipoles_1d_me, zelec_ks_multipoles_1d_me
86 procedure :: delec_ks_multipoles_2d_me, zelec_ks_multipoles_2d_me
90 procedure :: delec_ks_multipoles_3d_me, zelec_ks_multipoles_3d_me
94 procedure :: delec_one_body_me, zelec_one_body_me
98 procedure :: delec_two_body_me, zelec_two_body_me
104 subroutine elec_momentum_me(namespace, gr, st, space, hm, ions, momentum, non_local)
105 type(namespace_t),
intent(in) :: namespace
106 type(grid_t),
intent(in) :: gr
107 type(states_elec_t),
intent(in) :: st
108 type(space_t),
intent(in) :: space
109 type(hamiltonian_elec_t),
intent(in) :: hm
110 type(ions_t),
intent(in) :: ions
111 real(real64),
contiguous,
intent(out) :: momentum(:,:,:)
112 logical,
optional,
intent(in) :: non_local
127 type(grid_t),
intent(in) :: gr
128 type(states_elec_t),
intent(in) :: st
129 type(space_t),
intent(in) :: space
130 real(real64),
contiguous,
intent(out) :: ll(:, :, :)
131 real(real64),
contiguous,
optional,
intent(out) :: l2(:, :)
166 type(namespace_t),
intent(in) :: namespace
167 type(grid_t),
intent(in) :: gr
168 type(states_elec_t),
intent(in) :: st
169 type(space_t),
intent(in) :: space
170 type(hamiltonian_elec_t),
intent(in) :: hm
171 real(real64),
intent(out) :: velocity(:,:,:)
173 integer :: ik, ib, iloc, ist_global, idir, imat, iproj, jproj, nprojs, iprojection, idim, ist
174 complex(real64) :: loc, corr
175 complex(real64),
allocatable :: psi(:,:), chi(:,:), xchi(:)
176 real(real64),
allocatable :: aug_op_dir(:,:,:,:)
182 assert(hm%ep%requires_generalized_overlap)
186 safe_allocate(psi(1:gr%np, 1:st%d%dim))
187 safe_allocate(chi(1:gr%np, 1:st%d%dim))
188 safe_allocate(xchi(1:gr%np))
191 safe_allocate(aug_op_dir(1:hm%vnl%max_nprojs, 1:hm%vnl%max_nprojs, 1:hm%vnl%nprojector_matrices, 1:space%dim))
192 do idir = 1, space%dim
196 do ik = st%d%kpt%start, st%d%kpt%end
197 do ib = st%group%block_start, st%group%block_end
199 call st%group%psib(ib, ik)%copy_to(psib_mut, copy_data = .
true.)
200 call psib_mut%copy_to(chib)
205 do iloc = 1, st%group%psib(ib, ik)%nst
206 ist_global = st%group%psib(ib, ik)%linear_to_ist(iloc)
209 do idir = 1, space%dim
211 do idim = 1, st%d%dim
212 xchi(1:gr%np) = gr%x_t(1:gr%np, idir)*chi(1:gr%np, idim)
213 loc = loc +
zmf_dotp(gr, psi(:, idim), xchi)
215 velocity(idir, ist_global, ik) = aimag(loc)
221 if (hm%phase%is_allocated())
then
222 call psib_mut%copy_to(epsib)
223 call hm%phase%apply_to(gr, gr%np, .false., epsib, src = psib_mut)
224 epsib%has_phase = .
true.
226 call hm%phase%apply_to(gr, gr%np, .false., epsib, src = chib)
227 epsib%has_phase = .
true.
234 if (gr%parallel_in_domains)
then
235 call gr%allreduce(proj_psi%zprojection)
236 call gr%allreduce(proj_chi%zprojection)
240 do ist = 1, st%group%psib(ib, ik)%nst_linear
241 ist_global = st%group%psib(ib, ik)%linear_to_ist(ist)
242 do idir = 1, space%dim
245 do imat = 1, hm%vnl%nprojector_matrices
246 nprojs = hm%vnl%projector_matrices(imat)%nprojs
249 corr = corr + conjg(proj_psi%zprojection(ist, iprojection + iproj)) * &
250 aug_op_dir(iproj, jproj, imat, idir) * proj_chi%zprojection(ist, iprojection + jproj)
253 iprojection = iprojection + nprojs
255 velocity(idir, ist_global, ik) = velocity(idir, ist_global, ik) + aimag(corr)
259 safe_deallocate_a(proj_psi%zprojection)
260 safe_deallocate_a(proj_chi%zprojection)
269 velocity =
m_two*velocity
271 safe_deallocate_a(psi)
272 safe_deallocate_a(chi)
273 safe_deallocate_a(xchi)
274 safe_deallocate_a(aug_op_dir)
279#include "complex.F90"
280#include "elec_matrix_elements_inc.F90"
284#include "elec_matrix_elements_inc.F90"
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 calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public elec_angular_momentum_me(gr, st, space, ll, l2)
subroutine delec_momentum_me(namespace, gr, st, space, hm, ions, momentum, non_local)
The routine calculates the expectation value of the momentum operator.
subroutine, public zelec_velocity_me_uspp(namespace, gr, st, space, hm, velocity)
Ultrasoft/PAW conserved macroscopic current (= dipole velocity), per state.
subroutine zelec_momentum_me(namespace, gr, st, space, hm, ions, momentum, non_local)
The routine calculates the expectation value of the momentum operator.
subroutine zelec_angular_momentum_me(gr, st, space, ll, l2)
It calculates the expectation value of the angular momentum of the states. If l2 is passed,...
subroutine delec_angular_momentum_me(gr, st, space, ll, l2)
It calculates the expectation value of the angular momentum of the states. If l2 is passed,...
subroutine, public elec_momentum_me(namespace, gr, st, space, hm, ions, momentum, non_local)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
complex(real64), parameter, public m_z0
This module implements the underlying real-space grid.
subroutine, public zhamiltonian_elec_apply_sinvh_batch(hm, namespace, mesh, psib, hspsib, terms, set_bc, set_phase)
Apply the operator A = S^{-1} H to a batch (for ultrasoft/PAW).
A module to handle KS potential, without the external potential.
This module defines functions over batches of mesh functions.
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
This module contains some common usage patterns of MPI routines.
subroutine, public 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, public nonlocal_pseudopotential_aug_moment(this, mesh, epot, op, aug_op)
Ultrasoft augmentation moments of a local operator A(r): int A(r) Q_ij(r-R_I) dr.
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
Class for projections of wave functions.
batches of electronic states