38 static std::unique_ptr<Pseudopotential>
read(
const std::string& filename,
39 int dataset_index = 0) {
40 std::ifstream file_stream(filename);
41 if (!file_stream.is_open())
42 throw std::runtime_error(
"Cannot open PP file: " + filename);
43 std::string first_line;
44 std::getline(file_stream, first_line);
49 for (
const auto& format : registry.entries()) {
50 if (!format->recognizes(first_line))
53 chosen = format.get();
55 if (chosen !=
nullptr)
56 return chosen->
read(filename, dataset_index);
57 throw std::runtime_error(
58 "No registered pseudopotential format recognises " + filename +
59 "; the formats this build reads are: " + registry.canonical_names(
", "));