[yt-users] Density Profiles with PBCs in RAMSES

Nathan Goldbaum nathan12343 at gmail.com
Fri Aug 12 08:41:10 PDT 2016


On Fri, Aug 12, 2016 at 3:33 AM, Thor Andreas Seiff Ellewsen <
tellewsen at gmail.com> wrote:

> Hi everyone.
>
> I'm fairly new to yt and I'm having some problems.
> I'm trying to plot radial density profiles for some halos in a RAMSES
> simulation with periodic boundary conditions.
> The problem arises when dealing with a halo close to the edge.
>
> The relevant part of the code looks like this:
> ds = yt.load(datapath)
> cen = halos[0] # numpy array [x,y,z] in code units
> rad = haloradius[0] # float in code units
> sph = ds.sphere(cen, (10.*rad, 'Mpc/h'))
> plot = yt.ProfilePlot(sph, "radius", 'particle_mass')
>

The issue is actually that you're comparing a mesh field, "radius" with a
particle field "particle_mass". Mesh fields are defined on the ramses AMR
mesh and particle fields are defined at the particle locations. The
indexing error comes from the fact that there there are different number of
particles and mesh cells. More information about this distinction here:

http://yt-project.org/doc/analyzing/fields.html

In addition, ProfilePlot is supposed to only be used for fields defined on
the AMR mesh, for particle fields you should use ParticlePlot.

I thought that we had resolved the issue with providing a nice error
message when trying to create a plot mixing mesh and particle fields, but I
guess we missed ProfilePlot. I will take a closer look at this and
hopefully add a better error message so future newcomers don't get
confused. I've filed an issue about this here:
https://bitbucket.org/yt_analysis/yt/issues/1261

You *could* use ParticlePlot instead of ProfilePlot to plot the average of
the particle masses as a function of radius - although that's not really
what you want if I understand you correctly.

To get a profile of the particle density as a function of radius, you
really want to do:

plot = yt.ProfilePlot(sph, "radius", ("deposit", "io_cic"),
weight_field=None)

This uses a deposit field (described here
http://yt-project.org/doc/analyzing/fields.html#deposited-particle-fields).
This particle field is the deposited particle density - the particle masses
are deposited onto the AMR mesh using the cloud in cell algorithm. This
doesn't make a distinction between dark matter particles and stars, so if
you're not running a dark-matter only simulation you'll need to use a
particle filter to create a dark matter particle type:

http://yt-project.org/doc/analyzing/filtering.html#filtering-particle-fields

and then use the deposited particle field for the new particle type (e.g.
('deposit', 'dark_matter_cic')) to create a dark matter density profile.

Hope that's helpful, please let us know if you have any additional
questions.

-Nathan


>
> This returns
> IndexError: index 3665 is out of bounds for axis 1 with size 3665
>
> If I understand this correctly the problem is in the sphere object.
> It works fine if I keep the sphere inside the edge of the simulation.
>
> Is there a way to deal with this problem?
>
> PS: I know particle_mass is not the density of the dark matter, but I
> haven't found a field for that, so this will have to do until I find one or
> learn how to make one myself.
>
> Best,
> Andreas Ellewsen
>
> _______________________________________________
> 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/20160812/a3a0e117/attachment-0001.html>


More information about the yt-users mailing list