[yt-users] Star Speeds

John Wise jwise at physics.gatech.edu
Mon Apr 7 19:16:31 PDT 2014


Hi Munier,

In v2.x, it seems like the interpolated star velocities aren't defined 
in the Enzo-specific fields in frontends/enzo/fields.py, even though 
that the metallicity_fraction, creation_time, and dynamical_time fields 
are defined.  However, the machinery is there to create these fields.

You can put the following in your .yt/my_plugins.py file or at the 
beginning of your script or add it to Enzo's fields.py file.

from yt.data_objects.field_info_container import ValidateSpatial
from yt.frontends.enzo.fields import _star_field
add_field('star_particle_velocity_x', function=_star_field,
           validators=[ValidateSpatial(0)])
add_field('star_particle_velocity_y', function=_star_field,
           validators=[ValidateSpatial(0)])
add_field('star_particle_velocity_z', function=_star_field,
           validators=[ValidateSpatial(0)])

With v3.0, this code looks like it will still work because _star_field 
is still defined.

However one new feature in 3.0 is particle filters, where you can single 
out the star particles and then use a deposit operator to interpolate it 
to the grid.  Here's what I tried, but I couldn't get it to work.  Maybe 
someone more familiar with 3.0 can chime in.  I tried for about 15-30 
minutes, but I'm out of time now.  It'd be great to see an example like 
this.  I couldn't figure it out from YTEP-0013...

@particle_filter("star", ["particle_type"])
def finest(pfilter, data):
     return data["all", "particle_type"] != 1

def _my_star_field(field, data):
     pfield = "particle_" + field.name[5:]
     pos = data["star", "Coordinates"]
     d = data.deposit(pos, [data["star", pfield], data["star", 
"particle_mass"]], method = "weighted_mean")
     return d

add_field(name = ("deposit", "star_velocity_x"), function = 
_my_star_field, validators=[ValidateSpatial()])
add_field(name = ("deposit", "star_velocity_y"), function = 
_my_star_field, validators=[ValidateSpatial()])
add_field(name = ("deposit", "star_velocity_z"), function = 
_my_star_field, validators=[ValidateSpatial()])


Cheers,
John

On 04/07/2014 07:56 PM, Munier Azzam Salem wrote:
> Hey Guys,
>
>          I'm looking to work with star particle velocities, ideally:
> some sort of mass-weighted-average of star particle velocities within a
> given cell (I'm using enzo, if that's relevant). This doesn't seem to
> exist in th universal field list, although the cic_particle_velocity_x
> <http://yt-project.org/docs/dev/reference/field_list.html?highlight=field%20list#cic-particle-velocity-x>/y/z in
> the enzo field list seem relevant.
>
>          Any advice?
>
>                 thanks!
>                      Munier
>
> --
> Munier A. Salem // 845.489.6450
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>

-- 
John Wise
Assistant Professor of Physics
Center for Relativistic Astrophysics, Georgia Tech
http://cosmo.gatech.edu



More information about the yt-users mailing list