47 std::vector<Complex> potential_complex(
48 static_cast<std::size_t
>(std::max(local_dense_points, local_dense_g_points)),
50 for (
int index = 0; index < local_dense_points; ++index) {
51 potential_complex[index] =
Complex(dense_real_space_potential[index], 0.0);
55 Real inverse_dense_points = 1.0 / total_dense_points;
56 for (
int index = 0; index < local_dense_g_points; ++index) {
57 potential_complex[index] *= inverse_dense_points;
61 std::vector<Complex> full_smooth_potential_g(total_smooth_points,
Complex(0.0, 0.0));
78 for (
int wrapped_1 = 0; wrapped_1 < smooth_dimension_1; ++wrapped_1) {
80 (wrapped_1 <= smooth_dimension_1 / 2) ? wrapped_1 : wrapped_1 - smooth_dimension_1;
81 for (
int wrapped_2 = 0; wrapped_2 < smooth_dimension_2; ++wrapped_2) {
83 (wrapped_2 <= smooth_dimension_2 / 2) ? wrapped_2 : wrapped_2 - smooth_dimension_2;
84 for (
int wrapped_3 = 0; wrapped_3 < smooth_dimension_3; ++wrapped_3) {
85 int miller_3 = (wrapped_3 <= smooth_dimension_3 / 2)
87 : wrapped_3 - smooth_dimension_3;
89 miller_1, miller_2, miller_3);
91 if (dense_index >= 0) {
93 (wrapped_1 * smooth_dimension_2 + wrapped_2) * smooth_dimension_3 +
95 full_smooth_potential_g[global_index] = potential_complex[dense_index];
101 return full_smooth_potential_g;
120 std::vector<Complex> local_smooth_potential_g(
121 static_cast<std::size_t
>(std::max(local_smooth_points, local_smooth_g_points)),
124 local_smooth_potential_g.data());
128 std::vector<Real> smooth_real_space_potential(local_smooth_points);
129 for (
int index = 0; index < local_smooth_points; ++index) {
130 smooth_real_space_potential[index] = local_smooth_potential_g[index].real();
132 return smooth_real_space_potential;
142 const std::vector<int>& g_vector_indices,
144 std::vector<int>& g_to_fft_mapping) {
148 g_to_fft_mapping.resize(number_of_plane_waves);
149 for (
int g_vector_index = 0; g_vector_index < number_of_plane_waves; g_vector_index++) {
150 const auto& g_vector = planewave_basis.
g_vectors()[g_vector_indices[g_vector_index]];
151 int miller_index_1 =
static_cast<int>(std::round(g_vector.miller.x));
152 int miller_index_2 =
static_cast<int>(std::round(g_vector.miller.y));
153 int miller_index_3 =
static_cast<int>(std::round(g_vector.miller.z));
154 if (std::abs(miller_index_1) <= fft_grid_dimension_1 / 2 &&
155 std::abs(miller_index_2) <= fft_grid_dimension_2 / 2 &&
156 std::abs(miller_index_3) <= fft_grid_dimension_3 / 2) {
157 g_to_fft_mapping[g_vector_index] =
159 miller_index_1, miller_index_2, miller_index_3);
161 g_to_fft_mapping[g_vector_index] = -1;