Removed d'Alembert force and chaned halo model to NFW

This commit is contained in:
Yohai Meiron 2020-05-04 21:31:01 -04:00
parent f8eae117dd
commit 8cb62ac88c
7 changed files with 316 additions and 73 deletions

View file

@ -78,8 +78,18 @@ for i in range(len(snap)):
X_center_halo = def_dc(m, X)
r = linalg.norm(X-X_center_halo, axis=1)
rh = get_half_mass_radius(m, r)
b_halo = 0.76642093654*rh
M_halo = sum(m)
b_halo_plummer = 0.76642093654*rh
M_halo_plummer = sum(m)
j = r.argsort()
rr = r[j]
m_cumulative = cumsum(m[j])/sum(m)
nfw_cumulative_mass = lambda rho_0, b, r: 4*pi*rho_0*b**3*(log(1+r/b) - r/(b+r))
cost = lambda args: sum((nfw_cumulative_mass(*args, rr) - m_cumulative)**2)
res = scipy.optimize.minimize(cost, [1e-3, 30.], method='Nelder-Mead')
rho_0_nfw, b_nfw = res.x
rho_0_nfw *= sum(m)
lsq_nfw = res.fun/len(rr)
m = f[str(snapshot)][particle_types['stars']]['Masses'][...]
X = f[str(snapshot)][particle_types['stars']]['Coordinates'][...] * a[i] / h0
@ -103,6 +113,6 @@ for i in range(len(snap)):
m_d = median(sqrt(x[mask]**2+y[mask]**2))
a_mn, b_mn = miyamoto_nagai_params_from_medians(m_d, m_z)
M_disk = sum(m)
print('%d %.8E %.8E %15.8E %15.8E %15.8E %15.8E %15.8E %15.8E %15.8E %.8E %.8E %.8E %15.8E %15.8E %15.8E %15.8E' % (snapshot, t[i], M_disk, *X_center_stars, phi_inertia, theta_inertia, phi_L, theta_L, a_mn, b_mn, M_halo, *X_center_halo, b_halo))
print('%d %.8E %15.8E %15.8E %15.8E %15.8E %15.8E %15.8E %15.8E %.8E %.8E %.8E %15.8E %15.8E %15.8E %.8E %.8E %.8E %.8E %.8E' % (snapshot, t[i], *X_center_stars, phi_inertia, theta_inertia, phi_L, theta_L, M_disk, a_mn, b_mn, *X_center_halo, M_halo_plummer, b_halo_plummer, rho_0_nfw, b_nfw, lsq_nfw))
f.close()