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

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/integration/finiteT/integrator_fT_p2_4d_2ang.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
integrator_fT_p2_4d_2ang.hh
Go to the documentation of this file.
1#pragma once
2
3// DiFfRG
6
7namespace DiFfRG
8{
9 namespace internal
10 {
11 template <typename NT, typename KERNEL> class Transform_fT_p2_4D_2ang
12 {
13 public:
14 using ctype = typename get_type::ctype<NT>;
15
16 static constexpr ctype int_prefactor = powr<-3>((ctype)2 * M_PI); // fourier factor
17
18 // Forward the kernel's Matsubara traits. The measure this adapter multiplies in is
19 // independent of the frequency, so it changes neither the parity in q0 nor the support in
20 // q0. Without this forwarding the traits are silently lost: QuadratureIntegrator_fT only
21 // ever sees the adapter, never KERNEL, so `matsubara_even` never fired for any
22 // Integrator_fT_p2* flow.
26
27 template <typename... T>
28 static KOKKOS_FORCEINLINE_FUNCTION NT kernel_finite_extent(const ctype q, const ctype cos1, const ctype phi,
29 const ctype q0, const T &...t)
30 {
31 using namespace DiFfRG::compute;
32
33 const ctype int_element = powr<3 - 1>(q); // from p integral
34 return int_prefactor * int_element * KERNEL::kernel_finite_extent(q, cos1, phi, q0, t...);
35 }
36
37 template <typename... T>
38 static KOKKOS_FORCEINLINE_FUNCTION NT kernel_tail(const ctype q, const ctype cos1, const ctype phi,
39 const ctype q0, const T &...t)
40 {
41 using namespace DiFfRG::compute;
42
43 const ctype int_element = powr<3 - 1>(q); // from p integral
44 return int_prefactor * int_element * KERNEL::kernel_tail(q, cos1, phi, q0, t...);
45 }
46
47 template <typename... T>
48 static KOKKOS_FORCEINLINE_FUNCTION NT kernel(const ctype q, const ctype cos1, const ctype phi, const ctype q0,
49 const T &...t)
50 {
51 using namespace DiFfRG::compute;
52
53 const ctype int_element = powr<3 - 1>(q); // from p integral
54
55 const NT result = KERNEL::kernel(q, cos1, phi, q0, t...);
56
57 return int_prefactor * int_element * result;
58 }
59
60 template <typename... T> static KOKKOS_FORCEINLINE_FUNCTION NT constant(const T &...t)
61 {
62 return KERNEL::constant(t...);
63 }
64 };
65 } // namespace internal
66
67 template <int dim, typename NT, typename KERNEL, typename ExecutionSpace>
68 requires(dim == 4)
70 : public QuadratureIntegrator_fT<4, NT, internal::Transform_fT_p2_4D_2ang<NT, KERNEL>, ExecutionSpace>
71 {
73
74 public:
78 using ctype = typename get_type::ctype<NT>;
82 using execution_space = ExecutionSpace;
83
94 {
95 if (config.contains("/integration/force_exact_matsubara_sum"))
96 Base::set_allow_exact_matsubara_sum(config.get_bool("/integration/force_exact_matsubara_sum", false));
97 if (config.contains("/integration/matsubara_extent_margin"))
98 Base::set_matsubara_extent_margin(config.get_double("/integration/matsubara_extent_margin", 1.));
99 }
100
104 quadrature_provider, internal::make_int_grid<3, NT>(config, {"x_order", "cos1_order", "phi_order"}),
105 optimize_x_extent<typename KERNEL::Regulator>(config), config.get_double("/physical/T", 1.0))
106 {
107 apply_matsubara_overrides(config);
108 }
109
110 Integrator_fT_p2_4D_2ang(QuadratureProvider &quadrature_provider, const std::array<size_t, 3> grid_size,
111 ctype x_extent = 2., ctype T = 1, ctype typical_E = 1)
112 // The azimuthal angle phi in [0,2pi) has a smooth 2pi-periodic integrand; the periodic trapezoidal
113 // rule integrates it with spectral (exponential) accuracy, unlike Gauss-Legendre.
114 : Base(quadrature_provider, grid_size, {0, -1, 0}, {std::sqrt(x_extent), 1, 2 * M_PI},
116 x_extent(x_extent), k(1.)
117 {
118 // The spatial grid is already cut at sqrt(x_extent) * k because the regulator dies there;
119 // the summand's support in FREQUENCY is the same ball, so the exact Matsubara sum can be cut
120 // at the same radius. See QuadratureIntegrator_fT::set_frequency_cutoff.
121 Base::set_frequency_cutoff(std::sqrt(this->x_extent) * this->k);
122 }
123
124 void set_x_extent(ctype x_extent)
125 {
126 this->x_extent = x_extent;
127 Base::set_grid_extents({0, -1, 0}, {std::sqrt(x_extent) * k, 1, 2 * M_PI});
128 // The spatial grid is already cut at sqrt(x_extent) * k because the regulator dies there;
129 // the summand's support in FREQUENCY is the same ball, so the exact Matsubara sum can be cut
130 // at the same radius. See QuadratureIntegrator_fT::set_frequency_cutoff.
131 Base::set_frequency_cutoff(std::sqrt(this->x_extent) * this->k);
132 }
133
134 void set_k(ctype k)
135 {
136 this->k = k;
137 Base::set_grid_extents({0, -1, 0}, {std::sqrt(x_extent) * k, 1, 2 * M_PI});
138 Base::set_k(k);
139 // The spatial grid is already cut at sqrt(x_extent) * k because the regulator dies there;
140 // the summand's support in FREQUENCY is the same ball, so the exact Matsubara sum can be cut
141 // at the same radius. See QuadratureIntegrator_fT::set_frequency_cutoff.
142 Base::set_frequency_cutoff(std::sqrt(this->x_extent) * this->k);
143 }
144
145 void set_typical_E(ctype typical_E) { Base::set_typical_E(typical_E); }
146
147 private:
150 };
151} // namespace DiFfRG
A hierarchical configuration tree, readable from JSON and TOML files.
Definition config_tree.hh:32
Definition integrator_fT_p2_4d_2ang.hh:71
ctype x_extent
Definition integrator_fT_p2_4d_2ang.hh:148
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_4d_2ang.hh:78
ExecutionSpace execution_space
Execution space to be used for the integration, e.g. GPU_exec, TBB_exec.
Definition integrator_fT_p2_4d_2ang.hh:82
void set_x_extent(ctype x_extent)
Definition integrator_fT_p2_4d_2ang.hh:124
Integrator_fT_p2_4D_2ang(QuadratureProvider &quadrature_provider, const std::array< size_t, 3 > grid_size, ctype x_extent=2., ctype T=1, ctype typical_E=1)
Definition integrator_fT_p2_4d_2ang.hh:110
ctype k
Definition integrator_fT_p2_4d_2ang.hh:149
Integrator_fT_p2_4D_2ang(QuadratureProvider &quadrature_provider, const ConfigTree &config)
Definition integrator_fT_p2_4d_2ang.hh:101
void set_typical_E(ctype typical_E)
Definition integrator_fT_p2_4d_2ang.hh:145
void set_k(ctype k)
Definition integrator_fT_p2_4d_2ang.hh:134
void apply_matsubara_overrides(const ConfigTree &config)
Apply the /integration/force_exact_matsubara_sum override, if the model sets it.
Definition integrator_fT_p2_4d_2ang.hh:93
Definition quadrature_integrator_fT.hh:54
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_4d_2ang.hh:12
static constexpr bool matsubara_finite_extent
Definition integrator_fT_p2_4d_2ang.hh:24
static KOKKOS_FORCEINLINE_FUNCTION NT kernel_finite_extent(const ctype q, const ctype cos1, const ctype phi, const ctype q0, const T &...t)
Definition integrator_fT_p2_4d_2ang.hh:28
static KOKKOS_FORCEINLINE_FUNCTION NT kernel_tail(const ctype q, const ctype cos1, const ctype phi, const ctype q0, const T &...t)
Definition integrator_fT_p2_4d_2ang.hh:38
static constexpr bool matsubara_even
Definition integrator_fT_p2_4d_2ang.hh:23
static constexpr bool matsubara_split
Definition integrator_fT_p2_4d_2ang.hh:25
static KOKKOS_FORCEINLINE_FUNCTION NT constant(const T &...t)
Definition integrator_fT_p2_4d_2ang.hh:60
static constexpr ctype int_prefactor
Definition integrator_fT_p2_4d_2ang.hh:16
static KOKKOS_FORCEINLINE_FUNCTION NT kernel(const ctype q, const ctype cos1, const ctype phi, const ctype q0, const T &...t)
Definition integrator_fT_p2_4d_2ang.hh:48
typename get_type::ctype< NT > ctype
Definition integrator_fT_p2_4d_2ang.hh:14
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 bool kernel_has_matsubara_split
Definition quadrature_integrator_fT.hh:49
double optimize_x_extent(const ConfigTree &config)
Definition optimize.hh:8
@ trapezoidal
Definition quadrature.hh:45
@ legendre
Definition quadrature.hh:45