Esempio n. 1
0
def rho_zr(ICobj):
    """
    Iterates over calc_rho.py to calculate rho(z,r) on a grid of z and r
    values.
    
    Requires ICobj.sigma to be defined already
    
    * Arguments *
    
    ICobj - The initial conditions object for which rho will be calculated
    
    * Output *
    Returns dictionary containing:
        dict['rho'] : 2D array, rho at all pairs of points (z,r)
        dict['z']   : a 1D array of z points
        dict['r']   : a 1D array of r points
        
    If output=filename, dictionary is pickled and saved to filename
    
    To be safe, keep all units in Msol and au
    """
    # Get what's need from the IC object
    settings = ICobj.settings

    # PARSE SETTINGS
    # Rho calculation parameters
    nr = settings.rho_calc.nr
    nz = settings.rho_calc.nz
    rmin = settings.rho_calc.rmin
    rmax = settings.rho_calc.rmax
    # Initialize r,z, and rho
    r = np.linspace(rmin, rmax, nr)
    rho = SimArray(np.zeros([nz, nr]), 'Msol au**-3')

    start_time = time.time()

    for n in range(nr):

        print '************************************'
        print 'Calculating rho(z) - {0} of {1}'.format(n + 1, nr)
        print '{0} min elapsed'.format((time.time() - start_time) / 60)
        print '************************************'
        rho_vector, z = calc_rho.rho_z(ICobj, r[[n]])
        rho[:, n] = rho_vector

    # Convert to the units generated by calc_rho
    rho.convert_units(rho_vector.units)

    return rho, z, r
Esempio n. 2
0
def rho_zr(ICobj):
    """
    Iterates over calc_rho.py to calculate rho(z,r) on a grid of z and r
    values.
    
    Requires ICobj.sigma to be defined already
    
    * Arguments *
    
    ICobj - The initial conditions object for which rho will be calculated
    
    * Output *
    Returns dictionary containing:
        dict['rho'] : 2D array, rho at all pairs of points (z,r)
        dict['z']   : a 1D array of z points
        dict['r']   : a 1D array of r points
        
    If output=filename, dictionary is pickled and saved to filename
    
    To be safe, keep all units in Msol and au
    """
    # Get what's need from the IC object
    settings = ICobj.settings
    
    # PARSE SETTINGS
    # Rho calculation parameters
    nr = settings.rho_calc.nr
    nz = settings.rho_calc.nz
    rmin = ICobj.sigma.r_bins.min()
    rmax = ICobj.sigma.r_bins.max()
    # Initialize r,z, and rho
    r = np.linspace(rmin,rmax,nr)
    rho = SimArray(np.zeros([nz,nr]), 'Msol au**-3')
    
    start_time = time.time()
    
    for n in range(nr):
        
        print '************************************'
        print 'Calculating rho(z) - {0} of {1}'.format(n+1,nr)
        print '{0} min elapsed'.format((time.time()-start_time)/60)
        print '************************************'
        rho_vector, z = calc_rho.rho_z(ICobj, r[[n]])
        rho[:,n] = rho_vector
        
    # Convert to the units generated by calc_rho
    rho.convert_units(rho_vector.units)
    
    return rho, z, r
Esempio n. 3
0
def multirun_rho(args):
    # A wrapper for multiprocessing calls to rho_z (allows multiple args)
    return calc_rho.rho_z(*args)