# shift the cluster to an orbit around Galactic center acc, _, _ = galaxy.get_gravity_at_point(0 | units.kpc, Rinit, 0 | units.kpc, 0 | units.kpc) vcirc = (-acc * Rinit)**0.5 print("Vcirc=%f km/s" % vcirc.value_in(units.kms)) particles.x += Rinit particles.vy += vcirc cluster.particles.add_particles(particles) # set up bridge; cluster is evolved under influence of the galaxy sys = bridge(verbose=False) sys.add_system(cluster, (galaxy, ), False) # evolve and make plots times = units.Myr([0., 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4]) f = pyplot.figure(figsize=(16, 8)) for i, t in enumerate(times): sys.evolve_model(t, timestep=timestep) print("Evolved the system to time %f" % t) x = sys.particles.x.value_in(units.parsec) y = sys.particles.y.value_in(units.parsec) subplot = f.add_subplot(2, 4, i + 1) subplot.plot(x, y, 'r .') subplot.plot([0.], [0.], 'b +') subplot.set_xlim(-60, 60) subplot.set_ylim(-60, 60) subplot.set_title(t)
# shift the cluster to an orbit around GC # (note the systems share the same coordinate frame, although units may # differ) vcirc = circular_velocity_for_stable_orbit(Rinit, central_mass) shift_particles(cluster, Rinit, 0 | units.parsec, 0. | units.parsec, 0 | units.kms, 0.8 * vcirc, 0 | units.kms) code.particles.add_particles(cluster) # add galactic center to the code code.particles.add_particle(galactic_center) print("Start evolution") # evolve and make plots times = units.Myr([0., 0.2, 0.4, 0.6]) f = pyplot.figure(figsize=(8, 8)) for i, time in enumerate(times): code.evolve_model(time) print("Evolved to time:", time) x = code.particles.x.value_in(units.parsec) y = code.particles.y.value_in(units.parsec) subplot = f.add_subplot(2, 2, i + 1) subplot.plot(x, y, 'r .') subplot.plot([0.], [0.], 'b +') subplot.set_xlim(-60, 60) subplot.set_ylim(-60, 60) subplot.set_title(time) if i == 7: