Octopus
exchange_operator_oct_m Module Reference

Data Types

type  ace_t
 
type  exchange_operator_t
 

Functions/Subroutines

subroutine ace_init (this, namespace, st)
 Initialize an instance of ACE_t. More...
 
subroutine ace_end (this)
 End an instance of ACE_t. More...
 
subroutine ace_write_info (this, namespace)
 
subroutine, public exchange_operator_init (this, namespace, space, st, der, mc, stencil, kpoints, cam)
 
subroutine, public exchange_operator_reinit (this, cam, st)
 
subroutine, public exchange_operator_end (this)
 
subroutine, public exchange_operator_rdmft_occ_apply (this, mesh, hpsib)
 
subroutine exchange_operator_write_info (this, namespace)
 
subroutine, public dexchange_operator_single (this, namespace, space, mesh, st_d, kpoints, phase, ist, ik, psi, hpsi, rdmft, force_noace)
 
subroutine, public dexchange_operator_apply (this, namespace, space, mesh, st_d, kpoints, phase, psib, hpsib, rdmft, force_noace)
 
subroutine dexchange_operator_apply_standard (this, namespace, space, mesh, st_d, kpoints, phase, psib, hpsib, rdmft)
 
subroutine dexchange_operator_apply_ace (this, mesh, st_d, psib, hpsib)
 
subroutine dexchange_operator_apply_ace_gemm (this, mesh, chib, psib, hpsib)
 Apply the ACE operator \( |h\psi_j\rangle \mathrel{-}= \sum_i \langle\chi_i|\psi_j\rangle\,|\chi_i\rangle \) to a packed batch as GEMM operations on the device buffers. More...
 
subroutine, public dexchange_operator_compute_potentials (this, namespace, space, gr, st, xst, kpoints, F_out)
 
subroutine dexchange_accumulate (np, xket, ff, ff_bra_host, pot_host, bra_buffer, ld_bra, ist_bra, pot_buffer)
 Accumulate the exchange contribution \( |x_j\rangle \mathrel{-}= ff\,\psi_{sym}\,V_{ij} \) into the whole target block xket, on host or device. More...
 
subroutine dexchange_operator_accumulate_return (gr, st, kpoints, ib2, ik2, exx_weight, pot, psi2, xpsi_ret, pot_buffer, xret_buffer, ff2_buffer, ff2_base, base_ret)
 Accumulates the exchange contribution of one batch of local states acting on a received state. More...
 
subroutine dexchange_operator_add_returned (gr, st, xst, ib_send, ik_send, xpsi_rec, xret_buffer)
 Add the returned exchange potential into the local xst block (sending task). More...
 
real(real64) function, public dexchange_operator_compute_ex (mesh, st, xst)
 Compute the exact exchange energy. More...
 
subroutine, public dexchange_operator_ace (this, namespace, mesh, st, xst, phase)
 Construct the ACE vectors. More...
 
subroutine dexchange_operator_ace_overlap (this, mesh, st, xst, xpsi, MM)
 Build the ACE overlap matrix for state-parallel wave functions. More...
 
subroutine dexchange_operator_ace_overlap_batched (this, mesh, st, xst, MM)
 Build the ACE overlap matrix from non-state-parallel wave-function batches. More...
 
subroutine, public dexchange_operator_commute_r (this, namespace, mesh, st_d, ik, psi, gpsi)
 
subroutine, public dexchange_operator_hartree_apply (this, namespace, mesh, st_d, kpoints, exx_coef, psib, hpsib)
 
subroutine, public zexchange_operator_single (this, namespace, space, mesh, st_d, kpoints, phase, ist, ik, psi, hpsi, rdmft, force_noace)
 
subroutine, public zexchange_operator_apply (this, namespace, space, mesh, st_d, kpoints, phase, psib, hpsib, rdmft, force_noace)
 
subroutine zexchange_operator_apply_standard (this, namespace, space, mesh, st_d, kpoints, phase, psib, hpsib, rdmft)
 
subroutine zexchange_operator_apply_ace (this, mesh, st_d, psib, hpsib)
 
