Ejemplo n.º 1
0
#Convert to SI
rho = rho * 2.0 * 10.0**30.0 / (parsec**3.0)
#Simulation time
T = 10.0**7.0 * year
#print('T =', T)
#Mass of perturbers
M_p = 3.0 * 2.0 * 10.0**30.0
#RMS of Maxwellian velocity distribution, m/s
v_rms = 220.0 * 1000.0
#Number density of perturbers
n_p = rho / M_p

#Minimum impact parameter
b_min = (np.pi * n_p * v_rms * T)**(-0.5)
#Maximum impact parameter
b_max = calc_b_max(M_p, v_rms, a, m1, m2)
#Minimum velocity
v_min = 10.0**(-2.0) * v_rms * 0.0
#Maximum velocity
v_max = 10.0**2.0 * v_rms

N_v = 1000
N_b = 1000

#Monte Carlo
#Number of encounters
print('M Mean =', T * encounterRate(n_p, v_rms, b_min, b_max, v_min, v_max))
N_enc_MC = np.random.poisson(
    T * encounterRate(n_p, v_rms, b_min, b_max, v_min, v_max))
#b values
#b_MC = draw_b(b_max, N_enc_MC)
Ejemplo n.º 2
0
N_enc = 1000

#Set up logarithmic a bins
dloga = (np.log(a_max)-np.log(a_min))/N_a
a_bins = np.array([a_min*np.exp(dloga*i) for i in range(N_a)])
#Set up logarithmic M_p bins
dlogM = (np.log(M_p_max)-np.log(M_p_min))/N_M
M_p_bins = np.array([M_p_min*np.exp(dlogM*i) for i in range(N_M)])
#Average fractional difference in a
a_frac_avg = np.zeros((N_a, N_M), dtype=float)

#b=parsec
for j in range(N_M):
        n_p = rho/M_p_bins[j]
        for i in range(N_a):
                b = calc_b_max(M_p_bins[j], v_rms, a_bins[i], m1, m2)
                for k in range(N_enc):
                        (notBound, a_new, e_new) = impulseEncounter(m1, m2, v_rms, b, a_bins[i], e, M_p_bins[j])
                        a_frac_avg[i,j] += (a_new-a_bins[i])/a_bins[i]
#Normalise a_frac_avg
a_frac_avg /= N_enc

#Plot
plt.title(r'Absolute average fractional change in semi-major axis due to single encounter at $b=b_{\mathrm{max}}$')
ax = plt.gca()
cs = ax.contourf(a_bins/au, M_p_bins/(2.0*10.0**30.0), np.transpose(np.absolute(a_frac_avg)), locator=ticker.LogLocator())
plt.colorbar(cs)
plt.ylabel(r'Perturber mass, $M_\odot$')
plt.xlabel('Initial semi-major axis, au')
plt.xscale('log')
plt.yscale('log')
a_0 = 0.1 * parsec / length_scale()
#Eccentricity
e_0 = 0.7
#Number of binaries per simulation
N_bin = 10
print('N_bin =', N_bin)
#Number of simulations
N_sim = 1
#Starting index in file names
i_start = 0

#Time steps
#Minimum impact parameter
b_min = 0.0
#Maximum impact parameter
b_max = calc_b_max(M_p, v_rel, a_0, m1, m2)
print('b_max =', b_max)
#Minimum velocity
v_min = 10.0**(-2.0) * v_rel
#Maximum velocity
v_max = 10.0**2.0 * v_rel
#Encounter rate
rate = encounterRate(n_p, v_rel, b_min, b_max, v_min, v_max)
print('rate =', rate)
#Timestep
dt = 0.5 / rate
#Number of timesteps
N_t = int(T / dt) + 1
print('N_t =', N_t)
#Adjust timestep
dt = T / (N_t - 1)
Ejemplo n.º 4
0
#Number of a's to test
N_a = 50
#Number of encounters per each pair of values
N_enc = 50
#Delta
delta = 10.0**(-6.0)

#Set up logarithmic a bins
dloga = (np.log(a_max) - np.log(a_min)) / N_a
a_bins = np.array([a_min * np.exp(dloga * i) for i in range(N_a)])
#Average fractional difference in a
a_frac_avg = np.zeros(N_a, dtype=float)

#b_max array
b_max = np.array(
    [calc_b_max(M_p, v_rms, a_bins[i], m1, m2, delta) for i in range(N_a)])

for i in range(N_a):
    for j in range(N_enc):
        (notBound, a_new, e_new) = integrateEncounter(m1, m2, v_rms, b_max[i],
                                                      a_bins[i], e, M_p)
        a_frac_avg[i] += (a_new - a_bins[i]) / a_bins[i]
#Normalise a_frac_avg
a_frac_avg /= N_enc

#Plot absolute a_frac_avg against a and b_max/a
fig = plt.figure()
ax1 = plt.gca()
ax2 = ax1.twinx()
plt.title(
    r'Absolute average fractional change in $a$ due to a single encounter at $b=b_{{max}}$ with $M_p = {}$, $N_a = {}$, $N_{{enc}} = {}$, log10($\delta$) = {}'