40 miller_indices[3 * g_index + 0] = miller.x;
41 miller_indices[3 * g_index + 1] = miller.y;
42 miller_indices[3 * g_index + 2] = miller.z;
44 write_block(output_file,
46 miller_indices.data(),
47 miller_indices.size() *
sizeof(int32_t));
55 output_file, counts.data(),
static_cast<int32_t
>(counts.size() *
sizeof(int32_t)));
73 double weight_sum = 0.0;
74 for (
double weight : weights) {
77 if (weight_sum <= 0.0) {
78 throw std::runtime_error(
79 "BerkeleyGW export: k-point weights sum to " + std::to_string(weight_sum) +
80 ", so they cannot be normalized to BerkeleyGW's required sum of 1. "
81 "Check control.kpoints_list.");
83 for (
auto& weight : weights) {
87 output_file, weights.data(),
static_cast<int32_t
>(weights.size() *
sizeof(double)));
100 coordinates[3 * kpoint_index + 0] = point.
x;
101 coordinates[3 * kpoint_index + 1] = point.
y;
102 coordinates[3 * kpoint_index + 2] = point.
z;
106 static_cast<int32_t
>(coordinates.size() *
sizeof(
double)));
113 std::vector<int32_t> miller_indices(3 *
static_cast<size_t>(number_of_plane_waves));
114 for (
int plane_wave_index = 0; plane_wave_index < number_of_plane_waves;
115 plane_wave_index++) {
118 miller_indices[3 * plane_wave_index + 0] = miller.x;
119 miller_indices[3 * plane_wave_index + 1] = miller.y;
120 miller_indices[3 * plane_wave_index + 2] = miller.z;
122 write_block(output_file,
123 number_of_plane_waves,
124 miller_indices.data(),
125 miller_indices.size() *
sizeof(int32_t));
132 size_t number_of_values)
const {
133 write_block(output_file, count, values, number_of_values *
sizeof(
Complex));
146 void write_block(std::ofstream& output_file,
149 size_t payload_bytes)
const {
150 int32_t number_of_records = 1;
151 record_format_.
write_record(output_file, &number_of_records,
sizeof(number_of_records));
152 record_format_.
write_record(output_file, &count,
sizeof(count));
153 record_format_.
write_record(output_file, payload,
static_cast<int32_t
>(payload_bytes));
Writes the records BerkeleyGW's files share; see the file comment.
void write_kpoint_gvectors(std::ofstream &output_file, int kpoint_index) const
[nrecord=1][ngk][gvec_k(3,ngk)] – the plane waves of one k-point, in the record's order.
BerkeleyGWRecordWriter(const MeanFieldRecord &&)=delete
See the file writers' own deleted rvalue constructors: this holds a reference.
void write_plane_wave_counts(std::ofstream &output_file) const
ngk(nk) – plane waves per k-point.
void write_charge_density_gvectors(std::ofstream &output_file) const
[nrecord=1][ng][gvec(3,ng)] – the charge-density G-set, in the record's order.
void write_kpoint_coordinates(std::ofstream &output_file) const
void write_complex_block(std::ofstream &output_file, int32_t count, const Complex *values, size_t number_of_values) const
[nrecord=1][count][values] – one data block of count complex values per spin.
BerkeleyGWRecordWriter(const MeanFieldRecord &record)
void write_normalized_kpoint_weights(std::ofstream &output_file) const
std::complex< double > Complex
std::vector< Vector3D > kpoint_coordinates
Crystal (fractional) coordinates, one per physical k-point.
std::vector< std::vector< int > > kpoint_g_vector_indices
Per physical k-point, indices into charge_density_miller_indices.
std::vector< int > plane_waves_per_kpoint
std::vector< IntegerVector3D > charge_density_miller_indices
std::vector< Real > kpoint_weights
Engine-convention weights; formats renormalize as they require.