[yt-users] Star Speeds
Matthew Turk
matthewturk at gmail.com
Mon Apr 7 19:23:24 PDT 2014
Hi John,
On Apr 7, 2014 10:17 PM, "John Wise" <jwise at physics.gatech.edu> wrote:
>
> 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
Ah, here's the trick- filters can't act on unions, and "all" is a union. If
you try it on "io" it should work.
Matt
>
> 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
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20140407/8fc8e153/attachment.htm>
More information about the yt-users
mailing list