Ejemplo n.º 1
0
def get_particle_data(ds, axis='xy', sink_id=None, region=None):
    """
    Retrieve particle data for plotting. NOTE: CANNOT RETURN PARTICLE VELOCITIES AS THESES ARE NOT STORED IN THE MOVIE FILES.
    """
    dd = ds.all_data()
    if sink_id != None:
        sink_id = sink_id
    else:
        sink_id = np.argmin(dd['sink_particle_speed'])
    myf.set_centred_sink_id(sink_id)

    #TODO: Possibly update to set the usuable sink particle IDs to custom values (f.x. [80, 90])
    if region != None:
        usable_sinks = np.argwhere(
            (dd['sink_particle_posx'].in_units('au') > region.left_edge[0])
            & (dd['sink_particle_posx'].in_units('au') < region.right_edge[0])
            & (dd['sink_particle_posy'].in_units('au') > region.left_edge[1])
            & (dd['sink_particle_posy'].in_units('au') < region.right_edge[1])
            & (dd['sink_particle_posz'].in_units('au') > region.left_edge[2])
            & (dd['sink_particle_posz'].in_units('au') < region.right_edge[2])
        ).T[0]
    else:
        usable_sinks = np.arange(sink_id, len(dd['sink_particle_tag']))

    part_tags = dd['sink_particle_tag'][usable_sinks]
    part_mass = dd['sink_particle_mass'][usable_sinks].in_units('msun').value

    accretion_rad = 4. * np.min(dd['dx']).in_units('au').value
    #center_pos = myf.get_center_pos()
    if axis == 'xy':
        part_pos_x = dd['sink_particle_posx'][usable_sinks].in_units(
            'au').value
        part_pos_y = dd['sink_particle_posy'][usable_sinks].in_units(
            'au').value
    elif axis == 'xz':
        part_pos_x = dd['sink_particle_posx'][usable_sinks].in_units(
            'au').value
        part_pos_y = dd['sink_particle_posz'][usable_sinks].in_units(
            'au').value
    elif axis == 'yz':
        part_pos_x = dd['sink_particle_posy'][usable_sinks].in_units(
            'au').value
        part_pos_y = dd['sink_particle_posz'][usable_sinks].in_units(
            'au').value
    positions = np.array([part_pos_x, part_pos_y])
    part_info = {
        'particle_mass': part_mass,
        'particle_position': positions,
        'accretion_rad': accretion_rad,
        'particle_tag': part_tags
    }
    return part_info
Ejemplo n.º 2
0
else:
    weight_field = args.weight_field

       
sys.stdout.flush()
CW.Barrier()

#Find sink particle that your are interested in, and get the formation
dd = ds.all_data()
if args.sink_number == None:
    sink_id = np.argmin(dd['sink_particle_speed'])
else:
    sink_id = args.sink_number
if rank == 0:
    print("CENTERED SINK ID:", sink_id)
myf.set_centred_sink_id(sink_id)
sink_form_time = dd['sink_particle_form_time'][sink_id]
sink_form_companion = dd['sink_particle_form_time'][sink_id+1]#Assumes the companion has the sink id of the primary sink id +1
if args.start_frame == 0 and args.plot_time == None:
    args.start_frame = int((sink_form_companion - sink_form_time)/(args.time_step))+1
del dd

sys.stdout.flush()
CW.Barrier()


verbatim = False
if rank == 0:
    verbatim = True
if args.specific_file == None:
    if args.plot_time != None: