Exemple #1
0
def new_disk_with_bump(Mstar=1 | units.MSun,
                       Ndisk=100,
                       Mdisk=0.9 | units.MSun,
                       Rmin=1.0 | units.AU,
                       Rmax=100.0 | units.AU,
                       Mbump=0.1 | units.MSun,
                       Rbump=10.0 | units.AU,
                       abump=10 | units.AU):

    converter = nbody_system.nbody_to_si(Mdisk, Rmin)
    from amuse.ext.protodisk import ProtoPlanetaryDisk
    bodies = ProtoPlanetaryDisk(Ndisk,
                                convert_nbody=converter,
                                densitypower=1.5,
                                Rmin=1,
                                Rmax=Rmax / Rmin,
                                q_out=1.0,
                                discfraction=1.0).result
    Mdisk = bodies.mass.sum()
    bodies.move_to_center()
    com = bodies.center_of_mass()

    mm = Mdisk / float(Ndisk)
    Nbump = Mbump / mm
    bump = new_plummer_gas_model(Nbump,
                                 convert_nbody=nbody_system.nbody_to_si(
                                     Mbump, Rbump))

    bump.x += abump
    r_bump = abump
    inner_particles = bodies.select(lambda r: (com - r).length() < abump,
                                    ["position"])
    M_inner = inner_particles.mass.sum() + Mstar

    v_circ = (constants.G * M_inner *
              (2. / r_bump - 1. / abump)).sqrt().value_in(units.kms)
    bump.velocity += [0, v_circ, 0] | units.kms
    bodies.add_particles(bump)

    bodies = bodies.select(lambda r: (com - r).length() > Rmin, ["position"])
    bodies = bodies.select(lambda r: (com - r).length() < Rmax, ["position"])

    print("Nbump=", Ndisk, Mbump, Rbump, Nbump)
    print("Mass =", Mstar, Mdisk,
          bodies.mass.sum().in_(units.MSun),
          bodies.mass.sum() / Mstar)

    print("X-min/max:", min(bodies.x), max(bodies.x))
    bodies = bodies.select(lambda r: r.length() < 1.0 * Rmax, ["position"])
    print("X-min/max:", min(bodies.x), max(bodies.x))

    return bodies
Exemple #2
0
def new_disk_with_bump(Mstar = 1|units.MSun,
                       Ndisk=100, Mdisk=0.9|units.MSun, 
                       Rmin=1.0|units.AU, Rmax=100.0|units.AU, 
                       Mbump=0.1|units.MSun,Rbump=10.0|units.AU, 
                       abump=10|units.AU):
    converter=nbody_system.nbody_to_si(Mdisk, Rmin)
    bodies = ProtoPlanetaryDisk(Ndisk, convert_nbody=converter, 
                                densitypower=1.5, 
                                Rmin=1.0, 
                                Rmax=Rmax/Rmin,
                                q_out=1.0,
                                discfraction=1.0).result
    Mdisk = bodies.mass.sum()
    bodies.move_to_center()
    com = bodies.center_of_mass()

    mm = Mdisk/float(Ndisk)
    Nbump = Mbump/mm
    print "Nbump=", Mbump, Rbump, Nbump
    print "Mass =", Mstar, Mdisk, bodies.mass.sum().in_(units.MSun), bodies.mass.sum()/Mstar
    bump = new_plummer_gas_model(Nbump, convert_nbody=nbody_system.nbody_to_si(Mbump, Rbump))

    bump.x += abump
    r_bump = abump 
    inner_particles = bodies.select(lambda r: (com-r).length()<abump,["position"])
    M_inner = inner_particles.mass.sum() + Mstar

    v_circ = (constants.G*M_inner*(2./r_bump - 1./abump)).sqrt().value_in(units.kms)
    bump.velocity += [0, v_circ, 0] | units.kms
    bodies.add_particles(bump)
    return bodies