subroutine zexchange_operator_apply_ace_gemm (this, mesh, chib, psib, hpsib)
 Apply the ACE operator \( |h\psi_j\rangle \mathrel{-}= \sum_i \langle\chi_i|\psi_j\rangle\,|\chi_i\rangle \) to a packed batch as GEMM operations on the device buffers. More...
 
subroutine, public zexchange_operator_compute_potentials (this, namespace, space, gr, st, xst, kpoints, F_out)
 
subroutine zexchange_accumulate (np, xket, ff, ff_bra_host, pot_host, bra_buffer, ld_bra, ist_bra, pot_buffer)
 Accumulate the exchange contribution \( |x_j\rangle \mathrel{-}= ff\,\psi_{sym}\,V_{ij} \) into the whole target block xket, on host or device. More...
 
subroutine zexchange_operator_accumulate_return (gr, st, kpoints, ib2, ik2, exx_weight, pot, psi2, xpsi_ret, pot_buffer, xret_buffer, ff2_buffer, ff2_base, base_ret)
 Accumulates the exchange contribution of one batch of local states acting on a received state. More...
 
subroutine zexchange_operator_add_returned (gr, st, xst, ib_send, ik_send, xpsi_rec, xret_buffer)
 Add the returned exchange potential into the local xst block (sending task). More...
 
real(real64) function, public zexchange_operator_compute_ex (mesh, st, xst)
 Compute the exact exchange energy. More...
 
subroutine, public zexchange_operator_ace (this, namespace, mesh, st, xst, phase)
 Construct the ACE vectors. More...
 
subroutine zexchange_operator_ace_overlap (this, mesh, st, xst, xpsi, MM)
 Build the ACE overlap matrix for state-parallel wave functions. More...
 
subroutine zexchange_operator_ace_overlap_batched (this, mesh, st, xst, MM)
 Build the ACE overlap matrix from non-state-parallel wave-function batches. More...
 
subroutine, public zexchange_operator_commute_r (this, namespace, mesh, st_d, ik, psi, gpsi)
 
subroutine, public zexchange_operator_hartree_apply (this, namespace, mesh, st_d, kpoints, exx_coef, psib, hpsib)
 

Variables

type(fourier_space_op_tcoulb
 Operator in Fourier space. More...
 
real(real64), parameter, private tol_exx_weight = 1.0e-3_real64
 Minimum weight below which EXX is not added. More...
 

Function/Subroutine Documentation

◆ ace_init()

subroutine exchange_operator_oct_m::ace_init ( class(ace_t), intent(inout)  this,
type(namespace_t), intent(in)  namespace,
type(states_elec_t), intent(in)  st 
)
private

Initialize an instance of ACE_t.

Definition at line 230 of file exchange_operator.F90.

◆ ace_end()

subroutine exchange_operator_oct_m::ace_end ( class(ace_t), intent(inout)  this)
private

End an instance of ACE_t.

Definition at line 271 of file exchange_operator.F90.

◆ ace_write_info()

subroutine exchange_operator_oct_m::ace_write_info ( class(ace_t), intent(in)  this,
type(namespace_t), intent(in)  namespace 
)
private

Definition at line 293 of file exchange_operator.F90.

◆ exchange_operator_init()

subroutine, public exchange_operator_oct_m::exchange_operator_init ( type(exchange_operator_t), intent(inout)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(states_elec_t), intent(in)  st,
type(derivatives_t), intent(in)  der,
type(multicomm_t), intent(in)  mc,
type(stencil_t), intent(in)  stencil,
type(kpoints_t), intent(in)  kpoints,
type(xc_cam_t), intent(in)  cam 
)

Definition at line 306 of file exchange_operator.F90.

◆ exchange_operator_reinit()

subroutine, public exchange_operator_oct_m::exchange_operator_reinit ( type(exchange_operator_t), intent(inout)  this,
type(xc_cam_t), intent(in)  cam,
type(states_elec_t), intent(in), optional, target  st 
)

Definition at line 414 of file exchange_operator.F90.

◆ exchange_operator_end()

subroutine, public exchange_operator_oct_m::exchange_operator_end ( type(exchange_operator_t), intent(inout)  this)

Definition at line 430 of file exchange_operator.F90.

◆ exchange_operator_rdmft_occ_apply()

subroutine, public exchange_operator_oct_m::exchange_operator_rdmft_occ_apply ( type(exchange_operator_t), intent(in)  this,
type(mesh_t), intent(in)  mesh,
class(wfs_elec_t), intent(inout)  hpsib 
)

Definition at line 451 of file exchange_operator.F90.

◆ exchange_operator_write_info()

subroutine exchange_operator_oct_m::exchange_operator_write_info ( class(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace 
)
private

Definition at line 465 of file exchange_operator.F90.

◆ dexchange_operator_single()

subroutine, public exchange_operator_oct_m::dexchange_operator_single ( type(exchange_operator_t), intent(inout)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
type(phase_t), intent(in)  phase,
integer, intent(in)  ist,
integer, intent(in)  ik,
real(real64), dimension(:, :), intent(inout), contiguous  psi,
real(real64), dimension(:, :), intent(inout), contiguous  hpsi,
logical, intent(in)  rdmft,
logical, intent(in), optional  force_noace 
)

Definition at line 554 of file exchange_operator.F90.

◆ dexchange_operator_apply()

subroutine, public exchange_operator_oct_m::dexchange_operator_apply ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
type(phase_t), intent(in)  phase,
class(wfs_elec_t), intent(inout)  psib,
class(wfs_elec_t), intent(inout)  hpsib,
logical, intent(in)  rdmft,
logical, intent(in), optional  force_noace 
)

Definition at line 585 of file exchange_operator.F90.

◆ dexchange_operator_apply_standard()

subroutine exchange_operator_oct_m::dexchange_operator_apply_standard ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
type(phase_t), intent(in)  phase,
class(wfs_elec_t), intent(inout)  psib,
class(wfs_elec_t), intent(inout)  hpsib,
logical, intent(in)  rdmft 
)
private

Definition at line 612 of file exchange_operator.F90.

◆ dexchange_operator_apply_ace()

subroutine exchange_operator_oct_m::dexchange_operator_apply_ace ( type(exchange_operator_t), intent(in)  this,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), intent(inout)  hpsib 
)
private

Definition at line 774 of file exchange_operator.F90.

◆ dexchange_operator_apply_ace_gemm()

subroutine exchange_operator_oct_m::dexchange_operator_apply_ace_gemm ( type(exchange_operator_t), intent(in)  this,
type(mesh_t), intent(in)  mesh,
type(wfs_elec_t), intent(in)  chib,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), intent(inout)  hpsib 
)
private

Apply the ACE operator \( |h\psi_j\rangle \mathrel{-}= \sum_i \langle\chi_i|\psi_j\rangle\,|\chi_i\rangle \) to a packed batch as GEMM operations on the device buffers.

GEMM operations run on the packed buffers (ist-1)*dim+idim. For spinors the spin diagonal of the coefficient matrix is summed and re-expanded so the same S(i,j) is applied to every spinor component.

Definition at line 858 of file exchange_operator.F90.

◆ dexchange_operator_compute_potentials()

subroutine, public exchange_operator_oct_m::dexchange_operator_compute_potentials ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(grid_t), intent(in)  gr,
type(states_elec_t), intent(inout), target  st,
type(states_elec_t), intent(inout)  xst,
type(kpoints_t), intent(in)  kpoints,
real(real64), dimension(:,:,:,:,:), intent(out), optional  F_out 
)
Parameters
[in,out]xstAction of V_X on a set of KS states
[out]f_outFor RDMFT

Definition at line 994 of file exchange_operator.F90.

◆ dexchange_accumulate()

subroutine exchange_operator_oct_m::dexchange_accumulate ( integer, intent(in)  np,
class(batch_t), intent(inout)  xket,
real(real64), intent(in)  ff,
real(real64), dimension(:,:), intent(in), optional  ff_bra_host,
real(real64), dimension(:,:), intent(in), optional  pot_host,
type(accel_mem_t), intent(in), optional  bra_buffer,
integer, intent(in), optional  ld_bra,
integer, intent(in), optional  ist_bra,
type(accel_mem_t), intent(in), optional  pot_buffer 
)
private

Accumulate the exchange contribution \( |x_j\rangle \mathrel{-}= ff\,\psi_{sym}\,V_{ij} \) into the whole target block xket, on host or device.

Parameters
[in]ffdevice: scaling factor; host: unused (folded in ff_bra_host)
[in]ff_bra_hosthost: ff*psi_sym (np,dim)
[in]pot_hosthost: pot(:,1:xketnst)

Definition at line 1612 of file exchange_operator.F90.

◆ dexchange_operator_accumulate_return()

subroutine exchange_operator_oct_m::dexchange_operator_accumulate_return ( type(grid_t), intent(in)  gr,
type(states_elec_t), intent(in)  st,
type(kpoints_t), intent(in)  kpoints,
integer, intent(in)  ib2,
integer, intent(in)  ik2,
real(real64), intent(in)  exx_weight,
real(real64), dimension(:,:), intent(in), optional, contiguous  pot,
real(real64), dimension(:,:), intent(inout), optional  psi2,
real(real64), dimension(:,:), intent(inout), optional, contiguous  xpsi_ret,
type(accel_mem_t), intent(in), optional  pot_buffer,
type(accel_mem_t), intent(inout), optional  xret_buffer,
type(accel_mem_t), intent(in), optional  ff2_buffer,
integer, intent(in), optional  ff2_base,
integer, intent(in), optional  base_ret 
)
private

Accumulates the exchange contribution of one batch of local states acting on a received state.

Parameters
[in]ib2Block index of the local states
[in]ik2k-point index of the local states
[in]exx_weightWeight of the exchange operator
[in]pothost: potentials for the local states of the batch
[in,out]psi2host: workspace for accessing device batches
[in,out]xpsi_rethost: accumulated potential to be returned
[in]pot_bufferdevice: potentials (np, nst2)
[in,out]xret_bufferdevice: (np, dim, nst_received) return buffer
[in]ff2_bufferdevice: precomputed per-lane weights (real64)
[in]ff2_basedevice: offset of this block weights in ff2_buffer
[in]base_retdevice: element offset of the current bra in xret_buffer

Definition at line 1702 of file exchange_operator.F90.

◆ dexchange_operator_add_returned()

subroutine exchange_operator_oct_m::dexchange_operator_add_returned ( type(grid_t), intent(in)  gr,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(inout), target  xst,
integer, intent(in)  ib_send,
integer, intent(in)  ik_send,
real(real64), dimension(:,:,:), intent(in), optional, contiguous  xpsi_rec,
type(accel_mem_t), intent(in), optional  xret_buffer 
)
private

Add the returned exchange potential into the local xst block (sending task).

Parameters
[in]ib_sendBlock index of the states that were sent
[in]ik_sendk-point index of the states that were sent
[in]xpsi_rechost: returned potential, (np, dim, nst)
[in]xret_bufferdevice: returned potential, (np, dim, nst)

Definition at line 1799 of file exchange_operator.F90.

◆ dexchange_operator_compute_ex()

real(real64) function, public exchange_operator_oct_m::dexchange_operator_compute_ex ( class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(in)  xst 
)

Compute the exact exchange energy.

\[ E_X = \frac{1}{2} \sum_{i, \sigma \mathbf{k}} w_\mathbf{k} f_{i\sigma\mathbf{k}} \int \psi^\ast_{i \sigma \mathbf{k}}(\mathbf{r}) W_{i \sigma \mathbf{k}}(\mathbf{r}) d\mathbf{r} \]

where

\[ W_{i\sigma\mathbf{k}}(\mathbf{r}) = - \sum_{j,\mathbf{k}^\prime} f_{j\sigma\mathbf{k}^\prime}\,\omega_{\mathbf{k}^\prime} V_{ij}^{\mathbf{k},\mathbf{k}^\prime,\sigma}(\mathbf{r}) \psi_{j\sigma\mathbf{k}^\prime}(\mathbf{r}) \]

is the action of the exchange operator on a set of Kohn-Sham states.

Note
The implementation ASSUMES that the appropriate range separation weight, exx_weight, and the electron occupation constant, stsmearel_per_state, have been absorbed in xst. This is what is done in the routine exchange_operator_compute_potentials.
Parameters
[in]stA set of KS states
[in]xstV_X operating on a set of KS states
Returns
Exact exchange energy

