Skip to content

Commit 646c479

Browse files
author
Man-Yat Chu
committed
Support transfer function without neutrinos.
1 parent e9c38b3 commit 646c479

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fastpm/multi.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,26 @@ def get_species_transfer_function_from_class(cosmology, z):
192192
# flip the sign to meet preserve the phase of the
193193
d['d_cdm'] = tf['d_cdm'] * -1
194194
d['d_b'] = tf['d_b'] * -1
195-
d['d_ncdm[0]'] = tf['d_ncdm[0]'] * -1
195+
if getattr(tf, 'd_ncdm[0]', None) is not None:
196+
d['d_ncdm[0]'] = tf['d_ncdm[0]'] * -1
196197
if cosmology.gauge == 'newtonian':
197198
# dtau to da, the negative sign in the 3 fluid equation of motion
198199
# eliminated due to the flip in d
199200
fac = 1.0 / (cosmology.hubble_function(z) * (1. + z) ** -2)
200201
d['dd_cdm'] = tf['t_cdm'] * fac
201202
d['dd_b'] = tf['t_b'] * fac
202-
d['dd_ncdm[0]'] = tf['t_ncdm[0]'] * fac
203+
if getattr(tf, 't_ncdm[0]', None) is not None:
204+
d['dd_ncdm[0]'] = tf['t_ncdm[0]'] * fac
203205
elif cosmology.gauge == 'synchronous':
204206
fac = 1.0 / (cosmology.hubble_function(z) * (1. + z) ** -2)
205207
d['dd_cdm'] = 0.5 * tf['h_prime'] * fac
206208
d['dd_b'] = (0.5 * tf['h_prime'] + tf['t_b']) * fac
207-
d['dd_ncdm[0]'] = (0.5 * tf['h_prime'] + tf['t_ncdm[0]']) * fac
209+
if getattr(tf, 't_ncdm[0]', None) is not None:
210+
d['dd_ncdm[0]'] = (0.5 * tf['h_prime'] + tf['t_ncdm[0]']) * fac
208211

209212
k = tf['k'].copy()
210213
e = {}
211214
for name in d:
212215
e[name] = lambda k, x=tf['k'], y=d[name]: numpy.interp(k, x, y, left=0, right=0)
213216
return e
214-
217+
correspondencecorrespondence

0 commit comments

Comments
 (0)