Octopus
paw_onsite_oct_m Module Reference

PAW radial engine. More...

Detailed Description

PAW radial engine.

Given a one-center density matrix rho_ij (over the (l,m)-resolved partial-wave projectors of a single species), this module computes the all-electron (AE) and pseudo (PS) one-center energies E^1, Etilde^1 and the D-matrix contribution D^1_ij - Dtilde^1_ij, on the radial x angular grid inside the augmentation sphere.

The physics is assembled uniformly for the AE and PS sides and the two are subtracted: E^1 = Tr[rho K^AE] + 1/2 <n^1|v_H[n^1]> + <n^1|v_AE_ref> + E_xc[n^1 + n_c] Etilde^1 = Tr[rho K^PS] + 1/2 <ntilde|v_H[ntilde]> + <ntilde|vbar> + E_xc[ntilde + ntilde_c] with ntilde = ntilde^1 + nhat (the compensation charge). The D matrix is the exact derivative D_ij = d E / d rho_ij, so a finite-difference of the energy validates it.

All radial integrals are restricted to the augmentation sphere r <= r_c of the dataset. The kinetic matrices K^AE and K^PS are evaluated in the symmetric form 1/2 int_0^r_c [u_i_prime u_j_prime + l(l+1) u_i u_j / r^2] dr (u = r phi), which differs from <phi_i|T|phi_j>_sphere by the surface term -1/2 u_i u_j_prime(r_c). That term is the same for the AE and PS partial waves (they coincide at r_c), so it cancels in E^1 - Etilde^1 and in D^1 - Dtilde^1, which are the only quantities entering the total energy and the Hamiltonian.

References

[Bloechl94] P. E. Bloechl, Projector augmented-wave method, Phys. Rev. B 50, 17953 (1994). doi:10.1103/PhysRevB.50.17953 – original PAW formulation; Eqs. (18)-(21), (52)-(54) for the one-center energies E^1 - Etilde^1 and the compensation charge. [KresseJoubert99] G. Kresse and D. Joubert, From ultrasoft pseudopotentials to the projector augmented-wave method, Phys. Rev. B 59, 1758 (1999). doi:10.1103/PhysRevB.59.1758 – the formulation matching UPF2 kjpaw datasets; the compensation charge enters the XC (usexcnhat) and the reference-potential double counting used here for PAW_KRESSE_JOUBERT. [Torrent08] M. Torrent, F. Jollet, F. Bottin, G. Zerah, X. Gonze, Implementation of the projector augmented-wave method in the ABINIT code, Comput. Mater. Sci. 42, 337 (2008). doi:10.1016/j.commatsci.2007.07.020 – the radial x angular one-center quadrature (Gauss-Legendre in cos(theta) x uniform in phi) and the E^1/Etilde^1 term decomposition (see Sec. 3). [WhiteBird94] S. J. A. White and D. M. Bird, Phys. Rev. B 50, 4954 (1994). – mesh functional for the GGA gradient.

Data Types

type  paw_sphere_t
 Per-species, geometry-independent one-center data. Built once at setup and immutable during the SCF; the compute routine only reads it. More...
 

Functions/Subroutines

subroutine, public paw_onsite_init (this, ps, namespace, formulation, nspin)
 Build the per-species one-center data from a (PAW) pseudopotential. More...
 
integer pure function paw_pair_index (ri, rj)
 Packed index of the unordered radial channel pair (ri, rj). The radial pair products and compensation shapes are symmetric under ri <-> rj, so only the ri <= rj triangle is stored and both orders map to the same column. More...
 
subroutine paw_onsite_init_pairs (this)
 Tabulate the species-constant radial pair products phi_i phi_j and pack the nonzero real Gaunt couplings of every (l,m)-resolved projector pair in CSR form. More...
 
subroutine paw_onsite_init_xc (this, ps, namespace)
 Initialize the exchange and correlation functionals from the ones stored in the pseudopotential. More...
 
logical function paw_onsite_xc_has_kernels (this)
 Whether all the functionals of the dataset provide the second and third derivatives (fxc, kxc) needed by the moment expansion of the one-center XC (paw_xc_kernels). More...
 
subroutine paw_onsite_kinetic (this, r_full, phi_ae_full, phi_ps_full)
 Kinetic matrices K^AE_ij = <phi_i|T|phi_j> and K^PS_ij = <phitilde_i|T|phitilde_j>, nonzero only for equal-l radial channels, in the symmetric gradient form 1/2 int_0^r_c [ u_i_prime u_j_prime + l(l+1) u_i u_j / r^2 ] dr, u = r phi. The surface term dropped by this form is common to AE and PS, so K^AE - K^PS is the frozen kinetic term of the one-center D matrix ([KresseJoubert99] Eq. (52), the DeltaE^kin contribution; [Torrent08] Eqs. (E.1)-(E.2), matrix K_ninj). The derivatives are taken on the full dataset grid (r_full), to avoid a spline boundary effect at r_c. More...
 
subroutine paw_radial_derivative (r, f, df)
 Radial derivative of a grid-sampled function via the cubic-spline derivative. More...
 
subroutine paw_onsite_init_derivative (this)
 Build the five-point Fornberg first-derivative weights for every radial point (B. Fornberg, Generation of finite difference formulas on arbitrarily spaced grids, Math. Comp. 51, 699 (1988)). The stencil is the sliding window of der_nw points centered on each point and clamped at the grid ends. The resulting banded operator and its transpose are used by the moment expansion of the GGA one-center XC. More...
 
subroutine paw_fornberg_weights (z, x, n, w)
 First-derivative weights at z from function values at the n points x (Fornberg 1988 recursion, restricted to derivative order 1). More...
 
subroutine paw_radial_derivative_fd (this, f, df)
 Radial derivative of a function sampled on the sphere grid: apply the banded Fornberg operator built at init. More...
 
subroutine paw_radial_derivative_t (this, f, df)
 Apply the transpose of the banded radial-derivative operator: df_j = sum_i D_ij f_i. This is the discrete adjoint needed for exact functional derivatives of energies that contain the radial gradient (the divergence term of the spherical GGA potential): with E = sum_i w_i f(n_i, (Dn)_i), dE/dn_j carries D^T (w df/dg), not the continuum integration-by-parts form. More...
 
subroutine paw_onsite_angular_grid (this)
 Angular grid: Gauss-Legendre in cos(theta) x uniform in phi, plus the real spherical harmonics tabulated at each node. More...
 
subroutine, public paw_onsite_compute (this, rho, e1, e1t, dij, hxc_only)
 Given the one-center density matrix rho_ij, compute the one-center energies E1 (AE) and E1t (PS) and the D-matrix contribution dij = D^1 - Dtilde^1 ([Torrent08] Eqs. (18)-(19) for the E^1/Etilde^1 sphere energies and Eqs. (23)-(25), (49) for the D matrix). E1 and E1t include their own kinetic term, Tr[rho K^AE] and Tr[rho K^PS]. Both are only defined up to a common surface term, so only E1 - E1t is physically meaningful. More...
 
subroutine, public paw_onsite_side (this, rho, ae, energy, dij, hxc_only)
 One side (AE or PS) of the one-center calculation: build the density in the Y_LM expansion, the Hartree + reference + XC potential, accumulate the energy and the D matrix. The compensation charge nhat is included when ae==.false. More...
 
subroutine paw_build_density (this, rho, ae, with_comp, nlm_rho, nlm_der)
 Build the density coefficients n_LM(r) from rho_ij ([Torrent08] Eqs. (44)-(47)). On the PS side, add the compensation charge nhat = sum rho_ij Qhat_ij^L, which restores the AE multipole moments on the smooth side ([Bloechl94] Eq. (24); [KresseJoubert99] Eq. (23); [Torrent08] Eqs. (12)-(17) and (48)). Angular coupling uses the real Gaunt coefficients G_{L M}^{l_i m_i, l_j m_j} = int Y_{l_i m_i} Y_{l_j m_j} Y_{L M} dOmega. When with_comp is .true. (pseudo side, Hartree density and Kresse-Joubert XC) the compensation charge is added; the Bloechl formulation excludes it from the XC density (with_comp=.false.). On the all-electron side with_comp is ignored. If nlm_der is present (GGA only), the radial derivative d n_LM/dr is also returned. More...
 
