<jupyter_start><jupyter_text><jupyter_code># Run this if you are on colab
!pip install git+https://github.com/modichirag/flowpm.git
!git clone https://github.com/modichirag/flowpm.git 
%pylab inline
import tensorflow as tf
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline as iuspline

# You may need to adapt this path depending on where you are running the notebook
# This is the power spectrum of initial conditions
klin = np.loadtxt('flowpm/flowpm/data/Planck15_a1p00.txt').T[0]
plin = np.loadtxt('flowpm/flowpm/data/Planck15_a1p00.txt').T[1]

ipklin = iuspline(klin, plin)
import flowpm

stages = np.linspace(0.1, 1.0, 10, endpoint=True)

initial_conditions = flowpm.linear_field(32,          # size of the cube
                                         100,         # Physical size of the cube
                                         ipklin,      # Initial powerspectrum
                                         batch_size=16)

# Sample particles
state = flowpm.lpt_init(initial_conditions, a0=0.1)   

# Evolve particles down to z=0
final_state = flowpm.nbody(state, stages, 32)         

# Retrieve final density field
final_field = flowpm.cic_paint(tf.zeros_like(initial_conditions), final_state[0])
imshow(final_field[0].numpy().sum(axis=0))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09243697478991597, 'fraction_numerical': 0.025974025974025976, 'mean_word_length': 3.0683229813664594, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '81462', 'license': 'MIT', 'n_tokens_mistral': 445, 'n_tokens_neox': 425, 'n_words': 105, 'path': 'notebooks/flowpm_tutorial.ipynb', 'repo_name': 'jplalor/flowpm', 'size': '1309'}