Exemple #3
0
def new_disk_with_bump(Mstar = 10|units.MSun,
                       Ndisk=100, Mdisk=1.0|units.MSun, 
                       Rmin=1.0|units.AU, Rmax=100.0|units.AU, 
                       Mbump=0.1|units.MSun,Rbump=5.0|units.AU, 
                       abump=10|units.AU):

    converter=nbody_system.nbody_to_si(Mstar, Rmin)
    disk = ProtoPlanetaryDisk(Ndisk, convert_nbody=converter,
                              densitypower=1.5, Rmin=1, Rmax=Rmax/Rmin,
                              q_out=1.0, discfraction=Mdisk/Mstar).result
    com = disk.center_of_mass()

    # determine bump's local velocity
    
    inner_particles = disk.select(lambda r: (com-r).length()
                                                   < abump,["position"])
    M_inner = Mstar + inner_particles.mass.sum() 
    v_circ = (constants.G*M_inner*(2./abump - 1./abump)) \
                 .sqrt().value_in(units.kms)

    # initialize bump
    
    Nbump = int(Ndisk*Mbump/Mdisk)
    bump = new_plummer_gas_model(Nbump,
                                 convert_nbody=nbody_system.nbody_to_si(Mbump,
                                                                        Rbump))
    bump.x += abump
    bump.velocity += [0, v_circ, 0] | units.kms

    disk.add_particles(bump)
    disk.move_to_center()
    return disk
Exemple #4
0
def main(N=1000, Lstar=100| units.LSun, boxsize=10| units.parsec, 
         rho=1.0| (units.amu/units.cm**3), t_end=0.1|units.Myr, n_steps=10):

    ionization_fraction = 0.0
    internal_energy = (9. |units.kms)**2

    source=Particles(1)
    source.position = (0, 0, 0) |units.parsec
    source.flux = Lstar/(20. | units.eV)
    source.luminosity = Lstar/(20. | units.eV)
    source.rho = rho
    source.xion = ionization_fraction
    source.u = internal_energy

    converter=nbody_system.nbody_to_si(1|units.MSun, boxsize)
    ism = ProtoPlanetaryDisk(N, convert_nbody=converter, 
                                densitypower=1.5, 
                                Rmin=0.1, 
                                Rmax=1,
                                q_out=1.0,
                                discfraction=1.0).result
    ism = ism.select(lambda r: r.length()<0.5*boxsize,["position"])
    gamma=5./3.
    mu=1.| units.amu
    Tinit = 10000|units.K
    ism.u = 1/(gamma-1)*constants.kB * Tinit/mu
    ism.rho = rho
    ism.flux = 0. | units.s**-1
    ism.xion = ionization_fraction 
    ism.h_smooth = 0 | units.AU

    rad = SimpleXSplitSet(redirect="none")
#    rad = SimpleX()
#    rad = SPHRay()
    rad.parameters.box_size=1.001*boxsize    
    rad.parameters.timestep=0.001 | units.Myr

    rad.src_particles.add_particle(source)
    rad.gas_particles.add_particles(ism)

    channel_to_local_gas = rad.gas_particles.new_channel_to(ism)
    write_set_to_file(ism, "rad.hdf5", 'hdf5')

    time = 0.0 | t_end.unit
    dt = t_end/float(n_steps)
    while time<t_end:
        time += dt
        rad.evolve_model(time)
        channel_to_local_gas.copy_attributes(["xion",])
        write_set_to_file(ism, "rad.hdf5", 'hdf5')

        print "Time=", time
        print "min ionization:", rad.gas_particles.xion.min()
        print "average Xion:", rad.gas_particles.xion.mean()
        print "max ionization:", rad.gas_particles.xion.max()
    rad.stop()
