|
3 | 3 | #include "read_input.h" |
4 | 4 | #include "read_input_tool.h" |
5 | 5 |
|
| 6 | +#include <map> |
| 7 | + |
| 8 | +// next time if there are other keywords need the support of alias, move this function |
| 9 | +// to an upper level |
| 10 | +std::string alias_to_full_name(const std::map<std::string, std::vector<std::string>>& m, |
| 11 | + const std::string& in) |
| 12 | +{ |
| 13 | + for (const auto& key : m) |
| 14 | + { |
| 15 | + if (std::find(key.second.begin(), key.second.end(), in) != key.second.end()) |
| 16 | + { |
| 17 | + return key.first; |
| 18 | + } |
| 19 | + } |
| 20 | + ModuleBase::WARNING_QUIT("ModuleIO::ReadInput::read_input_item_elec_stru::alias_to_full_name", |
| 21 | + "The alias: `" + in + "` is not supported."); |
| 22 | +} |
| 23 | + |
| 24 | +// support the alias for keyword `smearing_type` |
| 25 | +void alias_update_smearing_method(std::string& in) |
| 26 | +{ |
| 27 | + // once there is new option added, update this map |
| 28 | + const std::map<std::string, std::vector<std::string>> alias = { |
| 29 | + {"fixed", {"fixed"}}, |
| 30 | + {"gaussian", {"gaussian", "gauss", "gau"}}, |
| 31 | + {"fermi-dirac", {"fermi-dirac", "fd", "f-d"}}, |
| 32 | + {"mp", {"mp", "methfessel-paxton", "m-p"}}, |
| 33 | + {"mp2", {"mp2", "mp-2"}}, |
| 34 | + {"mp3", {"mp3", "mp-3"}}, |
| 35 | + {"marzari-vanderbilt", {"marzari-vanderbilt", "mv", "m-v", "cold"}} |
| 36 | + }; |
| 37 | + in = alias_to_full_name(alias, in); |
| 38 | +} |
| 39 | + |
6 | 40 | namespace ModuleIO |
7 | 41 | { |
8 | 42 | void ReadInput::item_elec_stru() |
@@ -335,20 +369,9 @@ void ReadInput::item_elec_stru() |
335 | 369 | } |
336 | 370 | { |
337 | 371 | Input_Item item("smearing_method"); |
338 | | - item.annotation = "type of smearing_method: gauss; fd; fixed; mp; mp2; mv"; |
| 372 | + item.annotation = "type of smearing on electronic occupation"; |
| 373 | + alias_update_smearing_method(item.str_values[0]); // it might not be the best place |
339 | 374 | read_sync_string(input.smearing_method); |
340 | | - item.check_value = [](const Input_Item& item, const Parameter& para) { |
341 | | - const std::vector<std::string> methods = {"gauss", "gaussian", |
342 | | - "fd", "fermi-dirac", |
343 | | - "fixed", |
344 | | - "mp", "mp2", "mp3" |
345 | | - "marzari-vanderbilt", "cold", "mv"}; |
346 | | - if (std::find(methods.begin(), methods.end(), para.input.smearing_method) == methods.end()) |
347 | | - { |
348 | | - const std::string warningstr = nofound_str(methods, "smearing_method"); |
349 | | - ModuleBase::WARNING_QUIT("ReadInput", warningstr); |
350 | | - } |
351 | | - }; |
352 | 375 | this->add_item(item); |
353 | 376 | } |
354 | 377 | { |
|
0 commit comments