Skip to content

Commit c827766

Browse files
committed
Fix: Enhance the warning message when the XC name cannot be recognized.
1 parent 06df0ee commit c827766

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

source/module_hamilt_general/module_xc/xc_functional.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
263263
func_id = std::get<1>(type_id);
264264
use_libxc = true;
265265
#else
266-
ModuleBase::WARNING_QUIT("xc_functional.cpp","functional name not recognized!");
266+
std::string message = "Unrecognized exchange-correlation functional '"+ xc_func +"'.\n"
267+
" Possible source: Pseudopotential file or dft_functional parameter.\n"
268+
" Please explicitly set dft_functional in INPUT,\n"
269+
" or verify the functional name is supported.";
270+
ModuleBase::WARNING_QUIT("xc_functional.cpp",message);
267271
#endif
268272
}
269273

source/module_hamilt_general/module_xc/xc_functional_libxc.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,27 @@ std::pair<int,std::vector<int>> XC_Functional_Libxc::set_xc_type_libxc(std::stri
8282
token = xc_func_in.substr(0, pos);
8383
int id = xc_functional_get_number(token.c_str());
8484
std::cout << "func,id" << token << " " << id << std::endl;
85-
if (id == -1) { ModuleBase::WARNING_QUIT("XC_Functional::set_xc_type_libxc","functional name not recognized!"); }
85+
if (id == -1)
86+
{
87+
std::string message = "Unrecognized exchange-correlation functional '"+ xc_func_in +"'.\n"
88+
" Possible source: Pseudopotential file or dft_functional parameter.\n"
89+
" Please explicitly set dft_functional in INPUT,\n"
90+
" or verify the functional name is supported.";
91+
ModuleBase::WARNING_QUIT("XC_Functional::set_xc_type_libxc",message);
92+
}
8693
func_id.push_back(id);
8794
xc_func_in.erase(0, pos + delimiter.length());
8895
}
8996
int id = xc_functional_get_number(xc_func_in.c_str());
9097
std::cout << "func,id" << xc_func_in << " " << id << std::endl;
91-
if (id == -1) { ModuleBase::WARNING_QUIT("XC_Functional::set_xc_type_libxc","functional name not recognized!"); }
98+
if (id == -1)
99+
{
100+
std::string message = "Unrecognized exchange-correlation functional '"+ xc_func_in +"'.\n"
101+
" Possible source: Pseudopotential file or dft_functional parameter.\n"
102+
" Please explicitly set dft_functional in INPUT,\n"
103+
" or verify the functional name is supported.";
104+
ModuleBase::WARNING_QUIT("XC_Functional::set_xc_type_libxc",message);
105+
}
92106
func_id.push_back(id);
93107

94108
return std::make_pair(func_type, func_id);

0 commit comments

Comments
 (0)