Definition at line 1917 of file exchange_operator.F90.

◆ dexchange_operator_ace()

subroutine, public exchange_operator_oct_m::dexchange_operator_ace ( type(exchange_operator_t), intent(inout)  this,
type(namespace_t), intent(in)  namespace,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(inout)  st,
type(states_elec_t), intent(inout)  xst,
type(phase_t), intent(in), optional  phase 
)

Construct the ACE vectors.

This follows the procedure defined in Lin, J. Chem. Theory Comput. 2016, 12, 2242. It constructs the \( M \) matrix, defined as the projection of the exact exchange operator onto the occupied Kohn-Sham states:

\[ M_{ij} = \langle \psi_i | \hat{V}_X | \psi_j \rangle = \langle \psi_i | W_j \rangle, \]

where \( W_j(\mathbf{r}) = (\hat{V}_X \psi_j)(\mathbf{r}) \) is the exchange operator applied to state \( j \). \( M \) is then decomposed into \( L \), which is inverted and used to construct the ACE vectors:

\[ \xi_k(\mathbf{r}) = \sum_{j=1}^n W_j(\mathbf{r}) \left(L^{-H}\right)_{j k} \]

Parameters
[in,out]thisACE vectors, of size thisacenst
[in,out]xstApplication of the exact exchange

Definition at line 1972 of file exchange_operator.F90.

◆ dexchange_operator_ace_overlap()

subroutine exchange_operator_oct_m::dexchange_operator_ace_overlap ( type(exchange_operator_t), intent(in)  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(inout)  xst,
real(real64), dimension(:,:), intent(inout)  xpsi,
real(real64), dimension(1:this%ace%nst, 1:this%ace%nst, st%d%kpt%start:st%d%kpt%end), intent(out)  MM 
)
private

Build the ACE overlap matrix for state-parallel wave functions.

For each local spin/k-point, construct the lower triangle of the ACE overlap matrix:

\[ M_{ij}^{(k)} = -\left\langle \psi_i^{(k)} \middle| \hat{X} \middle| \psi_j^{(k)} \right\rangle, \qquad (i, j) \leq N_{\mathrm{ACE}}. \]

Here, st contains the Kohn–Sham states \(\psi_i\) and xst contains their images under the exact-exchange operator, \(\hat{X}\psi_j\).

Parameters
[in,out]xpsiWork array

Definition at line 2121 of file exchange_operator.F90.

◆ dexchange_operator_ace_overlap_batched()

subroutine exchange_operator_oct_m::dexchange_operator_ace_overlap_batched ( type(exchange_operator_t), intent(in)  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(in)  xst,
real(real64), dimension(1:this%ace%nst, 1:this%ace%nst, st%d%kpt%start:st%d%kpt%end), intent(out)  MM 
)
private

Build the ACE overlap matrix from non-state-parallel wave-function batches.

For each local spin/k-point, construct the lower triangle of the ACE overlap matrix:

\[ M_{ij}^{(k)} = -\left\langle \psi_i^{(k)} \middle| \hat{X} \middle| \psi_j^{(k)} \right\rangle, \qquad (i, j) \leq N_{\mathrm{ACE}}. \]

The unused upper triangle, and spin/k-points without electrons, are returned as zero.

Parameters
[out]mmOverlap

Definition at line 2186 of file exchange_operator.F90.

◆ dexchange_operator_commute_r()

subroutine, public exchange_operator_oct_m::dexchange_operator_commute_r ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
integer, intent(in)  ik,
real(real64), dimension(:, :), intent(in), contiguous  psi,
real(real64), dimension(:, :, :), intent(inout), contiguous  gpsi 
)

Definition at line 2235 of file exchange_operator.F90.

◆ dexchange_operator_hartree_apply()

subroutine, public exchange_operator_oct_m::dexchange_operator_hartree_apply ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
real(real64), intent(in)  exx_coef,
class(wfs_elec_t), intent(inout)  psib,
class(wfs_elec_t), intent(inout)  hpsib 
)

Definition at line 2306 of file exchange_operator.F90.

◆ zexchange_operator_single()

