|
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 | | - item.annotation = "cg; bfgs; sd; cg; cg_bfgs;"; |
| 14 | + item.annotation = "cg [param]; bfgs [param]; ..."; |
13 | 15 | read_sync_string(input.relax_method); |
| 16 | + item.read_value = [](const Input_Item& item, Parameter& para) { |
| 17 | + std::istringstream iss(para.input.relax_method); |
| 18 | + iss >> para.input.relax_method_param.method; |
| 19 | + if (!(iss >> para.input.relax_method_param.param)) { |
| 20 | + para.input.relax_method_param.param = 1; |
| 21 | + } |
| 22 | +}; |
14 | 23 | item.check_value = [](const Input_Item& item, const Parameter& para) { |
15 | | - const std::vector<std::string> relax_methods = {"cg", "bfgs_old", "sd", "cg_bfgs","bfgs","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 | | - } |
| 24 | + const std::vector<std::string> relax_methods = {"cg", "sd","bfgs_old" "cg_bfgs","bfgs","lbfgs"}; |
| 25 | + if (std::find(relax_methods.begin(), relax_methods.end(), para.input.relax_method_param.method) == relax_methods.end()) { |
| 26 | + const std::string warningstr = nofound_str(relax_methods, "relax_method"); |
| 27 | + ModuleBase::WARNING_QUIT("ReadInput", warningstr); |
| 28 | + } |
21 | 29 | }; |
22 | 30 | this->add_item(item); |
| 31 | + // Input_Item item("relax_method"); |
| 32 | + // item.annotation = "cg; bfgs; sd; cg; cg_bfgs;"; |
| 33 | + // read_sync_string(input.relax_method); |
| 34 | + // item.check_value = [](const Input_Item& item, const Parameter& para) { |
| 35 | + // const std::vector<std::string> relax_methods = {"cg", "bfgs_old", "sd", "cg_bfgs","bfgs","lbfgs"}; |
| 36 | + // if (std::find(relax_methods.begin(),relax_methods.end(), para.input.relax_method)==relax_methods.end()) |
| 37 | + // { |
| 38 | + // const std::string warningstr = nofound_str(relax_methods, "relax_method"); |
| 39 | + // ModuleBase::WARNING_QUIT("ReadInput", warningstr); |
| 40 | + // } |
| 41 | + // }; |
| 42 | + // this->add_item(item); |
23 | 43 | } |
24 | 44 | { |
25 | 45 | Input_Item item("relax_new"); |
|
0 commit comments