/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/integration/finiteT/integrator_fT_p2.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/integration/finiteT/integrator_fT_p2.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
integrator_fT_p2.hh
Go to the documentation of this file.
1#pragma once
2
3// DiFfRG
6
7namespace DiFfRG
8{
9 namespace internal
10 {
11 template <int dim, typename NT, typename KERNEL> class Transform_fT_p2
12 {
13 public:
14 using ctype = typename get_type::ctype<NT>;
15 static constexpr int sdim = dim - 1; // spatial dimension
16
17 static constexpr ctype int_prefactor = S_d_prec<ctype>(sdim) // solid nd angle
18 / powr<sdim>(2 * (ctype)M_PI); // fourier factor
19
20 // Forward the kernel's Matsubara traits. The measure this adapter multiplies in is
21 // independent of the frequency, so it changes neither the parity in q0 nor the support in
22 // q0. Without this forwarding the traits are silently lost: QuadratureIntegrator_fT only
23 // ever sees the adapter, never KERNEL, so `matsubara_even` never fired for any
24 // Integrator_fT_p2* flow.
28
29 template <typename... T>
30 static KOKKOS_FORCEINLINE_FUNCTION NT kernel_finite_extent(const ctype q, const ctype q0, const T &...t)
31 {
32 using namespace DiFfRG::compute;
33
34 const ctype int_element = powr<sdim - 1>(q); // from p integral
35 return int_prefactor * int_element * KERNEL::kernel_finite_extent(q, q0, t...);
36 }
37
38 template <typename... T>
39 static KOKKOS_FORCEINLINE_FUNCTION NT kernel_tail(const ctype q, const ctype q0, const T &...t)
40 {
41 using namespace DiFfRG::compute;
42
43 const ctype int_element = powr<sdim - 1>(q); // from p integral
44 return int_prefactor * int_element * KERNEL::kernel_tail(q, q0, t...);
45 }
46
47 template <typename... T>
48 static KOKKOS_FORCEINLINE_FUNCTION NT kernel(const ctype q, const ctype q0, const T &...t)
49 {
50 using namespace DiFfRG::compute;
51
52 const ctype int_element = powr<sdim - 1>(q); // from p integral
53 const NT result = KERNEL::kernel(q, q0, t...);
54
55 return int_prefactor * int_element * result;
56 }
57
58 template <typename... T> static KOKKOS_FORCEINLINE_FUNCTION NT constant(const T &...t)
59 {
60 return NT(KERNEL::constant(t...));
61 }
62 };
63
64 } // namespace internal
65
66 template <int dim, typename NT, typename KERNEL, typename ExecutionSpace>
68 : public QuadratureIntegrator_fT<2, NT, internal::Transform_fT_p2<dim, NT, KERNEL>, ExecutionSpace>
69 {
71
72 public:
76 using ctype = typename get_type::ctype<NT>;
80 using execution_space = ExecutionSpace;
81
92 {
93 if (config.contains("/integration/force_exact_matsubara_sum"))
94 Base::set_allow_exact_matsubara_sum(config.get_bool("/integration/force_exact_matsubara_sum", false));
95 if (config.contains("/integration/matsubara_extent_margin"))
96 Base::set_matsubara_extent_margin(config.get_double("/integration/matsubara_extent_margin", 1.));
97 }
98
106
108 ctype x_extent = 2., ctype T = 1, ctype typical_E = 1)
109 : Base(quadrature_provider, grid_size, {0}, {std::sqrt(x_extent)}, {QuadratureType::legendre}, T, typical_E),
110 x_extent(x_extent), k(1.)
111 {
112 // The spatial grid is already cut at sqrt(x_extent) * k because the regulator dies there;
113 // the summand's support in FREQUENCY is the same ball, so the exact Matsubara sum can be cut
114 // at the same radius. See QuadratureIntegrator_fT::set_frequency_cutoff.
115 Base::set_frequency_cutoff(std::sqrt(this->x_extent) * this->k);
116 }
117
119 {
120 this->x_extent = x_extent;
121 Base::set_grid_extents({0}, {std::sqrt(x_extent) * k});
122 // The spatial grid is already cut at sqrt(x_extent) * k because the regulator dies there;
123 // the summand's support in FREQUENCY is the same ball, so the exact Matsubara sum can be cut
124 // at the same radius. See QuadratureIntegrator_fT::set_frequency_cutoff.
125 Base::set_frequency_cutoff(std::sqrt(this->x_extent) * this->k);
126 }
127
129 {
130 this->k = k;
131 Base::set_grid_extents({0}, {std::sqrt(x_extent) * k});
132 Base::set_k(k);
133 // The spatial grid is already cut at sqrt(x_extent) * k because the regulator dies there;
134 // the summand's support in FREQUENCY is the same ball, so the exact Matsubara sum can be cut
135 // at the same radius. See QuadratureIntegrator_fT::set_frequency_cutoff.
136 Base::set_frequency_cutoff(std::sqrt(this->x_extent) * this->k);
137 }
138
139 void set_typical_E(ctype typical_E) { Base::set_typical_E(typical_E); }
140
141 private:
144 };
145} // namespace DiFfRG
A hierarchical configuration tree, readable from JSON and TOML files.
Definition config_tree.hh:32
Definition integrator_fT_p2.hh:69
Integrator_fT_p2(QuadratureProvider &quadrature_provider, const std::array< size_t, 1 > grid_size, ctype x_extent=2., ctype T=1, ctype typical_E=1)
Definition integrator_fT_p2.hh:107
ExecutionSpace execution_space
Execution space to be used for the integration, e.g. GPU_exec, TBB_exec.
Definition integrator_fT_p2.hh:80
typename get_type::ctype< NT > ctype
Numerical type to be used for integration tasks e.g. the argument or possible jacobians.
Definition integrator_fT_p2.hh:76
void set_k(ctype k)
Definition integrator_fT_p2.hh:128
ctype x_extent
Definition integrator_fT_p2.hh:142
ctype k
Definition integrator_fT_p2.hh:143
void set_x_extent(ctype x_extent)
Definition integrator_fT_p2.hh:118
void set_typical_E(ctype typical_E)
Definition integrator_fT_p2.hh:139
Integrator_fT_p2(QuadratureProvider &quadrature_provider, const ConfigTree &config)
Definition integrator_fT_p2.hh:99
void apply_matsubara_overrides(const ConfigTree &config)
Apply the /integration/force_exact_matsubara_sum override, if the model sets it.
Definition integrator_fT_p2.hh:91
Definition quadrature_integrator_fT.hh:54
QuadratureProvider & quadrature_provider
Definition quadrature_integrator_fT.hh:794
void set_matsubara_extent_margin(const ctype margin)
Definition quadrature_integrator_fT.hh:187
void set_allow_exact_matsubara_sum(const bool allow)
Definition quadrature_integrator_fT.hh:180
void set_frequency_cutoff(const ctype freq_cutoff)
Definition quadrature_integrator_fT.hh:165
void set_typical_E(const ctype typical_E)
Definition quadrature_integrator_fT.hh:142
void set_grid_extents(const std::array< ctype, sdim > grid_min, const std::array< ctype, sdim > grid_max)
Definition quadrature_integrator_fT.hh:94
device::array< size_t, dim > grid_size
Definition quadrature_integrator_fT.hh:799
A class that provides quadrature points and weights, in host and device memory. The quadrature points...
Definition quadrature_provider.hh:239
Definition integrator_fT_p2.hh:12
static KOKKOS_FORCEINLINE_FUNCTION NT kernel_finite_extent(const ctype q, const ctype q0, const T &...t)
Definition integrator_fT_p2.hh:30
typename get_type::ctype< NT > ctype
Definition integrator_fT_p2.hh:14
static constexpr bool matsubara_split
Definition integrator_fT_p2.hh:27
static constexpr bool matsubara_even
Definition integrator_fT_p2.hh:25
static KOKKOS_FORCEINLINE_FUNCTION NT kernel(const ctype q, const ctype q0, const T &...t)
Definition integrator_fT_p2.hh:48
static constexpr ctype int_prefactor
Definition integrator_fT_p2.hh:17
static constexpr int sdim
Definition integrator_fT_p2.hh:15
static constexpr bool matsubara_finite_extent
Definition integrator_fT_p2.hh:26
static KOKKOS_FORCEINLINE_FUNCTION NT constant(const T &...t)
Definition integrator_fT_p2.hh:58
static KOKKOS_FORCEINLINE_FUNCTION NT kernel_tail(const ctype q, const ctype q0, const T &...t)
Definition integrator_fT_p2.hh:39
Definition abstract_integrator.hh:38
Definition math.hh:229
typename internal::_ctype< CT >::value ctype
Definition types.hh:76
std::array< size_t, dim > make_int_grid(const ConfigTree &config, const std::array< std::string, dim > &names)
Definition abstract_integrator.hh:23
Definition complex_math.hh:10
constexpr bool kernel_is_matsubara_even
Definition quadrature_integrator_fT.hh:28
constexpr bool kernel_has_finite_matsubara_extent
Definition quadrature_integrator_fT.hh:37
@ config
/discretization/threads.
constexpr KOKKOS_INLINE_FUNCTION NumberType powr(const NumberType x)
A compile-time evaluatable power function for whole number exponents.
Definition math.hh:50
consteval NT S_d_prec(uint d)
Surface of a d-dimensional sphere (precompiled)
Definition math.hh:121
constexpr bool kernel_has_matsubara_split
Definition quadrature_integrator_fT.hh:49
double optimize_x_extent(const ConfigTree &config)
Definition optimize.hh:8
@ legendre
Definition quadrature.hh:45