subroutine, public exchange_operator_oct_m::zexchange_operator_single ( type(exchange_operator_t), intent(inout)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
type(phase_t), intent(in)  phase,
integer, intent(in)  ist,
integer, intent(in)  ik,
complex(real64), dimension(:, :), intent(inout), contiguous  psi,
complex(real64), dimension(:, :), intent(inout), contiguous  hpsi,
logical, intent(in)  rdmft,
logical, intent(in), optional  force_noace 
)

Definition at line 2459 of file exchange_operator.F90.

◆ zexchange_operator_apply()

subroutine, public exchange_operator_oct_m::zexchange_operator_apply ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
type(phase_t), intent(in)  phase,
class(wfs_elec_t), intent(inout)  psib,
class(wfs_elec_t), intent(inout)  hpsib,
logical, intent(in)  rdmft,
logical, intent(in), optional  force_noace 
)

Definition at line 2490 of file exchange_operator.F90.

◆ zexchange_operator_apply_standard()

subroutine exchange_operator_oct_m::zexchange_operator_apply_standard ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
type(phase_t), intent(in)  phase,
class(wfs_elec_t), intent(inout)  psib,
class(wfs_elec_t), intent(inout)  hpsib,
logical, intent(in)  rdmft 
)
private

Definition at line 2517 of file exchange_operator.F90.

◆ zexchange_operator_apply_ace()

subroutine exchange_operator_oct_m::zexchange_operator_apply_ace ( type(exchange_operator_t), intent(in)  this,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), intent(inout)  hpsib 
)
private

Definition at line 2679 of file exchange_operator.F90.

◆ zexchange_operator_apply_ace_gemm()

subroutine exchange_operator_oct_m::zexchange_operator_apply_ace_gemm ( type(exchange_operator_t), intent(in)  this,
type(mesh_t), intent(in)  mesh,
type(wfs_elec_t), intent(in)  chib,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), intent(inout)  hpsib 
)
private

Apply the ACE operator \( |h\psi_j\rangle \mathrel{-}= \sum_i \langle\chi_i|\psi_j\rangle\,|\chi_i\rangle \) to a packed batch as GEMM operations on the device buffers.

GEMM operations run on the packed buffers (ist-1)*dim+idim. For spinors the spin diagonal of the coefficient matrix is summed and re-expanded so the same S(i,j) is applied to every spinor component.

Definition at line 2763 of file exchange_operator.F90.

◆ zexchange_operator_compute_potentials()

subroutine, public exchange_operator_oct_m::zexchange_operator_compute_potentials ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(grid_t), intent(in)  gr,
type(states_elec_t), intent(inout), target  st,
type(states_elec_t), intent(inout)  xst,
type(kpoints_t), intent(in)  kpoints,
complex(real64), dimension(:,:,:,:,:), intent(out), optional  F_out 
)
Parameters
[in,out]xstAction of V_X on a set of KS states
[out]f_outFor RDMFT

Definition at line 2899 of file exchange_operator.F90.

◆ zexchange_accumulate()

subroutine exchange_operator_oct_m::zexchange_accumulate ( integer, intent(in)  np,
class(batch_t), intent(inout)  xket,
real(real64), intent(in)  ff,
complex(real64), dimension(:,:), intent(in), optional  ff_bra_host,
complex(real64), dimension(:,:), intent(in), optional  pot_host,
type(accel_mem_t), intent(in), optional  bra_buffer,
integer, intent(in), optional  ld_bra,
integer, intent(in), optional  ist_bra,
type(accel_mem_t), intent(in), optional  pot_buffer 
)
private

Accumulate the exchange contribution \( |x_j\rangle \mathrel{-}= ff\,\psi_{sym}\,V_{ij} \) into the whole target block xket, on host or device.

Parameters
[in]ffdevice: scaling factor; host: unused (folded in ff_bra_host)
[in]ff_bra_hosthost: ff*psi_sym (np,dim)
[in]pot_hosthost: pot(:,1:xketnst)

Definition at line 3526 of file exchange_operator.F90.

◆ zexchange_operator_accumulate_return()

