Skip to content
Snippets Groups Projects
Commit 850f1277 authored by Armin Damon Riess's avatar Armin Damon Riess
Browse files

now with correct a for Hernquist profile

parent 40d115c7
No related branches found
No related tags found
No related merge requests found
plots/densityprofile.png

69.8 KiB | W: | H:

plots/densityprofile.png

69.1 KiB | W: | H:

plots/densityprofile.png
plots/densityprofile.png
plots/densityprofile.png
plots/densityprofile.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -13,7 +13,17 @@ M = np.sum(m) ...@@ -13,7 +13,17 @@ M = np.sum(m)
print("Number of particles:",len(m)) print("Number of particles:",len(m))
rmax = 32 halfmassradius = 0
tmpmass = 0
rsorted = np.sort(r)
for i in range(len(rsorted)):
tmpmass += m[i]
if tmpmass > M/2:
halfmassradius = rsorted[i]
break
print("Half mass radius:",halfmassradius)
rmax = 128
dr = 0.075 dr = 0.075
nbins = int(rmax/dr) nbins = int(rmax/dr)
...@@ -23,7 +33,7 @@ for i in range(len(hist)): ...@@ -23,7 +33,7 @@ for i in range(len(hist)):
volume = 4/3*np.pi*(bins[i+1]**3 - bins[i]**3) volume = 4/3*np.pi*(bins[i+1]**3 - bins[i]**3)
hist[i] /= volume hist[i] /= volume
a = np.diff(bins) a = halfmassradius/(1+np.sqrt(2))
rhoHernquist = M / (2*np.pi) * a / (bins[1:]-dr/2) / (bins[1:]-dr/2 + a)**3 rhoHernquist = M / (2*np.pi) * a / (bins[1:]-dr/2) / (bins[1:]-dr/2 + a)**3
print("Number of bins:",nbins) print("Number of bins:",nbins)
...@@ -33,16 +43,6 @@ print("Bin size:",dr) ...@@ -33,16 +43,6 @@ print("Bin size:",dr)
# if hist[i] == 0: # if hist[i] == 0:
# hist[i] = np.nan # hist[i] = np.nan
halfmassradius = 0
tmpmass = 0
rsorted = np.sort(r)
for i in range(len(rsorted)):
tmpmass += m[i]
if tmpmass > M/2:
halfmassradius = rsorted[i]
break
print("Half mass radius:",halfmassradius)
# plot poissonian error bars # plot poissonian error bars
plt.errorbar(bins[1:], rhoHernquist, yerr=np.sqrt(rhoHernquist), color='grey', fmt='.', label='Hernquist with Poisson error', markersize=0) plt.errorbar(bins[1:], rhoHernquist, yerr=np.sqrt(rhoHernquist), color='grey', fmt='.', label='Hernquist with Poisson error', markersize=0)
# plot Hernquist profile # plot Hernquist profile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment