mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
npr doc extended, CObs now have real and imag properties
This commit is contained in:
parent
e7efa822b0
commit
7efe9612bc
2 changed files with 25 additions and 9 deletions
|
@ -38,7 +38,7 @@ class Npr_matrix(np.ndarray):
|
||||||
if s_mom is not None and o_mom is not None:
|
if s_mom is not None and o_mom is not None:
|
||||||
if not np.allclose(s_mom, o_mom):
|
if not np.allclose(s_mom, o_mom):
|
||||||
raise Exception(name + ' does not match.')
|
raise Exception(name + ' does not match.')
|
||||||
return o_mom if o_mom else s_mom
|
return o_mom if o_mom is not None else s_mom
|
||||||
|
|
||||||
def __matmul__(self, other):
|
def __matmul__(self, other):
|
||||||
return self.__new__(Npr_matrix,
|
return self.__new__(Npr_matrix,
|
||||||
|
@ -65,13 +65,23 @@ def _check_geometry():
|
||||||
raise Exception("Temporal extent 'T' must be an integer.")
|
raise Exception("Temporal extent 'T' must be an integer.")
|
||||||
|
|
||||||
|
|
||||||
def _invert_propagator(prop):
|
def inv_propagator(prop):
|
||||||
|
""" Inverts a 12x12 quark propagator"""
|
||||||
|
if prop.shape != (12, 12):
|
||||||
|
raise Exception("Only 12x12 propagators can be inverted.")
|
||||||
return Npr_matrix(mat_mat_op(anp.linalg.inv, prop), prop.mom_in)
|
return Npr_matrix(mat_mat_op(anp.linalg.inv, prop), prop.mom_in)
|
||||||
|
|
||||||
|
|
||||||
def Zq(prop, fermion='Wilson'):
|
def Zq(inv_prop, fermion='Wilson'):
|
||||||
|
""" Calculates the quark field renormalization constant Zq
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
inv_prop -- Inverted 12x12 quark propagator
|
||||||
|
fermion -- Fermion type for which the tree-level propagator is used
|
||||||
|
in the calculation of Zq. Default Wilson.
|
||||||
|
"""
|
||||||
_check_geometry()
|
_check_geometry()
|
||||||
mom = np.copy(prop.mom_in)
|
mom = np.copy(inv_prop.mom_in)
|
||||||
mom[3] /= T / L
|
mom[3] /= T / L
|
||||||
sin_mom = np.sin(2 * np.pi / L * mom)
|
sin_mom = np.sin(2 * np.pi / L * mom)
|
||||||
|
|
||||||
|
@ -80,8 +90,6 @@ def Zq(prop, fermion='Wilson'):
|
||||||
else:
|
else:
|
||||||
raise Exception("Fermion type '" + fermion + "' not implemented")
|
raise Exception("Fermion type '" + fermion + "' not implemented")
|
||||||
|
|
||||||
inv_prop = _invert_propagator(prop)
|
|
||||||
|
|
||||||
res = 1 / 12. * np.trace(inv_prop @ np.kron(np.eye(3, dtype=int), p_slash))
|
res = 1 / 12. * np.trace(inv_prop @ np.kron(np.eye(3, dtype=int), p_slash))
|
||||||
res.gamma_method()
|
res.gamma_method()
|
||||||
|
|
||||||
|
|
|
@ -650,13 +650,21 @@ class Obs:
|
||||||
|
|
||||||
class CObs:
|
class CObs:
|
||||||
"""Class for a complex valued observable."""
|
"""Class for a complex valued observable."""
|
||||||
__slots__ = ['real', 'imag', 'tag']
|
__slots__ = ['_real', '_imag', 'tag']
|
||||||
|
|
||||||
def __init__(self, real, imag=0.0):
|
def __init__(self, real, imag=0.0):
|
||||||
self.real = real
|
self._real = real
|
||||||
self.imag = imag
|
self._imag = imag
|
||||||
self.tag = None
|
self.tag = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def real(self):
|
||||||
|
return self._real
|
||||||
|
|
||||||
|
@property
|
||||||
|
def imag(self):
|
||||||
|
return self._imag
|
||||||
|
|
||||||
def gamma_method(self, **kwargs):
|
def gamma_method(self, **kwargs):
|
||||||
if isinstance(self.real, Obs):
|
if isinstance(self.real, Obs):
|
||||||
self.real.gamma_method(**kwargs)
|
self.real.gamma_method(**kwargs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue