Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
spherical_bessel.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * Spherical Bessel transform (Fourier-Bessel / Hankel transform).
5 *
6 * Computes f(q) = 4π ∫₀^∞ f(r) · j_l(qr) · r · dr for each q in q_points,
7 * evaluated numerically via Simpson's rule on the provided grid.
8 *
9 * This is the radial part of a 3D Fourier transform in spherical coordinates.
10 * Used to tabulate beta projectors, atomic charge density, and core charge
11 * density from their real-space representations onto reciprocal space.
12 */
13
14#include <vector>
15
19
20namespace q3 {
21
22/**
23 * Spherical Bessel transform of a function onto a uniform q-grid.
24 *
25 * @param grid r values on the (typically logarithmic) mesh
26 * @param integration_factors dr/di integration factors for Simpson's rule
27 * @param function f(r) to transform
28 * @param degree l for the spherical Bessel function j_l
29 * @param mesh_size number of grid points to integrate over
30 * @param q_points q values at which to evaluate the transform
31 * @param fourier_transform [out] f(q) result, resized to q_points.size()
32 */
33inline void transform_spherical_bessel(const std::vector<Real>& grid,
34 const std::vector<Real>& integration_factors,
35 const std::vector<Real>& function,
36 int degree,
37 int mesh_size,
38 const std::vector<Real>& q_points,
39 std::vector<Real>& fourier_transform) {
40 fourier_transform.resize(q_points.size());
41 std::vector<Real> integrand(mesh_size);
42 std::vector<Real> bessel_values(mesh_size);
43 for (size_t q_index = 0; q_index < q_points.size(); q_index++) {
44 Real q_value = q_points[q_index];
45 spherical_bessel_batch(degree, q_value, grid.data(), mesh_size, bessel_values.data());
46 for (int grid_index = 0; grid_index < mesh_size; grid_index++) {
47 integrand[grid_index] =
48 function[grid_index] * grid[grid_index] * bessel_values[grid_index];
49 }
50 fourier_transform[q_index] =
51 constants::four_pi * simpson_rule(integrand, integration_factors, mesh_size);
52 }
53}
54
55} // namespace q3
constexpr Real four_pi
Definition constants.hpp:26
Real simpson_rule(const std::vector< Real > &function_values, const std::vector< Real > &integration_factors, int number_of_grid_points)
Definition simpson.hpp:23
double Real
void transform_spherical_bessel(const std::vector< Real > &grid, const std::vector< Real > &integration_factors, const std::vector< Real > &function, int degree, int mesh_size, const std::vector< Real > &q_points, std::vector< Real > &fourier_transform)
void spherical_bessel_batch(int degree, Real q_value, const Real *radial_grid, int mesh_size, Real *result)
Definition bessel.hpp:105