/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/loop_integrals.hh Source File#

DiFfRG: /home/runner/work/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 // Summed serially on purpose: tbb::parallel_reduce would make the summation order depend on
49 // work stealing, and the result of this integral is compared against a tolerance in
50 // optimize_x_extent(). A last-bit difference there can flip the convergence test and change
51 // x_extent - the upper limit of every subsequent momentum integral - by a factor of 1.15.
52 // The grids here are a few thousand points and this runs a handful of times at startup, so
53 // there is nothing to gain from parallelising it.
54 NT result(0);
55 const double q_max = std::sqrt(x_extent) * k;
56 for (int x_it = 0; x_it < x_size; x_it++) {
57 const double q = x_q_p[x_it][0] * q_max;
58 const double q_weight = x_q_w[x_it] * q_max;
59 const double q2 = powr<2>(q);
60
61 result += q_weight * prefactor * std::pow(q, d - 1) // integral over q in d dimensions
62 * fun(q2); // integrand
63 }
64 return result;
65 }
66 } // namespace LoopIntegrals
67} // 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:108
constexpr KOKKOS_INLINE_FUNCTION NumberType powr(const NumberType x)
A compile-time evaluatable power function for whole number exponents.
Definition math.hh:50