diff --git a/source/module_io/read_input_item_elec_stru.cpp b/source/module_io/read_input_item_elec_stru.cpp index 910b59ac18..b191c87dc0 100644 --- a/source/module_io/read_input_item_elec_stru.cpp +++ b/source/module_io/read_input_item_elec_stru.cpp @@ -330,6 +330,18 @@ void ReadInput::item_elec_stru() Input_Item item("smearing_method"); item.annotation = "type of smearing_method: gauss; fd; fixed; mp; mp2; mv"; read_sync_string(input.smearing_method); + item.check_value = [](const Input_Item& item, const Parameter& para) { + const std::vector methods = {"gauss", "gaussian", + "fd", "fermi-dirac", + "fixed", + "mp", "mp2", "mp3" + "marzari-vanderbilt", "cold", "mv"}; + if (std::find(methods.begin(), methods.end(), para.input.smearing_method) == methods.end()) + { + const std::string warningstr = nofound_str(methods, "smearing_method"); + ModuleBase::WARNING_QUIT("ReadInput", warningstr); + } + }; this->add_item(item); } { diff --git a/source/module_io/test_serial/read_input_item_test.cpp b/source/module_io/test_serial/read_input_item_test.cpp index 91325b9f00..001545f5b3 100644 --- a/source/module_io/test_serial/read_input_item_test.cpp +++ b/source/module_io/test_serial/read_input_item_test.cpp @@ -99,6 +99,14 @@ TEST_F(InputTest, Item_test) output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output, testing::HasSubstr("NOTICE")); } + { // smearing_method + auto it = find_label("smearing_method", readinput.input_lists); + param.input.smearing_method = "fix"; + testing::internal::CaptureStdout(); + EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(1), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + } { // kspacing auto it = find_label("kspacing", readinput.input_lists); it->second.str_values = {"1"};