32namespace internal::interpolation_checkpoint {
34constexpr uint32_t
magic = 0x50493351;
40 const std::string& file_path) {
41 namespace stream_io = internal::interpolation_stream;
42 namespace constants = internal::interpolation_checkpoint;
43 if (record.
method.empty()) {
44 throw std::invalid_argument(
45 "interpolation record: the record names no method; nothing to write.");
47 std::ofstream stream(file_path, std::ios::binary);
49 throw std::runtime_error(
"interpolation record: cannot open '" + file_path +
52 stream_io::write_scalar<uint32_t>(stream, constants::magic);
53 stream_io::write_scalar<uint32_t>(stream, constants::version);
54 stream_io::write_string(stream, record.
method);
58 if (record.
method ==
"wannier") {
61 throw std::invalid_argument(
"interpolation record: no serializer for method '" +
65 throw std::runtime_error(
"interpolation record: writing '" + file_path +
"' failed.");
70 namespace stream_io = internal::interpolation_stream;
71 namespace constants = internal::interpolation_checkpoint;
72 std::ifstream stream(file_path, std::ios::binary);
74 throw std::runtime_error(
"interpolation record: cannot open '" + file_path +
"'.");
76 if (stream_io::read_scalar<uint32_t>(stream) != constants::magic) {
77 throw std::runtime_error(
"interpolation record: '" + file_path +
78 "' is not an interpolation record (bad magic).");
80 const uint32_t
version = stream_io::read_scalar<uint32_t>(stream);
81 if (
version != constants::version) {
82 throw std::runtime_error(
"interpolation record: '" + file_path +
"' has format version " +
83 std::to_string(
version) +
"; this build reads version " +
84 std::to_string(constants::version) +
".");
87 record.
method = stream_io::read_string(stream);
91 if (record.
method ==
"wannier") {
94 throw std::runtime_error(
"interpolation record: '" + file_path +
95 "' was built by unknown method '" + record.
method +
"'.");
constexpr uint32_t version
WannierInputs read(std::istream &stream)
void write(std::ostream &stream, const WannierInputs &record)
void write_interpolation_record(const InterpolationRecord &record, const std::string &file_path)
constexpr const char * version
InterpolationRecord read_interpolation_record(const std::string &file_path)
WannierInputs wannier
Payload for method == "wannier": interface matrices on the full k-grid.
Matrix3x3 real_lattice_bohr
Rows a1, a2, a3, Cartesian, in bohr.
std::string method
The method that built the payload: "wannier".
Matrix3x3 reciprocal_lattice_inverse_bohr
Rows b1, b2, b3, Cartesian, in inverse bohr, with the 2 pi included.
Real fermi_energy_rydberg