Fix Molden GTO normalization and coordinate conversion#7421
Conversation
Title: Improve ABACUS Molden output for wavefunction analysis Summary: This PR fixes several Molden conversion issues in tools/molden/molden.py while keeping the default workflow unchanged as much as possible. Changes: - Correct the primitive Gaussian coefficient convention when writing Molden GTO data. The NAO-to-GTO fit uses unnormalized radial primitives, while Molden readers usually normalize primitive Gaussian functions internally. - Fix Cartesian_angstrom coordinate conversion. Coordinates in Angstrom are now converted to Bohr for the Molden [Atoms] AU section by dividing by 0.529177210903. - Add optional multi-start NAO-to-GTO fitting. A single -r value keeps the old single-start behavior; comma-separated -r values enable multi-start fitting and keep the fit with the lowest nonlinear error. - Add optional Molden [Nval] output via --write-nval. The values are read from UPF z_valence. This option is disabled by default. Notes: - The changes are limited to the Molden converter. Validation: - Ran the existing molden.py unit tests successfully. - Checked that default output does not contain [Nval]. - Checked that --write-nval writes C/O/H valence charges for the PhenolDimer test case. - Checked that Cartesian_angstrom coordinates are written at the correct Bohr scale.
|
@kirk0830 have a look |
There was a problem hiding this comment.
Thanks for your contribution!
This PR LGTM mostly, except the GTO-normalization procedure.
Can you provide some references supporting your idea about normalizing the GTO in molden file? Because as far as I remember, it is also the point I tried to ensure for times when I implemented such a post-processing script, and that is also the reason why I left a warning message informing users of the potential inconsistent number of electrons. But if I was wrong, that would be a good news for users who expect analyzing wavefunction with Multiwfn.
Thanks ;)
|
@kirk0830 I checked this point against the actual Molden handling in Multiwfn and CP2K, and I think the normalization correction is needed. What the PR ChangesIn the current ABACUS fitting code, the radial primitive is built without a primitive normalization factor: g = c * np.exp(-a * r**2) * r**lIn this PR, before writing the fitted coefficient to the Molden def _gto_radial_norm(a, l):
return math.sqrt(2.0 * (2.0 * a)**(l + 1.5) / math.gamma(l + 1.5))
c /= GTORadials._gto_radial_norm(a, l)This is not adding an extra normalization to the fitted ABACUS radial function. It converts the fitted coefficient to the convention expected by Molden readers such as Multiwfn. Multiwfn BehaviorIn Multiwfn real*8,external :: normgauIt reads the Molden read(10,*) exptmp,concoefftmp
primexp(iprimshell)=exptmp
concoeff(iprimshell)=concoefftmpLater, when building internal primitive GTF and MO coefficients, Multiwfn multiplies the Molden coefficient by tnormgau=normgau(b(k)%type,b(k)%exp)
temp=concoeff(iexp+l-1)
primconnorm(k)=temp*tnormgau
CO(imo,k)=CObasa(ibasis,imo)*temp*tnormgauTherefore, if ABACUS writes the fitted coefficient instead of the fitted primitive Writing CP2K BehaviorCP2K's Molden writer uses the same idea. In gcc(ipgf, ishell, iset)/(prefac*zet(ipgf, iset)**expzet)Source: Relevant source lines are around file lines 228-234 in This supports the same convention conversion: internal GTO coefficients and Molden Numerical CheckThis correction also improves the electron count significantly. For H2O, the ideal valence electron number is 8. With a 0.1 Bohr density grid: This does not mean the NAO-to-GTO fitting becomes exact, so I think the original warning should remain. The fitting itself can still introduce residual errors. But the normalization correction avoids the extra primitive normalization factor applied by Molden readers such as Multiwfn, and the H2O density integral is consistent with that interpretation. |
|
Thanks for your contribution! LGTM. |
Title: Improve ABACUS Molden output for wavefunction analysis
Summary:
This PR fixes several Molden conversion issues in tools/molden/molden.py while keeping the default workflow unchanged as much as possible.
Changes:
Notes:
Validation: