#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') plt.show()
N_a = 100 #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)]) #Fraction of encounters that break binary F_enc = np.zeros((N_M, N_a)) #Number density of perturbers n_p = rho/M_bins #Minimum impact parameter b_min = (np.pi*n_p*v_rms*(10.0*giga*year))**(-0.5) for k in range(N_a): for j in range(N_M): for i in range(N_enc): (notBound, a_new, e_new) = impulseEncounter(m1, m2, v_rms, b_min[j], a_bins[k], e, M_bins[j]) if notBound: F_enc[j,k] += 1 #Normalise F_enc F_enc /= N_enc #Contour plot #plt.title(r'Fraction of binaries broken due to a single encounter at $b=b_\mathrm{min}$') plt.contourf(M_bins/(2.0*10.0**30.0), a_bins/au, np.transpose(F_enc), levels=np.linspace(0.0, 1.0, 11)) plt.xlabel('Perturber mass, solar masses') plt.ylabel('Semi-major axis, au') plt.xscale('log') plt.yscale('log') plt.colorbar(); plt.show()
b_max = 100.0 * 1.5 * (G * M_p**2.0 * a_max**3.0 / ((m1 + m2) * v_rms**2.0))**0.25 #Number of masses to test N_b = 100 #Set up logarithmic mass bins dlogb = (np.log(b_max) - np.log(b_min)) / N_b b_bins = np.array([b_min * np.exp(dlogb * i) for i in range(N_b)]) #Fraction of encounters that break binary F_enc = np.zeros((N_b, N_a)) for k in range(N_a): for j in range(N_b): for i in range(N_enc): (notBound, a_new, e_new) = impulseEncounter(m1, m2, v_rms, b_bins[j], a_bins[k], e, M_p) if notBound: F_enc[j, k] += 1 #Normalise F_enc F_enc /= N_enc #Contour plot plt.title( r'Fraction of binaries broken due to a single encounter with $M_p=1000M_\odot$' ) plt.contourf(b_bins / parsec, a_bins / parsec, np.transpose(F_enc), levels=np.linspace(0.0, 1.0, 11)) plt.plot(1.5 * (G * M_p**2.0 * a_bins**3.0 / ((m1 + m2) * v_rms**2.0))**0.25 /
#WSW b_max b_max_wsw = v_rms * P / (2.0 * np.pi) b = 0.05 * b_max_wsw print('b = ', b) #Number of encounters N_enc = 10**4 #Average energy change from impulse dE_imp_mean = 0.0 dE_imp_meansq = 0.0 #Number of negative energy changes #N_neg = 0 for i in range(N_enc): notBound_new, a_new, e_new = impulseEncounter(m1, m2, v_rms, b, a, e, M_p) #print('a_new =', a_new) #if notBound_new: #print('BINARY BROKEN!') E_new = -G * (m1 + m2) / (2.0 * a_new) #print('E_new =', E_new) #print('E_new-E_old =', E_new-E_old) #if (E_new-E_old) < 0.0: #N_neg += 1 dE_imp_mean += (E_new - E_old) dE_imp_meansq += (E_new - E_old)**2.0 #Normalise dE_imp_mean /= N_enc dE_imp_meansq /= N_enc #Calculate variance
#Set up logarithmic mass bins dlogM = (np.log(M_max) - np.log(M_min)) / N_M M_bins = np.array([M_min * np.exp(dlogM * i) for i in range(N_M)]) v = v_rms #Fraction of encounters that break binary F_enc = np.zeros(N_M) for j in range(N_M): #Number density of perturbers n_p = rho / M_bins[j] #Minimum impact parameter b_min = (np.pi * n_p * v_rms * (10.0 * giga * year))**(-0.5) b = b_min #Implement encounters for i in range(N_enc): (notBound, a_new, e_new) = impulseEncounter(m1, m2, v, b, a, e, M_bins[j]) if notBound: F_enc[j] += 1 #Normalise F_enc F_enc /= N_enc #Plot plt.semilogx(M_bins / (2.0 * 10.0**30.0), F_enc) plt.xlabel('Perturber mass, solar masses') plt.ylabel('Fraction of binaries broken') plt.title( r'Fraction of binaries broken due to single encounter at $b=b_\mathrm{min}$, $a = 0.1$pc' ) plt.show()