Beispiel #1
0
def get_rh(Mtot):
    H = calculate_r200.get_H(z)
    rs = calculate_r200.get_r200(Mtot, H)
    concentration = 10.**(1.025-0.097*np.log(Mtot/((10.**12)/little_h)))
    rh = rs*(0.6082 - 0.1843*np.log(concentration) - 0.1011*(np.log(concentration)**2.) + \
             0.03918*(np.log(concentration)**3.))
    return rh
Beispiel #2
0
def run():
    tend = 13.722672e3 #Myr
    gal = '1'
    r200_list = []
    m200_list = []
    c_list = []
    R_half_mass_list = []
    R_H_list = []
    rho_c_list = []
    t_s = np.arange(t0, tend, 100.)
    for t in t_s: #increment is 100 Myr
        z = get_z(t)
        H = get_H(z)
        NFW_params = get_NFW_parameters(t, H, gal)
        m200, r200, c, R_S, rho_crit, rho_0 = NFW_params
        r200_list.append(r200)
        m200_list.append(m200)
        c_list.append(c)
#        R = np.linspace(0.01, r200, num=100000)
#        rho_NFW = get_rho_NFW(R, rho_0, R_S)
        R_half_mass = get_R_half_mass(c, r200=r200)
        R_half_mass_list.append(R_half_mass)
        R_H = R_half_mass
        R_H_list.append(R_H)
        R_C = Constants_NFW.R_C
        rho_c = get_rho_c(m200, R_C, R_H)
        rho_c_list.append(rho_c)

    r200_array = np.array(r200_list)
    m200_array = np.array(m200_list)
    c_array = np.array(c_list)
    R_half_mass_array = np.array(R_half_mass_list)
    R_H_array = np.array(R_H_list)
    rho_c_array = np.array(rho_c_list)

#    plot_c_vs_t(t_s, c_array)
    '''
    plt.figure()
    plt.loglog(t_s, rho_c_array)
    plt.xlabel('Log time (Myr)')
    plt.ylabel('Log rho_c of OS profile (Msun/pc**3)')
    plt.savefig(''.join([plots_folder, 'rho_c.png']))
    plt.close()
    '''
    R_H_index = 0
#    R = np.linspace(0.1, R_H_array[R_H_index], num=10000)
    '''
    rho_rhoc = ((1+R**2/R_C**2)*(1+R**2/R_H_array[R_H_index]**2))**(-1)
    plt.figure()
    plt.loglog(R, rho_rhoc)
    plt.axvline(x=R_H_array[R_H_index], color='r')
    plt.xlabel('Log R')
    plt.ylabel('Log rho/rho_c')
    plt.title('rho/rho_c as function of R for r_h=%.f' % (R_H_array[R_H_index]))
    plt.savefig(''.join([plots_folder, 'rho_rhoc_as_func_of_r.png']))
    '''
    m200_index = R_H_index
    rho_c_index = R_H_index
##############################
#  TEMPORARY, JUST FOR NICK'S TEST CASE FROM THE PAPER
    R_H = 1.
    m200 = 1.e5
    R_C = [.002, .01, .05, .1]
#    colors = ['k', 'b', 'm', 'r']
    R = np.linspace(1.e-3, 100., num=100000)
    R_near = [R[R<=0.065*1.15], R[R<=0.12*1.15], R[R<=0.2*1.15], R[R<=0.25*1.15]]
    R_far = [R[R>=0.075*.85], R[R>=0.15*.85], R[R>=0.25*.85], R[R>=0.3*.85]]
###############################
    fig, ax = plt.subplots(2, 2)
    for i, a in enumerate(ax.flatten()):
        rho_c = get_rho_c(m200, R_C[i], R_H)
        sigma_near = get_sigma_near(R, R_H, R_C[i], rho_c)
##############################
#    sigma_near = get_sigma_near(R, R_H_array[R_H_index], R_C, rho_c_array[rho_c_index])
#        a.loglog(R_near[i], sigma_near[:len(R_near[i])], c='k', label='sigma near')
        a.loglog(R, sigma_near, c='k', label='sigma near')
##############################
#  TEMPORARY, JUST FOR NICK'S TEST CASE FROM THE PAPER
        sigma_far = get_sigma_far(R, R_H, R_C[i], m200)
##############################
#    sigma_far = get_sigma_far(R, R_H_array[R_H_index], R_C, m200_array[m200_index])
#        a.loglog(R_far[i], sigma_far[len(sigma_far)-len(R_far[i]):], c='r', label='sigma far')
        a.loglog(R, sigma_far, c='r', label='sigma far')
##############################
#  TEMPORARY, JUST FOR NICK'S TEST CASE FROM THE PAPER
        a.axvline(x=R_C[i], color='b', linestyle='--')
        a.set_ylim([8., 25.])
        a.set_xlim([.001, 10.])
##############################
        a.set_xlabel('Log r[pc]')
        a.set_ylabel('Log sigma[km/s]')
#    plt.legend(loc='best')
        a.grid(b=True, which='major', color='r', linestyle='-')
##############################
#  TEMPORARY, JUST FOR NICK'S TEST CASE FROM THE PAPER
        a.set_title('r_c=%.3f' % (R_C[i]), fontsize=10)
##############################
#    plt.title('sigma as function of R for r_h=%.f' % (R_H_array[R_H_index]))
    fig.suptitle(''.join(['sigma as f\'n of r for r_h=%.1f, m200=%.f' % (R_H, m200)]), fontsize=12, y=1.)
    fig.tight_layout()
    fig.savefig(os.path.join(plots_folder, 'sigma_as_func_of_r.png'))
    print(plots_folder)