Loading...
Searching...
No Matches
upf_pseudopotential_format.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * UPFPseudopotentialFormat — the Unified Pseudopotential Format, v1 and v2.
5 *
6 * Every UPF file opens with an XML tag (`<UPF version=...>` for v2,
7 * `<PP_INFO>` for v1), which is how it is recognised. A UPF file holds one
8 * dataset, so the dataset index is ignored.
9 */
10
11#include <memory>
12#include <string>
13#include <vector>
14
17
18namespace q3 {
19
20/// UPF v1 and v2, recognised by the XML tag every UPF file opens with.
22 public:
23 /// Ranked as a definite signature: every UPF file opens with an XML tag.
24 static constexpr int signature_detection_priority = 100;
25
26 /// "upf".
27 [[nodiscard]] std::vector<std::string> names() const override {
28 return {"upf"};
29 }
30
31 /// A first line holding an XML tag.
32 [[nodiscard]] bool recognizes(const std::string& first_line) const override {
33 return first_line.find('<') != std::string::npos;
34 }
35
36 /// signature_detection_priority.
37 [[nodiscard]] int detection_priority() const override {
39 }
40
41 /// The file's one dataset, read by UPFReader.
42 [[nodiscard]] std::unique_ptr<Pseudopotential> read(const std::string& filename,
43 int /*dataset_index*/) const override {
44 return UPFReader::read(filename);
45 }
46};
47
48} // namespace q3
One file format pseudopotential datasets are read from; see the file comment.
UPF v1 and v2, recognised by the XML tag every UPF file opens with.
int detection_priority() const override
signature_detection_priority.
std::unique_ptr< Pseudopotential > read(const std::string &filename, int) const override
The file's one dataset, read by UPFReader.
static constexpr int signature_detection_priority
Ranked as a definite signature: every UPF file opens with an XML tag.
std::vector< std::string > names() const override
"upf".
bool recognizes(const std::string &first_line) const override
A first line holding an XML tag.
static std::unique_ptr< Pseudopotential > read(const std::string &filename)