def setup_sph_code(N1, N2, L, rho, u): #rho -- local group density #converter = nbody_system.nbody_to_si(1 | units.MSun, 1 | units.kpc) #sph_code = sph_code(converter)#, mode = 'periodic')#, redirection = 'none')#change periodic #sph_code.parameters.periodic_box_size = 10.0 | units.kpc dm = Particles(N1) dm.mass = 0.8 * (rho * L**3) / N1 #np.random.seed(12345) dm.x = L * np.random.uniform(-0.5, 0.5, N1) dm.y = L * np.random.uniform(-0.5, 0.5, N1) dm.z = L * np.random.uniform(-0.5, 0.5, N1) dm.vx = np.zeros(N1) | units.km / units.s dm.vy = np.zeros(N1) | units.km / units.s dm.vz = np.zeros(N1) | units.km / units.s gas = Particles(N2) gas.mass = 0.2 * (rho * L**3) / N2 gas.x = L * np.random.uniform(-0.5, 0.5, N2) gas.y = L * np.random.uniform(-0.5, 0.5, N2) gas.z = L * np.random.uniform(-0.5, 0.5, N2) gas.vx = np.zeros(N2) | units.km / units.s gas.vy = np.zeros(N2) | units.km / units.s gas.vz = np.zeros(N2) | units.km / units.s gas.u = u gas.h_smooth = L / N2**(1 / 3.0) dm.h_smooth = L / N1**(1 / 3.0) #sph_code.gas_particles.add_particles(gas) #sph_code.dm_particles.add_particles(dm) #sph_code.commit_particles() return gas, dm
def setup_sph_code(sph_code, N1, N2, L, rho,u): #rho -- local group density converter = nbody_system.nbody_to_si(1 | units.MSun, 1 | units.kpc) sph_code = sph_code(converter, redirection = 'none')#, mode = 'periodic')#, redirection = 'none')#change periodic #sph_code.parameters.periodic_box_size = 10.0 | units.kpc dm = Particles(N1) dm.mass = (rho * L**3) / N1 np.random.seed(12345) dm.x = L * np.random.uniform(0.0, 1.0, N1) dm.y = L * np.random.uniform(0.0, 1.0, N1) dm.z = L * np.random.uniform(0.0, 1.0, N1) dm.vx = np.zeros(N1) | units.km / units.s dm.vy = np.zeros(N1) | units.km / units.s dm.vz = np.zeros(N1) | units.km / units.s gas = Particles(N2) gas.mass = (rho * L**3) / N2 gas.x = L * np.random.uniform(0.0, 1.0, N2) gas.y = L * np.random.uniform(0.0, 1.0, N2) gas.z = L * np.random.uniform(0.0, 1.0, N2) gas.vx = np.zeros(N2) | units.km / units.s gas.vy = np.zeros(N2) | units.km / units.s gas.vz = np.zeros(N2) | units.km / units.s gas.u = u if isinstance(sph_code, Fi): sph_code.parameters.self_gravity_flag = True sph_code.parameters.timestep = 5 | units.Myr gas.h_smooth = L / N2**(1/3.0) dm.h_smooth = L / N1**(1/3.0) #gas.position -= 0.5 * L sph_code.gas_particles.add_particles(gas) sph_code.dm_particles.add_particles(dm) sph_code.commit_particles() return sph_code
height=image_width, ) evolve_to_age(fieldstars, age) # TODO: add distance modulus stars.add_particles(fieldstars) if gasfilename: gas = read_set_from_file( gasfilename, filetype, close_file=True, ) gas.position -= com else: gas = Particles() gas.h_smooth = 0.05 | units.parsec # FIXME: add these features # - Rotate so that xy = observed x/y axes of figure # - Scale positions to desired ra/dec (script Alison) # - calculate vmax based on nr of photons/exposure time fig, ax = plt.subplots(nrows=1, ncols=1, figsize=figsize, dpi=dpi) fig.subplots_adjust(left=left, right=right, top=top, bottom=bottom) ax.set_xlim([xmin, xmax]) ax.set_ylim([ymin, ymax]) ax.set_xlabel("[%s]" % (length_unit)) ax.set_ylabel("[%s]" % (length_unit)) ax.set_aspect(1) ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False)