flowpm.tfpm

Core FastPM elements

flowpm.tfpm.linear_field(nc, boxsize, pk, kvec=None, batch_size=1, seed=None, dtype=tf.float32, name='LinearField')[source]

Generates a linear field with a given linear power spectrum.

nc: int, or list of ints

Number of cells in the field. If a list is provided, number of cells per dimension.

boxsize: float, or list of floats

Physical size of the cube, in Mpc/h.

pk: interpolator

Power spectrum to use for the field

kvec: array

k_vector corresponding to the cube, optional

batch_size: int

Size of batches

seed: int

Seed to initialize the gaussian random field

dtype: tf.dtype

Type of the sampled field, e.g. tf.float32 or tf.float64

Returns

linfield (tensor (batch_size, nc, nc, nc)) – Realization of the linear field with requested power spectrum

flowpm.tfpm.lpt_init(cosmo, linear, a, order=2, kvec=None, name='LPTInit')[source]

Estimate the initial LPT displacement given an input linear (real) field

TODO: documentation

flowpm.tfpm.nbody(cosmo, state, stages, nc, pm_nc_factor=1, return_intermediate_states=False, name='NBody')[source]

Integrate the evolution of the state across the givent stages

cosmo: cosmology

Cosmological parameter object

state: tensor (3, batch_size, npart, 3)

Input state

stages: array

Array of scale factors

nc: int, or list of ints

Number of cells

pm_nc_factor: int

Upsampling factor for computing

return_intermediate_states: boolean

If true, the frunction will return each intermediate states, not only the last one.

Returns

state (tensor (3, batch_size, npart, 3), or list of states) – Integrated state to final condition, or list of intermediate steps