[yt-users] different hydrogen densities from different versions of yt

Nathan Goldbaum nathan12343 at gmail.com
Fri Mar 3 14:01:06 PST 2017

Hi Lauren,

Thanks for the detailed report. It was very straightforward to reproduce
what you're seeing using one of the test cosmological datasets on

I'm pretty sure you've stumbled across a bug in the way species fields are
set up for Enzo.

Here's what's happening:

In yt-2, the field "H_NumberDensity" corresponds to the number density of
all hydrogen ion species (i.e. HI + HII number density).

In yt-3, for some reason, ('gas', 'H_number_density') represents the number
density of just HI ions. To get what you had before, you'd need to defined
a new field which sums ('gas', 'H_number_density') and ('gas',

The following IPython session illustrates the issue:

In [10]: ds.fields.gas.H_density
Out[10]: Alias Field for "('enzo', 'HI_Density')" (gas, H_density): (units:

In [11]: ds.fields.gas.H_p0_density
Out[11]: Alias Field for "('gas', 'H_density')" (gas, H_p0_density):
(units: g/cm**3)

In [12]: ds.fields.gas.H_p1_density
Out[12]: Alias Field for "('enzo', 'HII_Density')" (gas, H_p1_density):
(units: g/cm**3)

Right now ('gas', 'H_density') is an alias to ('enzo', 'HI_Density'), and
('gas', 'H_p0_density') is an alias to ('gas', 'H_density'). I'm pretty
sure that's wrong, ('gas', 'H_p0_density') should be an alias to ('enzo',
'HI_Density') and ('gas', 'H_density') should be a derived field formed by
summing HI_density and HII_density.

Now, I'm pretty sure this is a bug, but I also don't normally with with
Enzo multispecies data, so I'd like some confirmation about this from
others who are more experienced with cosmological enzo data before I make a
pull request.


On Fri, Mar 3, 2017 at 2:44 PM, Lauren Corlies <laurennc009 at gmail.com>

> Hello,
> I've been a yt user for a while now but have recently noticed something
> concerning. A few months ago, I made the switch to yt3 and am currently
> using the new yt 3.3.4
> I've been working with recently generated, cosmological zoom in
> simulations and I've generated a basic yt ray object.  When I plot the
> hydrogen number density along the ray, the values that it's generating are
> un-physically low (seen here <http://i.imgur.com/1C1oAVr.png>).
> It's especially concerning because when I use the old yt2 installation:
> Version = 2.7-dev
> Changeset = 1f9ca06815d0
> and generate a yt ray object with the exact same trajectory, the hydrogen
> number density values are much more sensible (seen here
> <http://i.imgur.com/tcDcNd8.png>). The rays in both yt versions have
> mostly the same shape but there are some strong features in the yt2 version
> than in the yt3 one.
> The discrepancy is specifically with this field and not other intrinsic
> fields like temperature or regular density (also attached).
> Am I accessing the field incorrectly and there's a better way to get these
> values with the new version of yt? Or is there something deeper happening?
> The hydrogen number density is particularly important for the ion densities
> and emission that I've been interested in.
> All of the plots and the script <http://paste.yt-project.org/show/7066/>
> to generate them are attached and posted online as described on the docs
> page, tagged with my last name with links included as an attachment.
> Thanks for the help,
> Lauren Corlies
> _______________________________________________
> 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/20170303/f5310e41/attachment.html>

More information about the yt-users mailing list