def get_inclined_disk(disk, incl_deg=0., omega_deg=0., lon_deg=0.): """ rotate particles by inclination, longitude of ascending node, and argument of pericenter """ incl = incl_deg * pi_180 omega = omega_deg * pi_180 longitude = lon_deg * pi_180 # get rotation matrix a1 = ([numpy.cos(longitude), -numpy.sin(longitude), 0.0], [numpy.sin(longitude), numpy.cos(longitude), 0.0], [0.0, 0.0, 1.0]) a2 = ([1.0, 0.0, 0.0], [0.0, numpy.cos(incl), -numpy.sin(incl)], [0.0, numpy.sin(incl), numpy.cos(incl)]) a3 = ([numpy.cos(omega), -numpy.sin(omega), 0.0], [numpy.sin(omega), numpy.cos(omega), 0.0], [0.0, 0.0, 1.0]) rot = numpy.dot(numpy.dot(a1,a2),a3) # reshape positions and velocity vectors pos = disk.position.value_in(units.kpc) vel = disk.velocity.value_in(units.kpc/units.Myr) # rotate pos_rot = (numpy.dot(rot, pos.T)).T | units.kpc vel_rot = (numpy.dot(rot, vel.T)).T | (units.kpc/units.Myr) inclined_disk = Particles(len(disk)) inclined_disk.mass = disk.mass inclined_disk.position = pos_rot inclined_disk.velocity = vel_rot inclined_disk.id = disk.id return inclined_disk
def new_gas_particle(self, mass, x, y, z, vx, vy, vz, *args): next_id = len(self._gas_particles) + 1000000 temp = Particles(len(mass)) temp.mass = mass temp.x = x temp.y = y temp.z = z temp.vx = vx temp.vy = vy temp.vz = vz temp.id = list(range(next_id, next_id + len(mass))) self._gas_particles.add_particles(temp) return [temp.id, temp.id]
def new_gas_particle(self, mass, x, y, z, vx, vy, vz, *args): next_id = len(self._gas_particles) + 1000000 temp = Particles(len(mass)) temp.mass = mass temp.x = x temp.y = y temp.z = z temp.vx = vx temp.vy = vy temp.vz = vz temp.id = list(range(next_id, next_id + len(mass))) self._gas_particles.add_particles(temp) return [temp.id, temp.id]
def test61(self): test_results_path = self.get_path_to_results() output_file = os.path.join(test_results_path, "test61"+self.store_version()+".h5") if os.path.exists(output_file): os.remove(output_file) x = Particles(10) x.mass = 1 | units.kg y = Particles(20) y.id = range(20) x[0].y = y[5:7] io.write_set_to_file(x, output_file,"amuse", version=self.store_version()) z = io.read_set_from_file(output_file,"amuse") self.assertEquals(x[0].y[0].id, 5) self.assertEquals(z[0].y[0].id, 5) os.remove(output_file)
def get_tt72_disk(m=10.e11|units.MSun, r_min=25.|units.kpc, n_rings=[12,15,18,21,24,27,30,33,36,39,42,45], r_rings_rel=[0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75], disk_id='a', eps=0.|units.m): """ initialize disk ala TT72 (see the first paragraphs of sec. II and III of the paper) positions and velocities with respect to the central particle of mass m """ disk = Particles() for i,ri in enumerate(r_rings_rel): disk_rad_i = Particles(n_rings[i]) a = ri*r_min phi_i = numpy.linspace(0., pipi, num=n_rings[i], endpoint=False) disk_rad_i.x = a * numpy.cos(phi_i) disk_rad_i.y = a * numpy.sin(phi_i) disk_rad_i.z = 0. * a x_r = disk_rad_i.x/a y_r = disk_rad_i.y/a #vc = (constants.G*m/a)**0.5 vc = ( constants.G*m*a**2/(a**2 + eps**2)**1.5 )**0.5 disk_rad_i.vx = -vc * y_r disk_rad_i.vy = vc * x_r disk_rad_i.vz = 0.0 * vc disk.add_particles(disk_rad_i) # test particles disk.mass = 0.|units.MSun # identification of the disk disk.id = disk_id return disk