Octopus
nonlocal_pseudopotential_oct_m Module Reference

Data Types

type  nonlocal_pseudopotential_t
 nonlocal part of the pseudopotential More...
 
type  projection_t
 Class for projections of wave functions. More...
 

Functions/Subroutines

subroutine nonlocal_pseudopotential_init (this)
 initialize the nonlocal_pseudopotential_t object More...
 
subroutine, public nonlocal_pseudopotential_rebind_projectors (this, epot)
 Rebind projector matrix pointers (map, position) to a target epot. More...
 
subroutine, public nonlocal_pseudopotential_share_projector_data (this, donor)
 Alias the heavy per-point projector data of a donor instance. More...
 
subroutine, public nonlocal_pseudopotential_detach_copy (this, donor)
 Detach the projector data of an instance obtained by intrinsic assignment. More...
 
subroutine nonlocal_pseudopotential_destroy_proj (this)
 Destroy the data of nonlocal_pseudopotential_t. More...
 
subroutine nonlocal_pseudopotential_build_proj (this, space, mesh, epot, ispin, overlap_operator, inverse_overlap_operator)
 build the projectors for the application of pseudo-potentials More...
 
integer function projector_beta_index (proj, ll, ic)
 
subroutine, public nonlocal_pseudopotential_accel_rebuild (this, space, mesh)
 Rebuild accelerator buffers after an intrinsic copy. More...
 
subroutine nonlocal_pseudopotential_detach_accel_buffers (this)
 Clear copied accelerator handles so they do not alias source buffers. More...
 
subroutine nonlocal_pseudopotential_build_accel_buffers (this, space, mesh)
 Build accelerator buffers for projectors from host-side projector matrices. More...
 
subroutine nonlocal_pseudopotential_build_projector_phase_accel_buffer (this)
 Rebuild projector phase accelerator buffer from host-side projector phases. More...
 
logical pure function nonlocal_pseudopotential_self_overlap (this)
 Returns .true. if the Hamiltonian contains projectors, which overlap with themself. More...
 
subroutine, public nonlocal_pseudopotential_update_dij (this, mesh, epot, veff, add_bare, onsite_density_matrix)
 Screen the ultrasoft nonlocal coupling matrix D_ij with the local potential. More...
 
subroutine nonlocal_pseudopotential_ghost_check (this, mesh, epot)
 Warn about augmentation ghost channels: a near-singular direction of the channel-block overlap metric combined with an attractive screened coupling. More...
 
subroutine nonlocal_pseudopotential_paw_onsite (this, epot, n_paw, paw_imat, onsite_density_matrix, dij_buf)
 Compute the PAW one-center Hamiltonian coupling of every PAW atom and accumulate the energy correction. More...
 
subroutine, public nonlocal_pseudopotential_build_paw_symm (this, epot, space, gr, ions)
 Build the crystal-symmetry data used to symmetrize the PAW one-center density matrix. More...
 
subroutine, public nonlocal_pseudopotential_symmetrize_onsite (this)
 Symmetrize the PAW one-center density matrix rho_ij over the crystal symmetries. More...
 
subroutine nonlocal_pseudopotential_qij_to_pairs (proj, pmat, np, ncomp, field, pairm)
 Integrate a mesh field against the augmentation charges Q_ij over one augmentation sphere: pairm_ij^c = sum_is field(is,c) Q_ij(r_is). More...
 
subroutine nonlocal_pseudopotential_soc_build_zmix_cmplx (pmat, proj, use_qij, so_strength)
 Build the spin-orbit 2x2 spin coupling (zmix) in the COMPLEX-Y_lm projector basis. More...
 
subroutine nonlocal_pseudopotential_soc_screen_cmplx (pmat, proj, mesh, veff, dij_onsite)
 Add the screening int V^{ab}(r) Q_ij(r) to the complex-Y_lm SOC zmix. More...
 
subroutine, public nonlocal_pseudopotential_density_matrix_spinor (this, mesh, std, spiral_bnd, psib, weight, beta_density, beta_current)
 Noncollinear (spinor) projector density matrix for the ultrasoft augmentation. More...
 
subroutine nonlocal_pseudopotential_spinor_current_slabs (nprojs, rho_uu, rho_dd, rho_ud, cur)
 Accumulate the four one-center current slabs of a spinor projector density matrix. More...
 
subroutine, public nonlocal_pseudopotential_density_matrix_spinor_cmplx (this, mesh, std, spiral_bnd, psib, weight, beta_density)
 Full COMPLEX spinor projector density matrix (fully-relativistic ultrasoft). More...
 
subroutine, public nonlocal_pseudopotential_soc_density_to_real (this, epot, rho_cmplx, beta_density, beta_current)
 Rotate the complex-Y_lm projector density matrix to the real-Y_lm basis (SOC USPP). More...
 
complex(real64) function soc_recouple_a (ll, jplus, m, m_target, s, uu)
 A(l,jplus,m,m_l_target,s) = spinor_coeff(l,jplus,m,s) * conjg(uu(a, m_l+l+1)), with m_l = m + (s-1) required to equal the target m_l (pmatm). Returns 0 if out of range or if the spinor m_l does not match the requested target. More...
 
subroutine nonlocal_pseudopotential_soc_recoupling_matrix (pmat, proj, gmat)
 Build the mixed (l,j)->spin recoupling matrix G on composite (projector, spin) indices. More...
 
real(real64) function nonlocal_pseudopotential_aug_contract (proj, pmat, np, ncomp, vweight, wij, cw, volume_element)
 Integrate a gathered per-sphere-point field against the augmentation charges and contract with the component-weighted density-matrix weights: result = sum_ij sum_c cw(c) w_ij(c) [int field_c(r) Q_ij(r-R) dr]. This is the common tail of the augmentation force and stress accumulations; only the gathered field (and the sign and target of the result) differ between them. More...
 
subroutine, public nonlocal_pseudopotential_force_uspp (this, mesh, epot, ndim, grad_pot, force_aug_weight, force)
 Ultrasoft augmentation contribution to the forces. More...
 
subroutine, public nonlocal_pseudopotential_stress_uspp (this, mesh, epot, periodic_dim, grad_pot, aug_weight, stress_aug)
 Ultrasoft augmentation contribution to the stress tensor. More...
 
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. More...
 
subroutine, public nonlocal_pseudopotential_aug_density (this, mesh, epot, force_aug_weight, aug_density)
 Accumulate the ultrasoft augmentation density n_aug(r) = sum_ij rho_ij Q_ij(r-R) (summed over all ultrasoft atoms) on the mesh, given the projector density matrix. More...
 
subroutine, public 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. More...
 
subroutine dnonlocal_pseudopotential_finish (this, mesh, spiral_bnd, std, projection, vpsib)
 finish the application of non-local potentials. More...
 
subroutine, public dnonlocal_pseudopotential_apply_overlap (this, mesh, std, psib, spsib, phase, spiral_bnd, apply_phase)
 Apply the ultrasoft/PAW generalized overlap S = 1 + sum_ij |beta_i> q_ij <beta_j| (or, with another operator passed as this, S^{-1}) to a batch: spsib = S psib. More...
 
