Conversation
…allback method_init_density='pp' builds the initial electron density from the pseudopotential's atomic valence density (rho_pp_tbl), which is smooth and positive everywhere -- unlike the default 'wf' guess built from gaussian initial orbitals, whose near-zero regions make meta-GGA (e.g. TBmBJ) diverge. Previously 'pp' aborted with "radial density is not available" for beta-projector pseudopotentials other than UPF. - psp8: the valence charge density is in the file but was read and discarded. Store it into rho_pp_tbl as 4*pi*r^2*rho (= r^2 * rho_tmp, since psp8 stores 4*pi*rho as for its NLCC data), so 'pp' now works with psp8 pseudopotentials. - Generic fallback: if a pseudopotential still provides no tabulated atomic density, build one from the valence charge (exponential model normalised to pp%zps) instead of aborting. New subroutine set_generic_atomic_density. method_init_density='wf'/'read_dns_cube' and UPF are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Can one of the admins verify this patch? |
MZKC
left a comment
There was a problem hiding this comment.
psp8 valence-density support and the generic fallback look correct: the psp8 reader runs before the empty-table check, so the fallback only fires when the file genuinely has no atomic density, and the exponential model integrates to zps. One robustness concern on the storage bounds, inline.
| sum_rho_pp=0.0d0 | ||
| do i=1,pp%mr(ik)+1 | ||
| read(4,*) dummy_text, r_tmp, rho_tmp | ||
| if (i <= pp%nrmax) pp%rho_pp_tbl(i,ik) = pp%rad(i,ik)**2 * rho_tmp |
There was a problem hiding this comment.
if (i <= pp%nrmax) pp%rho_pp_tbl(i,ik) = pp%rad(i,ik)**2 * rho_tmp
The i <= pp%nrmax guard avoids an out-of-bounds write, but it does so by silently truncating the valence density when the psp8 grid has more points than pp%nrmax: the loop runs i=1..pp%mr(ik)+1, yet sum_rho_pp on the next line still accumulates all of them, so the stored table and the reported norm would disagree. The tail-fill just below (do i=pp%mr(ik)+2,pp%nrmax) and the other readers assume pp%mr(ik)+1 <= pp%nrmax. Consider asserting that explicitly (error out on an oversized grid) rather than partial storage, so the case is caught instead of silently dropped.
There was a problem hiding this comment.
Fixed in b29617d: the reader now errors out when pp%mr(ik)+1 > pp%nrmax instead of silently truncating (which would have left the stored density inconsistent with sum_rho_pp). Builds cleanly on Fugaku (A64FX).
✅ Verified on Fugaku (A64FX), 2026-06-24: a psp8 pseudopotential (Be) with method_init_density='pp' reads the valence density and runs the SCF, confirming the psp8 initial-density path is intact after the change.
…ently truncating the valence density
Summary
method_init_density='pp'builds the initial electron density from thepseudopotential's atomic valence density (
rho_pp_tbl). That density is smoothand positive everywhere, unlike the default
'wf'guess that is built from thegaussian initial orbitals — whose near-zero regions make meta-GGA functionals
(e.g. TBmBJ) diverge on the first iterations. So
'pp'is the natural,non-pathological initial density (cf. issue #1253).
Two gaps are fixed so that
'pp'works for more pseudopotentials:it only to print a diagnostic and then discarded it. It is now stored
into
rho_pp_tblas4*pi*r^2*rho(= r^2 * rho_tmp, since psp8 stores4*pi*rho, the same convention as its NLCC data).density,
'pp'previously aborted with"radial density is not available".It now builds a generic atomic density from the valence charge
(
set_generic_atomic_density: an exponential model normalised topp%zps)instead of aborting.
'wf'/'read_dns_cube'and UPF (which already reads<PP_RHOATOM>) areunaffected.
Verification (Wisteria-O, A64FX)
1. psp8
'pp'works and is correctly normalised. bulk Si (8 atoms,Si.psp8ONCVPSP,zion=4, so 32 valence electrons),nproc_k=4:'pp'no longer aborts;calc_density_ppreportsInt(rho) = 32.0000000—i.e. the initial density integrates to exactly the number of valence
electrons, confirming the normalisation.
'pp'is infact a better starting guess here than
'wf'(which still had a negative gapat iter 60).
2.
'pp'cures the meta-GGA initial-density pathology (issue #1253). bulk Si(8 atoms,
Si_rps.dat),xc='TBmBJ':'wf'(gaussian)'pp'🤖 Generated with Claude Code