subroutine paw_qaug_gemv (this, qtab, trans, xx, yy)
 Contract the packed compensation shapes against per-LM fields, restricted to the Gaunt-live L channels of each LM: with trans = N accumulate yy(:, lm) += qtab(:, :, L(lm)) . xx(:, lm), with trans = T the transposed reduction yy(:, lm) += qtab(:, :, L(lm))^T . xx(:, lm). qtab is qaug or its radial derivative. More...
 
subroutine paw_gaunt_scatter_dij (this, w, dij)
 Scatter the per-(pair, LM) reductions through the packed Gaunt couplings into the symmetric D matrix: D_ij += sum_LM c(i j; LM) w(pair_ij, LM). More...
 
subroutine paw_emit_lm_columns (this, field_lm, tol, ncol, spl, ll, mm, rcut)
 Fit the nonzero (L, M) columns of a one-center radial field field_lm(np, nlm_rho) into splines ready to be splatted on the mesh with double_grid_transform. More...
 
subroutine paw_partial_wave_derivatives (this, dphi_ae, dphi_ps)
 Radial derivatives of all (AE, PS) partial waves phi (not u = r phi): grad(phi Y) uses dphi/dr. More...
 
subroutine paw_adjoint_divergence_add (this, flux, div, vfield)
 Add the discrete-adjoint divergence of a vwr-weighted radial flux to a potential-like field: vfield(ip) += [D^T flux](ip) / vwr(ip). Points with vwr = 0 (the origin) are skipped; every consumer integrates vfield against vwr, so their value is irrelevant. div is a caller-provided (np) workspace. More...
 
subroutine, public paw_onsite_reorder_pmat (nprojs, map, src, dst)
 Reorder one spin channel of a projector-ordered matrix. More...
 
subroutine paw_hartree_lm (this, lm, nl, vl)
 Radial Hartree potential for one (L,M) channel (classical multipole expansion of 1/|r-r_prime|, [Torrent08] Eq. (A.9), entering the Hartree kernels of Eqs. (E.3)-(E.11)): V_L(r) = 4pi/(2L+1) [ r^{-L-1} int_0^r n_L s^{L+2} ds + r^L int_r^inf n_L s^{1-L} ds ]. More...
 
subroutine paw_xc (this, nlm_rho, nlm_der, ncore, ae, with_comp, e_xc, dij)
 Exchange-correlation on the radial x angular grid: LibXC evaluated pointwise, accumulating the XC energy e_xc and the XC contribution to the D matrix dij. This is the exact angular-sampling scheme of [Torrent08] Sec. 4.3.1 (pawxcdev = 0), Eqs. (E.12)-(E.13), extended here beyond LDA: LDA projects v_xc onto Y_LM and reuses paw_accumulate_dij; GGA uses the explicit (White-Bird) derivative D_ij = int [ vrho g_ij + 2 vsigma grad(n).grad(g_ij) ]. More...
 
subroutine paw_xc_density (this, nlm_rho, ncore, dens, densp, dpol)
 : Prepare the density for the XC calculation with libxc The polarization magnitude dpol (noncollinear only) is returned for reuse in the sigma and potential-rotation stages so it is not recomputed there. More...
 
subroutine paw_xc_gradient (this, nlm_rho, nlm_der, ncder, g)
 Gradient stage of paw_xc. More...
 
subroutine paw_xc_sigma (this, dens, dpol, g, gp, sigma)
 Conversion from gradients to sigma, for GGA with libxc. More...
 
subroutine paw_xc_lda_process (this, dens, vr)
 Rotate the LDA potential from the local spin frame back to the global fram. More...
 
subroutine paw_xc_gga_process (this, ae, with_comp, dens, g, gp, vr, vs, dij)
 Rotate the GGA part of the potential from the local spin frame back to the global fram. More...
 
subroutine paw_xc_eval (this, np, nsp, nsig, dens, sigma, exc, vrho, vsigma)
 Functional-specific part of the one-center XC. More...
 
subroutine paw_xc_eval_block (this, np, ip0, bs, nsp, nsig, dens, sigma, exc, vrho, vsigma)
 Evaluate the functionals on one contiguous block of bs points. More...
 
subroutine paw_xc_sph_potential (this, nsp, nsig, n0, sigma0, dn0, exc0, vsph)
 Energy density and full XC potential of a spherically symmetric density on the radial grid. For GGA the potential carries the divergence term in its discrete-adjoint form ([Torrent08] Eq. (69) in the continuum): with E = sum_i vwr_i f(n_i, (Dn)_i), the functional derivative is v_j = (df/dn)_j + (1/vwr_j) [D^T (vwr df/dg)]_j, which keeps the D matrix built from this potential the exact derivative of the discrete energy. Points with vwr = 0 (the origin) skip the adjoint term: every consumer integrates v against vwr, so their value is irrelevant. More...
 
subroutine paw_xc_kernels (this, nsp, nsig, n0, sigma0, dn0, kk, k2)
 Analytic XC kernels of the spherical one-center problem at fixed radial gradient: K_st(r) = d v_s(r) / d n_t(r) K2_stu(r) = d2 v_s(r) / d n_t(r) d n_u(r) (density-only channel) with v_s the spherical potential of paw_xc_sph_potential. For LDA these are the LibXC fxc / kxc; for GGA, K additionally carries the discrete-adjoint divergence of the flux response at fixed gradient, d f_s / d n_t = 2 v2rhosigma(t; ss) dn_s. More...
 
subroutine paw_xc_moments (this, nlm_rho, ncore, ae, with_comp, e_xc, dij)
 One-center XC by the second-order moment expansion around the spherical density ([Torrent08] Sec. 4.3.1, Eqs. (56)-(61) and (65): E_xc = 4 pi int f(n0) r^2 dr + 1/2 sum_st int K_st(r) M_st(r) r^2 dr v_00 = sqrt(4 pi) v_xc[n0] + 1/(2 sqrt(4 pi)) sum_tu K2_stu M_tu (Eq. (60)) v_LM = sum_t K_st n_LM,t for L > 0 (Eq. (61)) with M_st(r) = sum_{LM /= 00} n_LM,s n_LM,t and the analytic kernels K = dv_xc/dn, K2 = d2v_xc/dn2 at the spherical density n0 (fixed-gradient derivative of Eq. (57), from the LibXC fxc/kxc; see paw_xc_kernels). The functional is evaluated on the np radial points only, instead of the np x nang one-center grid of paw_xc. More...
 
pure real(real64) function paw_xc_noncol_dpol (n1, n2, n3, n4)
 Noncollinear polarization magnitude dpol = |m| at one point. More...
 
pure subroutine paw_xc_noncol_weights (n1, n2, n3, n4, dpol, fw)
 Noncollinear local-frame projection weights F_c^s = d n_s / d n_c at one point. More...
 
subroutine paw_xc_dij_gga_noncollinear (this, ae, with_comp, dens, g, gp, vr, vs, dij)
 Noncollinear GGA D-matrix contribution: the exact derivative of the local-frame projected E_xc with respect to the four density components. Per grid point, with the projection weights F_c^s and their gradients h_c = grad F_c^+ (grad F_c^- = -h_c for every components, so the weight-variation term contracts to a single channel difference), a1 = sum_s F_c^s vrho_s + (B_1 - B_2) . h_c a_k = F_c^1 B_1,k + F_c^2 B_2,k with B_s,k = 2 vsigma_ss grad_k n_s + vsigma_12 grad_k n_os the projected-channel flux. More...
 
subroutine paw_xc_dij_gga_fields (this, ae, with_comp, a1, a2, a3, a4, dij)
 Accumulate the D-matrix components from the angular fields of the White-Bird GGA coupling, one set per spin component: a1 carries the local (vrho-like) coupling to the pair density, a2/a3/a4 the radial/theta/phi components of the gradient coupling to grad(pair density). The angular quadrature weight enters through the weighted harmonics, so the fields must not carry it. More...
 
subroutine paw_accumulate_dij (this, ae, with_comp, vlm, dij)
 Accumulate D_ij = sum_LM gaunt(l_i m_i, l_j m_j, L M) int v_LM(r) g_ij^L(r) r^2 dr where g_ij^L is the radial pair density (phi_i phi_j for AE, phitilde_i phitilde_j. More...
 
integer pure function, public paw_onsite_nlm (this)
 Number of (l,m)-resolved projectors, i.e. the leading dimension of rho_ij. More...
 
integer pure function, public paw_onsite_nlm_rho (this)
 Number of real-harmonic columns (lmax_rho+1)^2 of the one-center density expansion; the upper bound on the number of Y_LM columns any *_diff routine returns. More...
 
integer pure function, public paw_onsite_nspin (this)
 Number of collinear spin channels (1 or 2) the sphere was built for. More...
 
subroutine, public paw_onsite_pmat_map (this, nprojs, pl, pm, pchannel, map)
 Map the projector-matrix enumeration (l, m, channel) used by the mesh nonlocal machinery to the one-center (l,m)-resolved projector index of this sphere. More...
 
subroutine, public paw_onsite_reference_density (this, occ, rho)
 Build the spherical reference density matrix from per-radial-channel occupations occ(1:nrad): each shell occupation is spread equally over its 2l+1 m-states and its nspin channels, rho(im,im,s) = occ(rad(im)) / ((2 l + 1) nspin), giving a spherically symmetric, non-magnetic reference density. More...
 
real(real64) function, public paw_onsite_charge (this, rho, ae)
 Integrated L=0 charge of the one-center density (spin-summed) for a given rho: the all-electron (ae==.true.) valence charge int n^1 d^3r, or the pseudo+compensation charge int (ntilde^1 + nhat) d^3r (ae==.false.). Used for the neutrality sum rule: the two must be equal by construction of the compensation charge. More...
 
subroutine, public paw_onsite_density_diff (this, rho, ncol, spl, ll, mm, rcut)
 Build the one-center all-electron-minus-(pseudo+compensation) density difference for a single collinear spin channel, Delta n_LM(r) = n^1_LM(r) - ( ntilde^1_LM(r) + nhat_LM(r) ), as radial splines ready to be splatted on the mesh with double_grid_transform (which forms feff = spline(r) Y_LM). Because the smooth mesh density already carries the compensation charge nhat (Kresse-Joubert), adding sum_a Delta n over the atoms reconstructs the true all-electron density n_AE = ntilde + sum_a (n^1 - ntilde^1). More...
 
subroutine, public paw_onsite_tau_diff (this, rho, ncol, spl, ll, mm, rcut, tau_integral)
 Build the one-center all-electron-minus-pseudo kinetic-energy-density difference for a single collinear spin channel, Delta tau_LM(r) = tau^1_LM(r) - tautilde^1_LM(r), as radial splines ready to be splatted on the mesh with double_grid_transform. The kinetic-energy density (octopus convention, no 1/2 factor, matching states_elec_calc_quantities) of a one-center density matrix rho_ij is tau(r,Omega) = sum_ij rho_ij grad(phi_i Y_i) . grad(phi_j Y_j) = sum_ij rho_ij [ phi_i'(r) phi_j'(r) Y_i Y_j. More...
 
subroutine, public paw_onsite_current_diff (this, arho, idir, ncol, spl, ll, mm, rcut, current_integral)
 One-center all-electron current-density correction Delta j^alpha = j^1 - j~^1. More...
 
subroutine, public paw_onsite_get_velocity_matrix (this, vmat)
 Velocity (momentum) matrix of the partial waves, V^alpha_ij = int (g_i grad_alpha g_j) dV, all-electron minus pseudo, over the augmentation sphere (g = phi Y_lm). This is the macroscopic one-center current integral factor: int Delta j^alpha dV = sum_ij A_ij V^alpha_ij, so it cross-checks the field built by paw_onsite_current_diff (whose L=0 radial moment is the same integral) against a direct radial x angular quadrature. More...
 
subroutine, public paw_onsite_partial_wave_diff (this, nprojs, pl, pm, pchannel, spl, ll, mm, rcut)
 Build the partial-wave difference (phi_i - phitilde_i)(r) for each projector, as radial splines ready to be splatted on the mesh with double_grid_transform (feff = spline(r) Y_LM). This is the one-center building block of the all-electron wavefunction reconstruction psi(r) = psitilde(r) + sum_i (phi_i(r) - phitilde_i(r)) Y_{l_i m_i}(rhat) <beta_i|psitilde>, so the caller weights each column i by the projection <beta_i|psitilde>. The projectors are passed in their (l, m, channel) enumeration (pl/pm/pchannel, as in the projector matrix) and mapped to the corresponding radial partial wave through paw_onsite_pmat_map; ll(i)=pl(i), mm(i)=pm(i). One column per projector (ncol = nprojs); spl/ll/mm are allocated here and must be spline_end`d / deallocated by the caller. rcut is the outer radial-grid bound. More...
 
subroutine, public paw_onsite_get_kinetic_data (this, deltaK, p_rad, p_l, p_m)
 Read-only access to the frozen kinetic correction DeltaK = K^AE - K^PS (the radial-channel matrix, nrad x nrad) and to the one-center projector enumeration (the radial channel, l and m of each of the nlm projectors). This lets a caller form the kinetic one-center energy Tr[rho DeltaK] in the (l,m)-diagonal one-center basis (the kinetic operator is diagonal in the angular index); the reconstructed kinetic-energy-density correction integrates to int Delta tau d^3r = 2 Tr[rho DeltaK] (the factor 2 from the octopus tau convention without the one half), cross-checking paw_onsite_tau_diff. More...
 
subroutine, public paw_onsite_end (this)
 

Variables

integer, parameter, public paw_kresse_joubert = 1
 PAW formulation: selects the compensation-charge / reference treatment. More...
 
integer, parameter, public paw_blochl = 2
 Bloechl (GPAW/ABINIT); nhat excluded from XC. More...
 
integer, parameter paw_xc_scheme_full = 1
 exact evaluation on the radial x angular grid More...
 
integer, parameter paw_xc_scheme_moments = 2
 second-order moment expansion around the spherical density More...
 
real(real64), parameter gaunt_tol = 1.0e-12_real64
 
real(real64), parameter paw_xc_tiny = 1.0e-12_real64
 Relative polarization threshold of the noncollinear local-frame projection. More...
 

Function/Subroutine Documentation

◆ paw_onsite_init()

subroutine, public paw_onsite_oct_m::paw_onsite_init ( type(paw_sphere_t), intent(out)  this,
type(ps_t), intent(in)  ps,
type(namespace_t), intent(in)  namespace,
integer, intent(in)  formulation,
integer, intent(in)  nspin 
)

Build the per-species one-center data from a (PAW) pseudopotential.

Parameters
[in]formulationPAW_KRESSE_JOUBERT or PAW_BLOCHL

Definition at line 312 of file paw_onsite.F90.

◆ paw_pair_index()

integer pure function paw_onsite_oct_m::paw_pair_index ( integer, intent(in)  ri,
integer, intent(in)  rj 
)
private

Packed index of the unordered radial channel pair (ri, rj). The radial pair products and compensation shapes are symmetric under ri <-> rj, so only the ri <= rj triangle is stored and both orders map to the same column.

Definition at line 608 of file paw_onsite.F90.

◆ paw_onsite_init_pairs()

subroutine paw_onsite_oct_m::paw_onsite_init_pairs ( type(paw_sphere_t), intent(inout)  this)
private

Tabulate the species-constant radial pair products phi_i phi_j and pack the nonzero real Gaunt couplings of every (l,m)-resolved projector pair in CSR form.

Definition at line 622 of file paw_onsite.F90.

◆ paw_onsite_init_xc()

subroutine paw_onsite_oct_m::paw_onsite_init_xc ( type(paw_sphere_t), intent(inout)  this,
type(ps_t), intent(in)  ps,
type(namespace_t), intent(in)  namespace 
)
private

Initialize the exchange and correlation functionals from the ones stored in the pseudopotential.

Definition at line 694 of file paw_onsite.F90.

◆ paw_onsite_xc_has_kernels()

logical function paw_onsite_oct_m::paw_onsite_xc_has_kernels ( type(paw_sphere_t), intent(in)  this)
private

Whether all the functionals of the dataset provide the second and third derivatives (fxc, kxc) needed by the moment expansion of the one-center XC (paw_xc_kernels).

Definition at line 743 of file paw_onsite.F90.

◆ paw_onsite_kinetic()

subroutine paw_onsite_oct_m::paw_onsite_kinetic ( type(paw_sphere_t), intent(inout)  this,
real(real64), dimension(:), intent(in)  r_full,
real(real64), dimension(:,:), intent(in)  phi_ae_full,
real(real64), dimension(:,:), intent(in)  phi_ps_full 
)
private

Kinetic matrices K^AE_ij = <phi_i|T|phi_j> and K^PS_ij = <phitilde_i|T|phitilde_j>, nonzero only for equal-l radial channels, in the symmetric gradient form 1/2 int_0^r_c [ u_i_prime u_j_prime + l(l+1) u_i u_j / r^2 ] dr, u = r phi. The surface term dropped by this form is common to AE and PS, so K^AE - K^PS is the frozen kinetic term of the one-center D matrix ([KresseJoubert99] Eq. (52), the DeltaE^kin contribution; [Torrent08] Eqs. (E.1)-(E.2), matrix K_ninj). The derivatives are taken on the full dataset grid (r_full), to avoid a spline boundary effect at r_c.

Definition at line 769 of file paw_onsite.F90.

◆ paw_radial_derivative()

subroutine paw_onsite_oct_m::paw_radial_derivative ( real(real64), dimension(:), intent(in)  r,
real(real64), dimension(:), intent(in)  f,
real(real64), dimension(:), intent(out)  df 
)
private

Radial derivative of a grid-sampled function via the cubic-spline derivative.

Definition at line 828 of file paw_onsite.F90.

◆ paw_onsite_init_derivative()

subroutine paw_onsite_oct_m::paw_onsite_init_derivative ( type(paw_sphere_t), intent(inout)  this)
private

Build the five-point Fornberg first-derivative weights for every radial point (B. Fornberg, Generation of finite difference formulas on arbitrarily spaced grids, Math. Comp. 51, 699 (1988)). The stencil is the sliding window of der_nw points centered on each point and clamped at the grid ends. The resulting banded operator and its transpose are used by the moment expansion of the GGA one-center XC.

Definition at line 858 of file paw_onsite.F90.

◆ paw_fornberg_weights()

subroutine paw_onsite_oct_m::paw_fornberg_weights ( real(real64), intent(in)  z,
real(real64), dimension(:), intent(in)  x,
integer, intent(in)  n,
real(real64), dimension(:), intent(out)  w 
)
private

First-derivative weights at z from function values at the n points x (Fornberg 1988 recursion, restricted to derivative order 1).

Definition at line 909 of file paw_onsite.F90.

◆ paw_radial_derivative_fd()

subroutine paw_onsite_oct_m::paw_radial_derivative_fd ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:), intent(in)  f,
real(real64), dimension(:), intent(out)  df 
)
private

Radial derivative of a function sampled on the sphere grid: apply the banded Fornberg operator built at init.

Definition at line 953 of file paw_onsite.F90.

◆ paw_radial_derivative_t()

subroutine paw_onsite_oct_m::paw_radial_derivative_t ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:), intent(in)  f,
real(real64), dimension(:), intent(out)  df 
)
private

Apply the transpose of the banded radial-derivative operator: df_j = sum_i D_ij f_i. This is the discrete adjoint needed for exact functional derivatives of energies that contain the radial gradient (the divergence term of the spherical GGA potential): with E = sum_i w_i f(n_i, (Dn)_i), dE/dn_j carries D^T (w df/dg), not the continuum integration-by-parts form.

Definition at line 980 of file paw_onsite.F90.

◆ paw_onsite_angular_grid()

subroutine paw_onsite_oct_m::paw_onsite_angular_grid ( type(paw_sphere_t), intent(inout)  this)
private

Angular grid: Gauss-Legendre in cos(theta) x uniform in phi, plus the real spherical harmonics tabulated at each node.

Definition at line 1004 of file paw_onsite.F90.

◆ paw_onsite_compute()

subroutine, public paw_onsite_oct_m::paw_onsite_compute ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(in), contiguous  rho,
real(real64), intent(out)  e1,
real(real64), intent(out)  e1t,
real(real64), dimension(:,:,:), intent(out), contiguous  dij,
logical, intent(in), optional  hxc_only 
)

Given the one-center density matrix rho_ij, compute the one-center energies E1 (AE) and E1t (PS) and the D-matrix contribution dij = D^1 - Dtilde^1 ([Torrent08] Eqs. (18)-(19) for the E^1/Etilde^1 sphere energies and Eqs. (23)-(25), (49) for the D matrix). E1 and E1t include their own kinetic term, Tr[rho K^AE] and Tr[rho K^PS]. Both are only defined up to a common surface term, so only E1 - E1t is physically meaningful.

Parameters
[in]hxc_onlyHartree+XC only: drop the (frozen) kinetic difference DeltaK and the reference-potential coupling.

Definition at line 1094 of file paw_onsite.F90.

◆ paw_onsite_side()

subroutine, public paw_onsite_oct_m::paw_onsite_side ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(in), contiguous  rho,
logical, intent(in)  ae,
real(real64), intent(out)  energy,
real(real64), dimension(:,:,:), intent(out), contiguous  dij,
logical, intent(in), optional  hxc_only 
)

One side (AE or PS) of the one-center calculation: build the density in the Y_LM expansion, the Hartree + reference + XC potential, accumulate the energy and the D matrix. The compensation charge nhat is included when ae==.false.

Parameters
[in]hxc_onlyHartree+XC only: drop the reference-potential (nuclear + core-Hartree + local) coupling and its energy.

Definition at line 1153 of file paw_onsite.F90.

◆ paw_build_density()

subroutine paw_onsite_oct_m::paw_build_density ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:), intent(in), contiguous  rho,
logical, intent(in)  ae,
logical, intent(in)  with_comp,
real(real64), dimension(:,:), intent(out), contiguous  nlm_rho,
real(real64), dimension(:,:), intent(out), optional, contiguous  nlm_der 
)
private

Build the density coefficients n_LM(r) from rho_ij ([Torrent08] Eqs. (44)-(47)). On the PS side, add the compensation charge nhat = sum rho_ij Qhat_ij^L, which restores the AE multipole moments on the smooth side ([Bloechl94] Eq. (24); [KresseJoubert99] Eq. (23); [Torrent08] Eqs. (12)-(17) and (48)). Angular coupling uses the real Gaunt coefficients G_{L M}^{l_i m_i, l_j m_j} = int Y_{l_i m_i} Y_{l_j m_j} Y_{L M} dOmega. When with_comp is .true. (pseudo side, Hartree density and Kresse-Joubert XC) the compensation charge is added; the Bloechl formulation excludes it from the XC density (with_comp=.false.). On the all-electron side with_comp is ignored. If nlm_der is present (GGA only), the radial derivative d n_LM/dr is also returned.

Definition at line 1282 of file paw_onsite.F90.

◆ paw_qaug_gemv()

subroutine paw_onsite_oct_m::paw_qaug_gemv ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:, :, 0:), intent(in), contiguous  qtab,
character(1), intent(in)  trans,
real(real64), dimension(:, :), intent(in), contiguous  xx,
real(real64), dimension(:, :), intent(inout), contiguous  yy 
)
private

Contract the packed compensation shapes against per-LM fields, restricted to the Gaunt-live L channels of each LM: with trans = N accumulate yy(:, lm) += qtab(:, :, L(lm)) . xx(:, lm), with trans = T the transposed reduction yy(:, lm) += qtab(:, :, L(lm))^T . xx(:, lm). qtab is qaug or its radial derivative.

Definition at line 1338 of file paw_onsite.F90.

◆ paw_gaunt_scatter_dij()

subroutine paw_onsite_oct_m::paw_gaunt_scatter_dij ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:, :), intent(in), contiguous  w,
real(real64), dimension(:, :), intent(inout), contiguous  dij 
)
private

Scatter the per-(pair, LM) reductions through the packed Gaunt couplings into the symmetric D matrix: D_ij += sum_LM c(i j; LM) w(pair_ij, LM).

Definition at line 1361 of file paw_onsite.F90.

◆ paw_emit_lm_columns()

subroutine paw_onsite_oct_m::paw_emit_lm_columns ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:, :), intent(in), contiguous  field_lm,
real(real64), intent(in)  tol,
integer, intent(out)  ncol,
type(spline_t), dimension(:), intent(out), allocatable  spl,
integer, dimension(:), intent(out), allocatable  ll,
integer, dimension(:), intent(out), allocatable  mm,
real(real64), intent(out)  rcut 
)
private

Fit the nonzero (L, M) columns of a one-center radial field field_lm(np, nlm_rho) into splines ready to be splatted on the mesh with double_grid_transform.

Definition at line 1388 of file paw_onsite.F90.

◆ paw_partial_wave_derivatives()

subroutine paw_onsite_oct_m::paw_partial_wave_derivatives ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:, :), intent(out), contiguous  dphi_ae,
real(real64), dimension(:, :), intent(out), contiguous  dphi_ps 
)
private

Radial derivatives of all (AE, PS) partial waves phi (not u = r phi): grad(phi Y) uses dphi/dr.

Definition at line 1423 of file paw_onsite.F90.

◆ paw_adjoint_divergence_add()

subroutine paw_onsite_oct_m::paw_adjoint_divergence_add ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:), intent(in), contiguous  flux,
real(real64), dimension(:), intent(inout), contiguous  div,
real(real64), dimension(:), intent(inout), contiguous  vfield 
)
private

Add the discrete-adjoint divergence of a vwr-weighted radial flux to a potential-like field: vfield(ip) += [D^T flux](ip) / vwr(ip). Points with vwr = 0 (the origin) are skipped; every consumer integrates vfield against vwr, so their value is irrelevant. div is a caller-provided (np) workspace.

Definition at line 1445 of file paw_onsite.F90.

◆ paw_onsite_reorder_pmat()

subroutine, public paw_onsite_oct_m::paw_onsite_reorder_pmat ( integer, intent(in)  nprojs,
integer, dimension(:), intent(in)  map,
real(real64), dimension(:, :), intent(in), contiguous  src,
real(real64), dimension(:, :), intent(out), contiguous  dst 
)

Reorder one spin channel of a projector-ordered matrix.

Definition at line 1466 of file paw_onsite.F90.

◆ paw_hartree_lm()

subroutine paw_onsite_oct_m::paw_hartree_lm ( type(paw_sphere_t), intent(in)  this,
integer, intent(in)  lm,
real(real64), dimension(:), intent(in)  nl,
real(real64), dimension(:), intent(out)  vl 
)
private

Radial Hartree potential for one (L,M) channel (classical multipole expansion of 1/|r-r_prime|, [Torrent08] Eq. (A.9), entering the Hartree kernels of Eqs. (E.3)-(E.11)): V_L(r) = 4pi/(2L+1) [ r^{-L-1} int_0^r n_L s^{L+2} ds + r^L int_r^inf n_L s^{1-L} ds ].

Definition at line 1488 of file paw_onsite.F90.

◆ paw_xc()

subroutine paw_onsite_oct_m::paw_xc ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(in), contiguous  nlm_rho,
real(real64), dimension(:,:,:), intent(in), optional, contiguous  nlm_der,
real(real64), dimension(:), intent(in), contiguous  ncore,
logical, intent(in)  ae,
logical, intent(in)  with_comp,
real(real64), intent(out)  e_xc,
real(real64), dimension(:,:,:), intent(inout), contiguous  dij 
)
private

Exchange-correlation on the radial x angular grid: LibXC evaluated pointwise, accumulating the XC energy e_xc and the XC contribution to the D matrix dij. This is the exact angular-sampling scheme of [Torrent08] Sec. 4.3.1 (pawxcdev = 0), Eqs. (E.12)-(E.13), extended here beyond LDA: LDA projects v_xc onto Y_LM and reuses paw_accumulate_dij; GGA uses the explicit (White-Bird) derivative D_ij = int [ vrho g_ij + 2 vsigma grad(n).grad(g_ij) ].

Noncollinear case: the density is projected on the local frame and the potential is rotated back. GGA projected gradients follow by the chain rule, and because the weights are position dependent the exact derivative of the discrete E_xc carries the extra local term B_s . grad F_c^s next to F_c^s vrho_s in the White-Bird coupling (the one-center analog of rotating the divergence-form potential on the mesh), so a finite difference over any component of rho_ij validates the D matrix.

The energy density is integrated with the clamped (non-negative) density, the one at which LibXC evaluated exc and vrho, so that E_xc and D are consistent.

Parameters
[in]nlm_der(nr, nlm_rho, nspin) radial derivative of nlm_rho; required for GGA only

Definition at line 1551 of file paw_onsite.F90.

◆ paw_xc_density()

subroutine paw_onsite_oct_m::paw_xc_density ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(in)  nlm_rho,
real(real64), dimension(:), intent(in)  ncore,
real(real64), dimension(:,:), intent(out), contiguous  dens,
real(real64), dimension(:,:), intent(out), contiguous  densp,
real(real64), dimension(:), intent(out), contiguous  dpol 
)
private

: Prepare the density for the XC calculation with libxc The polarization magnitude dpol (noncollinear only) is returned for reuse in the sigma and potential-rotation stages so it is not recomputed there.

Definition at line 1667 of file paw_onsite.F90.

◆ paw_xc_gradient()

subroutine paw_onsite_oct_m::paw_xc_gradient ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(in), contiguous  nlm_rho,
real(real64), dimension(:,:,:), intent(in), contiguous  nlm_der,
real(real64), dimension(:), intent(in), contiguous  ncder,
real(real64), dimension(:,:,:,:), intent(out), contiguous  g 
)
private

Gradient stage of paw_xc.

The gradient of every native density component at every angular node, g(:, ic, ia, 1:3) = (d/dr, (1/r) d/dtheta, (1/(r sin)) d/dphi), from the radial derivative of the density multipoles (built by paw_build_density from the precomputed pair-derivative tables) and the tabulated Y_LM derivatives. The spherical core contributes its radial gradient to the diagonal components only.

Definition at line 1724 of file paw_onsite.F90.

◆ paw_xc_sigma()

subroutine paw_onsite_oct_m::paw_xc_sigma ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:), intent(in), contiguous  dens,
real(real64), dimension(:), intent(in), contiguous  dpol,
real(real64), dimension(:,:,:,:), intent(in), contiguous  g,
real(real64), dimension(:,:,:,:), intent(out), contiguous  gp,
real(real64), dimension(:,:), intent(out), contiguous  sigma 
)
private

Conversion from gradients to sigma, for GGA with libxc.

The sigma channels are (1 = |grad n_1|^2 [, 2 = grad n_1 . grad n_2, 3 = |grad n_2|^2])

Definition at line 1768 of file paw_onsite.F90.

◆ paw_xc_lda_process()

subroutine paw_onsite_oct_m::paw_xc_lda_process ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:), intent(in), contiguous  dens,
real(real64), dimension(:,:), intent(inout), contiguous  vr 
)
private

Rotate the LDA potential from the local spin frame back to the global fram.

Definition at line 1824 of file paw_onsite.F90.

◆ paw_xc_gga_process()

subroutine paw_onsite_oct_m::paw_xc_gga_process ( type(paw_sphere_t), intent(in)  this,
logical, intent(in)  ae,
logical, intent(in)  with_comp,
real(real64), dimension(:,:), intent(in), contiguous  dens,
real(real64), dimension(:,:,:,:), intent(in), contiguous  g,
real(real64), dimension(:,:,:,:), intent(in), contiguous  gp,
real(real64), dimension(:,:), intent(in), contiguous  vr,
real(real64), dimension(:,:), intent(in), contiguous  vs,
real(real64), dimension(:,:,:), intent(inout), contiguous  dij 
)
private

Rotate the GGA part of the potential from the local spin frame back to the global fram.

Definition at line 1851 of file paw_onsite.F90.

◆ paw_xc_eval()

subroutine paw_onsite_oct_m::paw_xc_eval ( type(paw_sphere_t), intent(in)  this,
integer, intent(in)  np,
integer, intent(in)  nsp,
integer, intent(in)  nsig,
real(real64), dimension(:,:), intent(in), contiguous  dens,
real(real64), dimension(:,:), intent(in), contiguous  sigma,
real(real64), dimension(:), intent(out), contiguous  exc,
real(real64), dimension(:,:), intent(out), contiguous  vrho,
real(real64), dimension(:,:), intent(out), contiguous  vsigma 
)
private

Functional-specific part of the one-center XC.

The np points are processed in blocks

Definition at line 1917 of file paw_onsite.F90.

◆ paw_xc_eval_block()

subroutine paw_onsite_oct_m::paw_xc_eval_block ( type(paw_sphere_t), intent(in)  this,
integer, intent(in)  np,
integer, intent(in)  ip0,
integer, intent(in)  bs,
integer, intent(in)  nsp,
integer, intent(in)  nsig,
real(real64), dimension(:,:), intent(in), contiguous  dens,
real(real64), dimension(:,:), intent(in), contiguous  sigma,
real(real64), dimension(:), intent(out), contiguous  exc,
real(real64), dimension(:,:), intent(out), contiguous  vrho,
real(real64), dimension(:,:), intent(out), contiguous  vsigma 
)
private

Evaluate the functionals on one contiguous block of bs points.

Definition at line 1944 of file paw_onsite.F90.

◆ paw_xc_sph_potential()

subroutine paw_onsite_oct_m::paw_xc_sph_potential ( type(paw_sphere_t), intent(in)  this,
integer, intent(in)  nsp,
integer, intent(in)  nsig,
real(real64), dimension(:,:), intent(in), contiguous  n0,
real(real64), dimension(:,:), intent(in), contiguous  sigma0,
real(real64), dimension(:,:), intent(in), contiguous  dn0,
real(real64), dimension(:), intent(out), contiguous  exc0,
real(real64), dimension(:,:), intent(out), contiguous  vsph 
)
private

Energy density and full XC potential of a spherically symmetric density on the radial grid. For GGA the potential carries the divergence term in its discrete-adjoint form ([Torrent08] Eq. (69) in the continuum): with E = sum_i vwr_i f(n_i, (Dn)_i), the functional derivative is v_j = (df/dn)_j + (1/vwr_j) [D^T (vwr df/dg)]_j, which keeps the D matrix built from this potential the exact derivative of the discrete energy. Points with vwr = 0 (the origin) skip the adjoint term: every consumer integrates v against vwr, so their value is irrelevant.

Definition at line 2045 of file paw_onsite.F90.

◆ paw_xc_kernels()

subroutine paw_onsite_oct_m::paw_xc_kernels ( type(paw_sphere_t), intent(in)  this,
integer, intent(in)  nsp,
integer, intent(in)  nsig,
real(real64), dimension(:,:), intent(in), contiguous  n0,
real(real64), dimension(:,:), intent(in), contiguous  sigma0,
real(real64), dimension(:,:), intent(in), contiguous  dn0,
real(real64), dimension(:,:,:), intent(out), contiguous  kk,
real(real64), dimension(:,:,:,:), intent(out), contiguous  k2 
)
private

Analytic XC kernels of the spherical one-center problem at fixed radial gradient: K_st(r) = d v_s(r) / d n_t(r) K2_stu(r) = d2 v_s(r) / d n_t(r) d n_u(r) (density-only channel) with v_s the spherical potential of paw_xc_sph_potential. For LDA these are the LibXC fxc / kxc; for GGA, K additionally carries the discrete-adjoint divergence of the flux response at fixed gradient, d f_s / d n_t = 2 v2rhosigma(t; ss) dn_s.

  • v2rhosigma(t; ud) dn_o, while K2 keeps the density-only v3rho3 (the flux response of K2 enters at the same order as the dropped term-2 contributions of Eq. (61)).

LibXC component counts of the mixed third derivatives, indexed by the number of spin channels

Definition at line 2097 of file paw_onsite.F90.

◆ paw_xc_moments()

subroutine paw_onsite_oct_m::paw_xc_moments ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(in), contiguous  nlm_rho,
real(real64), dimension(:), intent(in), contiguous  ncore,
logical, intent(in)  ae,
logical, intent(in)  with_comp,
real(real64), intent(out)  e_xc,
real(real64), dimension(:,:,:), intent(inout), contiguous  dij 
)
private

One-center XC by the second-order moment expansion around the spherical density ([Torrent08] Sec. 4.3.1, Eqs. (56)-(61) and (65): E_xc = 4 pi int f(n0) r^2 dr + 1/2 sum_st int K_st(r) M_st(r) r^2 dr v_00 = sqrt(4 pi) v_xc[n0] + 1/(2 sqrt(4 pi)) sum_tu K2_stu M_tu (Eq. (60)) v_LM = sum_t K_st n_LM,t for L > 0 (Eq. (61)) with M_st(r) = sum_{LM /= 00} n_LM,s n_LM,t and the analytic kernels K = dv_xc/dn, K2 = d2v_xc/dn2 at the spherical density n0 (fixed-gradient derivative of Eq. (57), from the LibXC fxc/kxc; see paw_xc_kernels). The functional is evaluated on the np radial points only, instead of the np x nang one-center grid of paw_xc.

For the noncollinear density the spherical density defines a frozen local axis at every radial point (weights F_c^s of paw_xc_noncol_weights), the L /= 00 moments are projected on that axis, M_s,LM = sum_c w_c F_c^s n_LM,c with w = (1,1,2,2), the collinear second-order machinery runs on the projected problem, and the potential moments are rotated back with the same weights, v_LM,c = sum_s F_c^s v_LM,s. The axis variation is dropped, consistent with the second-order truncation of the scheme. A density whose spherical magnetization vanishes while the aspherical moments do not is treated as locally unpolarized; the full-grid scheme handles that case exactly.

Definition at line 2298 of file paw_onsite.F90.

◆ paw_xc_noncol_dpol()

pure real(real64) function paw_onsite_oct_m::paw_xc_noncol_dpol ( real(real64), intent(in)  n1,
real(real64), intent(in)  n2,
real(real64), intent(in)  n3,
real(real64), intent(in)  n4 
)
private

Noncollinear polarization magnitude dpol = |m| at one point.

Definition at line 2487 of file paw_onsite.F90.

◆ paw_xc_noncol_weights()

pure subroutine paw_onsite_oct_m::paw_xc_noncol_weights ( real(real64), intent(in)  n1,
real(real64), intent(in)  n2,
real(real64), intent(in)  n3,
real(real64), intent(in)  n4,
real(real64), intent(out)  dpol,
real(real64), dimension(:,:), intent(out)  fw 
)
private

Noncollinear local-frame projection weights F_c^s = d n_s / d n_c at one point.

Parameters
[out]fw(4, 2) F_c^s

Definition at line 2498 of file paw_onsite.F90.

◆ paw_xc_dij_gga_noncollinear()

subroutine paw_onsite_oct_m::paw_xc_dij_gga_noncollinear ( type(paw_sphere_t), intent(in)  this,
logical, intent(in)  ae,
logical, intent(in)  with_comp,
real(real64), dimension(:,:), intent(in), contiguous  dens,
real(real64), dimension(:,:,:,:), intent(in), contiguous  g,
real(real64), dimension(:,:,:,:), intent(in), contiguous  gp,
real(real64), dimension(:,:), intent(in), contiguous  vr,
real(real64), dimension(:,:), intent(in), contiguous  vs,
real(real64), dimension(:,:,:), intent(inout), contiguous  dij 
)
private

Noncollinear GGA D-matrix contribution: the exact derivative of the local-frame projected E_xc with respect to the four density components. Per grid point, with the projection weights F_c^s and their gradients h_c = grad F_c^+ (grad F_c^- = -h_c for every components, so the weight-variation term contracts to a single channel difference), a1 = sum_s F_c^s vrho_s + (B_1 - B_2) . h_c a_k = F_c^1 B_1,k + F_c^2 B_2,k with B_s,k = 2 vsigma_ss grad_k n_s + vsigma_12 grad_k n_os the projected-channel flux.

Definition at line 2535 of file paw_onsite.F90.

◆ paw_xc_dij_gga_fields()

subroutine paw_onsite_oct_m::paw_xc_dij_gga_fields ( type(paw_sphere_t), intent(in)  this,
logical, intent(in)  ae,
logical, intent(in)  with_comp,
real(real64), dimension(:,:,:), intent(in), contiguous  a1,
real(real64), dimension(:,:,:), intent(in), contiguous  a2,
real(real64), dimension(:,:,:), intent(in), contiguous  a3,
real(real64), dimension(:,:,:), intent(in), contiguous  a4,
real(real64), dimension(:,:,:), intent(inout), contiguous  dij 
)
private

Accumulate the D-matrix components from the angular fields of the White-Bird GGA coupling, one set per spin component: a1 carries the local (vrho-like) coupling to the pair density, a2/a3/a4 the radial/theta/phi components of the gradient coupling to grad(pair density). The angular quadrature weight enters through the weighted harmonics, so the fields must not carry it.

Definition at line 2612 of file paw_onsite.F90.

◆ paw_accumulate_dij()

subroutine paw_onsite_oct_m::paw_accumulate_dij ( type(paw_sphere_t), intent(in)  this,
logical, intent(in)  ae,
logical, intent(in)  with_comp,
real(real64), dimension(:,:), intent(in), contiguous  vlm,
real(real64), dimension(:,:), intent(inout), contiguous  dij 
)
private

Accumulate D_ij = sum_LM gaunt(l_i m_i, l_j m_j, L M) int v_LM(r) g_ij^L(r) r^2 dr where g_ij^L is the radial pair density (phi_i phi_j for AE, phitilde_i phitilde_j.

  • Qhat_ij^L for PS). This is exactly d(E_H + E_ref + E_xc)/d rho_ij – the sphere contributions to D^1 - Dtilde^1 of [Torrent08] Eqs. (23)-(25) and (49), evaluated per SCF step from the current v_LM instead of the precontracted e_ijkl kernel of Eq. (50) (the Hartree radial work is negligible here).

Definition at line 2687 of file paw_onsite.F90.

◆ paw_onsite_nlm()

integer pure function, public paw_onsite_oct_m::paw_onsite_nlm ( type(paw_sphere_t), intent(in)  this)

Number of (l,m)-resolved projectors, i.e. the leading dimension of rho_ij.

Definition at line 2728 of file paw_onsite.F90.

◆ paw_onsite_nlm_rho()

integer pure function, public paw_onsite_oct_m::paw_onsite_nlm_rho ( type(paw_sphere_t), intent(in)  this)

Number of real-harmonic columns (lmax_rho+1)^2 of the one-center density expansion; the upper bound on the number of Y_LM columns any *_diff routine returns.

Definition at line 2736 of file paw_onsite.F90.

◆ paw_onsite_nspin()

integer pure function, public paw_onsite_oct_m::paw_onsite_nspin ( type(paw_sphere_t), intent(in)  this)

Number of collinear spin channels (1 or 2) the sphere was built for.

Definition at line 2743 of file paw_onsite.F90.

◆ paw_onsite_pmat_map()

subroutine, public paw_onsite_oct_m::paw_onsite_pmat_map ( type(paw_sphere_t), intent(in)  this,
integer, intent(in)  nprojs,
integer, dimension(:), intent(in)  pl,
integer, dimension(:), intent(in)  pm,
integer, dimension(:), intent(in)  pchannel,
integer, dimension(:), intent(out)  map 
)

Map the projector-matrix enumeration (l, m, channel) used by the mesh nonlocal machinery to the one-center (l,m)-resolved projector index of this sphere.

The projector matrix orders its columns (l, m, channel = ic-th radial channel of l); the one-center engine orders them (radial channel in file order, m). Both enumerate the same set of (radial, m) projectors, so map is a bijection onto 1..nlm. The ic-th channel of angular momentum l on the projector side is the ic-th partial wave with lrad == l on the one-center side (partial waves and beta projectors are paired in file order in UPF2 PAW).

Parameters
[in]pl(nprojs) l of each projector
[in]pm(nprojs) m of each projector
[in]pchannel(nprojs) channel (ic) of each projector
[out]map(nprojs) one-center index in 1..nlm

Definition at line 2757 of file paw_onsite.F90.

◆ paw_onsite_reference_density()

subroutine, public paw_onsite_oct_m::paw_onsite_reference_density ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:), intent(in)  occ,
real(real64), dimension(:,:,:), intent(out)  rho 
)

Build the spherical reference density matrix from per-radial-channel occupations occ(1:nrad): each shell occupation is spread equally over its 2l+1 m-states and its nspin channels, rho(im,im,s) = occ(rad(im)) / ((2 l + 1) nspin), giving a spherically symmetric, non-magnetic reference density.

Definition at line 2822 of file paw_onsite.F90.

◆ paw_onsite_charge()

real(real64) function, public paw_onsite_oct_m::paw_onsite_charge ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(in)  rho,
logical, intent(in)  ae 
)

Integrated L=0 charge of the one-center density (spin-summed) for a given rho: the all-electron (ae==.true.) valence charge int n^1 d^3r, or the pseudo+compensation charge int (ntilde^1 + nhat) d^3r (ae==.false.). Used for the neutrality sum rule: the two must be equal by construction of the compensation charge.

Definition at line 2846 of file paw_onsite.F90.

◆ paw_onsite_density_diff()

subroutine, public paw_onsite_oct_m::paw_onsite_density_diff ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:), intent(in)  rho,
integer, intent(out)  ncol,
type(spline_t), dimension(:), intent(out), allocatable  spl,
integer, dimension(:), intent(out), allocatable  ll,
integer, dimension(:), intent(out), allocatable  mm,
real(real64), intent(out)  rcut 
)

Build the one-center all-electron-minus-(pseudo+compensation) density difference for a single collinear spin channel, Delta n_LM(r) = n^1_LM(r) - ( ntilde^1_LM(r) + nhat_LM(r) ), as radial splines ready to be splatted on the mesh with double_grid_transform (which forms feff = spline(r) Y_LM). Because the smooth mesh density already carries the compensation charge nhat (Kresse-Joubert), adding sum_a Delta n over the atoms reconstructs the true all-electron density n_AE = ntilde + sum_a (n^1 - ntilde^1).

Parameters
[in]rho(nlm, nlm) one spin channel
[out]spl(ncol) radial splines of Delta n_LM
[out]ll(ncol) l of each channel
[out]mm(ncol) m of each channel
[out]rcutouter radial bound (spline range)

Definition at line 2880 of file paw_onsite.F90.

◆ paw_onsite_tau_diff()

subroutine, public paw_onsite_oct_m::paw_onsite_tau_diff ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:), intent(in)  rho,
integer, intent(out)  ncol,
type(spline_t), dimension(:), intent(out), allocatable  spl,
integer, dimension(:), intent(out), allocatable  ll,
integer, dimension(:), intent(out), allocatable  mm,
real(real64), intent(out)  rcut,
real(real64), intent(out), optional  tau_integral 
)

Build the one-center all-electron-minus-pseudo kinetic-energy-density difference for a single collinear spin channel, Delta tau_LM(r) = tau^1_LM(r) - tautilde^1_LM(r), as radial splines ready to be splatted on the mesh with double_grid_transform. The kinetic-energy density (octopus convention, no 1/2 factor, matching states_elec_calc_quantities) of a one-center density matrix rho_ij is tau(r,Omega) = sum_ij rho_ij grad(phi_i Y_i) . grad(phi_j Y_j) = sum_ij rho_ij [ phi_i'(r) phi_j'(r) Y_i Y_j.

  • (phi_i phi_j / r^2)(dth Y_i dth Y_j + dph Y_i dph Y_j) ] with phi the (AE or PS) partial wave, phi` its radial derivative, Y = Y_{l m} the real harmonic, dth Y = dY/dtheta and dph Y = (1/sin theta) dY/dphi. Delta tau is projected onto the real harmonics on the tabulated angular grid.
    Parameters
    [in]rho(nlm, nlm) one spin channel
    [out]tau_integralOptional: the integrated KED correction int Delta tau d^3r = sqrt(4pi) int Delta tau_00 r^2 dr. By the one-center kinetic identity this equals 2 Tr[rho DeltaK] (DeltaK from paw_onsite_get_kinetic_matrix), which cross-checks the reconstructed tau against the frozen kinetic term of the D matrix.

Definition at line 2922 of file paw_onsite.F90.

◆ paw_onsite_current_diff()

subroutine, public paw_onsite_oct_m::paw_onsite_current_diff ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:), intent(in)  arho,
integer, intent(in)  idir,
integer, intent(out)  ncol,
type(spline_t), dimension(:), intent(out), allocatable  spl,
integer, dimension(:), intent(out), allocatable  ll,
integer, dimension(:), intent(out), allocatable  mm,
real(real64), intent(out)  rcut,
real(real64), intent(out), optional  current_integral 
)

One-center all-electron current-density correction Delta j^alpha = j^1 - j~^1.

Given the antisymmetric one-center current matrix A_ij = Im[rho_ij] (onsite_current_matrix), the paramagnetic current density of the real partial-wave pair (g_i = phi_i Y_i) is j^alpha(r) = sum_ij A_ij g_i(r) (grad_alpha g_j)(r), summed all-electron minus pseudo. This mirrors the smooth current j~ = sum ww Im[conj(psi~) grad psi~] evaluated on the partial waves, so j_AE = j~ + sum_a (j^1_a - j~^1_a). The Cartesian gradient of phi(r) Y_LM(Omega) is grad(phi Y) = phi`(r) Y rhat + (phi(r)/r)( dY/dth that + (1/sin th) dY/dph phat ), with rhat/that/phat the Cartesian spherical basis tabulated on the angular grid. The field is projected onto real harmonics Delta j^alpha_LM(r) = int Delta j^alpha Y_LM dOmega, exactly as in paw_onsite_tau_diff. Optional current_integral returns the macroscopic one-center current int Delta j^alpha dV = sqrt(4pi) int Delta j^alpha_00(r) r^2 dr (only the L=0 multipole survives), used to cross-check total_current against the augmented dipole velocity d<X>/dt.

Parameters
[in]arho(nlm, nlm) antisymmetric, one spin channel
[in]idirCartesian direction 1..3

Definition at line 3014 of file paw_onsite.F90.

◆ paw_onsite_get_velocity_matrix()

subroutine, public paw_onsite_oct_m::paw_onsite_get_velocity_matrix ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(out), allocatable  vmat 
)

Velocity (momentum) matrix of the partial waves, V^alpha_ij = int (g_i grad_alpha g_j) dV, all-electron minus pseudo, over the augmentation sphere (g = phi Y_lm). This is the macroscopic one-center current integral factor: int Delta j^alpha dV = sum_ij A_ij V^alpha_ij, so it cross-checks the field built by paw_onsite_current_diff (whose L=0 radial moment is the same integral) against a direct radial x angular quadrature.

Parameters
[out]vmat(nlm, nlm, 3)

Definition at line 3108 of file paw_onsite.F90.

◆ paw_onsite_partial_wave_diff()

subroutine, public paw_onsite_oct_m::paw_onsite_partial_wave_diff ( type(paw_sphere_t), intent(in)  this,
integer, intent(in)  nprojs,
integer, dimension(:), intent(in)  pl,
integer, dimension(:), intent(in)  pm,
integer, dimension(:), intent(in)  pchannel,
type(spline_t), dimension(:), intent(out), allocatable  spl,
integer, dimension(:), intent(out), allocatable  ll,
integer, dimension(:), intent(out), allocatable  mm,
real(real64), intent(out)  rcut 
)

Build the partial-wave difference (phi_i - phitilde_i)(r) for each projector, as radial splines ready to be splatted on the mesh with double_grid_transform (feff = spline(r) Y_LM). This is the one-center building block of the all-electron wavefunction reconstruction psi(r) = psitilde(r) + sum_i (phi_i(r) - phitilde_i(r)) Y_{l_i m_i}(rhat) <beta_i|psitilde>, so the caller weights each column i by the projection <beta_i|psitilde>. The projectors are passed in their (l, m, channel) enumeration (pl/pm/pchannel, as in the projector matrix) and mapped to the corresponding radial partial wave through paw_onsite_pmat_map; ll(i)=pl(i), mm(i)=pm(i). One column per projector (ncol = nprojs); spl/ll/mm are allocated here and must be spline_end`d / deallocated by the caller. rcut is the outer radial-grid bound.

Parameters
[in]pl(nprojs) l of each projector
[in]pm(nprojs) m of each projector
[in]pchannel(nprojs) radial channel of each projector
[out]spl(nprojs) splines of (phi_i - phitilde_i)
[out]ll(nprojs) = pl
[out]mm(nprojs) = pm

Definition at line 3171 of file paw_onsite.F90.

◆ paw_onsite_get_kinetic_data()

subroutine, public paw_onsite_oct_m::paw_onsite_get_kinetic_data ( type(paw_sphere_t), intent(in)  this,
real(real64), dimension(:,:), intent(out), allocatable  deltaK,
integer, dimension(:), intent(out), allocatable  p_rad,
integer, dimension(:), intent(out), allocatable  p_l,
integer, dimension(:), intent(out), allocatable  p_m 
)

Read-only access to the frozen kinetic correction DeltaK = K^AE - K^PS (the radial-channel matrix, nrad x nrad) and to the one-center projector enumeration (the radial channel, l and m of each of the nlm projectors). This lets a caller form the kinetic one-center energy Tr[rho DeltaK] in the (l,m)-diagonal one-center basis (the kinetic operator is diagonal in the angular index); the reconstructed kinetic-energy-density correction integrates to int Delta tau d^3r = 2 Tr[rho DeltaK] (the factor 2 from the octopus tau convention without the one half), cross-checking paw_onsite_tau_diff.

Parameters
[out]deltak(nrad, nrad) radial kinetic correction
[out]p_rad(nlm) radial channel of each projector
[out]p_l(nlm) l of each projector
[out]p_m(nlm) m of each projector

Definition at line 3219 of file paw_onsite.F90.

◆ paw_onsite_end()

subroutine, public paw_onsite_oct_m::paw_onsite_end ( type(paw_sphere_t), intent(inout)  this)

Definition at line 3241 of file paw_onsite.F90.

Variable Documentation

◆ paw_kresse_joubert

integer, parameter, public paw_onsite_oct_m::paw_kresse_joubert = 1

PAW formulation: selects the compensation-charge / reference treatment.

UPF2 kjpaw default; nhat enters the XC density

Definition at line 180 of file paw_onsite.F90.

◆ paw_blochl

integer, parameter, public paw_onsite_oct_m::paw_blochl = 2

Bloechl (GPAW/ABINIT); nhat excluded from XC.

Definition at line 181 of file paw_onsite.F90.

◆ paw_xc_scheme_full

integer, parameter paw_onsite_oct_m::paw_xc_scheme_full = 1
private

exact evaluation on the radial x angular grid

Definition at line 184 of file paw_onsite.F90.

◆ paw_xc_scheme_moments

integer, parameter paw_onsite_oct_m::paw_xc_scheme_moments = 2
private

second-order moment expansion around the spherical density

Definition at line 184 of file paw_onsite.F90.

◆ gaunt_tol

real(real64), parameter paw_onsite_oct_m::gaunt_tol = 1.0e-12_real64
private

Definition at line 303 of file paw_onsite.F90.

◆ paw_xc_tiny

real(real64), parameter paw_onsite_oct_m::paw_xc_tiny = 1.0e-12_real64
private

Relative polarization threshold of the noncollinear local-frame projection.

Definition at line 306 of file paw_onsite.F90.