subroutine, public dnonlocal_pseudopotential_add_overlap_inplace (this, mesh, std, xb, phase, spiral_bnd, apply_phase)
 In-place version of the generalized overlap: xb := S xb (or S^{-1} xb, depending on this). Avoids the identity copy of the out-of-place version (and lets the caller skip a scratch batch): the augmentation is accumulated directly onto the input. More...
 
subroutine dnonlocal_pseudopotential_force (this, mesh, st, spiral_bnd, iqn, ndim, psi1b, psi2b, force)
 calculate contribution to forces, from non-local potentials More...
 
subroutine dnl_force_gather_projs (this, mesh, ndim, valb, gradb, projs)
 Gather the raw projector overlaps <beta|val> and <beta|grad val> on the sphere points. More...
 
subroutine dnonlocal_pseudopotential_force_overlap_cross (this, mesh, st, iqn, ndim, psib, gpsib, chib, gchib, force)
 Ultrasoft DFT+U force: the overlap-derivative (d_R S) term, as a cross density matrix. More...
 
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. More...
 
subroutine dnonlocal_pseudopotential_r_vnlocal (this, mesh, std, spiral_bnd, psib, commpsib, eigenval, only_qmix)
 Accumulates to commpsib the result of x V_{nl} | psib > More...
 
subroutine, public dnonlocal_pseudopotential_density_matrix (this, mesh, std, spiral_bnd, psib, weight, beta_density, weight2, beta_density2, beta_current)
 Accumulate occupation-weighted beta-projector density matrices for USPP density. More...
 
subroutine, public dnonlocal_pseudopotential_reconstruct_paw_wfs (this, epot, mesh, ik, psi)
 Add the PAW one-center correction to a single smooth wavefunction, reconstructing the all-electron wavefunction. More...
 
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. More...
 
subroutine znonlocal_pseudopotential_finish (this, mesh, spiral_bnd, std, projection, vpsib)
 finish the application of non-local potentials. More...
 
subroutine, public znonlocal_pseudopotential_apply_overlap (this, mesh, std, psib, spsib, phase, spiral_bnd, apply_phase)
 Apply the ultrasoft/PAW generalized overlap S = 1 + sum_ij |beta_i> q_ij <beta_j| (or, with another operator passed as this, S^{-1}) to a batch: spsib = S psib. More...
 
subroutine, public znonlocal_pseudopotential_add_overlap_inplace (this, mesh, std, xb, phase, spiral_bnd, apply_phase)
 In-place version of the generalized overlap: xb := S xb (or S^{-1} xb, depending on this). Avoids the identity copy of the out-of-place version (and lets the caller skip a scratch batch): the augmentation is accumulated directly onto the input. More...
 
subroutine znonlocal_pseudopotential_force (this, mesh, st, spiral_bnd, iqn, ndim, psi1b, psi2b, force)
 calculate contribution to forces, from non-local potentials More...
 
subroutine znl_force_gather_projs (this, mesh, ndim, valb, gradb, projs)
 Gather the raw projector overlaps <beta|val> and <beta|grad val> on the sphere points. More...
 
subroutine znonlocal_pseudopotential_force_overlap_cross (this, mesh, st, iqn, ndim, psib, gpsib, chib, gchib, force)
 Ultrasoft DFT+U force: the overlap-derivative (d_R S) term, as a cross density matrix. More...
 
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. More...
 
subroutine znonlocal_pseudopotential_r_vnlocal (this, mesh, std, spiral_bnd, psib, commpsib, eigenval, only_qmix)
 Accumulates to commpsib the result of x V_{nl} | psib > More...
 
subroutine, public znonlocal_pseudopotential_density_matrix (this, mesh, std, spiral_bnd, psib, weight, beta_density, weight2, beta_density2, beta_current)
 Accumulate occupation-weighted beta-projector density matrices for USPP density. More...
 
subroutine, public znonlocal_pseudopotential_reconstruct_paw_wfs (this, epot, mesh, ik, psi)
 Add the PAW one-center correction to a single smooth wavefunction, reconstructing the all-electron wavefunction. More...
 

Function/Subroutine Documentation

◆ nonlocal_pseudopotential_init()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_init ( class(nonlocal_pseudopotential_t), intent(inout)  this)
private

initialize the nonlocal_pseudopotential_t object

Definition at line 293 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_rebind_projectors()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_rebind_projectors ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
type(epot_t), intent(in), target  epot 
)

Rebind projector matrix pointers (map, position) to a target epot.

After intrinsic assignment, these pointer components still point to the source epot spheres and must be rebound to the snapshot epot.

Definition at line 312 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_share_projector_data()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_share_projector_data ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
class(nonlocal_pseudopotential_t), intent(in), target  donor 
)

Alias the heavy per-point projector data of a donor instance.

The ultrasoft/PAW overlap and inverse-overlap instances project onto the same beta functions as the Hamiltonian (vnl) instance; they differ only in the small per-atom mix matrix (D_ij vs q_ij vs -T_ij). After both instances are built, this frees the duplicate projector-value (and aug_ylm) arrays and points them at the donor arrays, so the heavy data exists once. Ownership is recorded so the destructor and the deep copies leave the donor data alone.

Definition at line 363 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_detach_copy()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_detach_copy ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
class(nonlocal_pseudopotential_t), intent(in), optional  donor 
)

Detach the projector data of an instance obtained by intrinsic assignment.

Intrinsic assignment aliases the projector-value pointers of the source, which can be rebuilt or freed while the copy is alive (e.g. moving ions in the Magnus propagators). An instance that owned its data gets a private copy; one that aliased a donor (overlap instances) aliases the already detached donor copy instead. The lazily built aug_ylm caches are dropped and rebuilt on demand.

Parameters
[in]donorDetached instance whose data this one aliases, when it does not own its data

Definition at line 411 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_destroy_proj()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_destroy_proj ( class(nonlocal_pseudopotential_t), intent(inout)  this)
private

Destroy the data of nonlocal_pseudopotential_t.

Definition at line 445 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_build_proj()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_build_proj ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
type(epot_t), intent(in), target  epot,
integer, intent(in)  ispin,
logical, intent(in), optional  overlap_operator,
logical, intent(in), optional  inverse_overlap_operator 
)
private

build the projectors for the application of pseudo-potentials

This routine also determines the regions for the projectors and whether any projector overlaps with itself in a periodic system.

Parameters
[in]overlap_operatorbuild the overlap S (mix = q_ij)
[in]inverse_overlap_operatorbuild the inverse overlap S^{-1} (mix = -T_ij)

Definition at line 509 of file nonlocal_pseudopotential.F90.

◆ projector_beta_index()

integer function nonlocal_pseudopotential_oct_m::projector_beta_index ( type(projector_t), intent(in)  proj,
integer, intent(in)  ll,
integer, intent(in)  ic 
)
private

Definition at line 1203 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_accel_rebuild()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_accel_rebuild ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh 
)

Rebuild accelerator buffers after an intrinsic copy.

Definition at line 1226 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_detach_accel_buffers()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_detach_accel_buffers ( class(nonlocal_pseudopotential_t), intent(inout)  this)
private

Clear copied accelerator handles so they do not alias source buffers.

Definition at line 1253 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_build_accel_buffers()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_build_accel_buffers ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh 
)
private

Build accelerator buffers for projectors from host-side projector matrices.

Definition at line 1276 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_build_projector_phase_accel_buffer()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_build_projector_phase_accel_buffer ( class(nonlocal_pseudopotential_t), intent(inout)  this)
private

Rebuild projector phase accelerator buffer from host-side projector phases.

Definition at line 1461 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_self_overlap()

logical pure function nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_self_overlap ( class(nonlocal_pseudopotential_t), intent(in)  this)
private

Returns .true. if the Hamiltonian contains projectors, which overlap with themself.

Definition at line 1500 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_update_dij()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_update_dij ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
class(mesh_t), intent(in)  mesh,
type(epot_t), intent(in), target  epot,
real(real64), dimension(:, :), intent(in)  veff,
logical, intent(in), optional  add_bare,
real(real64), dimension(:, :, :, :), intent(in), optional, contiguous  onsite_density_matrix 
)

Screen the ultrasoft nonlocal coupling matrix D_ij with the local potential.

For ultrasoft/PAW the nonlocal coefficients are screened by the self-consistent local potential: D_ij = D_ij^(0) + \int V_eff(r) Q_ij(r) dr , where D_ij^(0) is the bare (descreened) matrix from the pseudopotential and Q_ij(r) the augmentation function. This must be recomputed whenever V_eff changes (every SCF step) so the augmentation enters the Hamiltonian self-consistently. The bare block-diagonal part is reconstructed from projaugdij; the screening integral is the adjoint of the real-space density augmentation (see density_calc_accumulate_aug). With add_bare = .false. only the screening integral is stored, which is the augmentation part of an arbitrary local potential (e.g. the delta-kick potential).

Parameters
[in]vefflocal effective potential (1:meshnp, 1:nspin)
[in]add_bareadd the bare D_ij^(0) (default: .true.)
[in]onsite_density_matrixPAW one-center density matrix rho_ij (max_nprojs, max_nprojs, nprojector_matrices, spin); required when any species is PAW, used to build the one-center D and energy correction.

Definition at line 1519 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_ghost_check()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_ghost_check ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(epot_t), intent(in), target  epot 
)
private

Warn about augmentation ghost channels: a near-singular direction of the channel-block overlap metric combined with an attractive screened coupling.

For every 2-channel (l, m) projector block the restricted dual overlap metric B^-1 + q (B the mesh Gram matrix of the two projectors, q the augmentation charges) can have a near-null eigendirection v when the projectors are nearly parallel. The generalized eigenvalue of the pencil in that direction is amplified by 1/lambda; if the screened coupling projected on it is negative (v D v < 0), a deep spurious (ghost) state exists on the real-space grid, the eigensolvers correctly find and occupy it, and the SCF diverges.

Definition at line 1721 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_paw_onsite()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_paw_onsite ( class(nonlocal_pseudopotential_t), intent(inout), target  this,
type(epot_t), intent(in), target  epot,
integer, intent(in)  n_paw,
integer, dimension(:), intent(in)  paw_imat,
real(real64), dimension(:, :, :, :), intent(in), contiguous  onsite_density_matrix,
real(real64), dimension(:, :, :, :), intent(out), allocatable  dij_buf 
)
private

Compute the PAW one-center Hamiltonian coupling of every PAW atom and accumulate the energy correction.

The one-center engine (paw_onsite) returns, in the Hxc-only mode, the Hartree/XC one-center coupling D_onsite = (D^1 - D~^1)_Hxc and the AE/PS one-center Hartree+XC energies E^1, E~^1 for the current one-center density matrix rho_ij. The frozen kinetic and reference/nuclear one-center part stays in the descreened D^0 (PP_DIJ), added separately by the mesh nonlocal machinery, exactly as for ultrasoft. The physical one-center energy is E^1 - E~^1, so the double-counting correction added to the total energy is e_corr = (E^1 - E~^1) - sum_c w_c Tr[rho_c D_onsite,c], leaving the usual +1/2 int n v_H and (E_xc - int v_xc n) corrections.

Definition at line 1863 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_build_paw_symm()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_build_paw_symm ( class(nonlocal_pseudopotential_t), intent(inout)  this,
type(epot_t), intent(in)  epot,
class(space_t), intent(in)  space,
type(grid_t), intent(in)  gr,
type(ions_t), intent(in)  ions 
)

Build the crystal-symmetry data used to symmetrize the PAW one-center density matrix.

