Exemplo n.º 1
0
def enzo_m_gen(fname, field_add):

    reg, ds1 = enzo_grid_generate(fname, field_add)

    amr = AMRGrid.from_yt(
        ds1, quantity_mapping={'density': ('gas', 'dust_density')})
    '''
    levels = ds.index.max_level
    
    amr = AMRGrid()
    for ilevel in range(levels):
        level = amr.add_level()
        
    for igrid in ds.index.select_grids(ilevel):
        print igrid
        grid = level.add_grid()
        grid.xmin,grid.xmax = igrid.LeftEdge[0].in_units('cm'),igrid.RightEdge[0].in_units('cm')
        grid.ymin,grid.ymax = igrid.LeftEdge[1].in_units('cm'),igrid.RightEdge[1].in_units('cm')
        grid.zmin,grid.zmax = igrid.LeftEdge[2].in_units('cm'),igrid.RightEdge[2].in_units('cm')
        grid.quantities["density"] = np.transpose(np.array(igrid[("gas","metal_density")].in_units('g/cm**3')*cfg.par.dusttometals_ratio))
        grid.nx,grid.ny,grid.nz = igrid[("gas","metal_density")].shape
    '''

    m = Model()

    m.set_amr_grid(amr)

    #CMB DISABLED -- UNCOMMENT THIS TO FIX THIS.  The main issue is
    #that I'm not sure what shape to give to the np.repeat
    #array of energy_density_absorbed; I think it needs to be the ARM Grid shape but i'm not quite sure if it needs to be an AMRGrid()
    #energy_density_absorbed=energy_density_absorbed_by_CMB()
    #energy_density_absorbed =np.repeat(energy_density_absorbed.value,reg.index.num_grids)#amr['density'].shape)

    d = SphericalDust(cfg.par.dustdir + cfg.par.dustfile)
    if cfg.par.SUBLIMATION == True:
        d.set_sublimation_temperature(
            'fast', temperature=cfg.par.SUBLIMATION_TEMPERATURE)

    m.add_density_grid(amr["density"], d)
    #uncomment when we're ready to put CMB in (and comment out previous line)
    #m.add_density_grid(amr['density'],d,specific_energy=energy_density_absorbed)
    #m.set_specific_energy_type('additional')

    center = ds1.arr([cfg.model.x_cent, cfg.model.y_cent, cfg.model.z_cent],
                     'code_length')
    [xcent, ycent, zcent
     ] = center.in_units('cm')  #boost needs to be in cm since that's what the

    boost = np.array([xcent, ycent, zcent])

    dx = ds1.domain_width[0].in_units('cm')
    dy = ds1.domain_width[1].in_units('cm')
    dz = ds1.domain_width[2].in_units('cm')

    return m, xcent, ycent, zcent, dx, dy, dz, reg, ds1, boost
Exemplo n.º 2
0
def enzo_m_gen(fname, field_add):

    reg, ds1 = enzo_grid_generate(fname, field_add)

    amr = yt_dataset_to_amr_grid_xyz(
        ds1, quantity_mapping={'density': ('gas', 'dust_density')})

    m = Model()

    #save in the m__dict__ that we're in an amr geometry
    m.__dict__['grid_type'] = 'amr'

    m.set_amr_grid(amr)

    #CMB DISABLED -- UNCOMMENT THIS TO FIX THIS.  The main issue is
    #that I'm not sure what shape to give to the np.repeat
    #array of energy_density_absorbed; I think it needs to be the ARM Grid shape but i'm not quite sure if it needs to be an AMRGrid()
    #energy_density_absorbed=energy_density_absorbed_by_CMB()
    #energy_density_absorbed =np.repeat(energy_density_absorbed.value,reg.index.num_grids)#amr['density'].shape)

    d = SphericalDust(cfg.par.dustdir + cfg.par.dustfile)
    if cfg.par.SUBLIMATION == True:
        d.set_sublimation_temperature(
            'fast', temperature=cfg.par.SUBLIMATION_TEMPERATURE)

    m.add_density_grid(amr["density"], d)
    #uncomment when we're ready to put CMB in (and comment out previous line)
    #m.add_density_grid(amr['density'],d,specific_energy=energy_density_absorbed)
    #m.set_specific_energy_type('additional')

    center = ds1.arr([cfg.model.x_cent, cfg.model.y_cent, cfg.model.z_cent],
                     'code_length')
    [xcent, ycent, zcent
     ] = center.in_units('cm')  #boost needs to be in cm since that's what the

    boost = np.array([xcent, ycent, zcent])

    dx = ds1.domain_width[0].in_units('cm')
    dy = ds1.domain_width[1].in_units('cm')
    dz = ds1.domain_width[2].in_units('cm')

    return m, xcent, ycent, zcent, dx, dy, dz, reg, ds1, boost
Exemplo n.º 3
0
def enzo_m_gen(fname,field_add):
    

    
    #add the fields in pd format
    pf = field_add(fname)
    ad = pf.all_data()
   
 

    #cutout
    center = pf.arr([cfg.model.x_cent,cfg.model.y_cent,cfg.model.z_cent],'code_length')
    
    box_len = pf.quan(cfg.par.zoom_box_len,'kpc').in_units('code_length')
   
    min_region = [center[0]-box_len,center[1]-box_len,center[2]-box_len]
    max_region = [center[0]+box_len,center[1]+box_len,center[2]+box_len]
    region = pf.region(center,min_region,max_region)
  
    pf = region.ds
  
    proj_plots(pf)
    #def. dust density
    def _dust_density(field, data):
        return data[('gas', 'metal_density')].in_units("g/cm**3")*cfg.par.dusttometals_ratio
    
    pf.add_field(('gas', 'dust_density'), function=_dust_density, units = 'g/cm**3')
       
    amr = AMRGrid.from_yt(pf, quantity_mapping={'density':('gas','dust_density')})
    


    '''
    levels = pf.index.max_level
    
    amr = AMRGrid()
    for ilevel in range(levels):
        level = amr.add_level()
        
    for igrid in pf.index.select_grids(ilevel):
        print igrid
        grid = level.add_grid()
        grid.xmin,grid.xmax = igrid.LeftEdge[0].in_units('cm'),igrid.RightEdge[0].in_units('cm')
        grid.ymin,grid.ymax = igrid.LeftEdge[1].in_units('cm'),igrid.RightEdge[1].in_units('cm')
        grid.zmin,grid.zmax = igrid.LeftEdge[2].in_units('cm'),igrid.RightEdge[2].in_units('cm')
        grid.quantities["density"] = np.transpose(np.array(igrid[("gas","metal_density")].in_units('g/cm**3')*cfg.par.dusttometals_ratio))
        grid.nx,grid.ny,grid.nz = igrid[("gas","metal_density")].shape
    '''


    m = Model()

    m.set_amr_grid(amr)

    energy_density_absorbed=energy_density_absorbed_by_CMB()
    energy_density_absorbed = np.repeat(energy_density_absorbed.value,amr['density'].shape)


    d = SphericalDust(cfg.par.dustdir+cfg.par.dustfile)
    if cfg.par.SUBLIMATION == True:
        d.set_sublimation_temperature('fast',temperature=cfg.par.SUBLIMATION_TEMPERATURE)
    m.add_density_grid(amr['density'],d,specific_energy=energy_density_absorbed)
    m.set_specific_energy_type('additional')
 #m.add_density_grid(amr['density'], cfg.par.dustdir+cfg.par.dustfile)
    

    #define the random things needed for parsing out the output args
    #center = pf.domain_center
    [xcent,ycent,zcent] = center
   
    boost = np.array([xcent,ycent,zcent])
    dx = pf.domain_width.in_units('cm')
    dy = pf.domain_width.in_units('cm')
    dz = pf.domain_width.in_units('cm')
    
    
    return m,xcent,ycent,zcent,dx,dy,dz,pf,boost

       
Exemplo n.º 4
0
    return data[('gas', 'metal_density')].in_units("g/cm**3")*0.4

ds.add_field(('gas', 'dust_density'), function=_dust_density, units='g/cm**3')

amr = AMRGrid.from_yt(ds, quantity_mapping={'density':('gas','dust_density')})

# Set up Hyperion model

import numpy as np

from hyperion.model import Model
from hyperion.util.constants import pc

m = Model()

m.set_amr_grid(amr)

m.add_density_grid(amr['density'], '/Users/desika//pd/hyperion-dust-0.1.0/dust_files/d03_3.1_6.0_A.hdf5')

m.set_minimum_temperature(10)

m.set_n_initial_iterations(0)

m.set_raytracing(True)

# Add a point source in the center
s = m.add_point_source()
s.position = (0, 0., 0.)
s.luminosity = 1000 * lsun
s.temperature = 6000.