subroutine exchange_operator_oct_m::zexchange_operator_accumulate_return ( type(grid_t), intent(in)  gr,
type(states_elec_t), intent(in)  st,
type(kpoints_t), intent(in)  kpoints,
integer, intent(in)  ib2,
integer, intent(in)  ik2,
real(real64), intent(in)  exx_weight,
complex(real64), dimension(:,:), intent(in), optional, contiguous  pot,
complex(real64), dimension(:,:), intent(inout), optional  psi2,
complex(real64), dimension(:,:), intent(inout), optional, contiguous  xpsi_ret,
type(accel_mem_t), intent(in), optional  pot_buffer,
type(accel_mem_t), intent(inout), optional  xret_buffer,
type(accel_mem_t), intent(in), optional  ff2_buffer,
integer, intent(in), optional  ff2_base,
integer, intent(in), optional  base_ret 
)
private

Accumulates the exchange contribution of one batch of local states acting on a received state.

Parameters
[in]ib2Block index of the local states
[in]ik2k-point index of the local states
[in]exx_weightWeight of the exchange operator
[in]pothost: potentials for the local states of the batch
[in,out]psi2host: workspace for accessing device batches
[in,out]xpsi_rethost: accumulated potential to be returned
[in]pot_bufferdevice: potentials (np, nst2)
[in,out]xret_bufferdevice: (np, dim, nst_received) return buffer
[in]ff2_bufferdevice: precomputed per-lane weights (real64)
[in]ff2_basedevice: offset of this block weights in ff2_buffer
[in]base_retdevice: element offset of the current bra in xret_buffer

Definition at line 3616 of file exchange_operator.F90.

◆ zexchange_operator_add_returned()

subroutine exchange_operator_oct_m::zexchange_operator_add_returned ( type(grid_t), intent(in)  gr,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(inout), target  xst,
integer, intent(in)  ib_send,
integer, intent(in)  ik_send,
complex(real64), dimension(:,:,:), intent(in), optional, contiguous  xpsi_rec,
type(accel_mem_t), intent(in), optional  xret_buffer 
)
private

Add the returned exchange potential into the local xst block (sending task).

Parameters
[in]ib_sendBlock index of the states that were sent
[in]ik_sendk-point index of the states that were sent
[in]xpsi_rechost: returned potential, (np, dim, nst)
[in]xret_bufferdevice: returned potential, (np, dim, nst)

Definition at line 3713 of file exchange_operator.F90.

◆ zexchange_operator_compute_ex()

real(real64) function, public exchange_operator_oct_m::zexchange_operator_compute_ex ( class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(in)  xst 
)

Compute the exact exchange energy.

\[ E_X = \frac{1}{2} \sum_{i, \sigma \mathbf{k}} w_\mathbf{k} f_{i\sigma\mathbf{k}} \int \psi^\ast_{i \sigma \mathbf{k}}(\mathbf{r}) W_{i \sigma \mathbf{k}}(\mathbf{r}) d\mathbf{r} \]

where

\[ W_{i\sigma\mathbf{k}}(\mathbf{r}) = - \sum_{j,\mathbf{k}^\prime} f_{j\sigma\mathbf{k}^\prime}\,\omega_{\mathbf{k}^\prime} V_{ij}^{\mathbf{k},\mathbf{k}^\prime,\sigma}(\mathbf{r}) \psi_{j\sigma\mathbf{k}^\prime}(\mathbf{r}) \]

is the action of the exchange operator on a set of Kohn-Sham states.

Note
The implementation ASSUMES that the appropriate range separation weight, exx_weight, and the electron occupation constant, stsmearel_per_state, have been absorbed in xst. This is what is done in the routine exchange_operator_compute_potentials.
Parameters
[in]stA set of KS states
[in]xstV_X operating on a set of KS states
Returns
Exact exchange energy

Definition at line 3831 of file exchange_operator.F90.

◆ zexchange_operator_ace()

subroutine, public exchange_operator_oct_m::zexchange_operator_ace ( type(exchange_operator_t), intent(inout)  this,
type(namespace_t), intent(in)  namespace,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(inout)  st,
type(states_elec_t), intent(inout)  xst,
type(phase_t), intent(in), optional  phase 
)

Construct the ACE vectors.

