Skip to content

Commit 1cac88b

Browse files
committed
Require exact Libxc external parameter count
1 parent d31e418 commit 1cac88b

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

source/source_hamilt/module_xc/libxc_setup.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -304,27 +304,18 @@ XC_Functional_Libxc::init_func(const std::vector<int> &func_id,
304304
const xc_func_info_type* info = xc_func_get_info(&funcs.back());
305305
const int nref = xc_func_info_get_n_ext_params(info);
306306

307-
// xc_func_set_ext_params() reads exactly nref entries. Never pass a
308-
// shorter buffer: Libxc may append new parameters in a newer release
309-
// (GGA_C_PBE gained _tscale in Libxc 7.1).
310-
if (requested_ext_params.size() > static_cast<std::size_t>(nref))
307+
// xc_func_set_ext_params() reads exactly nref entries
308+
if (requested_ext_params.size() != static_cast<std::size_t>(nref))
311309
{
312310
ModuleBase::WARNING_QUIT(
313311
"XC_Functional_Libxc::init_func",
314-
"Too many external parameters for Libxc functional id "
312+
"Invalid number of external parameters for Libxc functional id "
315313
+ std::to_string(id) + ": got "
316314
+ std::to_string(requested_ext_params.size())
317-
+ ", expected at most " + std::to_string(nref) + ".");
315+
+ ", expected " + std::to_string(nref) + ".");
318316
}
319317

320-
// Missing trailing parameters retain Libxc's own defaults. This is
321-
// backward- and forward-compatible when Libxc appends parameters.
322-
std::vector<double> complete_ext_params(
323-
nref, static_cast<double>(XC_EXT_PARAMS_DEFAULT));
324-
std::copy(requested_ext_params.begin(),
325-
requested_ext_params.end(),
326-
complete_ext_params.begin());
327-
xc_func_set_ext_params(&funcs.back(), complete_ext_params.data());
318+
xc_func_set_ext_params(&funcs.back(), requested_ext_params.data());
328319
}
329320
}
330321
return funcs;

0 commit comments

Comments
 (0)