Skip to content

Instantly share code, notes, and snippets.

View oliverphilcox's full-sized avatar

Oliver Philcox oliverphilcox

View GitHub Profile
@oliverphilcox
oliverphilcox / spherical_collapse.py
Last active March 16, 2021 16:17
Compute the explicit solution of the spherical collapse equations, using the method of Slepian & Philcox (2021).
import numpy as np
def spherical_collapse(time_array, N_fft=32, eps=1e-4):
"""Compute the spherical collapse radius r as a function of time.
This is done with the method of Slepian & Philcox (2021), via contour integration and FFTs.
Note that the radius and time are given in dimensionless units.
Args:
time_array (np.ndarray): Array of times in units of the free-fall time.