MatsubaraQuadrature< NT > Class Template Reference#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
A quadrature rule for (bosonic) Matsubara frequencies, based on the method of Monien [1]. This class provides nodes and weights for the summation. More...
#include <matsubara.hh>
Public Member Functions | |
| MatsubaraQuadrature (const NT T, const NT typical_E=1., const int step=2, const int min_size=8, const int max_size=128, const int vacuum_quad_size=64, const double precision_factor=1) | |
| Create a new quadrature rule for Matsubara frequencies. | |
| MatsubaraQuadrature () | |
| void | reinit (const NT T, const NT typical_E=1., const int step=2, const int min_size=8, const int max_size=128, const int vacuum_quad_size=64, const double precision_factor=1) |
| Update the quadrature rule with new parameters. | |
| void | reinit_with_size (const int size, const NT T, const NT typical_E=1.) |
| Build a rule with an explicitly prescribed number of nodes, bypassing predict_size(). | |
| void | reinit_exact_sum (const NT T, const NT freq_cutoff) |
| Build the EXACT Matsubara sum for a summand of finite extent in the frequency. | |
| void | reinit_finite_interval (const NT cutoff, const Kokkos::View< const NT *, CPU_memory > gl_nodes, const Kokkos::View< const NT *, CPU_memory > gl_weights) |
| Gauss-Legendre over the FINITE interval the summand actually lives on. | |
| size_t | size () const |
| Get the size of the quadrature rule, NOT counting the zero mode. | |
| size_t | sum_size () const |
| Size of the node list returned by sum_nodes()/sum_weights(): size() plus the zero mode, where there is one (i.e. everywhere but the T=0 rule). | |
| NT | get_T () const |
| Get the temperature of the quadrature rule. | |
| NT | get_typical_E () const |
| Get the typical energy scale of the quadrature rule. | |
| template<typename F > | |
| auto | sum (const F &f) const |
| Compute a matsubara sum of a given function. | |
| template<typename MemorySpace > | |
| Kokkos::View< const NT *, MemorySpace > | nodes () const |
| The positive-frequency nodes, without the zero mode. Length size(). | |
| template<typename MemorySpace > | |
| Kokkos::View< const NT *, MemorySpace > | weights () const |
| template<typename MemorySpace > | |
| Kokkos::View< const NT *, MemorySpace > | sum_nodes () const |
| Node list for a device-side sum: the positive frequencies followed by the zero mode. | |
| template<typename MemorySpace > | |
| Kokkos::View< const NT *, MemorySpace > | sum_weights () const |
Static Public Member Functions | |
| static int | predict_size (const NT T, const NT typical_E=1., const double precision_factor=1., const int step=2) |
Nodes the Monien rule needs to reach past typical_E at this temperature. | |
| static int | modes_below (const NT T, const NT freq_cutoff) |
| Number of positive Matsubara modes strictly inside a frequency cutoff. | |
Private Member Functions | |
| template<typename MemorySpace > | |
| Kokkos::View< const NT *, MemorySpace > | raw_nodes () const |
| template<typename MemorySpace > | |
| Kokkos::View< const NT *, MemorySpace > | raw_weights () const |
| void | build_monien () |
| Construct the Monien rule for the current m_size and T. | |
| void | reinit_0 () |
| Construct a quadrature rule for T=0. | |
| void | write_data (const std::vector< NT > &x, const std::vector< NT > &w) |
| Store x/w plus the appended zero mode; see sum_nodes(). x and w have m_size entries. | |
Private Attributes | |
| NT | T |
| NT | typical_E |
| Kokkos::View< NT *, GPU_memory > | device_nodes |
| Kokkos::View< NT *, GPU_memory > | device_weights |
| Kokkos::View< NT *, CPU_memory > | host_nodes |
| Kokkos::View< NT *, CPU_memory > | host_weights |
| int | m_size |
| The number of nodes in the quadrature rule. | |
| int | vacuum_quad_size |
| double | precision_factor |
Detailed Description
class DiFfRG::MatsubaraQuadrature< NT >
A quadrature rule for (bosonic) Matsubara frequencies, based on the method of Monien [1]. This class provides nodes and weights for the summation.
\[ T \sum_{n=\in \mathbb{Z}} f(2\pi n T) \approx \sum_{n=1}^{N} w_i (f(x_i) + f(-x_i)) + T f(0) \]
[1] H. Monien, "Gaussian quadrature for sums: a rapidly convergent summation scheme", Math. Comp. 79, 857 (2010). doi:10.1090/S0025-5718-09-02289-3
- Template Parameters
-
NT numeric type to be used for all calculations
Constructor & Destructor Documentation
◆ MatsubaraQuadrature() [1/2]
| DiFfRG::MatsubaraQuadrature< NT >::MatsubaraQuadrature | ( | const NT | T, |
| const NT | typical_E = 1., | ||
| const int | step = 2, | ||
| const int | min_size = 8, | ||
| const int | max_size = 128, | ||
| const int | vacuum_quad_size = 64, | ||
| const double | precision_factor = 1 ) |
Create a new quadrature rule for Matsubara frequencies.
- Parameters
-
T The temperature. Zero selects the vacuum rule; this is the only thing that does. typical_E The largest scale to cover, which determines the number of nodes. step The step size of considered node sizes (e.g. step=2 implies only even numbers of nodes). min_size Minimum number of nodes. max_size Node ceiling. A rule that wants more is clamped to it, and warns once. vacuum_quad_size Size of the vacuum rule, which a T of zero selects. precision_factor Multiplies the reach; the user-facing dial.
- Note
- These defaults are kept equal to the ConfigTree defaults read by QuadratureProvider (/integration/{min,max}_matsubara_size, vacuum_quad_size, matsubara_precision_factor), so that a directly constructed rule behaves like one a production run would build.
◆ MatsubaraQuadrature() [2/2]
| DiFfRG::MatsubaraQuadrature< NT >::MatsubaraQuadrature | ( | ) |
Member Function Documentation
◆ build_monien()
|
private |
Construct the Monien rule for the current m_size and T.
◆ get_T()
| NT DiFfRG::MatsubaraQuadrature< NT >::get_T | ( | ) | const |
Get the temperature of the quadrature rule.
◆ get_typical_E()
| NT DiFfRG::MatsubaraQuadrature< NT >::get_typical_E | ( | ) | const |
Get the typical energy scale of the quadrature rule.
◆ modes_below()
|
static |
Number of positive Matsubara modes strictly inside a frequency cutoff.
2 pi n T <= freq_cutoff, i.e. floor(freq_cutoff / (2 pi T)). Zero is a legitimate answer: below freq_cutoff = 2 pi T the whole sum is the zero mode.
◆ nodes()
|
inline |
The positive-frequency nodes, without the zero mode. Length size().
◆ predict_size()
|
static |
Nodes the Monien rule needs to reach past typical_E at this temperature.
The sizing law and nothing else: no ceiling, no floor, and no choice of rule. Which rule a summand deserves depends on its whole spectrum, and typical_E is only the top of it – that decision belongs to the caller, which is QuadratureIntegrator_fT::refresh_matsubara.
- Parameters
-
T The temperature. Zero returns zero: the vacuum rule is an integral, not a sum. typical_E The LARGEST scale the rule has to cover; the reach is a fixed multiple of it. precision_factor Multiplies the reach; the user-facing dial. step The step size of considered node sizes (e.g. step=2 implies only even numbers of nodes).
◆ raw_nodes()
|
inlineprivate |
◆ raw_weights()
|
inlineprivate |
◆ reinit()
| void DiFfRG::MatsubaraQuadrature< NT >::reinit | ( | const NT | T, |
| const NT | typical_E = 1., | ||
| const int | step = 2, | ||
| const int | min_size = 8, | ||
| const int | max_size = 128, | ||
| const int | vacuum_quad_size = 64, | ||
| const double | precision_factor = 1 ) |
Update the quadrature rule with new parameters.
- Parameters
-
T The temperature. typical_E A typical energy scale, which determines the number of nodes in the quadrature rule. step The step size of considered node sizes (e.g. step=2 implies only even numbers of nodes). min_size Minimum number of nodes. max_size Node ceiling. A rule that wants more is clamped to it, and warns once. vacuum_quad_size Size of the vacuum rule, which a T of zero selects. precision_factor Multiplies the reach; the user-facing dial.
- Note
- These defaults are kept equal to the ConfigTree defaults read by QuadratureProvider (/integration/{min,max}_matsubara_size, vacuum_quad_size, matsubara_precision_factor), so that a directly constructed rule behaves like one a production run would build.
◆ reinit_0()
|
private |
Construct a quadrature rule for T=0.
◆ reinit_exact_sum()
| void DiFfRG::MatsubaraQuadrature< NT >::reinit_exact_sum | ( | const NT | T, |
| const NT | freq_cutoff ) |
Build the EXACT Matsubara sum for a summand of finite extent in the frequency.
When every term carries a dR/dt insertion whose argument confines the loop frequency, the summand is identically zero for |p0| > freq_cutoff and
\[ T \sum_{n\in\mathbb Z} f(2\pi n T) = T f(0) + T \sum_{n=1}^{N} (f(\omega_n)+f(-\omega_n)) \]
with \(N = \) modes_below() is not an approximation but the sum itself. Nodes are the true frequencies and every weight is \(T\), which is what the caller convention of sum() already expects – so this is a drop-in replacement for the Monien rule, differing only in how many nodes it needs.
Below the crossover this is dramatically cheaper (at k/T ~ 10 it is one node against a 44-node Monien rule) AND exact; above it, it is more expensive, so the caller is expected to pick whichever rule is smaller. The cutoff is a property of the regulator's support, not of the temperature: for a 4D regulator with extent x_extent in q^2/k^2 it is sqrt(x_extent) * k.
- Parameters
-
T The temperature. Must be positive; at T=0 there is nothing to sum. freq_cutoff The frequency beyond which the summand vanishes.
◆ reinit_finite_interval()
| void DiFfRG::MatsubaraQuadrature< NT >::reinit_finite_interval | ( | const NT | cutoff, |
| const Kokkos::View< const NT *, CPU_memory > | gl_nodes, | ||
| const Kokkos::View< const NT *, CPU_memory > | gl_weights ) |
Gauss-Legendre over the FINITE interval the summand actually lives on.
The third rule, for a summand of finite extent in a regime where the caller has decided the sum may be replaced by an integral. The T=0 rule reaches that regime by the tangent map p0 = E tan(theta), which is built to cover an algebraic 1/p0^2 tail out to ~1e15 E – and for a summand that dies out past R = sqrt(x_extent) k that is a poor use of nodes twice over: only atan(R/E) / (pi/2) = 57% of the theta range carries any integrand at all (28 of 64 nodes evaluate an exact zero), and the ones that are wasted are the HEAVY ones, since the tangent map's weights ~ 1/cos^2(theta) grow towards the end it is throwing away. It also converges badly, being asked to resolve a near-discontinuity at the support edge with the ~36 nodes that remain.
Over [-R, R] there is no tail worth covering, so plain Gauss-Legendre is both cheaper and more accurate, and the frequency direction becomes just another radial direction: for a 4D regulator p0 and |q| enter the support on the same footing, which is why the natural order for this rule is the SPATIAL x_order rather than vacuum_quad_size.
R is not a true support boundary but the radius optimize_x_extent() converged to, so cutting there is a systematic error in its own right. Measured on the assembled 3+1D integrand (Part 13 of the convergence study): 3.5e-10 for PolynomialExp<8>, 3.0e-10 for Exponential<2>, at the shipped x_extent_tolerance. That is well below the aliasing error this rule exists to avoid, but it is not zero.
Caller convention as in sum(): \(\sum_i w_i (f(x_i)+f(-x_i)) = \frac{1}{2\pi}\int_{-R}^{R} f\,dp_0\), i.e. \(x_i = R u_i\) and \(w_i = R v_i / 2\pi\) for Gauss-Legendre nodes/weights \((u_i, v_i)\) on [0,1]. No zero mode: like the T=0 rule this integrates rather than sums.
- Parameters
-
cutoff The frequency R beyond which the summand vanishes. Must be positive. gl_nodes Gauss-Legendre nodes on [0,1] – passed in so the (cached) rule is not rebuilt for every cutoff; only the scaling depends on R. gl_weights The matching weights, summing to 1.
◆ reinit_with_size()
| void DiFfRG::MatsubaraQuadrature< NT >::reinit_with_size | ( | const int | size, |
| const NT | T, | ||
| const NT | typical_E = 1. ) |
Build a rule with an explicitly prescribed number of nodes, bypassing predict_size().
This is the entry point for convergence studies: it answers "what accuracy does N nodes
buy at this (T, typical_E)", which is the question predict_size() encodes an answer to. A T of zero selects the vacuum (T=0) rule with size nodes, exactly as reinit() would.
- Parameters
-
size The number of nodes to use. Must be positive. T The temperature. typical_E A typical energy scale. Only sets the scale of the vacuum rule; the Monien rule's nodes depend on T alone once the size is fixed.
◆ size()
| size_t DiFfRG::MatsubaraQuadrature< NT >::size | ( | ) | const |
Get the size of the quadrature rule, NOT counting the zero mode.
◆ sum()
|
inline |
Compute a matsubara sum of a given function.
- Template Parameters
-
F The function type.
- Parameters
-
f The function to be summed. Must have signature NT f(NT x).
- Returns
- NT The Matsubara sum of the function.
◆ sum_nodes()
|
inline |
Node list for a device-side sum: the positive frequencies followed by the zero mode.
The zero mode is appended as a node like any other – x = 0 with weight T/2 – so that the w * (f(+x) + f(-x)) body that evaluates every other node reproduces T f(0) exactly, with no branch. That matters twice over: a idx == 0 ? T*f(0) : 0 guard around a kernel call costs the whole warp a full extra kernel evaluation for one active lane, and the exact exact sum can legitimately have ZERO positive modes in the deep IR, where a rule that carries its zero mode outside the node list would integrate to nothing at all.
Empty for the T=0 rule, where there is no zero mode to add (it has weight zero).
◆ sum_size()
| size_t DiFfRG::MatsubaraQuadrature< NT >::sum_size | ( | ) | const |
Size of the node list returned by sum_nodes()/sum_weights(): size() plus the zero mode, where there is one (i.e. everywhere but the T=0 rule).
◆ sum_weights()
|
inline |
◆ weights()
|
inline |
◆ write_data()
|
private |
Store x/w plus the appended zero mode; see sum_nodes(). x and w have m_size entries.
Member Data Documentation
◆ device_nodes
|
private |
◆ device_weights
|
private |
◆ host_nodes
|
private |
◆ host_weights
|
private |
◆ m_size
|
private |
The number of nodes in the quadrature rule.
◆ precision_factor
|
private |
◆ T
|
private |
◆ typical_E
|
private |
◆ vacuum_quad_size
|
private |
The documentation for this class was generated from the following file:
- /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/common/quadrature/matsubara.hh
Generated by