Exemple #5
0
def main(N=1000,
         Lstar=100 | units.LSun,
         boxsize=10 | units.parsec,
         rho=1.0 | (units.amu / units.cm**3),
         t_end=0.1 | units.Myr,
         n_steps=10):

    ionization_fraction = 0.0
    internal_energy = (9. | units.kms)**2

    source = Particles(1)
    source.position = (0, 0, 0) | units.parsec
    source.flux = Lstar / (20. | units.eV)
    source.luminosity = Lstar / (20. | units.eV)
    source.rho = rho
    source.xion = ionization_fraction
    source.u = internal_energy

    converter = nbody_system.nbody_to_si(1 | units.MSun, boxsize)
    ism = ProtoPlanetaryDisk(N,
                             convert_nbody=converter,
                             densitypower=1.5,
                             Rmin=0.1,
                             Rmax=1,
                             q_out=1.0,
                             discfraction=1.0).result
    ism = ism.select(lambda r: r.length() < 0.5 * boxsize, ["position"])
    gamma = 5. / 3.
    mu = 1. | units.amu
    Tinit = 10000 | units.K
    ism.u = 1 / (gamma - 1) * constants.kB * Tinit / mu
    ism.rho = rho
    ism.flux = 0. | units.s**-1
    ism.xion = ionization_fraction
    ism.h_smooth = 0 | units.AU

    rad = SimpleXSplitSet(redirect="none")
    #    rad = SimpleX()
    #    rad = SPHRay()
    rad.parameters.box_size = 1.001 * boxsize
    rad.parameters.timestep = 0.001 | units.Myr

    rad.src_particles.add_particle(source)
    rad.gas_particles.add_particles(ism)

    channel_to_local_gas = rad.gas_particles.new_channel_to(ism)
    write_set_to_file(ism, "rad.hdf5", 'hdf5')

    time = 0.0 | t_end.unit
    dt = t_end / float(n_steps)
    while time < t_end:
        time += dt
        rad.evolve_model(time)
        channel_to_local_gas.copy_attributes([
            "xion",
        ])
        write_set_to_file(ism, "rad.hdf5", 'hdf5')

        print("Time=", time)
        print("min ionization:", rad.gas_particles.xion.min())
        print("average Xion:", rad.gas_particles.xion.mean())
        print("max ionization:", rad.gas_particles.xion.max())
    rad.stop()
Exemple #6
0
def main(Mstar=1 | units.MSun,
         Ndisk=100,
         Mdisk=0.9 | units.MSun,
         Rmin=1.0 | units.AU,
         Rmax=100.0 | units.AU,
         Mbump=0.1 | units.MSun,
         Rbump=10.0 | units.AU,
         abump=10 | units.AU,
         t_end=1,
         n_steps=10):

    converter = nbody_system.nbody_to_si(Mdisk, Rmin)
    from amuse.ext.protodisk import ProtoPlanetaryDisk
    bodies = ProtoPlanetaryDisk(Ndisk,
                                convert_nbody=converter,
                                densitypower=1.5,
                                Rmin=1.0,
                                Rmax=Rmax / Rmin,
                                q_out=1.0,
                                discfraction=1.0).result
    Mdisk = bodies.mass.sum()
    bodies.move_to_center()
    com = bodies.center_of_mass()

    mm = Mdisk / float(Ndisk)
    Nbump = int(Mbump / mm)
    bump = new_plummer_gas_model(Nbump,
                                 convert_nbody=nbody_system.nbody_to_si(
                                     Mbump, Rbump))

    bump.x += abump
    r_bump = abump
    inner_particles = bodies.select(lambda r: (com - r).length() < abump,
                                    ["position"])
    M_inner = inner_particles.mass.sum() + Mstar
    v_circ = (constants.G * M_inner *
              (2. / r_bump - 1. / abump)).sqrt().value_in(units.kms)
    bump.velocity += [0, v_circ, 0] | units.kms
    bodies.add_particles(bump)

    star = Particles(1)
    star.mass = Mstar
    star.radius = Rmin
    star.position = [0, 0, 0] | units.AU
    star.velocity = [0, 0, 0] | units.kms

    import math
    P_bump = (abump**3 * 4 * math.pi**2 / (constants.G *
                                           (Mbump + Mstar))).sqrt()
    t_end *= P_bump

    hydro = Gadget2(converter)
    hydro.gas_particles.add_particles(bodies)
    hydro.dm_particles.add_particles(star)
    Etot_init = hydro.kinetic_energy + hydro.potential_energy + hydro.thermal_energy

    particles = ParticlesSuperset([star, bodies])
    particles.move_to_center()
    particles.new_channel_to(hydro.particles).copy()
    bodies.h_smooth = Rmin  # for the plotting routine
    channel_to_star = hydro.dm_particles.new_channel_to(star)
    channel_to_bodies = hydro.gas_particles.new_channel_to(bodies)

    write_set_to_file(star, "stars.hdf5", "hdf5")
    write_set_to_file(bodies, "hydro.hdf5", "hdf5")

    time = 0.0 | t_end.unit
    dt = t_end / float(n_steps)
    while time < t_end:
        time += dt
        hydro.evolve_model(time)

        channel_to_star.copy()
        channel_to_bodies.copy()
        write_set_to_file(star, "stars.hdf5", "hdf5")
        write_set_to_file(bodies, "hydro.hdf5", "hdf5")
        star.radius = Rmin

        from hydro_sink_particles import hydro_sink_particles
        lost = hydro_sink_particles(star, bodies)
        if len(lost) > 0:
            hydro.particles.remove_particles(lost)
            hydro.particles.synchronize_to(particles)
            print("Disk=", hydro.model_time, len(bodies), len(lost),
                  lost.mass.sum(), star.mass)

        Ekin = hydro.kinetic_energy
        Epot = hydro.potential_energy
        Eth = hydro.thermal_energy
        Etot = Ekin + Epot + Eth
        print("T=",
              hydro.get_time(),
              "M=",
              hydro.gas_particles.mass.sum(),
              end=' ')
        print("E= ", Etot, "Q= ", (Ekin + Eth) / Epot, "dE=",
              (Etot_init - Etot) / Etot)
        print("Star=", hydro.model_time, star[0].mass, star[0].position)

    hydro.stop()
