[yt-users] Calculating turbulent energy
David Collins
dcollins4096 at gmail.com
Mon Dec 2 13:00:51 PST 2013
Hi, Stephanie--
I do this kind of thing with field_parameters. On some data object, you
call
>>> object.set_field_parameter('vzmean',478)
then in your field definition, I do
def _Eturb(field,data):
vzmean = data.get_field_parameter('vzmean')
return data['z-velocity']-vzmean
add_field( 'Eturb', _Eturb, validators=[ValidateParameter('vzmean')])
So in your analysis, you
1.) define some object, as you're doing,
2.) set the field parameters on that object
3.) call your function
and to define the function, you need to
1.) call get_field_parameter to retrieve the value
2.) use the ValidateParameter validator to have yt error check that you
have the field defined. (This, I believe, should be a list of
ValidateParameter for each vxmean, vymean, and vzmean. Alternatively, you
can supply a bulk velocity as a vector, which is my preference.)
I hope that helps. Let me know if you want me to clarify anything.
d.
On Mon, Dec 2, 2013 at 3:49 PM, Stephanie Tonnesen <stonnes at gmail.com>wrote:
> Hi yt-users!
>
> So I want to calculate the turbulent energy in a stripped tail of gas.
> This tail is moving with a bulk flow in the z-direction, which varies as a
> function of z, and is rotating, and v_theta will also likely change as a
> function of z (and while I am at it, might as well check v_r). So I would
> like to do something like this:
>
> def _Eturb(field,data):
> vrmean = value I calculate in the code
> vthetamean = value I calculate in the code
> vzmean = value I calculate in the code
> return(pow(data["cyl_RadialVelocity"]-vrmean,2) +
> pow(data["cyl_TangentialVelocity"]-vthetamean,2) +
> pow(data["z-velocity"]-vzmean,2))
>
> add_field("Eturb",function=_Eturb,units="velocityunits")
>
> totalEturb = np.zeros(100,float)
> pf = load("id0/rps."+outstring[i]+"
>
> .vtk",parameters={"TimeUnits":9.78262,"LengthUnits":26.,"DensityUnits":9.999e-30,"VelocityUnits":2.6e8})
>
> alld = pf.h.all_data()
> i = 0
> while i < 100:
> disk = pf.h.disk([0.0,0.0,i*0.385/2.],[0.0,0.0,1.0],1.0,0.385)
> vrmean =
> disk.quantities["WeightedAverageQuantity"]("cyl_RadialVelocity","Ones")
> vthetamean =
> disk.quantities["WeightedAverageQuantity"]("cyl_TangentialVelocity","Ones")
> vzmean =
> disk.quantities["WeightedAverageQuantity"]("z-velocity","Ones")
>
> totalEturb[i] = disk.quantities["TotalQuantity"]["Eturb"]
> i = i+1
>
> I am not sure if/how I can make the def statement read in vrmean,
> vthetamean, and vzmean?
>
> Thanks!
>
> Stephanie
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
--
-- Sent from a computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20131202/1171562a/attachment.html>
More information about the yt-users
mailing list