MStar / u.MSun
)**0.8  #Multiply by 10 Main Sequence relationship to account for bloated protostar
LStar = 9 * u.LSun  #u.LSun * ( MStar/u.MSun )**4 # 9Lsun from Li+2017
TStar = u.TSun * ((LStar / u.LSun) / (RStar / u.RSun)**2)**0.25
Rd = 68. * u.au

print('RStar:', RStar / u.RSun, ', LStar:', LStar / u.LSun, ', TStar:', TStar)

#---------------
#GRID Definition
#---------------
#Cubic grid, each edge ranges [-100, 100] au.

sizex = sizey = sizez = 100 * u.au
Nx = Ny = Nz = 200  #Number of divisions for each axis
GRID = Model.grid([sizex, sizey, sizez], [Nx, Ny, Nz])
NPoints = GRID.NPoints  #Number of nodes in the grid

#-------------
#DENSITY
#-------------

#-------
#DISC
#-------
if args.Arho: Arho = float(args.Arho)
else: Arho = 150.0  # (Mdisk=0.106*1.4=Msun=0.149Msun)

H0sf = 0.04  #Disc scale-height factor (H0 = H0sf * RStar)
Rdisc = 1.0 * Rd
Rho0 = Res.Rho0(MRate, Rd, MStar)  #Normalization density
import matplotlib.pyplot as plt
import time

#------------------
#General Parameters
#------------------
r_max = 2530 * u.au #H II sphere size
dens_e = 1.4e5 * 1e6 #Electron number density, from cgs to SI
t_e = 1.e4 #K

#---------------
#GRID Definition
#---------------
sizex = sizey = sizez = 2600 * u.au 
Nx = Ny = Nz = 63 #Number of divisions for each axis
GRID = Model.grid([sizex, sizey, sizez], [Nx, Ny, Nz], rt_code='radmc3d')
NPoints = GRID.NPoints #Final number of nodes in the grid

#-------------------
#PHYSICAL PROPERTIES
#-------------------
density = Model.density_Constant(r_max, GRID, envDens = dens_e)
temperature = Model.temperature_Constant(density, GRID, envTemp = t_e, backTemp = 2.725)

Model.PrintProperties(density, temperature, GRID) #Printing resultant properties (mass, mean temperature, etc)

#----------------------
#WRITING RADMC-3D FILES
#----------------------
prop = {'dens_e': density.total,
        'dens_ion': density.total,
Esempio n. 3
0
rho0 = 1e8 * 1e6  #[part/m3] Number density at r_min
r_rho = [r_min, 200 * u.au, 300 * u.au, r_max]  #r frontiers for density
q_rho = [-2.0, -1.5, -2.5]  #Powerlaws for density

T0 = 1000.  #[K] Temperature at r_min
r_T = [r_min, 250 * u.au, r_max]  #r frontiers for temperature
q_T = [-0.5, -1.0]  #Powerlaws for temperature

#---------------
#GRID Definition
#---------------

sizex = sizey = sizez = r_max
Nx = Ny = Nz = 95  #Number of divisions for each axis
GRID = Model.grid([sizex, sizey, sizez], [Nx, Ny, Nz], rt_code='lime')
NPoints = GRID.NPoints  #Final number of nodes in the grid

#-------------------
#PHYSICAL PROPERTIES
#-------------------
density = Model.density_PowerlawShells(r_rho, q_rho, rho0, GRID, rho_min=1.0e4)
temperature = Model.temperature_PowerlawShells(r_T, q_T, T0, GRID, T_min=25.)

#--------
#VELOCITY
#--------
vel = Model.velocity_random(1800, GRID.NPoints)

#-------------------------------
#ABUNDANCE and GAS-to-DUST RATIO
Esempio n. 4
0
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
Esempio n. 5
0
#------------------
from sf3dmodels import Model, Plot_model as Pm
import sf3dmodels.utils.units as u
import sf3dmodels.rt as rt
from sf3dmodels.grid import Overlap
#-----------------
#Extra libraries
#-----------------
import numpy as np

#********
#GRIDDING
#********
sizex = sizey = sizez = 0.3 * u.pc
Nx = Ny = Nz = 145
GRID = Model.grid([sizex, sizey, sizez], [Nx, Ny, Nz], include_zero=False)

#**********
#OVERLAPING
#**********
columns = [
    'id', 'x', 'y', 'z', 'dens_H', 'temp_gas', 'vel_x', 'vel_y', 'vel_z',
    'abundance', 'gtdratio'
]
data2merge = ['filament.dat', 'envelope.dat']
overlap = Overlap(GRID)
finalprop = overlap.fromfiles(columns, submodels=data2merge)

#**********
#WRITING
#**********