Two pieces, both geometry-dependent and constant during the SCF:

  • the real-spherical-harmonic rotation matrices D^l_{m m`}(S) for every symmetry operation S, obtained (as in the DFT+U occupation-matrix symmetrization, orbitals_get_symm_weight) by tabulating Y_lm on a small submesh, rotating it on the grid, and projecting back;
  • the map sending each projector matrix (atom) to the equivalent atom it is rotated from under each operation (ionsinv_map_symm_atoms). Only the PAW projector matrices need this; a single symmetry operation makes it a no-op.

Definition at line 1978 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_symmetrize_onsite()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_symmetrize_onsite ( class(nonlocal_pseudopotential_t), intent(inout), target  this)

Symmetrize the PAW one-center density matrix rho_ij over the crystal symmetries.

rho^sym_a(i,j) = (1/N_S) sum_S sum_{m_i' m_j'} D^{l_i}_{m_i m_i'}(S) D^{l_j}_{m_j m_j'}(S) rho_{S^{-1}a}(i',j'), where i‘ has the same (l_i, channel_i) as i but m = m_i’ (and likewise j'). This mirrors the DFT+U occupation-matrix symmetrization, and removes the mesh/one-center inconsistency that otherwise shows up as a symmetrization discrepancy when the k-point grid is reduced by symmetry. A no-op for a single symmetry operation or when no PAW matrix is present.

Definition at line 2100 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_qij_to_pairs()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_qij_to_pairs ( type(projector_t), intent(in)  proj,
type(projector_matrix_t), intent(in)  pmat,
integer, intent(in)  np,
integer, intent(in)  ncomp,
real(real64), dimension(:, :), intent(in), contiguous  field,
real(real64), dimension(:, :, :), intent(out)  pairm 
)
private

Integrate a mesh field against the augmentation charges Q_ij over one augmentation sphere: pairm_ij^c = sum_is field(is,c) Q_ij(r_is).

Shared kernel of update_dij, force_uspp, stress_uspp and aug_moment (and the natural reuse point for PAW on-site terms). The field must already be gathered at the sphere points pmatmap into a contiguous (np, ncomp) buffer; the volume element is applied by the caller. The whole grid reduction is a single GEMM against the combined Q Y_LM columns, followed by the Gaunt contraction back to projection pairs.

Parameters
[in]field(np, ncomp), gathered at pmatmap
[out]pairm(nprojs, nprojs, ncomp)

Definition at line 2189 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_soc_build_zmix_cmplx()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_soc_build_zmix_cmplx ( type(projector_matrix_t), intent(inout), target  pmat,
type(projector_t), intent(in), target  proj,
logical, intent(in)  use_qij,
real(real64), intent(in), optional  so_strength 
)
private

Build the spin-orbit 2x2 spin coupling (zmix) in the COMPLEX-Y_lm projector basis.

Direct closed-form Clebsch-Gordan coupling of the j-ordered channel matrix aug_dij (Hamiltonian, use_qij=.false.) or aug_qij (overlap, use_qij=.true.) onto the complex-Y_lm projectors, via soc_uspp_add_channel_coupling_cmplx. No complex->real transform (the projectors are already complex Y_lm). This is the fully-relativistic-ultrasoft coupling of the channel matrices.

Parameters
[in]so_strengthScale of the spin-orbit part

Definition at line 2220 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_soc_screen_cmplx()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_soc_screen_cmplx ( type(projector_matrix_t), intent(inout), target  pmat,
type(projector_t), intent(in), target  proj,
class(mesh_t), intent(in)  mesh,
real(real64), dimension(:, :), intent(in)  veff,
real(real64), dimension(:, :, :), intent(in), optional  dij_onsite 
)
private

Add the screening int V^{ab}(r) Q_ij(r) to the complex-Y_lm SOC zmix.

octopus has no complex Gaunt, so the screening is first evaluated in the REAL-Y_lm basis (exactly the noncollinear-magnetism screening: D^r_{(m_i c_i)(m_j c_j)}^{ab} = sum_L real_gaunt int V^{ab} Y_LM Q^L) and then RECOUPLED (not just rotated) to the complex-Y_lm projector basis as the energy dual of the density recoupling: D^c = G^H D^r G, with G the mixed (l,j)->spin coefficient of soc_density_to_real. This guarantees Tr[rho^c D^c] = Tr[onsite_density_matrix D^r], i.e. the nonlocal screening energy is consistent with the augmentation density that generated V_eff.

Parameters
[in]dij_onsitePAW one-center Hxc coupling

Definition at line 2305 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_density_matrix_spinor()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_density_matrix_spinor ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
real(real64), dimension(:), intent(in)  weight,
real(real64), dimension(:, :, :, :), intent(inout), allocatable  beta_density,
real(real64), dimension(:, :, :, :), intent(inout), optional, allocatable  beta_current 
)

Noncollinear (spinor) projector density matrix for the ultrasoft augmentation.

Builds the 2x2 spin-density matrix in projector space, rho_ij^{ab} = sum_n f_n <beta_i|psi_n^b>^* <beta_j|psi_n^a> , following the augmented-density operator n^{ab}(r) = sum_ij <psi^b|beta_i> Q_ij(r) <beta_j|psi^a> (Vanderbilt 1990). The four real slabs returned match the spinor density convention used by density_calc_accumulate (1 = up-up, 2 = down-down, 3 = Re(up-down), 4 = Im(up-down)); the caller scatters sum_ij Q_ij(r) rho_ij into density(:,1:4). Spinors are always complex, so only the complex projection path is needed. Companion of the collinear (d/z)density_matrix routines. If beta_current is present, the four one-center current slabs are accumulated as well (see nonlocal_pseudopotential_spinor_current_slabs).

Parameters
[in,out]beta_density(max_nprojs, max_nprojs, nmat, 4)
[in,out]beta_currentOne-center current slabs (max_nprojs, max_nprojs, nmat, 4)

Definition at line 2437 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_spinor_current_slabs()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_spinor_current_slabs ( integer, intent(in)  nprojs,
complex(real64), dimension(:, :), intent(in)  rho_uu,
complex(real64), dimension(:, :), intent(in)  rho_dd,
complex(real64), dimension(:, :), intent(in)  rho_ud,
real(real64), dimension(:, :, :), intent(inout)  cur 
)
private

Accumulate the four one-center current slabs of a spinor projector density matrix.

With C^{ab}_ij = sum_n f_n conjg(<beta_i|psi_n^b>) <beta_j|psi_n^a> and the partial waves g_i real, the paramagnetic spinor current components of current_calculate restricted to the sphere are sum_ij A^c_ij g_i grad g_j, with A^1 = Im C^{11}, A^2 = Im C^{22}, A^3 = 1/2 (Im C^{12} - (Im C^{12})^T), A^4 = -1/2 (Re C^{12} - (Re C^{12})^T).

Parameters
[in,out]cur(max_nprojs, max_nprojs, 4), accumulated

Definition at line 2543 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_density_matrix_spinor_cmplx()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_density_matrix_spinor_cmplx ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
real(real64), dimension(:), intent(in)  weight,
complex(real64), dimension(:, :, :, :, :), intent(inout), allocatable  beta_density 
)

Full COMPLEX spinor projector density matrix (fully-relativistic ultrasoft).

Same accumulation as nonlocal_pseudopotential_density_matrix_spinor, but keeps every spin block complex: rho(i, j, imat, s1, s2) = sum_n f_n conjg(<beta_i|psi_n^{s1}>) <beta_j|psi_n^{s2}>. With complex-Y_lm projectors the spin-diagonal blocks are genuinely complex (Hermitian, not symmetric), and the (l,j)->spin recoupling (soc_density_to_real) needs the full matrix — the four-real-slab storage of the noncollinear routine would silently drop the antisymmetric imaginary parts and corrupt the recoupled augmentation (spurious magnetization).

Parameters
[in,out]beta_density(nprojs, nprojs, nmat, 2, 2)

Definition at line 2572 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_soc_density_to_real()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_soc_density_to_real ( class(nonlocal_pseudopotential_t), intent(in), target  this,
type(epot_t), intent(in), target  epot,
complex(real64), dimension(:, :, :, :, :), intent(in), allocatable  rho_cmplx,
real(real64), dimension(:, :, :, :), intent(inout), allocatable  beta_density,
real(real64), dimension(:, :, :, :), intent(inout), optional, allocatable  beta_current 
)

Rotate the complex-Y_lm projector density matrix to the real-Y_lm basis (SOC USPP).

For fully-relativistic USPP with complex-Y_lm projectors, the projector density matrix rho^c is in the complex-Y_lm basis, but the augmentation scatter (real_gaunt + aug_ylm) works in real Y_lm. So rotate rho^c -> rho^r with the unitary transform uu (Y^real_a = sum_m uu(a,m) Y^cmplx_m): rho^r_{(a c_i)(b c_j)} = sum_{m n} conjg(uu(a,m)) uu(b,n) rho^c_{(m c_i)(n c_j)} , per l, per channel pair, spin untouched. The four real slabs (uu, dd, Re du, Im du) are overwritten in place, so the existing real-Y_lm augmentation scatter then produces the correct n^{ab}(r).

Parameters
[in]rho_cmplxfull complex rho (i,j,imat,s1,s2)
[in,out]beta_densityrecoupled real slabs (out)
[in,out]beta_currentRecoupled one-center current slabs (out, accumulated); see nonlocal_pseudopotential_spinor_current_slabs

Definition at line 2656 of file nonlocal_pseudopotential.F90.

◆ soc_recouple_a()

complex(real64) function nonlocal_pseudopotential_oct_m::soc_recouple_a ( integer, intent(in)  ll,
logical, intent(in)  jplus,
integer, intent(in)  m,
integer, intent(in)  m_target,
integer, intent(in)  s,
complex(real64), dimension(:, :), intent(in)  uu 
)
private

A(l,jplus,m,m_l_target,s) = spinor_coeff(l,jplus,m,s) * conjg(uu(a, m_l+l+1)), with m_l = m + (s-1) required to equal the target m_l (pmatm). Returns 0 if out of range or if the spinor m_l does not match the requested target.

Parameters
[in]sm_target = real-Y_lm m value of the projector

Definition at line 2732 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_soc_recoupling_matrix()

subroutine nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_soc_recoupling_matrix ( type(projector_matrix_t), intent(in)  pmat,
type(projector_t), intent(in)  proj,
complex(real64), dimension(:, :), intent(out)  gmat 
)
private

Build the mixed (l,j)->spin recoupling matrix G on composite (projector, spin) indices.

G relates the COMPLEX-Y_lm spinor basis of the fully-relativistic projectors (row: complex projector p, spin s) to the REAL-Y_lm (x) spin basis of the augmentation scatter (column: real projector a, spin alpha). With the composite index idx(p, s) = p + (s-1)*nprojs,

G(idx(p, s), idx(a, alpha)) = A(l, j; m_p - (s-1) -> m_a, alpha) C^{j m_j}_{l, m_p-(s-1), s} ,

i.e. a Clebsch-Gordan on the complex leg times the complex->real Y_lm rotation on the real leg (soc_recouple_A * soc_uspp_spinor_coeff), block-diagonal in the (l, radial channel) blocks. The two SOC recouplings are then plain matrix sandwiches with this single matrix: onsite_density_matrix = G^H rho^c G (density) D^c = conjg(G) D^r G^T (screening)

  • mutually the energy dual, Tr[rho^c D^c] = Tr[onsite_density_matrix D^r]. Because every projector pair appears in the flattened matrices, cross-l entries (coupled by the L>0 Gaunt terms of the scatter/screening) are recoupled too, each leg within its own (l, channel) block.
    Parameters
    [out]gmat(2*nprojs, 2*nprojs)

Definition at line 2766 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_aug_contract()

real(real64) function nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_aug_contract ( type(projector_t), intent(in)  proj,
type(projector_matrix_t), intent(in)  pmat,
integer, intent(in)  np,
integer, intent(in)  ncomp,
real(real64), dimension(:, :), intent(in)  vweight,
real(real64), dimension(:, :, :), intent(in)  wij,
real(real64), dimension(:), intent(in)  cw,
real(real64), intent(in)  volume_element 
)
private

Integrate a gathered per-sphere-point field against the augmentation charges and contract with the component-weighted density-matrix weights: result = sum_ij sum_c cw(c) w_ij(c) [int field_c(r) Q_ij(r-R) dr]. This is the common tail of the augmentation force and stress accumulations; only the gathered field (and the sign and target of the result) differ between them.

Parameters
[in]vweight(np, ncomp) gathered field
[in]wij(nprojs, nprojs, ncomp) density-matrix weights
[in]cw(ncomp) spin-component weights

Definition at line 2818 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_force_uspp()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_force_uspp ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(epot_t), intent(in), target  epot,
integer, intent(in)  ndim,
real(real64), dimension(:, :, :), intent(in)  grad_pot,
real(real64), dimension(:, :, :, :), intent(in)  force_aug_weight,
real(real64), dimension(:, :), intent(inout)  force 
)

Ultrasoft augmentation contribution to the forces.

Laasonen et al., PRB 47, 10142 (1993), Eq. (29), augmentation (newd) term:

F^aug_a(I) = - sum_ij rho_ij int (d_a V)(r) Q_ij(r - R_I) dr ,

with rho_ij = sum_{n} f_n <psi_n|beta_i><beta_j|psi_n> (force_aug_weight) the projector density matrix. It arises because moving atom I rigidly shifts Q_ij(r-R_I), which couples to the self-consistent potential through the augmentation density n_aug = sum_ij rho_ij Q_ij; after an integration by parts d_R Q = -d_r Q the derivative falls on the potential.

V is the FULL effective potential V_eff = V_loc + V_Hxc (caller passes grad_pot = grad V_eff). This is QE`s addusforce; together with the local-potential force evaluated with the FULL density (rho_val + n_aug, i.e. grad_rho includes grad n_aug) it gives the complete augmentation force. In particular, the local potential of the OTHER atoms acting on this atoms augmentation charge (a real, O(Z*q_aug) contribution for semicore pseudos) enters through V_eff here; dropping V_loc from V would silently omit it. The atoms OWN V_loc gives zero net force (the integral int V_loc^I(r-R) Q(r-R) dr is translationally invariant); that self term cancels between this routine and the full-density local force in the continuum. Gradient analogue of nonlocal_pseudopotential_update_dij; same Gaunt / Y_LM / Q^L(r) machinery.

Parameters
[in]grad_potgrad V_eff, (1:meshnp, 1:ndim, 1:ncomp)
[in]force_aug_weightrho_ij, (max_nprojs, max_nprojs, nmat, 1:ncomp)
[in,out]force(1:ndim, 1:natoms)

Definition at line 2877 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_stress_uspp()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_stress_uspp ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(epot_t), intent(in), target  epot,
integer, intent(in)  periodic_dim,
real(real64), dimension(:, :, :), intent(in)  grad_pot,
real(real64), dimension(:, :, :, :), intent(in)  aug_weight,
real(real64), dimension(3, 3), intent(out)  stress_aug 
)

