diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 06ba7b98fe..fbd4de9a27 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -882,7 +882,7 @@ calculations. - **Type**: String - **Description**: It indicates which occupation and smearing method is used in the calculation. - - **fixed**: fixed occupations. + - **fixed**: fixed occupations (available for non-coductors only) - **gauss** or **gaussian**: Gaussian smearing method. - **mp**: methfessel-paxton smearing method; recommended for metals. - **fd**: Fermi-Dirac smearing method: $f=1/\{1+\exp[(E-\mu)/kT]\}$ and smearing_sigma below is the temperature $T$ (in Ry). diff --git a/source/module_elecstate/occupy.cpp b/source/module_elecstate/occupy.cpp index 5fa40ac1fb..afd9a7d9a6 100644 --- a/source/module_elecstate/occupy.cpp +++ b/source/module_elecstate/occupy.cpp @@ -131,8 +131,12 @@ void Occupy::iweights(const int nks, const std::vector& isk) { assert(is < 2); + double degspin = 2.0; + if (GlobalV::NSPIN == 4) + degspin = 1.0; + if (is != -1) + degspin = 1.0; - double degspin = (GlobalV::NSPIN == 1) ? 2.0 : 1.0; double ib_mind = nelec / degspin; int ib_min = std::ceil(ib_mind); if (ib_min != int(ib_mind)) diff --git a/source/module_elecstate/test/elecstate_occupy_test.cpp b/source/module_elecstate/test/elecstate_occupy_test.cpp index 9b58996ddb..e95470cd98 100644 --- a/source/module_elecstate/test/elecstate_occupy_test.cpp +++ b/source/module_elecstate/test/elecstate_occupy_test.cpp @@ -225,7 +225,7 @@ TEST_F(OccupyTest, IweightsWarning) ekb(0, 0) = 0.1; testing::internal::CaptureStdout(); - EXPECT_EXIT(occupy.iweights(1, wk, 1, 1.0, ekb, ef, wg, 0, isk);, ::testing::ExitedWithCode(0), ""); + EXPECT_EXIT(occupy.iweights(1, wk, 1, 1.0, ekb, ef, wg, -1, isk);, ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output, testing::HasSubstr("It is not a semiconductor or insulator. Change 'smearing_method'.")); }