16 static_assert(d >= 3,
"dimension must be at least 3");
24 json.get_uint(
"/integration/cudathreadsperblock"))
32 ptr_x_quadrature_p = quadrature_provider.
get_points<ctype>(grid_sizes[0]).data();
33 ptr_x_quadrature_w = quadrature_provider.get_weights<ctype>(grid_sizes[0]).data();
34 ptr_ang_quadrature_p = quadrature_provider.get_points<ctype>(grid_sizes[1]).data();
35 ptr_ang_quadrature_w = quadrature_provider.get_weights<ctype>(grid_sizes[1]).data();
51 if (
is_close(T, m_T) && (std::abs(E - m_E) / std::max(E, m_E) < 2.5e-2))
return;
53 std::cout <<
"SETTING T" << std::endl;
57 m_E =
is_close(E, 0.) ? 10 * m_T : E;
60 grid_sizes[2] = quadrature_provider.get_matsubara_points<
ctype>(m_T, m_E).size();
61 ptr_matsubara_quadrature_p = quadrature_provider.get_matsubara_points<
ctype>(m_T, m_E).data();
62 ptr_matsubara_quadrature_w = quadrature_provider.get_matsubara_weights<
ctype>(m_T, m_E).data();
73 : quadrature_provider(other.quadrature_provider), grid_sizes(other.grid_sizes),
74 ptr_x_quadrature_p(other.ptr_x_quadrature_p), ptr_x_quadrature_w(other.ptr_x_quadrature_w),
75 ptr_ang_quadrature_p(other.ptr_ang_quadrature_p), ptr_ang_quadrature_w(other.ptr_ang_quadrature_w),
76 ptr_matsubara_quadrature_p(other.ptr_matsubara_quadrature_p),
77 ptr_matsubara_quadrature_w(other.ptr_matsubara_quadrature_w), x_extent(other.x_extent), m_T(other.m_T),
78 m_E(other.m_E), manual_E(other.manual_E)
82 template <
typename... T> NT
get(
const ctype k,
const T &...t)
84 if (!manual_E && (std::abs(k - m_E) / std::max(k, m_E) > 2.5e-2)) {
90 using std::sqrt, std::exp, std::log;
92 const auto constant = KERNEL::constant(k, t...);
95 tbb::blocked_range3d<uint, uint, uint>(0, grid_sizes[0], 0, grid_sizes[1], 0, grid_sizes[2]), NT(0.),
96 [&](
const tbb::blocked_range3d<uint, uint, uint> &r, NT value) -> NT {
97 for (
uint idx_x = r.pages().begin(); idx_x != r.pages().end(); ++idx_x) {
98 const ctype q = k * sqrt(ptr_x_quadrature_p[idx_x] * x_extent);
100 const ctype int_element = S_dm1
105 for (
uint idx_y = r.rows().begin(); idx_y != r.rows().end(); ++idx_y) {
106 const ctype cos = 2 * (ptr_ang_quadrature_p[idx_y] - (
ctype)0.5);
108 const ctype x_weight = 2 * ptr_ang_quadrature_w[idx_y] * ptr_x_quadrature_w[idx_x] * x_extent;
110 for (
uint idx_z = r.cols().begin(); idx_z != r.cols().end(); ++idx_z) {
111 const ctype q0 = ptr_matsubara_quadrature_p[idx_z];
112 const ctype weight = x_weight * ptr_matsubara_quadrature_w[idx_z];
113 value += int_element * weight *
114 (KERNEL::kernel(q, cos, q0, k, t...) + KERNEL::kernel(q, cos, -q0, k, t...));
115 if (m_T > 0 && idx_z == 0)
116 value += int_element * x_weight * m_T * KERNEL::kernel(q, cos, (
ctype)0, k, t...);
122 [&](NT x, NT y) -> NT {
return x + y; });
125 template <
typename... T> std::future<NT>
request(
const ctype k,
const T &...t)
127 return std::async(std::launch::deferred, [=,
this]() {
return get(k, t...); });
Definition integrator_angle_finiteTq0_cpu.hh:15
NT get(const ctype k, const T &...t)
Definition integrator_angle_finiteTq0_cpu.hh:82
std::future< NT > request(const ctype k, const T &...t)
Definition integrator_angle_finiteTq0_cpu.hh:125
ctype m_E
Definition integrator_angle_finiteTq0_cpu.hh:136
void set_T(const ctype T, const ctype E=0)
Set the temperature and typical energy scale of the integrator and recompute the Matsubara quadrature...
Definition integrator_angle_finiteTq0_cpu.hh:49
QuadratureProvider & quadrature_provider
Definition integrator_angle_finiteTq0_cpu.hh:131
const ctype * ptr_ang_quadrature_w
Definition integrator_angle_finiteTq0_cpu.hh:142
const ctype * ptr_matsubara_quadrature_p
Definition integrator_angle_finiteTq0_cpu.hh:143
std::array< uint, 3 > grid_sizes
Definition integrator_angle_finiteTq0_cpu.hh:133
typename get_type::ctype< NT > ctype
Definition integrator_angle_finiteTq0_cpu.hh:19
const ctype * ptr_ang_quadrature_p
Definition integrator_angle_finiteTq0_cpu.hh:141
bool manual_E
Definition integrator_angle_finiteTq0_cpu.hh:137
const ctype x_extent
Definition integrator_angle_finiteTq0_cpu.hh:135
void set_E(const ctype E)
Set the typical energy scale of the integrator and recompute the Matsubara quadrature rule.
Definition integrator_angle_finiteTq0_cpu.hh:70
const ctype * ptr_x_quadrature_w
Definition integrator_angle_finiteTq0_cpu.hh:140
IntegratorAngleFiniteTq0TBB(QuadratureProvider &quadrature_provider, const std::array< uint, 2 > grid_sizes, const ctype x_extent, const JSONValue &json)
Definition integrator_angle_finiteTq0_cpu.hh:21
IntegratorAngleFiniteTq0TBB(const IntegratorAngleFiniteTq0TBB &other)
Definition integrator_angle_finiteTq0_cpu.hh:72
const ctype * ptr_matsubara_quadrature_w
Definition integrator_angle_finiteTq0_cpu.hh:144
IntegratorAngleFiniteTq0TBB(QuadratureProvider &quadrature_provider, std::array< uint, 2 > _grid_sizes, const ctype x_extent, const ctype T, const uint max_block_size=0)
Definition integrator_angle_finiteTq0_cpu.hh:28
const ctype * ptr_x_quadrature_p
Definition integrator_angle_finiteTq0_cpu.hh:139
A wrapper around the boost json value class.
Definition json.hh:19
A class that provides quadrature points and weights, in host and device memory. The quadrature points...
Definition quadrature_provider.hh:139
const std::vector< NT > & get_points(const size_t order, const QuadratureType type=QuadratureType::legendre)
Get the quadrature points for a quadrature of size quadrature_size.
Definition quadrature_provider.hh:151
typename internal::_ctype< CT >::value ctype
Definition types.hh:106
Definition complex_math.hh:14
constexpr __forceinline__ __host__ __device__ NumberType powr(const NumberType x)
A compile-time evaluatable power function for whole number exponents.
Definition math.hh:45
constexpr auto & get(named_tuple< tuple_type, strs... > &ob)
get a reference to the element with the given name
Definition tuples.hh:82
bool __forceinline__ __host__ __device__ is_close(T1 a, T2 b, T3 eps_)
Function to evaluate whether two floats are equal to numerical precision. Tests for both relative and...
Definition math.hh:160
consteval NT S_d_prec(uint d)
Surface of a d-dimensional sphere (precompiled)
Definition math.hh:104
unsigned int uint
Definition utils.hh:22