Exemple #7
0
def main(Mstar=1,
         Ndisk=100,
         Mdisk=0.001,
         Rmin=1,
         Rmax=100,
         t_end=10,
         n_steps=10,
         filename="nbody.hdf5"):
    #    numpy.random.seed(111)
    Mstar = Mstar | units.MSun
    Mdisk = Mdisk | units.MSun
    Rmin = Rmin | units.AU
    Rmax = Rmax | units.AU
    t_end = t_end | units.yr

    #    converter=nbody_system.nbody_to_si(Mdisk, Rmax)
    converter = nbody_system.nbody_to_si(Mstar, Rmin)
    disk = ProtoPlanetaryDisk(Ndisk,
                              convert_nbody=converter,
                              densitypower=1.5,
                              Rmin=Rmin.value_in(units.AU),
                              Rmax=Rmax.value_in(units.AU),
                              q_out=1.0,
                              discfraction=1.0).result

    disk.move_to_center()

    center_of_mass = disk.center_of_mass()
    print(center_of_mass)
    a_bump = 50
    Rbump = 10 | units.AU
    bump_location = center_of_mass + ([0, a_bump, 0] | units.AU)
    bump_particles = disk.select(
        lambda r: (center_of_mass - r).length() < Rbump, ["position"])
    Mbump = bump_particles.mass.sum()

    Nbump = len(bump_particles)
    print("Nbump=", len(bump_particles), Mbump, Rbump, Nbump)
    print("Mass =", Mstar, Mdisk,
          disk.mass.sum().in_(units.MSun),
          disk.mass.sum() / Mstar)
    bump = new_plummer_gas_model(Nbump,
                                 convert_nbody=nbody_system.nbody_to_si(
                                     0.1 * Mbump, Rbump))

    a_bump = a_bump | units.AU
    bump.x += a_bump
    r_bump = a_bump
    inner_particles = disk.select(
        lambda r: (center_of_mass - r).length() < a_bump, ["position"])
    M_inner = inner_particles.mass.sum() + Mstar

    v_circ = (constants.G * M_inner *
              (2. / r_bump - 1. / a_bump)).sqrt().value_in(units.kms)
    bump.velocity += [0, v_circ, 0] | units.kms
    print("MM=", M_inner, v_circ)

    disk.add_particles(bump)

    disk.h_smooth = Rmin / (Ndisk + Nbump)
    star = Particles(1)
    star.mass = Mstar
    star.radius = 1. | units.RSun
    star.position = [0, 0, 0] | units.AU
    star.velocity = [0, 0, 0] | units.kms

    #    star2=Particles(1)
    #    star2.mass=Mstar
    #    star2.radius=1. | units.RSun
    #    star2.position = [1, 0, 0] | units.AU
    #    star2.velocity = [0, 30, 0] | units.kms

    hydro = Fi(converter)
    #    hydror = Fi(channel_type="ibis", hostname="galgewater")

    hydro.parameters.use_hydro_flag = True
    hydro.parameters.radiation_flag = False
    hydro.parameters.self_gravity_flag = True
    hydro.parameters.gamma = 1.
    hydro.parameters.isothermal_flag = True
    hydro.parameters.integrate_entropy_flag = False
    hydro.parameters.timestep = 0.125 | units.yr

    hydro.gas_particles.add_particles(disk)

    gravity = Hermite(converter)
    gravity.particles.add_particles(star)
    #    gravity.particles.add_particles(star2)
    #    gravity.particles.move_to_center()

    channel_from_gravity_to_framework = gravity.particles.new_channel_to(star)
    channel_from_hydro_to_framework = hydro.particles.new_channel_to(disk)

    # make a repository of the star+disk particles in moving bodies
    #    moving_bodies = star.union(disk)
    moving_bodies = ParticlesSuperset([star, disk])

    moving_bodies.move_to_center()

    write_set_to_file(moving_bodies, filename, 'hdf5')

    gravity_hydro = bridge.Bridge(use_threading=False)
    gravity_hydro.add_system(gravity, (hydro, ))
    gravity_hydro.add_system(hydro, (gravity, ))

    Etot_init = gravity_hydro.kinetic_energy + gravity_hydro.potential_energy
    Etot_prev = Etot_init

    time = 0.0 | t_end.unit
    dt = t_end / float(n_steps)
    gravity_hydro.timestep = dt / 10.
    while time < t_end:
        time += dt
        gravity_hydro.evolve_model(time)

        Etot_prev_se = gravity_hydro.kinetic_energy + gravity_hydro.potential_energy

        channel_from_gravity_to_framework.copy()
        channel_from_hydro_to_framework.copy()
        write_set_to_file(moving_bodies, filename, 'hdf5')

        Ekin = gravity_hydro.kinetic_energy
        Epot = gravity_hydro.potential_energy
        Etot = Ekin + Epot
        print("T=", time, end=' ')
        print("E= ", Etot, "Q= ", Ekin / Epot, end=' ')
        print("dE=", (Etot_init - Etot) / Etot, "ddE=",
              (Etot_prev - Etot) / Etot)
        print("star=", star)
        Etot_prev = Etot

    gravity_hydro.stop()
Exemple #8
0
def main(Mstar=1, Ndisk=100, Mdisk= 0.001, Rmin=1, Rmax=100, t_end=10, n_steps=10, filename="nbody.hdf5"):
#    numpy.random.seed(111)
    Mstar = Mstar | units.MSun
    Mdisk = Mdisk | units.MSun
    Rmin = Rmin | units.AU
    Rmax = Rmax | units.AU
    t_end = t_end | units.yr

#    converter=nbody_system.nbody_to_si(Mdisk, Rmax)
    converter=nbody_system.nbody_to_si(Mstar, Rmin)
    disk = ProtoPlanetaryDisk(Ndisk, convert_nbody=converter, densitypower=1.5, 
                              Rmin=Rmin.value_in(units.AU), 
                              Rmax=Rmax.value_in(units.AU),q_out=1.0,
                              discfraction=1.0).result
 

    disk.move_to_center()

    center_of_mass = disk.center_of_mass()
    print center_of_mass
    a_bump = 50 
    Rbump = 10 | units.AU
    bump_location = center_of_mass + ([0, a_bump, 0] | units.AU)
    bump_particles = disk.select(lambda r: (center_of_mass-r).length()<Rbump,["position"])
    Mbump =bump_particles.mass.sum()

    Nbump = len(bump_particles)
    print "Nbump=", len(bump_particles), Mbump, Rbump, Nbump
    print "Mass =", Mstar, Mdisk, disk.mass.sum().in_(units.MSun), disk.mass.sum()/Mstar
    bump = new_plummer_gas_model(Nbump, convert_nbody=nbody_system.nbody_to_si(0.1*Mbump, Rbump))

    a_bump = a_bump | units.AU
    bump.x += a_bump
    r_bump = a_bump 
    inner_particles = disk.select(lambda r: (center_of_mass-r).length()<a_bump,["position"])
    M_inner = inner_particles.mass.sum() + Mstar

    v_circ = (constants.G*M_inner*(2./r_bump - 1./a_bump)).sqrt().value_in(units.kms)
    bump.velocity += [0, v_circ, 0] | units.kms
    print "MM=", M_inner, v_circ

    disk.add_particles(bump)

    disk.h_smooth= Rmin/(Ndisk+Nbump)
    star=Particles(1)
    star.mass=Mstar
    star.radius=1. | units.RSun
    star.position = [0, 0, 0] | units.AU
    star.velocity = [0, 0, 0] | units.kms

