def cluster_init(N, mMin, mMax, alpha, mCluster, rCluster):

    converter = nbody_system.nbody_to_si(mCluster, rCluster)
    cluster = new_plummer_model(N, convert_nbody=converter)
    mZAMS = new_powerlaw_mass_distribution(N, mMin, mMax, alpha)
    cluster.mass = mZAMS
    cluster.scale_to_standard(converter)
    return cluster
示例#2
0
def evolve_cluster_in_galaxy(N, W0, Rinit, tend, timestep, M, R):

    R_galaxy = 0.1 | units.kpc
    M_galaxy = 1.6e10 | units.MSun
    converter = nbody_system.nbody_to_si(M_galaxy, R_galaxy)
    galaxy = new_plummer_model(10000, convert_nbody=converter)

    print "com:", galaxy.center_of_mass().in_(units.kpc)
    print "comv:", galaxy.center_of_mass_velocity().in_(units.kms)

    print len(galaxy)
    galaxy_code = BHTree(converter, number_of_workers=2)
    galaxy_code.parameters.epsilon_squared = (0.01 | units.kpc)**2
    channe_to_galaxy = galaxy_code.particles.new_channel_to(galaxy)
    channe_to_galaxy.copy()
    galaxy_code.particles.add_particles(galaxy)
    inner_stars = galaxy.select(lambda r: r.length() < Rinit, ["position"])
    Minner = inner_stars.mass.sum()
    print "Minner=", Minner.in_(units.MSun)
    print "Ninner=", len(inner_stars)
    vc_inner = (constants.G * Minner / Rinit).sqrt()

    converter = nbody_system.nbody_to_si(Mcluster, Rcluster)
    stars = new_king_model(N, W0, convert_nbody=converter)
    masses = new_powerlaw_mass_distribution(N, 0.1 | units.MSun,
                                            100 | units.MSun, -2.35)
    stars.mass = masses
    stars.scale_to_standard(converter)

    stars.x += Rinit
    stars.vy += 0.8 * vc_inner
    cluster_code = ph4(converter, number_of_workers=2)
    cluster_code.particles.add_particles(stars)
    channel_to_stars = cluster_code.particles.new_channel_to(stars)

    system = bridge(verbose=False)
    system.add_system(cluster_code, (galaxy_code, ))
    system.add_system(galaxy_code, (cluster_code, ))
    system.timestep = 0.1 * timestep

    times = quantities.arange(0 | units.Myr, tend, timestep)
    for i, t in enumerate(times):
        print "Time=", t.in_(units.Myr)
        channe_to_galaxy.copy()
        channel_to_stars.copy()

        inner_stars = galaxy.select(lambda r: r.length() < Rinit, ["position"])
        print "Minner=", inner_stars.mass.sum().in_(units.MSun)

        system.evolve_model(t, timestep=timestep)
    plot_galaxy_and_stars(galaxy, stars)
    galaxy_code.stop()
    cluster_code.stop()
示例#3
0
def evolve_cluster_in_galaxy(N, W0, Rinit, tend, timestep, M, R):

    R_galaxy=0.1 | units.kpc
    M_galaxy=1.6e10 | units.MSun
    converter=nbody_system.nbody_to_si(M_galaxy, R_galaxy)
    galaxy=new_plummer_model(10000,convert_nbody=converter)

    print "com:", galaxy.center_of_mass().in_(units.kpc)
    print "comv:", galaxy.center_of_mass_velocity().in_(units.kms)
   
    print len(galaxy)
    galaxy_code = BHTree(converter, number_of_workers=2)
    galaxy_code.parameters.epsilon_squared = (0.01 | units.kpc)**2
    channe_to_galaxy = galaxy_code.particles.new_channel_to(galaxy)
    channe_to_galaxy.copy()
    galaxy_code.particles.add_particles(galaxy)
    inner_stars = galaxy.select(lambda r: r.length()<Rinit,["position"])
    Minner = inner_stars.mass.sum()
    print "Minner=", Minner.in_(units.MSun)
    print "Ninner=", len(inner_stars)
    vc_inner = (constants.G*Minner/Rinit).sqrt()

    converter=nbody_system.nbody_to_si(Mcluster,Rcluster)
    stars=new_king_model(N,W0,convert_nbody=converter)
    masses = new_powerlaw_mass_distribution(N, 0.1|units.MSun, 100|units.MSun, -2.35)
    stars.mass = masses
    stars.scale_to_standard(converter)
    
    stars.x += Rinit
    stars.vy += 0.8*vc_inner
    cluster_code=ph4(converter, number_of_workers=2)
    cluster_code.particles.add_particles(stars)
    channel_to_stars=cluster_code.particles.new_channel_to(stars)

    system=bridge(verbose=False)
    system.add_system(cluster_code, (galaxy_code,))
    system.add_system(galaxy_code, (cluster_code,))
    system.timestep = 0.1*timestep

    times = quantities.arange(0|units.Myr, tend, timestep)
    for i,t in enumerate(times):
        print "Time=", t.in_(units.Myr)
        channe_to_galaxy.copy()
        channel_to_stars.copy()

        inner_stars =  galaxy.select(lambda r: r.length()<Rinit,["position"])
        print "Minner=", inner_stars.mass.sum().in_(units.MSun)

        system.evolve_model(t,timestep=timestep)
    plot_galaxy_and_stars(galaxy, stars)
    galaxy_code.stop()
    cluster_code.stop()
def make_galaxy_model(N, M_galaxy, R_galaxy, Mmin, Mmax):
    converter = nbody_system.nbody_to_si(M_galaxy, R_galaxy)
    n_halo = 0
    n_bulge = 0
    n_disk = N
    galaxy = new_galactics_model(n_halo,
                                 converter,
                                 do_scale=True,
                                 bulge_number_of_particles=n_bulge,
                                 disk_number_of_particles=n_disk)
    from amuse.lab import new_powerlaw_mass_distribution
    masses = new_powerlaw_mass_distribution(len(galaxy), Mmin, Mmax, -2.0)
    galaxy.mass = masses
    galaxy.radius = 10 | units.parsec
    galaxy.King_W0 = 3
    return galaxy
示例#5
0
def generate_power_law_mass_function(N, Mmin, Mmax, ximf):
    masses = new_powerlaw_mass_distribution(N, Mmin, Mmax, ximf)
    plot_mass_function(masses, ximf)
示例#6
0
def generate_power_law_mass_function(N, Mmin, Mmax, ximf):
    masses = new_powerlaw_mass_distribution(N, Mmin, Mmax, ximf)
    plot_mass_function(masses, ximf)