This follows the procedure defined in Lin, J. Chem. Theory Comput. 2016, 12, 2242. It constructs the \( M \) matrix, defined as the projection of the exact exchange operator onto the occupied Kohn-Sham states:

\[ M_{ij} = \langle \psi_i | \hat{V}_X | \psi_j \rangle = \langle \psi_i | W_j \rangle, \]

where \( W_j(\mathbf{r}) = (\hat{V}_X \psi_j)(\mathbf{r}) \) is the exchange operator applied to state \( j \). \( M \) is then decomposed into \( L \), which is inverted and used to construct the ACE vectors:

\[ \xi_k(\mathbf{r}) = \sum_{j=1}^n W_j(\mathbf{r}) \left(L^{-H}\right)_{j k} \]

Parameters
[in,out]thisACE vectors, of size thisacenst
[in,out]xstApplication of the exact exchange

Definition at line 3886 of file exchange_operator.F90.

◆ zexchange_operator_ace_overlap()

subroutine exchange_operator_oct_m::zexchange_operator_ace_overlap ( type(exchange_operator_t), intent(in)  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(inout)  xst,
complex(real64), dimension(:,:), intent(inout)  xpsi,
complex(real64), dimension(1:this%ace%nst, 1:this%ace%nst, st%d%kpt%start:st%d%kpt%end), intent(out)  MM 
)
private

Build the ACE overlap matrix for state-parallel wave functions.

For each local spin/k-point, construct the lower triangle of the ACE overlap matrix:

\[ M_{ij}^{(k)} = -\left\langle \psi_i^{(k)} \middle| \hat{X} \middle| \psi_j^{(k)} \right\rangle, \qquad (i, j) \leq N_{\mathrm{ACE}}. \]

Here, st contains the Kohn–Sham states \(\psi_i\) and xst contains their images under the exact-exchange operator, \(\hat{X}\psi_j\).

Parameters
[in,out]xpsiWork array

Definition at line 4035 of file exchange_operator.F90.

◆ zexchange_operator_ace_overlap_batched()

subroutine exchange_operator_oct_m::zexchange_operator_ace_overlap_batched ( type(exchange_operator_t), intent(in)  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(states_elec_t), intent(in)  xst,
complex(real64), dimension(1:this%ace%nst, 1:this%ace%nst, st%d%kpt%start:st%d%kpt%end), intent(out)  MM 
)
private

Build the ACE overlap matrix from non-state-parallel wave-function batches.

For each local spin/k-point, construct the lower triangle of the ACE overlap matrix:

\[ M_{ij}^{(k)} = -\left\langle \psi_i^{(k)} \middle| \hat{X} \middle| \psi_j^{(k)} \right\rangle, \qquad (i, j) \leq N_{\mathrm{ACE}}. \]

The unused upper triangle, and spin/k-points without electrons, are returned as zero.

Parameters
[out]mmOverlap

Definition at line 4100 of file exchange_operator.F90.

◆ zexchange_operator_commute_r()

subroutine, public exchange_operator_oct_m::zexchange_operator_commute_r ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
integer, intent(in)  ik,
complex(real64), dimension(:, :), intent(in), contiguous  psi,
complex(real64), dimension(:, :, :), intent(inout), contiguous  gpsi 
)

Definition at line 4149 of file exchange_operator.F90.

◆ zexchange_operator_hartree_apply()

subroutine, public exchange_operator_oct_m::zexchange_operator_hartree_apply ( type(exchange_operator_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
type(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  st_d,
type(kpoints_t), intent(in)  kpoints,
real(real64), intent(in)  exx_coef,
class(wfs_elec_t), intent(inout)  psib,
class(wfs_elec_t), intent(inout)  hpsib 
)

Definition at line 4220 of file exchange_operator.F90.

Variable Documentation

◆ coulb

type(fourier_space_op_t) exchange_operator_oct_m::coulb
private

Operator in Fourier space.

Definition at line 221 of file exchange_operator.F90.

◆ tol_exx_weight

real(real64), parameter, private exchange_operator_oct_m::tol_exx_weight = 1.0e-3_real64
private

Minimum weight below which EXX is not added.

Definition at line 225 of file exchange_operator.F90.