Skip to content

Commit 7b33110

Browse files
authored
add check for smearing_method (#5718)
1 parent 7c36c49 commit 7b33110

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

source/module_io/read_input_item_elec_stru.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,18 @@ void ReadInput::item_elec_stru()
330330
Input_Item item("smearing_method");
331331
item.annotation = "type of smearing_method: gauss; fd; fixed; mp; mp2; mv";
332332
read_sync_string(input.smearing_method);
333+
item.check_value = [](const Input_Item& item, const Parameter& para) {
334+
const std::vector<std::string> methods = {"gauss", "gaussian",
335+
"fd", "fermi-dirac",
336+
"fixed",
337+
"mp", "mp2", "mp3"
338+
"marzari-vanderbilt", "cold", "mv"};
339+
if (std::find(methods.begin(), methods.end(), para.input.smearing_method) == methods.end())
340+
{
341+
const std::string warningstr = nofound_str(methods, "smearing_method");
342+
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
343+
}
344+
};
333345
this->add_item(item);
334346
}
335347
{

source/module_io/test_serial/read_input_item_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ TEST_F(InputTest, Item_test)
9999
output = testing::internal::GetCapturedStdout();
100100
EXPECT_THAT(output, testing::HasSubstr("NOTICE"));
101101
}
102+
{ // smearing_method
103+
auto it = find_label("smearing_method", readinput.input_lists);
104+
param.input.smearing_method = "fix";
105+
testing::internal::CaptureStdout();
106+
EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(1), "");
107+
output = testing::internal::GetCapturedStdout();
108+
EXPECT_THAT(output, testing::HasSubstr("NOTICE"));
109+
}
102110
{ // kspacing
103111
auto it = find_label("kspacing", readinput.input_lists);
104112
it->second.str_values = {"1"};

0 commit comments

Comments
 (0)