|
5 | 5 |
|
6 | 6 | namespace ModuleIO |
7 | 7 | { |
| 8 | + |
| 9 | + |
8 | 10 | void ReadInput::item_relax() |
9 | 11 | { |
10 | 12 | { |
11 | 13 | Input_Item item("relax_method"); |
12 | 14 | item.annotation = "cg; bfgs; sd; cg; cg_bfgs;"; |
13 | | - read_sync_string(input.relax_method); |
14 | | - item.check_value = [](const Input_Item& item, const Parameter& para) { |
15 | | - const std::vector<std::string> relax_methods = {"cg", "bfgs", "sd", "cg_bfgs","bfgs_trad","lbfgs"}; |
16 | | - if (std::find(relax_methods.begin(),relax_methods.end(), para.input.relax_method)==relax_methods.end()) |
17 | | - { |
18 | | - const std::string warningstr = nofound_str(relax_methods, "relax_method"); |
19 | | - ModuleBase::WARNING_QUIT("ReadInput", warningstr); |
20 | | - } |
| 15 | + item.read_value = [](const Input_Item& item, Parameter& para) { |
| 16 | + if(item.get_size()==1) |
| 17 | + { |
| 18 | + para.input.relax_method[0] = item.str_values[0]; |
| 19 | + para.input.relax_method[1] = "1"; |
| 20 | + } |
| 21 | + else if(item.get_size()>=2) |
| 22 | + { |
| 23 | + para.input.relax_method[0] = item.str_values[0]; |
| 24 | + para.input.relax_method[1] = item.str_values[1]; |
| 25 | + } |
| 26 | + }; |
| 27 | + item.check_value = [](const Input_Item& item, const Parameter& para) { |
| 28 | + const std::vector<std::string> relax_methods = {"cg", "sd", "cg_bfgs","lbfgs","bfgs"}; |
| 29 | + if (std::find(relax_methods.begin(), relax_methods.end(), para.input.relax_method[0]) == relax_methods.end()) { |
| 30 | + const std::string warningstr = nofound_str(relax_methods, "relax_method"); |
| 31 | + ModuleBase::WARNING_QUIT("ReadInput", warningstr); |
| 32 | + } |
21 | 33 | }; |
22 | 34 | this->add_item(item); |
| 35 | + |
| 36 | + // Input_Item item("relax_method"); |
| 37 | + // item.annotation = "cg; bfgs; sd; cg; cg_bfgs;"; |
| 38 | + // read_sync_string(input.relax_method); |
| 39 | + // item.check_value = [](const Input_Item& item, const Parameter& para) { |
| 40 | + // const std::vector<std::string> relax_methods = {"cg", "bfgs_old", "sd", "cg_bfgs","bfgs","lbfgs"}; |
| 41 | + // if (std::find(relax_methods.begin(),relax_methods.end(), para.input.relax_method)==relax_methods.end()) |
| 42 | + // { |
| 43 | + // const std::string warningstr = nofound_str(relax_methods, "relax_method"); |
| 44 | + // ModuleBase::WARNING_QUIT("ReadInput", warningstr); |
| 45 | + // } |
| 46 | + // }; |
| 47 | + // this->add_item(item); |
23 | 48 | } |
24 | 49 | { |
25 | 50 | Input_Item item("relax_new"); |
26 | 51 | item.annotation = "whether to use the new relaxation method"; |
27 | 52 | read_sync_bool(input.relax_new); |
28 | 53 | item.reset_value = [](const Input_Item& item, Parameter& para) { |
29 | | - if (para.input.relax_new && para.input.relax_method != "cg") |
| 54 | + if (para.input.relax_new && para.input.relax_method[0] != "cg") |
30 | 55 | { |
31 | 56 | para.input.relax_new = false; |
32 | 57 | } |
|
0 commit comments