Ultrasoft augmentation contribution to the stress tensor.

For PAW this is the sigma_2 compensation-charge stress of Torrent et al., Comput. Mater. Sci. 42, 337 (2008), Eq. (41); the remaining PAW terms (Eqs. (40), (42)-(43)) are carried by the standard local, nonlocal (with the full D including ddd_paw) and NLCC stresses.

The augmentation density n_aug = sum_ij rho_ij Q_ij(r-R_I) is a rigid atomic function: under a homogeneous strain it only translates with R_I, while the smooth density scales homogeneously. The Hartree/local/xc stress terms (Sharma and Suryanarayana, J. Chem. Phys. 149, 194104 (2018)) assume homogeneous scaling of the full density, so the Q rigidity requires the correction (the delta_ab pieces cancel after an integration by parts over the localized augmentation sphere):

T_ab = sum_I sum_ij Tr_spin[ rho_ij . (d_a V_eff) ] (r-R_I)_b Q_ij(r-R_I) dr ,

with dE/d eps_ab = -T_ab. This is the analog of the force routine nonlocal_pseudopotential_force_uspp with an extra (r-R_I)_b weight. V_eff = V_loc + V_Hxc is the full effective potential and rho_ij the projector density matrix, as in Laasonen et al., PRB 47, 10142 (1993).

Parameters
[in]grad_potgrad V_eff, (1:meshnp, 1:ndim, 1:ncomp)
[in]aug_weightrho_ij, (max_nprojs, max_nprojs, nmat, 1:ncomp)
[out]stress_augT_ab as defined above (unsigned integral)

Definition at line 2967 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_aug_moment()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_aug_moment ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(epot_t), intent(in), target  epot,
real(real64), dimension(:), intent(in)  op,
real(real64), dimension(:, :, :), intent(inout)  aug_op 
)

Ultrasoft augmentation moments of a local operator A(r): int A(r) Q_ij(r-R_I) dr.

For ultrasoft/PAW the all-electron matrix element of a multiplicative operator A(r) between two pseudo-states carries an augmentation term, exactly as the charge density does (the density is the A = delta case):

<psi_i|A|psi_a> = int conjg(psitilde_i) A psitilde_a dr

  • sum_{I,nm} <psitilde_i|beta^I_n> <beta^I_m|psitilde_a> int A(r) Q^I_{nm}(r-R_I) dr .

This routine returns the geometry-dependent moments aug_op(n,m,I) = int A(r) Q^I_{nm}(r-R_I) dr. Because A is gathered at the ABSOLUTE mesh coordinates, the dipole operator A = x_alpha gives both the intrinsic L=1 moment of Q and the atom-position*charge offset R_{I,alpha} q_nm, which is what is needed to make the matrix element translationally consistent with the smooth term. Same Gaunt / Y_LM / Q^L(r) machinery as nonlocal_pseudopotential_update_dij (which is the A = V_eff case); here we do not add the bare block-diagonal D^(0).

Refs: Vanderbilt, PRB 41, 7892 (1990); Laasonen et al., PRB 47, 10142 (1993), Eq. (10); Gajdos, Hummer, Kresse, Furthmueller, Bechstedt, PRB 73, 045112 (2006) (optical matrix elements in the augmented-wave methodology).

Parameters
[in]opoperator A(r) on the mesh (1:meshnp)
[in,out]aug_op(max_nprojs, max_nprojs, nmat)

Definition at line 3058 of file nonlocal_pseudopotential.F90.

◆ nonlocal_pseudopotential_aug_density()

subroutine, public nonlocal_pseudopotential_oct_m::nonlocal_pseudopotential_aug_density ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(epot_t), intent(in), target  epot,
real(real64), dimension(:, :, :), intent(in)  force_aug_weight,
real(real64), dimension(:), intent(inout)  aug_density 
)

Accumulate the ultrasoft augmentation density n_aug(r) = sum_ij rho_ij Q_ij(r-R) (summed over all ultrasoft atoms) on the mesh, given the projector density matrix.

Same scatter as density_calc_accumulate_aug but driven by the total (occupation- and k-summed) force_aug_weight (= rho_ij). The forces use it to form the full density rho_val + n_aug, whose gradient enters the local-potential force; this is what supplies the V_loc shift acting on the augmentation charge (including the other atoms` local potential).

Parameters
[in]force_aug_weightrho_ij
[in,out]aug_density(1:meshnp_part), accumulated

Definition at line 3116 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_start()

subroutine, public nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_start ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
type(projection_t), intent(out)  projection,
logical, intent(in), optional  async 
)

Start application of non-local potentials (stored in the Hamiltonian) to the wave functions.

This routine is split into the *_start and *_finish parts, in order to allow for other operations during device transfer or communications.

TODO: add more details.

Parameters
[in]meshthe mesh
[in]stddimensions of the states
[in]spiral_bndflag for spiral boundary conditions
[in]psiboriginal wave functions
[out]projectionTODO: add description

Definition at line 3242 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_finish()

subroutine nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_finish ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
logical, intent(in)  spiral_bnd,
type(states_elec_dim_t), intent(in)  std,
type(projection_t), intent(inout), target  projection,
class(wfs_elec_t), intent(inout)  vpsib 
)
private

finish the application of non-local potentials.

Definition at line 3707 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_apply_overlap()

subroutine, public nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_apply_overlap ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
type(wfs_elec_t), intent(in), target  psib,
type(wfs_elec_t), intent(inout)  spsib,
type(phase_t), intent(in), optional  phase,
logical, intent(in), optional  spiral_bnd,
logical, intent(in), optional  apply_phase 
)

Apply the ultrasoft/PAW generalized overlap S = 1 + sum_ij |beta_i> q_ij <beta_j| (or, with another operator passed as this, S^{-1}) to a batch: spsib = S psib.

When a Bloch phase is supplied (and apply_phase is not .false.), the phase exp(ik.r) is applied before the augmentation projection and undone afterwards, so that spsib is returned in the same (periodic, phase-free) representation as psib. S is Hermitian, so <phi|S|psi> = <S phi|psi> = <phi|(S psi)>. The projector maps only address inner points (1:np), so the spiral boundary phase of the ghost/boundary points (phaseapply_phase_spiral) is not needed here.

This is the single S-application primitive: hamiltonian_elec_apply_overlap_batch delegates to it (adding the packing / S-vs-S^{-1} selection / norm-conserving short-circuit), and it is also called directly from src/states (states_elec_calc), a layer that cannot depend on hamiltonian_elec.

Note
spsib must already be a structural copy of psib (e.g. via psibcopy_to(spsib)); its data is overwritten here. The batch is not packed/unpacked here (the caller manages that).
Parameters
[in]psibonly read (no packing/mutation here)
[in]phaseBloch phase for S at k /= 0
[in]spiral_bndspiral boundary conditions (default .false.)
[in]apply_phaseoverride: skip the phase even if present (default .true.)

Definition at line 4057 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_add_overlap_inplace()

subroutine, public nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_add_overlap_inplace ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
type(wfs_elec_t), intent(inout), target  xb,
type(phase_t), intent(in), optional  phase,
logical, intent(in), optional  spiral_bnd,
logical, intent(in), optional  apply_phase 
)

In-place version of the generalized overlap: xb := S xb (or S^{-1} xb, depending on this). Avoids the identity copy of the out-of-place version (and lets the caller skip a scratch batch): the augmentation is accumulated directly onto the input.

Parameters
[in]phaseBloch phase for S at k /= 0
[in]spiral_bndspiral boundary conditions (default .false.)
[in]apply_phaseoverride: skip the phase even if present (default .true.)

Definition at line 4109 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_force()

subroutine nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_force ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
logical, intent(in)  spiral_bnd,
integer, intent(in)  iqn,
integer, intent(in)  ndim,
type(wfs_elec_t), intent(in)  psi1b,
type(wfs_elec_t), dimension(:), intent(in)  psi2b,
real(real64), dimension(:, :), intent(inout)  force 
)
private

calculate contribution to forces, from non-local potentials

TODO: add more details

spiral BC ik should be the same for psi2b

Definition at line 4154 of file nonlocal_pseudopotential.F90.

◆ dnl_force_gather_projs()

subroutine nonlocal_pseudopotential_oct_m::dnl_force_gather_projs ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
integer, intent(in)  ndim,
type(wfs_elec_t), intent(in)  valb,
type(wfs_elec_t), dimension(:), intent(in)  gradb,
real(real64), dimension(0:, 1:, 1:), intent(out)  projs 
)
private

Gather the raw projector overlaps <beta|val> and <beta|grad val> on the sphere points.

Fills projs(0:ndim, nst_linear, full_projection_size): projs(0,...) = sum_p beta(p) val(p) (the raw, un-scaled <beta_i|val>), and projs(idir,...) = sum_p beta(p) d_idir val(p). The physical integral is recovered by multiplying by pmatscal. Used by the cross overlap-derivative force below; mirrors the gather in nonlocal_pseudopotential_force.

Definition at line 4474 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_force_overlap_cross()

subroutine nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_force_overlap_cross ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
integer, intent(in)  iqn,
integer, intent(in)  ndim,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), dimension(:), intent(in)  gpsib,
type(wfs_elec_t), intent(in)  chib,
type(wfs_elec_t), dimension(:), intent(in)  gchib,
real(real64), dimension(:, :), intent(inout)  force 
)
private

Ultrasoft DFT+U force: the overlap-derivative (d_R S) term, as a cross density matrix.

Implements the contribution of the position dependence of the generalized overlap S to the +U force, F^B_a(J) = -2 sum_n f_n Re <psi~_n|(d_a S)|chi_n>, with chi_n the bare +U ket chi_n = sum_m |phi_m> sum_mp V_mmp <phi_mp|S|psi~_n> = P S psi~_n. With S = 1 + sum_ij q_ij |beta_i><beta_j| and d_{R_J} beta = -grad beta this is

F^B_a(J) = -2 sum_n f_n Re sum_ij q_ij [ <grad_a beta_i|psi~_n> <beta_j|chi_n>

  • <beta_i|psi~_n> <grad_a beta_j|chi_n> ] ,

the overlap charges q_ij = pmatqmix. See Timrov et al., PRB 102, 235159 (2020), Eqs. (17)-(18).

Parameters
[in]psibpsi~ (phase-set)
[in]gpsibgrad psi~ (ndim batches)
[in]chibchi = P S psi~ (phase-set)
[in]gchibgrad chi (ndim batches)

Definition at line 4592 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_position_commutator()

subroutine nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_position_commutator ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
class(wfs_elec_t), dimension(:), intent(inout), target  commpsib,
logical, intent(in), optional  async 
)
private

apply the commutator between the non-local potential and the position to the wave functions.

TODO: add more details

Parameters
[in]meshthe mesh
[in]stdthe electronic states
[in]spiral_bndflag for spiral boundary conditions
[in]psiboriginal wave functions psi
[in,out]commpsibresulting [v_nl, r]*psi

Definition at line 4681 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_r_vnlocal()

subroutine nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_r_vnlocal ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
class(wfs_elec_t), dimension(1:3), intent(inout), target  commpsib,
real(real64), dimension(:), intent(in), optional  eigenval,
logical, intent(in), optional  only_qmix 
)
private

Accumulates to commpsib the result of x V_{nl} | psib >

Here x = (r - R_I) is relative to each projector atom (pmatposition). For ultrasoft projectors (allocated pmatqmix) the coupling matrix is the per-state ( D^scr_ij - eps_n q_ij ), so eigenval must be passed

See Laasonen et al., PRB 47, 10142 (1993)

Parameters
[in]eigenvaleigenvalues for psib`s k-point, indexed by the true state index. Required for ultrasoft projectors (allocated pmatqmix): the coupling becomes D^scr_ij - eps_n q_ij per state.
[in]only_qmixwhen .true., couple with the overlap charges q_ij instead of D_ij: computes x (S-1) |psib>. Projectors without q (norm-conserving) give zero. Used by the overlap-strain cross terms (DFT+U stress).

Definition at line 5093 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_density_matrix()

subroutine, public nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_density_matrix ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
real(real64), dimension(:), intent(in)  weight,
real(real64), dimension(:, :, :, :), intent(inout), allocatable  beta_density,
real(real64), dimension(:), intent(in), optional  weight2,
real(real64), dimension(:, :, :, :), intent(inout), optional  beta_density2,
real(real64), dimension(:, :, :, :), intent(inout), optional, allocatable  beta_current 
)

Accumulate occupation-weighted beta-projector density matrices for USPP density.

Parameters
[in,out]beta_densitySpin-resolved projector density matrix rho_ij^sigma
[in]weight2Optional second weight and density matrix, accumulated from the same projections
[in,out]beta_currentOptional spin-resolved one-center current matrix A_ij^sigma = Im[ P^H WP ].

Definition at line 5523 of file nonlocal_pseudopotential.F90.

◆ dnonlocal_pseudopotential_reconstruct_paw_wfs()

subroutine, public nonlocal_pseudopotential_oct_m::dnonlocal_pseudopotential_reconstruct_paw_wfs ( class(nonlocal_pseudopotential_t), intent(in), target  this,
type(epot_t), intent(in), target  epot,
class(mesh_t), intent(in)  mesh,
integer, intent(in)  ik,
real(real64), dimension(:), intent(inout)  psi 
)

Add the PAW one-center correction to a single smooth wavefunction, reconstructing the all-electron wavefunction.

psi(r) = psitilde(r) + sum_a sum_i (phi_i(r) - phitilde_i(r)) Y_{l_i m_i}(rhat) <beta_i|psitilde> (Bloechl PRB 50, 17953 (1994)). For each PAW atom the projections c_i = <beta_i|psitilde> are formed on the projector sphere (carrying the Bloch phase for k /= 0), and the partial-wave differences (phi_i - phitilde_i)(r) Y_LM are splatted on the mesh (double_grid_transform), weighted by c_i. The projections are taken from a copy of the incoming (smooth) wavefunction, so the result is independent of the atom ordering even when augmentation spheres overlap.

Parameters
[in]ikk-point index (Bloch phase)
[in,out]psi(meshnp) smooth in, all-electron out

Definition at line 5632 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_start()

subroutine, public nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_start ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
type(projection_t), intent(out)  projection,
logical, intent(in), optional  async 
)

Start application of non-local potentials (stored in the Hamiltonian) to the wave functions.

This routine is split into the *_start and *_finish parts, in order to allow for other operations during device transfer or communications.

TODO: add more details.

Parameters
[in]meshthe mesh
[in]stddimensions of the states
[in]spiral_bndflag for spiral boundary conditions
[in]psiboriginal wave functions
[out]projectionTODO: add description

Definition at line 5816 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_finish()

subroutine nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_finish ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
logical, intent(in)  spiral_bnd,
type(states_elec_dim_t), intent(in)  std,
type(projection_t), intent(inout), target  projection,
class(wfs_elec_t), intent(inout)  vpsib 
)
private

finish the application of non-local potentials.

Definition at line 6364 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_apply_overlap()

subroutine, public nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_apply_overlap ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
type(wfs_elec_t), intent(in), target  psib,
type(wfs_elec_t), intent(inout)  spsib,
type(phase_t), intent(in), optional  phase,
logical, intent(in), optional  spiral_bnd,
logical, intent(in), optional  apply_phase 
)

Apply the ultrasoft/PAW generalized overlap S = 1 + sum_ij |beta_i> q_ij <beta_j| (or, with another operator passed as this, S^{-1}) to a batch: spsib = S psib.

When a Bloch phase is supplied (and apply_phase is not .false.), the phase exp(ik.r) is applied before the augmentation projection and undone afterwards, so that spsib is returned in the same (periodic, phase-free) representation as psib. S is Hermitian, so <phi|S|psi> = <S phi|psi> = <phi|(S psi)>. The projector maps only address inner points (1:np), so the spiral boundary phase of the ghost/boundary points (phaseapply_phase_spiral) is not needed here.

This is the single S-application primitive: hamiltonian_elec_apply_overlap_batch delegates to it (adding the packing / S-vs-S^{-1} selection / norm-conserving short-circuit), and it is also called directly from src/states (states_elec_calc), a layer that cannot depend on hamiltonian_elec.

Note
spsib must already be a structural copy of psib (e.g. via psibcopy_to(spsib)); its data is overwritten here. The batch is not packed/unpacked here (the caller manages that).
Parameters
[in]psibonly read (no packing/mutation here)
[in]phaseBloch phase for S at k /= 0
[in]spiral_bndspiral boundary conditions (default .false.)
[in]apply_phaseoverride: skip the phase even if present (default .true.)

Definition at line 6834 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_add_overlap_inplace()

subroutine, public nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_add_overlap_inplace ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
type(wfs_elec_t), intent(inout), target  xb,
type(phase_t), intent(in), optional  phase,
logical, intent(in), optional  spiral_bnd,
logical, intent(in), optional  apply_phase 
)

In-place version of the generalized overlap: xb := S xb (or S^{-1} xb, depending on this). Avoids the identity copy of the out-of-place version (and lets the caller skip a scratch batch): the augmentation is accumulated directly onto the input.

Parameters
[in]phaseBloch phase for S at k /= 0
[in]spiral_bndspiral boundary conditions (default .false.)
[in]apply_phaseoverride: skip the phase even if present (default .true.)

Definition at line 6886 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_force()

subroutine nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_force ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
logical, intent(in)  spiral_bnd,
integer, intent(in)  iqn,
integer, intent(in)  ndim,
type(wfs_elec_t), intent(in)  psi1b,
type(wfs_elec_t), dimension(:), intent(in)  psi2b,
real(real64), dimension(:, :), intent(inout)  force 
)
private

calculate contribution to forces, from non-local potentials

TODO: add more details

spiral BC ik should be the same for psi2b

Definition at line 6931 of file nonlocal_pseudopotential.F90.

◆ znl_force_gather_projs()

subroutine nonlocal_pseudopotential_oct_m::znl_force_gather_projs ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
integer, intent(in)  ndim,
type(wfs_elec_t), intent(in)  valb,
type(wfs_elec_t), dimension(:), intent(in)  gradb,
complex(real64), dimension(0:, 1:, 1:), intent(out)  projs 
)
private

Gather the raw projector overlaps <beta|val> and <beta|grad val> on the sphere points.

Fills projs(0:ndim, nst_linear, full_projection_size): projs(0,...) = sum_p beta(p) val(p) (the raw, un-scaled <beta_i|val>), and projs(idir,...) = sum_p beta(p) d_idir val(p). The physical integral is recovered by multiplying by pmatscal. Used by the cross overlap-derivative force below; mirrors the gather in nonlocal_pseudopotential_force.

Definition at line 7332 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_force_overlap_cross()

subroutine nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_force_overlap_cross ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
integer, intent(in)  iqn,
integer, intent(in)  ndim,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), dimension(:), intent(in)  gpsib,
type(wfs_elec_t), intent(in)  chib,
type(wfs_elec_t), dimension(:), intent(in)  gchib,
real(real64), dimension(:, :), intent(inout)  force 
)
private

Ultrasoft DFT+U force: the overlap-derivative (d_R S) term, as a cross density matrix.

Implements the contribution of the position dependence of the generalized overlap S to the +U force, F^B_a(J) = -2 sum_n f_n Re <psi~_n|(d_a S)|chi_n>, with chi_n the bare +U ket chi_n = sum_m |phi_m> sum_mp V_mmp <phi_mp|S|psi~_n> = P S psi~_n. With S = 1 + sum_ij q_ij |beta_i><beta_j| and d_{R_J} beta = -grad beta this is

F^B_a(J) = -2 sum_n f_n Re sum_ij q_ij [ <grad_a beta_i|psi~_n> <beta_j|chi_n>

  • <beta_i|psi~_n> <grad_a beta_j|chi_n> ] ,

the overlap charges q_ij = pmatqmix. See Timrov et al., PRB 102, 235159 (2020), Eqs. (17)-(18).

Parameters
[in]psibpsi~ (phase-set)
[in]gpsibgrad psi~ (ndim batches)
[in]chibchi = P S psi~ (phase-set)
[in]gchibgrad chi (ndim batches)

Definition at line 7483 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_position_commutator()

subroutine nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_position_commutator ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
class(wfs_elec_t), dimension(:), intent(inout), target  commpsib,
logical, intent(in), optional  async 
)
private

apply the commutator between the non-local potential and the position to the wave functions.

TODO: add more details

Parameters
[in]meshthe mesh
[in]stdthe electronic states
[in]spiral_bndflag for spiral boundary conditions
[in]psiboriginal wave functions psi
[in,out]commpsibresulting [v_nl, r]*psi

Definition at line 7572 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_r_vnlocal()

subroutine nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_r_vnlocal ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
class(wfs_elec_t), dimension(1:3), intent(inout), target  commpsib,
real(real64), dimension(:), intent(in), optional  eigenval,
logical, intent(in), optional  only_qmix 
)
private

Accumulates to commpsib the result of x V_{nl} | psib >

Here x = (r - R_I) is relative to each projector atom (pmatposition). For ultrasoft projectors (allocated pmatqmix) the coupling matrix is the per-state ( D^scr_ij - eps_n q_ij ), so eigenval must be passed

See Laasonen et al., PRB 47, 10142 (1993)

Parameters
[in]eigenvaleigenvalues for psib`s k-point, indexed by the true state index. Required for ultrasoft projectors (allocated pmatqmix): the coupling becomes D^scr_ij - eps_n q_ij per state.
[in]only_qmixwhen .true., couple with the overlap charges q_ij instead of D_ij: computes x (S-1) |psib>. Projectors without q (norm-conserving) give zero. Used by the overlap-strain cross terms (DFT+U stress).

Definition at line 8049 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_density_matrix()

subroutine, public nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_density_matrix ( class(nonlocal_pseudopotential_t), intent(in), target  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  std,
logical, intent(in)  spiral_bnd,
type(wfs_elec_t), intent(in)  psib,
real(real64), dimension(:), intent(in)  weight,
real(real64), dimension(:, :, :, :), intent(inout), allocatable  beta_density,
real(real64), dimension(:), intent(in), optional  weight2,
real(real64), dimension(:, :, :, :), intent(inout), optional  beta_density2,
real(real64), dimension(:, :, :, :), intent(inout), optional, allocatable  beta_current 
)

Accumulate occupation-weighted beta-projector density matrices for USPP density.

Parameters
[in,out]beta_densitySpin-resolved projector density matrix rho_ij^sigma
[in]weight2Optional second weight and density matrix, accumulated from the same projections
[in,out]beta_currentOptional spin-resolved one-center current matrix A_ij^sigma = Im[ P^H WP ].

Definition at line 8531 of file nonlocal_pseudopotential.F90.

◆ znonlocal_pseudopotential_reconstruct_paw_wfs()

subroutine, public nonlocal_pseudopotential_oct_m::znonlocal_pseudopotential_reconstruct_paw_wfs ( class(nonlocal_pseudopotential_t), intent(in), target  this,
type(epot_t), intent(in), target  epot,
class(mesh_t), intent(in)  mesh,
integer, intent(in)  ik,
complex(real64), dimension(:), intent(inout)  psi 
)

Add the PAW one-center correction to a single smooth wavefunction, reconstructing the all-electron wavefunction.

psi(r) = psitilde(r) + sum_a sum_i (phi_i(r) - phitilde_i(r)) Y_{l_i m_i}(rhat) <beta_i|psitilde> (Bloechl PRB 50, 17953 (1994)). For each PAW atom the projections c_i = <beta_i|psitilde> are formed on the projector sphere (carrying the Bloch phase for k /= 0), and the partial-wave differences (phi_i - phitilde_i)(r) Y_LM are splatted on the mesh (double_grid_transform), weighted by c_i. The projections are taken from a copy of the incoming (smooth) wavefunction, so the result is independent of the atom ordering even when augmentation spheres overlap.

Parameters
[in]ikk-point index (Bloch phase)
[in,out]psi(meshnp) smooth in, all-electron out

Definition at line 8649 of file nonlocal_pseudopotential.F90.