/__w/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/loop_integrals.hh Source File#

DiFfRG: /__w/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/loop_integrals.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
loop_integrals.hh
Go to the documentation of this file.
1#pragma once
2
3// standard library
4#include <cmath>
5
6// external libraries
7#include <deal.II/base/quadrature_lib.h>
8#include <tbb/tbb.h>
9
10// DiFfRG
12
13namespace DiFfRG
14{
15 using namespace dealii;
16
17 namespace LoopIntegrals
18 {
34 template <typename NT, int d, typename FUN>
35 NT integrate(const FUN &fun, const QGauss<1> &x_quadrature, const double x_extent, const double k)
36 {
37 const auto &x_q_p = x_quadrature.get_points();
38 const auto &x_q_w = x_quadrature.get_weights();
39 const int x_size = x_quadrature.size();
40
41 static_assert(d > 0, "Dimension must be greater than zero");
42 // Dimension of the spatial integral
43 const double S_d = 2. * std::pow(M_PI, d / 2.) / std::tgammal(d / 2.);
44 // Prefactor for the spatial integral
45 const double prefactor = S_d // angular integral
46 * powr<-d>(2. * M_PI); // fourier factors
47
48 const NT result = tbb::parallel_reduce(
49 tbb::blocked_range<int>(0, x_size), NT(0),
50 [&](const tbb::blocked_range<int> &r, NT running_total) -> NT {
51 const double q_max = std::sqrt(x_extent) * k;
52 for (int x_it = r.begin(); x_it < r.end(); x_it++) {
53 const double q = x_q_p[x_it][0] * q_max;
54 const double q_weight = x_q_w[x_it] * q_max;
55 const double q2 = powr<2>(q);
56
57 running_total += q_weight * prefactor * std::pow(q, d - 1) // integral over q in d dimensions
58 * fun(q2); // integrand
59 }
60 return running_total;
61 },
62 [](const NT a, const NT b) { return a + b; });
63 return result;
64 }
65 } // namespace LoopIntegrals
66} // namespace DiFfRG
NT integrate(const FUN &fun, const QGauss< 1 > &x_quadrature, const double x_extent, const double k)
Performs the integral.
Definition loop_integrals.hh:35
Definition complex_math.hh:10
constexpr KOKKOS_INLINE_FUNCTION double S_d(NT d)
Surface of a d-dimensional sphere.
Definition math.hh:99
constexpr KOKKOS_INLINE_FUNCTION NumberType powr(const NumberType x)
A compile-time evaluatable power function for whole number exponents.
Definition math.hh:41