#    star2=Particles(1)
#    star2.mass=Mstar
#    star2.radius=1. | units.RSun
#    star2.position = [1, 0, 0] | units.AU
#    star2.velocity = [0, 30, 0] | units.kms
 
    hydro=Fi(converter)
#    hydror = Fi(channel_type="ibis", hostname="galgewater")

 
    hydro.parameters.use_hydro_flag=True
    hydro.parameters.radiation_flag=False
    hydro.parameters.self_gravity_flag=True
    hydro.parameters.gamma=1.
    hydro.parameters.isothermal_flag=True
    hydro.parameters.integrate_entropy_flag=False
    hydro.parameters.timestep=0.125 | units.yr  

    hydro.gas_particles.add_particles(disk)

    gravity = Hermite(converter)
    gravity.particles.add_particles(star)
#    gravity.particles.add_particles(star2)
#    gravity.particles.move_to_center()

    channel_from_gravity_to_framework = gravity.particles.new_channel_to(star)
    channel_from_hydro_to_framework = hydro.particles.new_channel_to(disk)

    # make a repository of the star+disk particles in moving bodies
#    moving_bodies = star.union(disk)
    moving_bodies = ParticlesSuperset([star, disk])

    moving_bodies.move_to_center()

    write_set_to_file(moving_bodies, filename, 'hdf5')
    
    gravity_hydro = bridge.Bridge(use_threading=False)
    gravity_hydro.add_system(gravity, (hydro,) )
    gravity_hydro.add_system(hydro, (gravity,) )

    Etot_init = gravity_hydro.kinetic_energy + gravity_hydro.potential_energy
    Etot_prev = Etot_init

    time = 0.0 | t_end.unit
    dt = t_end/float(n_steps)
    gravity_hydro.timestep = dt/10.
    while time < t_end:
        time += dt
        gravity_hydro.evolve_model(time)

        Etot_prev_se = gravity_hydro.kinetic_energy + gravity_hydro.potential_energy

        channel_from_gravity_to_framework.copy()
        channel_from_hydro_to_framework.copy()
        write_set_to_file(moving_bodies, filename, 'hdf5')

        Ekin = gravity_hydro.kinetic_energy 
        Epot = gravity_hydro.potential_energy
        Etot = Ekin + Epot
        print "T=", time, 
        print "E= ", Etot, "Q= ", Ekin/Epot,
        print "dE=", (Etot_init-Etot)/Etot, "ddE=", (Etot_prev-Etot)/Etot 
        print "star=", star
        Etot_prev = Etot

    gravity_hydro.stop()
Exemple #9
0
def main(Mstar = 1|units.MSun,
         Ndisk=100, Mdisk=0.9|units.MSun, 
         Rmin=1.0|units.AU, Rmax=100.0|units.AU, 
         Mbump=0.1|units.MSun,Rbump=10.0|units.AU, abump=10|units.AU,
         t_end=1, n_steps=10):

    converter=nbody_system.nbody_to_si(Mdisk, Rmin)
    from amuse.ext.protodisk import ProtoPlanetaryDisk
    bodies = ProtoPlanetaryDisk(Ndisk, convert_nbody=converter, 
                                densitypower=1.5, Rmin=1.0, 
                                Rmax=Rmax/Rmin, q_out=1.0,
                                discfraction=1.0).result
    Mdisk = bodies.mass.sum()
    bodies.move_to_center()
    com = bodies.center_of_mass()

    mm = Mdisk/float(Ndisk)
    Nbump = Mbump/mm
    bump = new_plummer_gas_model(Nbump, convert_nbody=nbody_system.nbody_to_si(Mbump, Rbump))

    bump.x += abump
    r_bump = abump 
    inner_particles = bodies.select(lambda r: (com-r).length()<abump,["position"])
    M_inner = inner_particles.mass.sum() + Mstar
    v_circ = (constants.G*M_inner*(2./r_bump - 1./abump)).sqrt().value_in(units.kms)
    bump.velocity += [0, v_circ, 0] | units.kms
    bodies.add_particles(bump)

    star=Particles(1)
    star.mass=Mstar
    star.radius= Rmin
    star.position = [0, 0, 0] | units.AU
    star.velocity = [0, 0, 0] | units.kms

    import math
    P_bump = (abump**3*4*math.pi**2/(constants.G*(Mbump+Mstar))).sqrt()
    t_end *= P_bump

    hydro = Gadget2(converter)
    hydro.gas_particles.add_particles(bodies)
    hydro.dm_particles.add_particles(star)
    Etot_init = hydro.kinetic_energy + hydro.potential_energy + hydro.thermal_energy

    particles = ParticlesSuperset([star, bodies])
    particles.move_to_center()
    particles.new_channel_to(hydro.particles).copy()
    bodies.h_smooth = Rmin # for the plotting routine
    channel_to_star = hydro.dm_particles.new_channel_to(star)
    channel_to_bodies = hydro.gas_particles.new_channel_to(bodies)

    write_set_to_file(star, "stars.hdf5","hdf5")
    write_set_to_file(bodies, "hydro.hdf5","hdf5")

    time = 0.0 | t_end.unit
    dt = t_end/float(n_steps)
    while time < t_end:
        time += dt
        hydro.evolve_model(time)

        channel_to_star.copy()
        channel_to_bodies.copy()
        write_set_to_file(star, "stars.hdf5","hdf5")
        write_set_to_file(bodies, "hydro.hdf5","hdf5")
        star.radius = Rmin

        from hydro_sink_particles import hydro_sink_particles
        lost = hydro_sink_particles(star, bodies)
        if len(lost)>0:
            hydro.particles.remove_particles(lost)
            hydro.particles.synchronize_to(particles)
            print "Disk=", hydro.model_time, len(bodies), len(lost), lost.mass.sum(), star.mass

        Ekin = hydro.kinetic_energy 
        Epot = hydro.potential_energy
        Eth = hydro.thermal_energy
        Etot = Ekin + Epot + Eth
        print "T=", hydro.get_time(), "M=", hydro.gas_particles.mass.sum(), 
        print "E= ", Etot, "Q= ", (Ekin+Eth)/Epot, "dE=", (Etot_init-Etot)/Etot
        print "Star=", hydro.model_time, star[0].mass, star[0].position

    hydro.stop()