Beispiel #1
0
def irradiate_disk_with_bump(Mstar=10 | units.MSun,
                             tstar=20 | units.Myr,
                             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=10 | units.yr,
                             n_steps=10):
    dt = t_end / float(n_steps)

    stellar = SeBa()
    stellar.particles.add_particle(Particle(mass=Mstar))
    stellar.evolve_model(tstar)

    source = Particles(1)
    source.mass = stellar.particles[0].mass
    source.position = (0, 0, 0) | units.AU
    source.velocity = (0, 0, 0) | units.kms
    source.luminosity = stellar.particles[0].luminosity / (20. | units.eV)
    source.temperature = stellar.particles[0].temperature
    Teff = stellar.particles[0].temperature
    source.flux = source.luminosity
    source.rho = 1.0 | (units.g / units.cm**3)
    source.xion = 0.0  #ionization_fraction
    source.u = (9. | units.kms)**2  #internal_energy
    stellar.stop()

    ism = new_disk_with_bump(source[0].mass, Ndisk, Mdisk, Rmin, Rmax, Mbump,
                             Rbump, abump)
    ism.flux = 0 | units.s**-1
    ism.xion = 0.0  #ionization_fraction

    hydro = Gadget2(nbody_system.nbody_to_si(Mdisk, Rmax))
    hydro.gas_particles.add_particles(ism)
    hydro.dm_particles.add_particles(source)
    hydro.evolve_model(1 | units.day)
    hydro.gas_particles.new_channel_to(ism).copy()
    hydro.stop()

    rad = SimpleXSplitSet(redirect="none", numer_of_workers=4)
    rad.parameters.box_size = 2.01 * Rmax
    rad.parameters.timestep = 0.1 * dt
    rad.set_source_Teff(Teff)
    rad.src_particles.add_particle(source)
    rad.gas_particles.add_particles(ism)

    rad_to_framework = rad.gas_particles.new_channel_to(ism)
    particles = ParticlesSuperset([source, ism])
    write_set_to_file(particles, "rad.hdf5", 'hdf5')

    while rad.model_time < t_end:
        rad.evolve_model(rad.model_time + dt)
        rad_to_framework.copy_attributes(["x", "y", "z", "xion"])
        write_set_to_file(particles, "rad.hdf5", 'hdf5')
        print "Time=", rad.model_time, "Ionization (min, mean, max):", ism.xion.min(
        ), ism.xion.mean(), ism.xion.max()
    rad.stop()
Beispiel #2
0
def irradiate_disk_with_bump(Mstar = 10|units.MSun, tstar = 20|units.Myr,
                             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=10|units.yr, n_steps=10,
                             filename = None, image_id=1):
    dt = t_end/float(n_steps)

    stellar = SeBa()
    stellar.particles.add_particle(Particle(mass=Mstar))
    stellar.evolve_model(tstar)

    source=Particles(1)
    source.mass = stellar.particles[0].mass
    source.position = (0, 0, 0) |units.AU
    source.velocity = (0, 0, 0) |units.kms
    source.luminosity = stellar.particles[0].luminosity/(20. | units.eV)
    source.temperature = stellar.particles[0].temperature
    Teff = stellar.particles[0].temperature
    source.flux = source.luminosity
    source.rho = 1.0|(units.g/units.cm**3)
    source.xion = 0.0 #ionization_fraction
    source.u = (9. |units.kms)**2 #internal_energy
    stellar.stop()

    ism = new_disk_with_bump(source[0].mass, Ndisk, Mdisk, Rmin, Rmax,
                             Mbump, Rbump, abump)
    ism.flux = 0 | units.s**-1
    ism.xion = 0.0 #ionization_fraction

    hydro = Gadget2(nbody_system.nbody_to_si(Mdisk, Rmax))
    hydro.gas_particles.add_particles(ism)
    hydro.dm_particles.add_particles(source)
    hydro.evolve_model(1|units.day)
    hydro.gas_particles.new_channel_to(ism).copy()
    hydro.stop()
    
    rad = SimpleXSplitSet(redirect="none",numer_of_workers=4)
    rad.parameters.box_size=2.01*Rmax
    rad.parameters.timestep=0.1*dt
    rad.set_source_Teff(Teff)
    rad.src_particles.add_particle(source)
    rad.gas_particles.add_particles(ism)

    rad_to_framework = rad.gas_particles.new_channel_to(ism)
    particles = ParticlesSuperset([source, ism])
    write_set_to_file(particles, "rad.hdf5", 'hdf5')

    while rad.model_time<t_end:
        rad.evolve_model(rad.model_time + dt)
        rad_to_framework.copy_attributes(["x","y", "z", "xion"])
        write_set_to_file(particles, "rad.hdf5", 'hdf5')
        print "Time=", rad.model_time, "Ionization (min, mean, max):", ism.xion.min(), ism.xion.mean(), ism.xion.max()
    rad.stop()
Beispiel #3
0
def _irradiate_disk_with_pump(Mstar = 10|units.MSun,
         tstar = 20|units.Myr,
         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=10|units.yr, n_steps=10, filename = None, image_id=1):
    model_time = 0.0 | t_end.unit
    dt = t_end/float(n_steps)

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

    stellar = SeBa()
    stellar.particles.add_particle(Particle(mass=Mstar))
    stellar.evolve_model(tstar)

    print "L=", stellar.particles[0].luminosity.in_(units.LSun), stellar.particles[0].temperature

    source=Particles(1)
    source.mass = stellar.particles[0].mass
    source.position = (0, 0, 0) |units.AU
    source.velocity = (0, 0, 0) |units.kms
    source.luminosity = stellar.particles[0].luminosity/(20. | units.eV)
    source.temperature = stellar.particles[0].temperature
    Teff = stellar.particles[0].temperature
    source.flux = source.luminosity
    source.rho = 1.0|(units.g/units.cm**3)
    source.xion = ionization_fraction
    source.u = internal_energy
    stellar.stop()

    Mstar = source[0].mass
    if filename ==None:
        ism = new_disk_with_bump(Mstar = Mstar,
                                 Ndisk=Ndisk, Mdisk=Mdisk,
                                 Rmin=Rmin, Rmax=Rmax,
                                 Mbump=Mbump, Rbump=Rbump,
                                 abump=abump)
    else:
        ism = read_disk_with_bump(image_id=image_id, filename=filename)#, Rmax=Rmax)
    ism = ism.select(lambda r: r.length()<1.0*Rmax,["position"])
    ism.flux = 0 | units.s**-1
    ism.xion = ionization_fraction 

    if filename ==None:
        converter=nbody_system.nbody_to_si(Mdisk, Rmax)
        hydro = Gadget2(converter)
        hydro.gas_particles.add_particles(ism)
        hydro.dm_particles.add_particles(source)
        hydro.evolve_model(1|units.day)
        hydro.gas_particles.new_channel_to(ism).copy()
        hydro.stop()
    
    rad = SimpleXSplitSet(redirect="none",numer_of_workers=4)
    rad.parameters.number_of_freq_bins=5
    rad.parameters.thermal_evolution_flag=1
    rad.parameters.blackbody_spectrum_flag=1
    rad.parameters.metal_cooling_flag=0
    rad.parameters.box_size=2.01*Rmax
    if isinstance(rad, SPHRay):
        ism.h_smooth = 0.1 | (units.RSun)

    else:
        rad.parameters.timestep=0.1*dt
        rad.set_source_Teff(Teff)

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

    channel_from_rad_to_framework = rad.gas_particles.new_channel_to(ism)

    particles = ParticlesSuperset([source, ism])
    write_set_to_file(particles, "rad.hdf5", 'hdf5')

    tCPU = time()
    while model_time<t_end:
        model_time += dt

        rad.evolve_model(model_time)
        channel_from_rad_to_framework.copy_attributes(["x","y", "z", "xion"])
        write_set_to_file(particles, "rad.hdf5", 'hdf5')

        print "Date:"+str(localtime()[2])+"."+str(localtime()[1])+"."+str(localtime()[1]), "at", str(localtime()[3])+"h", str(localtime()[4])+"m"
        print "Time=", model_time, "dt_CPU=", time()-tCPU
        print "min ionization:", ism.xion.min()
        print "average Xion:", ism.xion.mean()
        print "max ionization:", ism.xion.max()
        tCPU = time()

    rad.stop()