Octopus
paw_onsite.F90 File Reference

Go to the source code of this file.

Modules

module  paw_onsite_oct_m
 PAW radial engine.
 

Data Types

type  paw_onsite_oct_m::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_oct_m::paw_onsite_init (this, ps, namespace, formulation, nspin)
 Build the per-species one-center data from a (PAW) pseudopotential. More...
 
integer pure function paw_onsite_oct_m::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_oct_m::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_oct_m::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_oct_m::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_oct_m::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_onsite_oct_m::paw_radial_derivative (r, f, df)
 Radial derivative of a grid-sampled function via the cubic-spline derivative. More...
 
subroutine paw_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_oct_m::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_oct_m::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_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_oct_m::paw_onsite_reorder_pmat (nprojs, map, src, dst)
 Reorder one spin channel of a projector-ordered matrix. More...
 
subroutine paw_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::paw_xc_gradient (this, nlm_rho, nlm_der, ncder, g)
 Gradient stage of paw_xc. More...
 
subroutine paw_onsite_oct_m::paw_xc_sigma (this, dens, dpol, g, gp, sigma)
 Conversion from gradients to sigma, for GGA with libxc. More...
 
subroutine paw_onsite_oct_m::paw_xc_lda_process (this, dens, vr)
 Rotate the LDA potential from the local spin frame back to the global fram. More...
 
subroutine paw_onsite_oct_m::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_onsite_oct_m::paw_xc_eval (this, np, nsp, nsig, dens, sigma, exc, vrho, vsigma)
 Functional-specific part of the one-center XC. More...
 
subroutine paw_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::paw_xc_noncol_dpol (n1, n2, n3, n4)
 Noncollinear polarization magnitude dpol = |m| at one point. More...
 
pure subroutine paw_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_onsite_oct_m::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_oct_m::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_oct_m::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_oct_m::paw_onsite_nspin (this)
 Number of collinear spin channels (1 or 2) the sphere was built for. More...
 
subroutine, public paw_onsite_oct_m::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_oct_m::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_oct_m::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_oct_m::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_oct_m::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_oct_m::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_oct_m::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_oct_m::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_oct_m::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_oct_m::paw_onsite_end (this)
 

Variables

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