-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSIS.py
More file actions
30 lines (20 loc) · 656 Bytes
/
SIS.py
File metadata and controls
30 lines (20 loc) · 656 Bytes
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
import numpy as np
from Profile import Profile
G = 4.492*10**(-6) #kpc^3/Modot/Gyr^2
class SIS(Profile):
def __init__(self,trunc_r,Vc):
super().__init__(trunc_r,Vc=Vc)
def density(self,r):
return self.Vc**2/(4*np.pi*G*r**2)
class SIS_analytic(SIS):
def __init__(self,trunc_r,Vc):
super().__init__(trunc_r,Vc)
def mass(self,r):
ndim = np.ndim(r)
if ndim == 0:
r = r if r<=self.trunc_r else self.trunc_r
elif ndim == 1:
r = np.clip(r,0,self.trunc_r)
else:
raise TypeError("'r' must be a scalar or a 1D array")
return r*self.Vc**2/G