gtd0 = 100. #Gas to dust ratio (H2 vs Dust) gtdratio = Model.gastodust(gtd0, NPoints) #----------------------------- #WRITING DATA for LIME #----------------------------- prop = { 'dens_H2': density.total, 'temp_gas': temperature.total, 'vel_x': vel.x, 'vel_y': vel.y, 'vel_z': vel.z, 'abundance': abundance, 'gtdratio': gtdratio } lime = rt.Lime(GRID) lime.finalmodel(prop) #----------------------------- #PRINTING resultant PROPERTIES #----------------------------- Model.PrintProperties(density, temperature, GRID) #------- #TIMING #------- print('Ellapsed time: %.3fs' % (time.time() - t0)) print( '-------------------------------------------------\n-------------------------------------------------\n' )
f1 = sf.FilamentModel([0,0,0], [1,0,0], -0.2*pc, 0.2*pc, 4e-3*pc) def new_temp(R,theta,z, *temp_pars): TR, R0, pR, zh = temp_pars cR = TR*R0**-pR return cR*R**pR * np.exp(np.abs(z)/zh) f1.func_temp = new_temp f1.cylinder(0.1*pc, 1e-4*pc, dens_pars = [7e10, 0.03*pc, 2.0], temp_pars = [200, 0.02*pc, -0.15, -0.17*pc], abund_pars = 1e-4) pm.scatter3D(f1.GRID, f1.density, np.min(f1.density), axisunit = pc, colordim = f1.density, colorlabel = 'T [K]', NRand = 10000, show=True) prop = {'dens_H': f1.density, 'temp_gas': f1.temperature, 'abundance': f1.abundance, 'gtdratio': f1.gtdratio, 'vel_x': f1.vel.x, 'vel_y': f1.vel.y, 'vel_z': f1.vel.z, } lime = rt.Lime(f1.GRID) lime.submodel(prop, output='filament.dat')
npoints=100000) #***************************************** #Computing relevant physical distributions #***************************************** density = transition.powerlaw_cavity(grid=grid, **kwargs_dens) gtdratio = 1. / transition.powerlaw_cavity( grid=grid, **kwargs_dtg) #Converting to gas-to-dust ratio for LIME temperature = np.zeros(grid.NPoints) + 100. #Constant temperature 100 K prop = {'dens_H2': density, 'gtdratio': gtdratio, 'temp_gas': temperature} #********************** #Writing files for LIME #********************** lime = rt.Lime(grid) lime.submodel(prop, output='datatab.dat', folder='./', lime_npoints=True, lime_header=True) print('Output columns', lime.columns) print('Ellapsed time:', time.time() - t0) #****************** #PLOTTING BLOCK #****************** SMALL_SIZE = 11 MEDIUM_SIZE = 15 BIGGER_SIZE = 18
def do_overlap(): #****************************** #PATH AND TAG #****************************** cwd = os.getcwd() cloud_kind = cwd.split('Lime-arepo/')[-1].split('-Lime') cloud_kind = cloud_kind[0] + cloud_kind[1] home = os.environ['HOME'] base = home + '/Downloads/Manchester_2018/Rowan-data/Andres/data/datasets/' base += cloud_kind base_content = os.popen('ls ' + base).readlines() snapshot = '' for file in base_content: if 'Restest' in file: snapshot = '/' + file.split('\n')[0] #****************************** #AREPO 3D-grids (not projected) #****************************** rsnap.io_flags['mc_tracer'] = True rsnap.io_flags['time_steps'] = True rsnap.io_flags['sgchem'] = True rsnap.io_flags['variable_metallicity'] = False #rsnap.io_flags['MHD']=True #There is no magnetic field information #****************************** #READING SNAPSHOT #****************************** f = base + snapshot data, header = rsnap.read_snapshot(f) nparts = header['num_particles'] ngas = nparts[0] nsinks = nparts[5] for key in data: print(key, np.shape(data[key])) #**************************** #GLOBAL GRID #**************************** pos_max = np.max(data['pos'], axis=0) pos_min = np.min(data['pos'], axis=0) pos_mean = 0.5 * (pos_max + pos_min) * ulength / 100. sizex = sizey = sizez = 0.5 * np.max(pos_max - pos_min) * ulength / 100. #print (sizex, sizey, sizez) Nx = Ny = Nz = 200 GRID = Model.grid([sizex, sizey, sizez], [Nx, Ny, Nz], include_zero=False) #, rt_code='radmc3d') columns = [ 'id', 'x', 'y', 'z', 'dens_H2', 'dens_H', 'dens_Hplus', 'temp_gas', 'temp_dust', 'vel_x', 'vel_y', 'vel_z', 'abundance', 'gtdratio', 'doppler' ] """ overlap = grid.Overlap(GRID) overlap.min_values['dens_H2'] = 0.0 newprop = overlap.fromfiles(columns, submodels=['datatab.dat']) """ props2use = ['dens_H', 'dens_H2', 'abundance', 'dens_Hplus'] newprop = {} datatab = np.loadtxt('./Subgrids/datatab.dat') #[:-30000] header_tab = np.loadtxt('./Subgrids/header.dat') coords = np.array(GRID.XYZ).T data_prop = {} Lime = rt.Lime(GRID) for prop in props2use: column, = np.where(Lime.sf3d_header[prop] == header_tab) data_prop[prop] = datatab[:, column] subgrid = Model.Struct(XYZ=[datatab[:, i] for i in range(1, 4)], NPoints=len(datatab)) fill = grid.fillgrid.Random(subgrid) fill_rand = fill.spherical( data_prop, #prop_fill = {'dens_H2': 1.0}, r_min=10 * pc, r_max=np.max(subgrid.XYZ) * np.sqrt(3), n_dummy=subgrid.NPoints / 3) coords_sub = np.array(subgrid.XYZ).T for prop in props2use: print('Merging %s ...' % prop) ind_nodummie = data_prop[prop] > 2 * data_prop[prop][-1] min_val = data_prop[prop][ind_nodummie].min() newprop[prop] = griddata(coords_sub, data_prop[prop], coords, fill_value=0.0) #, method='nearest') newprop[prop][ newprop[prop] < min_val] = min_val #very low value, just to get rid of zeroes #newprop[prop][np.isnan(newprop[prop])] = datatab[:,column].min() #newprop[prop][np.isnan(newprop[prop])].min() sink_pos = data['pos'][ngas:] * ulength / 100 - pos_mean dummy_pos.append(coords_sub[-int(subgrid.NPoints / 2):]) return GRID, sizex, newprop, sink_pos, nsinks