Skip to content

[Bug] Default yukawa_lambda can produce NaN U/J from tiny negative charge density #7905

Description

@bowenphys

Summary

When yukawa_potential = 1 is enabled and yukawa_lambda is not specified, the on-the-fly screening-length calculation can produce NaN values for the Yukawa DFT+U parameters U and J.

Environment

  • ABACUS 3.10.1 (LCAO build)
  • DFT+U with yukawa_potential 1
  • yukawa_lambda omitted, so it is calculated automatically
  • Collinear spin-polarized calculation (nspin = 2)

Relevant INPUT settings are:

dft_plus_u 1
yukawa_potential 1
# yukawa_lambda is not specified

Observed behavior

The calculation reports non-finite Yukawa parameters, for example:

U = -nan eV
J = -nan eV

The same calculation becomes finite when an explicit positive screening parameter is supplied (for example, yukawa_lambda 0.7, in the corresponding input units).

Suspected cause

In source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp, the automatic screening calculation evaluates a fractional power of the real-space charge density, schematically:

double lambda_ir = 2 * pow(3 * rho_ir / ModuleBase::PI, 1.0 / 6.0);

Small negative values of rho_ir caused by numerical round-off make this fractional power NaN, which then propagates into the computed screening length and subsequently into U and J.

Suggested fix

Could the automatic screening calculation:

  1. protect the fractional power against tiny negative densities, e.g. by using a non-negative density with an appropriate tolerance;
  2. check the normalization/denominator before dividing; and
  3. emit a diagnostic error or warning if the density is invalid rather than silently returning NaN?

A regression test containing a small negative mesh-density value would help prevent recurrence.

Note on a related issue

The separate interaction between Yukawa DFT+U and uramping/u_converged() appears to be addressed by PR #7369, so this issue is limited to the NaN generated by the default screening-length path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugsBugs that only solvable with sufficient knowledge of DFTDFT+UIssues related to DFT plus U functionLong-Time Support (LTS)Issues related to LTS version

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions