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()
def main(Ndisk, Mstar, Mdisk, Rin, Rout, t_end, Nray, x, y, z): time = 0 | units.Myr supernova_IIp = Supernova_IIp(10|units.day) efficiency_factor = 0.1 Rsn = efficiency_factor * (x**2 + y**2 + z**2)**0.5 supernova=Particle() supernova.position = (x.value_in(units.parsec), y.value_in(units.parsec), z.value_in(units.parsec)) |units.parsec supernova.position *= efficiency_factor supernova.luminosity = efficiency_factor**2 * supernova_IIp.luminosity_at_time(time)/(20.|units.eV) # supernova.flux = supernova.luminosity supernova.xion = 0.0 supernova.u = (10**51 | units.erg)/(10|units.MSun) stellar = SeBa() star = Particle() star.mass = Mstar star.position = (0,0,0) | units.AU star.velocity = (0,0,0) | units.kms stellar.particles.add_particle(star) stellar.evolve_model(1|units.Myr) star.luminosity = stellar.particles[0].luminosity/(20. | units.eV) star.temperature = stellar.particles[0].temperature stellar.stop() star.u = (9. |units.kms)**2 star.xion = 0.0 print star print "M=", Mdisk/Mstar converter=nbody_system.nbody_to_si(Mstar, 1 | units.AU) disk = ProtoPlanetaryDisk(Ndisk, convert_nbody=converter, Rmin=Rin.value_in(units.AU), Rmax=Rout.value_in(units.AU), q_out=25.0, discfraction=Mdisk/Mstar).result #### q_out=2.0, discfraction=Mdisk/Mstar).result print disk.x.max().in_(units.AU) print disk.mass.sum().in_(units.MSun) print disk.u.max().in_(units.kms**2) print disk.mass.min().in_(units.MSun) disk.flux = 0. | units.s**-1 disk.xion = 0.0 dt = t_end/1000. hydro = Fi(converter) 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 # Non-isothermal: lowest temperature remains constat at 20K # hydro.parameters.gamma=1.66667 # hydro.parameters.isothermal_flag=False hydro.parameters.integrate_entropy_flag=False hydro.parameters.timestep=0.5 | units.hour #0.125 | units.day # hydro.parameters.verbosity=99 hydro.parameters.epsilon_squared=0.1 | units.AU**2 hydro.parameters.courant=0.2 hydro.parameters.artificial_viscosity_alpha = 0.1 hydro.gas_particles.add_particles(disk) hydro.dm_particles.add_particle(star) hydro_to_disk = hydro.gas_particles.new_channel_to(disk) hydro_to_star = hydro.dm_particles.new_channel_to(star.as_set()) disk_to_hydro = disk.new_channel_to(hydro.gas_particles) star_to_hydro = star.as_set().new_channel_to(hydro.dm_particles) hydro.evolve_model(1|units.hour) hydro_to_disk.copy() hydro_to_star.copy() radiative = SPHRay(redirection="file", number_of_workers=4)#, debugger="gdb") radiative.parameters.number_of_rays=Nray/dt print dt.in_(units.yr) radiative.parameters.default_spectral_type=-3. radiative.parameters.box_size=10000. | units.AU radiative.parameters.ionization_temperature_solver=2 print radiative.parameters # radiative.src_particles.add_particle(star) radiative.src_particles.add_particle(supernova) radiative.gas_particles.add_particles(disk) gas_to_rad = disk.new_channel_to(radiative.gas_particles) rad_to_gas = radiative.gas_particles.new_channel_to(disk) print "Before" print "Luminosity:", radiative.src_particles.luminosity print "min ionization:", radiative.gas_particles.xion.min() print "average Xion:", radiative.gas_particles.xion.mean() print "max ionization:", radiative.gas_particles.xion.max() print "min u:", radiative.gas_particles.u.min() print "average u:", radiative.gas_particles.u.mean() print "max u:", radiative.gas_particles.u.max() Tmean = [] | units.K Tmin = [] | units.K Tmax = [] | units.K t = [] | units.day while radiative.model_time<t_end: supernova = update_source_particle(radiative, time+0.5*dt, supernova, efficiency_factor, supernova_IIp) radiative.evolve_model(time+0.5*dt) print "RT done at time:", time.in_(units.day) rad_to_gas.copy() disk_to_hydro.copy() star_to_hydro.copy() hydro.evolve_model(time + dt) hydro_to_disk.copy() hydro_to_star.copy() supernova = update_source_particle(radiative, time+dt, supernova, efficiency_factor, supernova_IIp) radiative.evolve_model(time+dt) print "RT done at time:", time.in_(units.day) rad_to_gas.copy() time += dt print_diagnostics(time, supernova, disk) Temperature = mu() / constants.kB * disk.u t.append(time) Tmean.append(Temperature.mean()) Tmin.append(Temperature.min()) Tmax.append(Temperature.max()) #write_set_to_file(disk, "disk_irradiation.amuse", "amuse") print "timescale:", (disk.mass.sum().value_in(units.amu)/((Rout/Rsn)**2*supernova.luminosity)).in_(units.yr) print "scaleheight:", abs(disk.z.value_in(units.AU)).mean() #pyplot.hist2d(abs(disk.x.value_in(units.AU)), abs(numpy.log10(Temperature.value_in(units.K))), bins=200) # pyplot.hist2d(abs(disk.x.value_in(units.AU)), abs(disk.z.value_in(units.AU)), bins=200) #,norm=LogNorm()) #, Temperature.in_(units.K)) # pyplot.tripcolor(abs(disk.x.value_in(units.AU)), abs(disk.y.value_in(units.AU)), Temperature.in_(units.K)) #pyplot.hist(abs(disk.x.value_in(units.AU)), 100) # pyplot.show() print_diagnostics(time, supernova, disk) #plot_ionization_fraction(disk.position, disk.xion) # plot_ionization_fraction(disk.z, disk.u.value_in(units.kms**2)) # plot_ionization_fraction(disk.x, disk.u.value_in(units.kms**2)) radiative.stop() plot_temperature(t, Tmin, Tmean, Tmax)
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()
def main(Ndisk, Mstar, Mdisk, Rin, Rout, t_end, Nray, x, y, z): time = 0 | units.Myr supernova_IIp = Supernova_IIp(10|units.day) efficiency_factor = 0.1 Rsn = efficiency_factor * (x**2 + y**2 + z**2)**0.5 supernova = Particle() supernova.position = (x.value_in(units.parsec), y.value_in(units.parsec), z.value_in(units.parsec)) |units.parsec supernova.position *= efficiency_factor supernova_IIp.particles.add_particle(supernova) supernova_IIp.evolve_model(time) supernova.luminosity = efficiency_factor**2 * supernova.luminosity supernova.xion = 0.0 supernova.u = (10**51 | units.erg)/(10|units.MSun) stellar = SeBa() star = Particle() star.mass = Mstar star.position = (0,0,0) | units.AU star.velocity = (0,0,0) | units.kms stellar.particles.add_particle(star) stellar.evolve_model(1|units.Myr) star.luminosity = stellar.particles[0].luminosity/(20. | units.eV) star.temperature = stellar.particles[0].temperature stellar.stop() star.u = (9. |units.kms)**2 star.xion = 0.0 print star print "M=", Mdisk/Mstar converter=nbody_system.nbody_to_si(Mstar, 1 | units.AU) disk = ProtoPlanetaryDisk(Ndisk, convert_nbody=converter, Rmin=Rin.value_in(units.AU), Rmax=Rout.value_in(units.AU), q_out=25.0, discfraction=Mdisk/Mstar).result #### q_out=2.0, discfraction=Mdisk/Mstar).result print disk.x.max().in_(units.AU) print disk.mass.sum().in_(units.MSun) print disk.u.max().in_(units.kms**2) print disk.mass.min().in_(units.MSun) disk.flux = 0. | units.s**-1 disk.xion = 0.0 dt = t_end/1000. hydro = Fi(converter) 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 # Non-isothermal: lowest temperature remains constat at 20K # hydro.parameters.gamma=1.66667 # hydro.parameters.isothermal_flag=False hydro.parameters.integrate_entropy_flag=False hydro.parameters.timestep=0.5 | units.hour #0.125 | units.day # hydro.parameters.verbosity=99 hydro.parameters.epsilon_squared=0.1 | units.AU**2 hydro.parameters.courant=0.2 hydro.parameters.artificial_viscosity_alpha = 0.1 hydro.gas_particles.add_particles(disk) hydro.dm_particles.add_particle(star) hydro_to_disk = hydro.gas_particles.new_channel_to(disk) hydro_to_star = hydro.dm_particles.new_channel_to(star.as_set()) disk_to_hydro = disk.new_channel_to(hydro.gas_particles) star_to_hydro = star.as_set().new_channel_to(hydro.dm_particles) hydro.evolve_model(1|units.hour) hydro_to_disk.copy() hydro_to_star.copy() radiative = SPHRay(redirection="file", number_of_workers=4)#, debugger="gdb") radiative.parameters.number_of_rays=Nray/dt print dt.in_(units.yr) radiative.parameters.default_spectral_type=-3. radiative.parameters.box_size=10000. | units.AU radiative.parameters.ionization_temperature_solver=2 print radiative.parameters # radiative.src_particles.add_particle(star) radiative.src_particles.add_particle(supernova) radiative.gas_particles.add_particles(disk) gas_to_rad = disk.new_channel_to(radiative.gas_particles) rad_to_gas = radiative.gas_particles.new_channel_to(disk) print "Before" print "Luminosity:", radiative.src_particles.luminosity print "min ionization:", radiative.gas_particles.xion.min() print "average Xion:", radiative.gas_particles.xion.mean() print "max ionization:", radiative.gas_particles.xion.max() print "min u:", radiative.gas_particles.u.min() print "average u:", radiative.gas_particles.u.mean() print "max u:", radiative.gas_particles.u.max() Tmean = [] | units.K Tmin = [] | units.K Tmax = [] | units.K t = [] | units.day while radiative.model_time<t_end: supernova = update_source_particle(radiative, time+0.5*dt, supernova, efficiency_factor, supernova_IIp) radiative.evolve_model(time+0.5*dt) print "RT done at time:", time.in_(units.day) rad_to_gas.copy() disk_to_hydro.copy() star_to_hydro.copy() hydro.evolve_model(time + dt) hydro_to_disk.copy() hydro_to_star.copy() supernova = update_source_particle(radiative, time+dt, supernova, efficiency_factor, supernova_IIp) radiative.evolve_model(time+dt) print "RT done at time:", time.in_(units.day) rad_to_gas.copy() time += dt print_diagnostics(time, supernova, disk) Temperature = mu() / constants.kB * disk.u t.append(time) Tmean.append(Temperature.mean()) Tmin.append(Temperature.min()) Tmax.append(Temperature.max()) #write_set_to_file(disk, "disk_irradiation.amuse", "amuse") print "timescale:", (disk.mass.sum().value_in(units.amu) \ / ((Rout/Rsn)**2*supernova.luminosity)).in_(units.yr) print "scaleheight:", abs(disk.z.value_in(units.AU)).mean() #pyplot.hist2d(abs(disk.x.value_in(units.AU)), abs(numpy.log10(Temperature.value_in(units.K))), bins=200) # pyplot.hist2d(abs(disk.x.value_in(units.AU)), abs(disk.z.value_in(units.AU)), bins=200) #,norm=LogNorm()) #, Temperature.in_(units.K)) # pyplot.tripcolor(abs(disk.x.value_in(units.AU)), abs(disk.y.value_in(units.AU)), Temperature.in_(units.K)) #pyplot.hist(abs(disk.x.value_in(units.AU)), 100) # pyplot.show() print_diagnostics(time, supernova, disk) #plot_ionization_fraction(disk.position, disk.xion) # plot_ionization_fraction(disk.z, disk.u.value_in(units.kms**2)) # plot_ionization_fraction(disk.x, disk.u.value_in(units.kms**2)) radiative.stop() plot_temperature(t, Tmin, Tmean, Tmax)