-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc_tidal_radius.py
49 lines (40 loc) · 1.07 KB
/
calc_tidal_radius.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python2.7
from __future__ import print_function, division
import numpy as np
import matplotlib
import os
#checks if there is a display to use.
if os.environ.get('DISPLAY') is None:
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.colors as clr
import dtk
import sys
import time
import astropy
from astropy.cosmology import WMAP7 as cosmo
import halotools
from halotools.empirical_models import NFWProfile
cosmo
_critical_density_func=None
def rho0(z):
global _rho0_func
if _critical_density_func is None:
zs = np.linspace(0,10,1000)
rho_0 = 2.77536627e11
density = cosmo.critical_density(zs)/cosmo.critical_density0*rho_0
_critical_density_func = np.interp(z,density)
nfwprofile = NFWProfile()
def F_grav(R,M200,c):
return dtk.NFW_enclosed_mass(R,c)*M200/R**2
def F_tidal(r, R, M200, c):
return -F_grav(R,M200,c) + F_grav(R-r, M200, c)
plt.figure()
r = np.linspace(0,0.2,1000)
R = 1
M1 = 1e14
M2 = 1e11
plt.plot(r, F_grav(r,M2,10))
plt.plot(r, F_tidal(r, R, M1,3))
plt.yscale('log')
plt.show()