Skip to content

Bug: Calculation continue with wrong smear setting #5693

@QuantumMisaka

Description

@QuantumMisaka

Describe the bug

I inaccurately set wrong smearing_method as fix while want fixed:

INPUT_PARAMETERS RUNNING ABACUS-DFT

#Parameters (1.General)
suffix                  ABACUS  # suffix of OUTPUT DIR
nspin                   2   #  1/2/4 4 for SOC
symmetry                0   #  0/1  1 for open, default
esolver_type            ksdft  # ksdft, ofdft, sdft, tddft, lj, dp
dft_functional          pbe  # same as upf file, can be lda/pbe/scan/hf/pbe0/hse
ks_solver               dav_subspace  # default for ksdft-lcao
pw_diag_ndim            2
vdw_method              none  # none, d3, d3_bj
pseudo_dir              ../../../PP
orbital_dir             ../../../ORB


#Parameters (2.Iteration)
calculation             scf # scf relax cell-relax md
ecutwfc                 200
scf_thr                 1e-9
#scf_ene_thr             1e-7
scf_nmax                50

#Parameters (3.Basis)
basis_type              pw  # lcao or pw
# kspacing                0.14 # replace KPT
gamma_only            1  # 0/1, replace KPT

#Parameters (4.Smearing)
smearing_method         fix   # mp/gaussian/fixed
smearing_sigma          0.001  # Rydberg
nupdown 2

#Parameters (5.Mixing)
mixing_type             broyden  # pulay/broyden
mixing_beta             0.4 # for metal: 0.05-0.4
mixing_beta_mag         0.4
#mixing_tau              true
mixing_gg0              0  # only for metal
mixing_ndim              20    # mixing dimension, for low-d can set to 20

But ABACUS calculation continue, and the behaviour looks like that the SCF is done by gaussian smearing

Expected behavior

While user give wrong smearing_method inputs, the calculation should quit with a warning/error

To Reproduce

No response

Environment

No response

Additional Context

Also, when I set smearing_method as gau, the calculation can be done as gaussian smearing, but it is not expected in ABACUS docs and codes.

in source/module_elecstate/occupy.cpp:

void Occupy::decision(const std::string& name, const std::string& smearing_method, const double& smearing_sigma)
{
    ModuleBase::TITLE("Occupy", "decision");
    use_gaussian_broadening = false;
    fixed_occupations = false;

    gaussian_type = 0;
    gaussian_parameter = smearing_sigma;

    if (name == "fixed")
    {
        if (gaussian_parameter != 0.0)
        {
            ModuleBase::WARNING("smearing_decision", "Fixed occupations,gauss broadening ignored");
            ModuleBase::GlobalFunc::AUTO_SET("gaussian_parameter", 0.0);
            gaussian_parameter = 0.0;
        }
    }
    else if (name == "smearing" && smearing_method == "fixed")
    {
        if (gaussian_parameter != 0.0)
        {
            ModuleBase::WARNING("smearing_decision", "Fixed occupations,gauss broadening ignored");
            ModuleBase::GlobalFunc::AUTO_SET("gaussian_parameter", 0.0);
            gaussian_parameter = 0.0;
        }
    }

    // there are four types of smearing methods:
    // (1) gaussian
    // (2) methfessel-paxton
    // (3) Marzari-Vanderbilt
    // (4) Fermi-Dirac
    else if (name == "smearing")
    {
        use_gaussian_broadening = true;
        if (gaussian_parameter == 0.0)
        {
            ModuleBase::WARNING_QUIT(
                "smearing_decision",
                "Smearing requires gaussian broadening,but gaussian_parameter = 0(default value = 0.01)");
        }
        if (smearing_method == "gaussian" || smearing_method == "gauss")
        {
            gaussian_type = 0; //  0: gaussian
        }
        else if (smearing_method == "methfessel-paxton" || smearing_method == "mp")
        {
            gaussian_type = 1; // >0 Methfessel-Paxton method.
        }
        else if (smearing_method == "mp2")
        {
            gaussian_type = 2; // 2nd Methfessel-Paxton method.
        }
        else if (smearing_method == "mp3")
        {
            // acually any order Methfessel-Paxton method can be supported in Occupy::w1gauss()
            // however the parameter is string instead of int
            ModuleBase::WARNING_QUIT(
                "occupy",
                "Some refactor of smearing shoule be done before supporting any order of Methfessel-Paxton method!");
        }

        else if (smearing_method == "marzari-vanderbilt" || smearing_method == "cold" || smearing_method == "mv")
        {
            gaussian_type = -1;
        }
        else if (smearing_method == "fermi-dirac" || smearing_method == "fd")
        {
            gaussian_type = -99;
        }
    }
    else if (name == "tetrahedra")
    {
        ModuleBase::WARNING_QUIT("occupy", "not implemented yet!");
    }
    else if (name == "from_input")
    {
        fixed_occupations = true;
    }
    else
    {
        ModuleBase::WARNING_QUIT("occupy_decision", "occupations, not implemented");
    }
    return;
}

It seems there is a WARNING_QUIT, but in practical, when user give wrong smearing_method input, the calculation will go on as gauss smearing.

Task list for Issue attackers (only for developers)

  • Verify the issue is not a duplicate.
  • Describe the bug.
  • Steps to reproduce.
  • Expected behavior.
  • Error message.
  • Environment details.
  • Additional context.
  • Assign a priority level (low, medium, high, urgent).
  • Assign the issue to a team member.
  • Label the issue with relevant tags.
  • Identify possible related issues.
  • Create a unit test or automated test to reproduce the bug (if applicable).
  • Fix the bug.
  • Test the fix.
  • Update documentation (if necessary).
  • Close the issue and inform the reporter (if applicable).

Metadata

Metadata

Assignees

Labels

Input&OutputSuitable for coders without knowing too many DFT detailsQuestionsRaise your quesiton! We will answer it.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions