43 for (
int axis = 0; axis < 3; axis++) {
58 write_scalar<int32_t>(stream, direction.grid_step.x);
59 write_scalar<int32_t>(stream, direction.grid_step.y);
60 write_scalar<int32_t>(stream, direction.grid_step.z);
62 write_scalar<double>(stream, direction.weight);
65 write_scalar<int64_t>(stream,
static_cast<int64_t
>(record.
overlap_matrices.size()));
84 for (
int axis = 0; axis < 3; axis++) {
91 for (
int axis = 0; axis < 3; axis++) {
93 throw std::runtime_error(
"interpolation record: non-positive k-point grid dimension; "
94 "the file is corrupt.");
98 throw std::runtime_error(
"interpolation record: non-positive band or trial-orbital "
99 "count; the file is corrupt.");
102 const int64_t number_of_kpoints = read_scalar<int64_t>(stream);
103 if (number_of_kpoints < 0) {
104 throw std::runtime_error(
"interpolation record: negative k-point count; the file is "
110 throw std::runtime_error(
"interpolation record: the k-point count does not match the "
111 "grid dimensions; the file is corrupt.");
114 static_cast<std::uint64_t
>(number_of_kpoints) * 3 *
sizeof(
double));
116 for (int64_t index = 0; index < number_of_kpoints; index++) {
120 const int64_t number_of_directions = read_scalar<int64_t>(stream);
121 if (number_of_directions < 0) {
122 throw std::runtime_error(
"interpolation record: negative neighbour count; the file is "
126 static_cast<std::uint64_t
>(number_of_directions) *
127 (3 *
sizeof(int32_t) + 3 *
sizeof(
double) +
sizeof(
double)));
128 for (int64_t index = 0; index < number_of_directions; index++) {
130 direction.
grid_step.
x = read_scalar<int32_t>(stream);
131 direction.
grid_step.
y = read_scalar<int32_t>(stream);
132 direction.
grid_step.
z = read_scalar<int32_t>(stream);
134 direction.
weight = read_scalar<double>(stream);
138 const int64_t overlap_kpoints = read_scalar<int64_t>(stream);
139 if (overlap_kpoints < 0) {
140 throw std::runtime_error(
"interpolation record: negative overlap count; the file is "
145 for (int64_t index = 0; index < overlap_kpoints; index++) {
151 const int64_t number_of_centers = read_scalar<int64_t>(stream);
153 throw std::runtime_error(
"interpolation record: " + std::to_string(number_of_centers) +
154 " trial-orbital centres for " +
156 " trial orbitals; the file is corrupt.");
159 for (int64_t index = 0; index < number_of_centers; index++) {
168 auto check_coverage = [&](std::size_t count,
const char* name) {
170 throw std::runtime_error(std::string(
"interpolation record: ") + name +
" cover " +
171 std::to_string(count) +
" k-points, the record has " +
173 "; the file is corrupt.");
189 throw std::runtime_error(
"interpolation record: impossible band or orbital count; the "
190 "file is corrupt or predates this reader's format.");
192 const std::size_t projection_block =
195 if (block.size() != projection_block) {
196 throw std::runtime_error(
"interpolation record: a projection block has " +
197 std::to_string(block.size()) +
" entries, expected " +
198 std::to_string(projection_block) +
199 "; the file is corrupt or predates this reader's format.");
204 throw std::runtime_error(
"interpolation record: an eigenvalue row has " +
205 std::to_string(row.size()) +
" entries, expected " +
207 "; the file is corrupt or predates this reader's format.");