[yt-users] YT analysis questions: cylindrical profile and RMS velocity
Matthew Turk
matthewturk at gmail.com
Mon Feb 6 13:05:42 PST 2012
Hi Jun-Hwan,
On Mon, Feb 6, 2012 at 4:00 PM, Jun-Hwan Choi <jhchoi at pa.uky.edu> wrote:
> Thank you Britton,
>
> However, what I would like to compute is RMS velocity field respect to their
> local mean velocity.
> I found a useful procedure in Matt Turk's YT field presentation.
> There is way to make AverageTemperature field using ValidateSpatial.
> I would like to do similar procedure to make average velocity field and
> compute the RMS velocity from this local average.
> But, in this case I get information for N adjust cell value and average
> them.
> But this grid size can vary depending on a given cell's AMR level, while I
> would like to compute local average for uniform spatial volume...
> Well, I may need to think a bit more to make this work.
Do you want to calculate the deviation from a radially averaged
velocity profile? I have had occasion to do this. What you want to
do is something similar to what I did in my presentation for setting
the bulk_velocity; instead of setting it to a vector, set it to the
result of a radial profile calculation. Then you can interpolate
between data points using numpy's interp1d function. Here's an
example:
@derived_field(name = "deltaLocalCircularVelocity")
def delta_LocalCircularVelocity(field, data):
fn, x, cv = data.get_field_parameter("local_circular_velocity")
cv0 = na.interp(data[fn].ravel(), x, cv)
cv0 = cv0.reshape(data[fn].shape)
delta_cv = cv0 - data["LocalCircularVelocity"]
return delta_cv
You'll need to do something like this on the data object from which
you are getting your data:
sp.set_field_parameter("local_circular_velocity",
(fn, prof[fn], prof["LocalCircularVelocity"]))
Note that mine uses circular velocity; yours can use whatever you
like. 'fn' in this case is the x field (I was experimenting with
density and radius, and wanted to easily switch between them.)
Sorry for the short email, deadlines approaching, but give this a
shot, and let me know if I can help out otherwise,
Matt
>
> Thank you,
> Junhwan
>
>
> Britton Smith wrote:
>>
>> Hi Junhwan,
>>
>> For your second question, you can calculate the mean velocity within that
>> sphere and use that to set the bulk velocity for your disk object. You can
>> do something like:
>> sphere = pf.h.sphere(...)
>> bulk_velocity = sphere.quantities['BulkVelocity']()
>>
>> disk = pf.h.disk(...)
>> disk.set_field_parameter('bulk_velocity', bulk_velocity)
>>
>> If you look at the source for the field VelocityMagnitude, it subtracts
>> off this bulk velocity, so I think that would do what you need.
>> The source for that is YT_DEST/yt/data_objects/universal_fields.py
>>
>> Britton
>>
>> On Sat, Feb 4, 2012 at 1:52 PM, Nathan Goldbaum <goldbaum at ucolick.org
>> <mailto:goldbaum at ucolick.org>> wrote:
>>
>> Hi Junhwan,
>>
>> You will need to define a cylindrical radius field. Here's how
>> I've done it in the past (copied from some old messages on the
>> newsgroup from last September):
>>
>> def _CylinderRadius(field, data):
>> center = data.get_field_parameter("center")
>> coords = na.array([data['x'] - center[0],
>> data['y'] - center[1],
>> data['z'] - center[2]])
>> J = na.zeros(coords.shape)
>> if len(coords.shape) == 4:
>> J[0,:,:,:] = -1
>> else:
>> J[0,:] = -1
>> JCrossR = na.cross(J,coords,axis=0)
>> return na.sqrt(na.sum(na.square(JCrossR),0))
>> def _ConvertCylinderRadiusCGS(data):
>> return data.convert("cm")
>> add_field("CylinderRadius", function=_CylinderRadius,
>> validators=[ValidateParameter("center")],
>> convert_function = _ConvertCylinderRadiusCGS,
>> units=r"\rm{cm}")
>>
>> Note that you need to set the field parameter 'center' before you
>> try to use this field.
>>
>> I'm not sure if there is a good way to answer your second
>> question. It's a good bet Kitsuk and Wise did not use yt as it
>> did not exist yet ;)
>>
>> -Nathan
>>
>> On Feb 4, 2012, at 10:46 AM, Jun-Hwan Choi wrote:
>>
>> > Hi YT users,
>> >
>> > I have two questions on the YT analysis:
>> >
>> > First, I would like to make profiles (mass, angular momentum) in
>> the cylindrical coordinate.
>> > In other world, the profiles depend on r_xy (x-y is the cylinder
>> plane).
>> > I define disk object and compute Profile as follow:
>> > > disk = pf.h.disk(center, [0, 0, -1], (100., 'pc'), (1., 'pc'))
>> > > profile = BinnedProfile1D(disk, 50, 'Radius', smallest_bin,
>> largest_bin, lazy_reader=True)
>> > ,but I find that Radius is for x,y, and z distance.
>> > Can I get the cylindrical profile, if I simply make derived
>> field for RadiusXY and replace Radius?
>> > And does there any RadiusXY kind of field exist?
>> >
>> > Second, I would like to compute the RMS velocity in my disk.
>> > However, I would like to compute RMS velocity according to local
>> mean velocity (e.g. mean velocity inside 0.1 pc sphere center on a
>> given position), instead of compute according to global mean velocity.
>> > Is there a routine (or way) to compute the local mean velocity
>> in YT and compute RMS of it?
>> > I found that some papers with Enzo simulation compute the RMS
>> velocity (such as Kitsuk et al 2007 and Wise et al 2008 although I
>> am not sure whether they use YT or not).
>> >
>> > Thank you in advance,
>> > Junhwan Choi
>> >
>> > --
>> > --------------------------------------------------------------
>> > Jun-Hwan Choi, Ph.D.
>> > Department of Physics and Astronomy, University of Kentucky
>> > Tel: (859) 897-6737 <tel:%28859%29%20897-6737> Fax: (859)
>> 323-2846 <tel:%28859%29%20323-2846>
>> > Email: jhchoi at pa.uky.edu <mailto:jhchoi at pa.uky.edu> URL:
>> http://www.pa.uky.edu/~jhchoi <http://www.pa.uky.edu/%7Ejhchoi>
>>
>> > --------------------------------------------------------------
>> >
>> >
>> > !DSPAM:10175,4f2d7d1519872718731035!
>> _______________________________________________
>> > yt-users mailing list
>> > yt-users at lists.spacepope.org <mailto:yt-users at lists.spacepope.org>
>>
>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>> >
>> >
>> > !DSPAM:10175,4f2d7d1519872718731035!
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org <mailto:yt-users at lists.spacepope.org>
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>
>
>
> --
> --------------------------------------------------------------
> Jun-Hwan Choi, Ph.D.
> Department of Physics and Astronomy, University of Kentucky
> Tel: (859) 897-6737 Fax: (859) 323-2846
> Email: jhchoi at pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi
> --------------------------------------------------------------
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
More information about the yt-users
mailing list