g2tools
Module¶
Moments¶
The main tools for creating and manipulating moments are:
-
g2tools.
moments
(G, Z=1.0, ainv=1.0, periodic=True, nlist=[4, 6, 8, 10, 12, 14, 16, 18, 20])¶ Compute t**n moments of correlator G.
Compute
sum_t t**n G(t)
forn
innlist
, where both positive and negativet
are included.Parameters: - G – Array of correlator values
G[t]
fort=0,1...
. - Z – Renormalization factor for current (moments multiplied by
Z**2
). Defaul is 1. - ainv – Inverse lattice spacing used to convert moments to
physical units (n-th moment multiplied by
1/ainv**(n-2)
). Default is 1. - periodic –
periodic=True
impliesG[-t] = G[t]
(default);periodic=False
implies no periodicity in arrayG[t]
(and results doubled to account for negativet
). - nlist – List of moments to calculate. Default is
nlist=[4,6,8...20]
.
Returns: Dictionary
Gmom
whereGmom[n]
is then-th
moment.- G – Array of correlator values
-
g2tools.
mom2taylor
(mom)¶ Convert moments in dictionary
mom
into Taylor series coefficients.
-
g2tools.
taylor2mom
(tayl)¶ Convert Taylor coefficients in array
tayl
to moments.
Subtracted Vacuum Polarization¶
A subtracted vacuum polarization function (Pi-hat
) is
represented by the following classes:
-
class
g2tools.
vacpol
(g, order=None, scale=None, rtol=None, warn=False)¶ Subtracted vac. pol’n (
Pi-hat(q2)
) from correlator momentsGmon[n]
.The vacuum polarization function is a Pade approximant to the Taylor series corresponding to the moments
g[n]
. The code estimates the precision of the moments and sets the tolerance for the Pade determination accordingly. The order(m,n)
of the Pade can be specified, but might be reduced by the code if the data are noisy.vacpol
objects are used primarily as functions (of q2) but also have several attributes. Attributepseries
is a dictionary containing various powerseries (seegvar.powerseries
) describing the function: the vacuum polarization function isq2
times a Pade approximant with a numerator given bypseries['num']
and a denominator given bypseries['den']
. The Taylor series for this function is given byq2
timespseries['taylor']
.vacpol
objects also have a methodvacpol.badpoles()
that tests the poles in the denomator of the Pade.badpoles(qth)
returnsFalse
if any of the poles is complex or if any are located above-(qth ** 2)
.qth
should be set equal to the threshold energy for the correlator. If it is unset,qth=0
is used.vacpol
has several static methods for creating specialized examples of vacuum polarizations (e.g., for testing):vacpol.fermion(m)
– 1-loop fermion (massm
) contribution;vacpol.scalar(m)
– 1-loop scalar (massm
) contribution;vacpol.vector(m, f)
– tree-level contribution from vectorwith mass
m
and decay constantf
.
Parameters: - g – Dictionary containing moments where
g[n] = sum_t t**n G(t)
, or array containing Taylor coefficients wherePi-hat(q2) = q2 * sum_j q2**j * g[j]
. - order – Tuple
(m,n)
specifying the order of the Pade approximant used to approximate the function. The order may be reduced (automatically) if the data are too noisy. If the order is not specified, it is set automatically according to the number of entries inG
. - scale – Scale factor used to rescale
q2
so that the Taylor coefficients are more uniform in size. This is normally set automatically (from the first two moments), but the automatic value is overridden ifscale
is set. - rtol – Relative tolerance assumed when determining the
Pade approximant. This is normally set automatically
(from the standard deviations of the moments), but the
automatic value is overridden if
rtol
is specified. - warn –
warn=True
causes a warning to be issued when there are bad poles in the Pade or when the order has been reduced automatically.warn=False
(default) suppresses the warnings.
-
class
g2tools.
fourier_vacpol
(G, Z=1.0, ainv=1.0, periodic=True)¶ Subtracted vac. pol’n (
Pi-hat(q2)
) from correlatorG(t)
.The correlator is Fourier transformed to produce a function
Pi_hat
of (Euclidean) q2 suitable for use ing2tools.a_mu()
.See Bernecker & Meyer, EPJA47 (2011) 148 , arXiv:1107.4388 for details on the Fouier transformation.
Parameters: - G (array) – Current-current correlator in an array whose elements
are
[G(0),G(a),G(2*a),...,G(-2*a),G(-a)]
ifperiodic=True
or[G(0),G(a),...,G(T*a-1)]
otherwise. - Z – Renormalization factor for current (moments multiplied by
Z**2
). Defaul is 1. - ainv – Inverse lattice spacing used to convert moments to
physical units (n-th moment multiplied by
1/ainv**(n-2)
). Default is 1. - periodic –
periodic=True
impliesG[-t] = G[t]
(default);periodic=False
implies no periodicity in arrayG[t]
(and results doubled to account for negativet
).
- G (array) – Current-current correlator in an array whose elements
are
Padé Approximants¶
The following two functions are used for calculating Padé approximants from
the Taylor coefficients of an arbitrary function. The first
(g2tools.pade_svd()
) implements an algorithm that uses svd cuts to
address instabilities caused by uncertainties in the Taylor coefficients. The
second function (g2tools.pade_gvar()
) is built on the first but allows
Taylor coefficients to have uncertainties (gvar.GVar
s). The statistical
uncertainties and correlations between different coefficients are propagated
through the analysis.
-
g2tools.
pade_svd
(f, m, n, rtol=1e-14)¶ [m,n]
Pade approximant tosum_i f[i] x**i
.The
[m,n]
Pade approximant to a series given bysum_i f[i] * x**i
is the ratio of polynomials of orderm
(numerator) andn
(denominator) whose Taylor expansion agrees with that of the original series up to orderm+n
.This code is adapted from P. Gonnet, S. Guttel, L. N. Trefethen, SIAM Review Vol 55, No. 1, 101 (2013). It uses an svd algorithm to deal with imprecision in the input data, here specified by the relative tolerance
rtol
for the input coefficientsf[i]
. It automatically reduces the order of the approximant if the extraction of Pade coefficients is too unstable given tolerancertol
.Parameters: - f – Array
f[i]
of power series coefficients fori=0...n+m
. - m – Maximum order of polynomial in numerator of Pade
approximant (
m>=0
). - n – Maximum order of polynomial in denominator of Pade
approximant (
m>=0
). - rtol – Relative accuracy of input coefficients.
Returns: Tuple of power series coefficients
(p, q)
such thatsum_i p[i] x**i
is the numerator of the approximant, andsum_i q[i] x**i
is the denominator.q[0]
is normalized to 1.- f – Array
-
g2tools.
pade_gvar
(f, m, n, rtol=None)¶ [m,n]
Pade approximant tosum_i f[i] x**i
forGVar
s.The
[m,n]
Pade approximant to a series given bysum_i f[i] * x**i
is the ratio of polynomials of orderm
(numerator) andn
(denominator) whose Taylor expansion agrees with that of the original series up to orderm+n
.This code uses an svd algorithm (see
pade_svd()
) to deal with imprecision in the input data. It automatically reduces the order of the approximant if the extraction of Pade coefficients is too unstable given noise in the input data.Parameters: - f – Array
f[i]
of power series coefficients fori=0...n+m
. - m – Maximum order of polynomial in numerator of Pade
approximant (
m>=0
). - n – Maximum order of polynomial in denominator of Pade
approximant (
m>=0
). - rtol – Relative accuracy of input coefficients. Overrides
default estimate from the
f[i]
unless set equal toNone
.
Returns: Tuple of power series coefficients
(p, q)
such thatsum_i p[i] x**i
is the numerator of the approximant, andsum_i q[i] x**i
is the denominator.q[0]
is normalized to 1.- f – Array