pierrexyz / pybird

Python code for Biased tracers in redshift space
https://pybird.readthedocs.io/en/latest/
MIT License
26 stars 17 forks source link

nnlo counterterm with_bias=True #7

Closed adematti closed 1 year ago

adematti commented 1 year ago

A small bug I found (I haven't investigated), with nnlo counterterm, with_bias=True:

N = Correlator() with_bias = True N.set({'output': 'bPk', 'multipole': 3, 'kmax': 0.3, 'xdata': kd, 'km': 0.7, 'kr': 0.35, 'nd': 3e-4, 'eft_basis': 'eftoflss', 'with_stoch': True, 'with_bias': with_bias, 'with_nnlo_counterterm': True}) eft_params = {'b1': 1.9535, 'c2': 0.5863, 'c4': 0.0, 'b3': -0.3948, 'cct': 0.1839, 'cr1': -0.8414, 'cr2': -0.8084, 'ce0': 1.5045, 'ce1': 0.0, 'ce2': -1.6803, 'b2': 0.4146, 'b4': 0.4146, 'cr4': 10., 'cr6': 20.} if with_bias: N.compute({'kk': kk, 'pk_lin': pk_lin, 'Psmooth': pk_lin, 'f': f1, 'bias': eft_params}) else: N.compute({'kk': kk, 'pk_lin': pk_lin, 'Psmooth': pk_lin, 'f': f1})

fails with:

325 self.Ps[1] += np.einsum('lb,bx->lx', self.b13, self.P13) + np.einsum('l,x,x->lx', self.bct, self.co.k**2, self.P11)
326 if self.with_stoch: self.Ps[1] += np.einsum('b,lbx->lx', self.bst, self.Pstl)

--> 327 if self.with_nnlo_counterterm: self.Ps[2] = np.einsum('lb,x->lx', self.cnnlo, self.Pnnlo) 328 if setfull: self.setfullPs()

File ~/anaconda3/envs/cosmodesi/lib/python3.9/site-packages/numpy/core/einsumfunc.py:1371, in einsum(out, optimize, *operands, *kwargs) 1369 if specified_out: 1370 kwargs['out'] = out -> 1371 return c_einsum(operands, **kwargs) 1373 # Check the kwargs to avoid a more cryptic error later, without having to 1374 # repeat default values here 1375 valid_einsum_kwargs = ['dtype', 'order', 'casting']

ValueError: einstein sum subscripts string contains too many subscripts for operand 0

While there is no such issue with with_bias=False

pierrexyz commented 1 year ago

Thanks for spotting that, bug solved! Just in case: although the chosen values for 'cr4' and 'cr6' in your example are totally fine for testing, in practice, they are order one numbers, as the nnlo counterterms appear with 1/k_r^4.
Cheers.