def get_potential(log_M_h, log_r_s, log_M_n, log_a): mw_potential = gp.CCompositePotential() mw_potential['bulge'] = gp.HernquistPotential(m=5E9, c=1., units=galactic) mw_potential['disk'] = gp.MiyamotoNagaiPotential(m=6.8E10 * u.Msun, a=3 * u.kpc, b=280 * u.pc, units=galactic) mw_potential['nucl'] = gp.HernquistPotential(m=np.exp(log_M_n), c=np.exp(log_a) * u.pc, units=galactic) mw_potential['halo'] = gp.NFWPotential(m=np.exp(log_M_h), r_s=np.exp(log_r_s), units=galactic) return mw_potential
def morphology(omega, m_b, release_every=1, n_particles=1, dt=-1, n_steps=6000): """ Takes the pattern speed (with units, in km/s/kpc), and release_every, which controls how often to release particles, and the bar mass m_b. Creates mock streams, returns RA, dec to be used for track calculation """ S = np.load('../data/Sn9l19m.npy') #expansion coeff. S = S[:2, :6, :6] w0 = gd.PhaseSpacePosition(pal5_c.transform_to(galcen_frame).cartesian) pot = gp.CCompositePotential() pot['disk'] = default_mw['disk'] pot['halo'] = default_mw['halo'] pot['bar'] = get_bar_model(Omega=omega, Snlm=S, m=m_b) frame = gp.ConstantRotatingFrame(Omega=[0, 0, -1] * omega, units=galactic) H = gp.Hamiltonian( pot, frame) #frame such that we're "moving" with respect to bar df = gd.FardalStreamDF(random_state=np.random.RandomState(42)) prog_pot = gp.PlummerPotential(pal5_M, 4 * u.pc, units=galactic) gen = gd.MockStreamGenerator(df=df, hamiltonian=H, progenitor_potential=prog_pot) # gen = gd.MockStreamGenerator(df=df, hamiltonian=H) stream_data, _ = gen.run(w0, pal5_M, dt=dt, n_steps=n_steps, release_every=release_every, n_particles=n_particles) cache_file = 'BarModels_RL{:d}_Mb{:.0e}_Om{:.1f}.hdf5'.format( release_every, m_b.value, omega.value) if path.exists(cache_file): os.unlink(cache_file) stream_data.to_hdf5(cache_file) sim_c = stream_data.to_coord_frame(coord.ICRS, galactocentric_frame=galcen_frame) return sim_c
phi = 2. / 4. * np.pi x_0 = r_0 * np.cos(phi) y_0 = r_0 * np.sin(phi) vx_0 = -1. * v_0 * np.sin(phi) vy_0 = v_0 * np.cos(phi) z_0 = 4 # kpc vz_0 = 20 # km/s M_progenitor = 1e8 # Msun n_steps = 3e4 ######################################## # Set up potential object pot = gp.CCompositePotential() # Using 3 Miyamoto-Nagai disc approximation to an exponential disc # Coefficients here have been calculated using online calculator (http://astronomy.swin.edu.au/~cflynn/expmaker.php) # but it's fairly straightforward to implement calculation following https://ui.adsabs.harvard.edu/abs/2015MNRAS.448.2934S/abstract pot['disk1'] = gp.MiyamotoNagaiPotential(m=10E10 * 1.9627 * u.Msun, a=1.9746 * 5 * u.kpc, b=1 * u.kpc, units=galactic) pot['disk2'] = gp.MiyamotoNagaiPotential(m=10E10 * -1.2756 * u.Msun, a=4.2333 * 5 * u.kpc, b=1 * u.kpc, units=galactic)
nmax = ConfigItem( 6, "Maximum number of radial terms in the SCF expansion " "of the bar component") lmax = ConfigItem(6, "Maximum number of spherical hamonic l terms") Omega = ConfigItem(40., "Bar pattern speed [km/s/kpc]") bar_mass = ConfigItem(1E10, "Bar mass [Msun]") # TODO: add other tunable parameters once I decide on the potential... # ============================================================================== # Define the potential model up to the bar component potential_no_bar = gp.CCompositePotential() potential_no_bar['disk'] = gp.MiyamotoNagaiPotential(m=5E10 * u.Msun, a=3 * u.kpc, b=280 * u.pc, units=galactic) potential_no_bar['spheroid'] = gp.HernquistPotential(m=4E9 * u.Msun, c=0.6 * u.kpc, units=galactic) potential_no_bar['halo'] = gp.NFWPotential(m=6E11, r_s=18 * u.kpc, units=galactic) def get_hamiltonian(config_file=None): c = Config() c.load(config_file)
# Third-party packages from astropy.coordinates.matrix_utilities import rotation_matrix import astropy.units as u from scipy.optimize import minimize import gala.potential as gp from gala.units import galactic default_mw = gp.BovyMWPotential2014() default_disk_bulge = gp.CCompositePotential() default_disk_bulge['disk'] = default_mw['disk'] default_disk_bulge['bulge'] = default_mw['bulge'] def corot_func(r_cr, Omega, mw_pot): vc = mw_pot.circular_velocity([r_cr, 0., 0.]) return abs(vc - Omega * r_cr * u.kpc).decompose().value[0] def get_bar_model(Omega, Snlm, alpha=-27 * u.deg, m=5e9 * u.Msun, mw_pot=None): """Get an SCF bar model with the specified pattern speed. Parameters ---------- Omega : `~astropy.units.Quantity` The bar pattern speed. Snlm : array_like The expansion coefficients for the bar model. alpha : `~astropy.units.Quantity`, optional The initial angle of the bar relative to the x-axis. m : `~astropy.units.Quantity`, optional The bar mass.