mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 03:53:41 +02:00
sinh effective mass implemented
This commit is contained in:
parent
66c443fd63
commit
117a925775
4 changed files with 28 additions and 20 deletions
2
.github/workflows/flake8.yml
vendored
2
.github/workflows/flake8.yml
vendored
|
@ -16,6 +16,6 @@ jobs:
|
||||||
- name: flake8 Lint
|
- name: flake8 Lint
|
||||||
uses: py-actions/flake8@v1
|
uses: py-actions/flake8@v1
|
||||||
with:
|
with:
|
||||||
ignore: "E501"
|
ignore: "E501,E722"
|
||||||
exclude: "__init__.py, input/__init__.py"
|
exclude: "__init__.py, input/__init__.py"
|
||||||
path: "pyerrors"
|
path: "pyerrors"
|
||||||
|
|
|
@ -252,14 +252,21 @@ class Corr:
|
||||||
|
|
||||||
return np.log(Corr(newcontent, padding_back=1))
|
return np.log(Corr(newcontent, padding_back=1))
|
||||||
|
|
||||||
elif variant == 'periodic':
|
elif variant in ['periodic', 'cosh', 'sinh']:
|
||||||
|
if variant in ['periodic', 'cosh']:
|
||||||
|
func = anp.cosh
|
||||||
|
else:
|
||||||
|
func = anp.sinh
|
||||||
|
|
||||||
|
def root_function(x, d):
|
||||||
|
return func(x * (t - self.T / 2)) / func(x * (t + 1 - self.T / 2)) - d
|
||||||
|
|
||||||
newcontent = []
|
newcontent = []
|
||||||
for t in range(self.T - 1):
|
for t in range(self.T - 1):
|
||||||
if (self.content[t] is None) or (self.content[t + 1] is None):
|
if (self.content[t] is None) or (self.content[t + 1] is None):
|
||||||
newcontent.append(None)
|
newcontent.append(None)
|
||||||
else:
|
else:
|
||||||
func = lambda x, d: anp.cosh(x * (t - self.T / 2)) / anp.cosh(x * (t + 1 - self.T / 2)) - d
|
newcontent.append(np.abs(find_root(self.content[t][0] / self.content[t + 1][0], root_function, guess=guess)))
|
||||||
newcontent.append(np.abs(find_root(self.content[t][0] / self.content[t + 1][0], func, guess=guess)))
|
|
||||||
if(all([x is None for x in newcontent])):
|
if(all([x is None for x in newcontent])):
|
||||||
raise Exception('m_eff is undefined at all timeslices')
|
raise Exception('m_eff is undefined at all timeslices')
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ def read_ADerrors(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
|
|
||||||
print('Reading of bdio file started')
|
print('Reading of bdio file started')
|
||||||
while 1 > 0:
|
while 1 > 0:
|
||||||
record = bdio_seek_record(fbdio)
|
bdio_seek_record(fbdio)
|
||||||
ruinfo = bdio_get_ruinfo(fbdio)
|
ruinfo = bdio_get_ruinfo(fbdio)
|
||||||
|
|
||||||
if ruinfo == 7:
|
if ruinfo == 7:
|
||||||
|
@ -75,13 +75,13 @@ def read_ADerrors(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
if ruinfo < 0:
|
if ruinfo < 0:
|
||||||
# EOF reached
|
# EOF reached
|
||||||
break
|
break
|
||||||
rlen = bdio_get_rlen(fbdio)
|
bdio_get_rlen(fbdio)
|
||||||
|
|
||||||
def read_c_double():
|
def read_c_double():
|
||||||
d_buf = ctypes.c_double
|
d_buf = ctypes.c_double
|
||||||
pd_buf = d_buf()
|
pd_buf = d_buf()
|
||||||
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
||||||
iread = bdio_read_f64(ppd_buf, ctypes.c_size_t(8), ctypes.c_void_p(fbdio))
|
bdio_read_f64(ppd_buf, ctypes.c_size_t(8), ctypes.c_void_p(fbdio))
|
||||||
return pd_buf.value
|
return pd_buf.value
|
||||||
|
|
||||||
mean = read_c_double()
|
mean = read_c_double()
|
||||||
|
@ -91,7 +91,7 @@ def read_ADerrors(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
d_buf = ctypes.c_size_t
|
d_buf = ctypes.c_size_t
|
||||||
pd_buf = d_buf()
|
pd_buf = d_buf()
|
||||||
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
||||||
iread = bdio_read_int32(ppd_buf, ctypes.c_size_t(4), ctypes.c_void_p(fbdio))
|
bdio_read_int32(ppd_buf, ctypes.c_size_t(4), ctypes.c_void_p(fbdio))
|
||||||
return pd_buf.value
|
return pd_buf.value
|
||||||
|
|
||||||
neid = read_c_size_t()
|
neid = read_c_size_t()
|
||||||
|
@ -137,7 +137,7 @@ def read_ADerrors(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
d_buf = ctypes.c_double * np.sum(ndata)
|
d_buf = ctypes.c_double * np.sum(ndata)
|
||||||
pd_buf = d_buf()
|
pd_buf = d_buf()
|
||||||
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
||||||
iread = bdio_read_f64(ppd_buf, ctypes.c_size_t(8 * np.sum(ndata)), ctypes.c_void_p(fbdio))
|
bdio_read_f64(ppd_buf, ctypes.c_size_t(8 * np.sum(ndata)), ctypes.c_void_p(fbdio))
|
||||||
delta = pd_buf[:]
|
delta = pd_buf[:]
|
||||||
|
|
||||||
samples = np.split(np.asarray(delta) + mean, np.cumsum([a for su in vrep for a in su])[:-1])
|
samples = np.split(np.asarray(delta) + mean, np.cumsum([a for su in vrep for a in su])[:-1])
|
||||||
|
@ -212,8 +212,7 @@ def write_ADerrors(obs_list, file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
fbdio = bdio_open(ctypes.c_char_p(b_path), ctypes.c_char_p(b_write), b_form)
|
fbdio = bdio_open(ctypes.c_char_p(b_path), ctypes.c_char_p(b_write), b_form)
|
||||||
|
|
||||||
for obs in obs_list:
|
for obs in obs_list:
|
||||||
|
# mean = obs.value
|
||||||
mean = obs.value
|
|
||||||
neid = len(obs.e_names)
|
neid = len(obs.e_names)
|
||||||
vrep = [[obs.shape[o] for o in sl] for sl in list(obs.e_content.values())]
|
vrep = [[obs.shape[o] for o in sl] for sl in list(obs.e_content.values())]
|
||||||
vrep_write = [item for sublist in vrep for item in sublist]
|
vrep_write = [item for sublist in vrep for item in sublist]
|
||||||
|
@ -251,12 +250,12 @@ def write_ADerrors(obs_list, file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
def write_c_double(double):
|
def write_c_double(double):
|
||||||
pd_buf = ctypes.c_double(double)
|
pd_buf = ctypes.c_double(double)
|
||||||
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
||||||
iwrite = bdio_write_f64(ppd_buf, ctypes.c_size_t(8), ctypes.c_void_p(fbdio))
|
bdio_write_f64(ppd_buf, ctypes.c_size_t(8), ctypes.c_void_p(fbdio))
|
||||||
|
|
||||||
def write_c_size_t(int32):
|
def write_c_size_t(int32):
|
||||||
pd_buf = ctypes.c_size_t(int32)
|
pd_buf = ctypes.c_size_t(int32)
|
||||||
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
ppd_buf = ctypes.c_void_p(ctypes.addressof(pd_buf))
|
||||||
iwrite = bdio_write_int32(ppd_buf, ctypes.c_size_t(4), ctypes.c_void_p(fbdio))
|
bdio_write_int32(ppd_buf, ctypes.c_size_t(4), ctypes.c_void_p(fbdio))
|
||||||
|
|
||||||
write_c_double(obs.value)
|
write_c_double(obs.value)
|
||||||
write_c_size_t(neid)
|
write_c_size_t(neid)
|
||||||
|
@ -365,7 +364,7 @@ def read_mesons(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
|
|
||||||
print('Reading of bdio file started')
|
print('Reading of bdio file started')
|
||||||
while 1 > 0:
|
while 1 > 0:
|
||||||
record = bdio_seek_record(fbdio)
|
bdio_seek_record(fbdio)
|
||||||
ruinfo = bdio_get_ruinfo(fbdio)
|
ruinfo = bdio_get_ruinfo(fbdio)
|
||||||
if ruinfo < 0:
|
if ruinfo < 0:
|
||||||
# EOF reached
|
# EOF reached
|
||||||
|
@ -530,7 +529,7 @@ def read_dSdm(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
corr_type = [] # Contains correlator data type (important for reading out numerical data)
|
corr_type = [] # Contains correlator data type (important for reading out numerical data)
|
||||||
corr_props = [] # Contains propagator types (Component of corr_kappa)
|
corr_props = [] # Contains propagator types (Component of corr_kappa)
|
||||||
d0 = 0 # tvals
|
d0 = 0 # tvals
|
||||||
d1 = 0 # nnoise
|
# d1 = 0 # nnoise
|
||||||
prop_kappa = [] # Contains propagator kappas (Component of corr_kappa)
|
prop_kappa = [] # Contains propagator kappas (Component of corr_kappa)
|
||||||
# Check noise type for multiple replica?
|
# Check noise type for multiple replica?
|
||||||
cnfg_no = -1
|
cnfg_no = -1
|
||||||
|
@ -541,7 +540,7 @@ def read_dSdm(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
|
|
||||||
print('Reading of bdio file started')
|
print('Reading of bdio file started')
|
||||||
while 1 > 0:
|
while 1 > 0:
|
||||||
record = bdio_seek_record(fbdio)
|
bdio_seek_record(fbdio)
|
||||||
ruinfo = bdio_get_ruinfo(fbdio)
|
ruinfo = bdio_get_ruinfo(fbdio)
|
||||||
if ruinfo < 0:
|
if ruinfo < 0:
|
||||||
# EOF reached
|
# EOF reached
|
||||||
|
@ -613,7 +612,6 @@ def read_dSdm(file_path, bdio_path='./libbdio.so', **kwargs):
|
||||||
print('Number of configurations: ', cnfg_no + 1)
|
print('Number of configurations: ', cnfg_no + 1)
|
||||||
|
|
||||||
corr_kappa = [] # Contains kappa values for both propagators of given correlation function
|
corr_kappa = [] # Contains kappa values for both propagators of given correlation function
|
||||||
corr_source = []
|
|
||||||
for item in corr_props:
|
for item in corr_props:
|
||||||
corr_kappa.append(float(prop_kappa[int(item)]))
|
corr_kappa.append(float(prop_kappa[int(item)]))
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,14 @@ from functools import partial
|
||||||
from autograd.extend import defvjp
|
from autograd.extend import defvjp
|
||||||
|
|
||||||
_dot = partial(anp.einsum, '...ij,...jk->...ik')
|
_dot = partial(anp.einsum, '...ij,...jk->...ik')
|
||||||
|
|
||||||
|
|
||||||
# batched diag
|
# batched diag
|
||||||
_diag = lambda a: anp.eye(a.shape[-1]) * a
|
def _diag(a):
|
||||||
|
return anp.eye(a.shape[-1]) * a
|
||||||
|
|
||||||
|
|
||||||
# batched diagonal, similar to matrix_diag in tensorflow
|
# batched diagonal, similar to matrix_diag in tensorflow
|
||||||
|
|
||||||
|
|
||||||
def _matrix_diag(a):
|
def _matrix_diag(a):
|
||||||
reps = anp.array(a.shape)
|
reps = anp.array(a.shape)
|
||||||
reps[:-1] = 1
|
reps[:-1] = 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue