Skip to content

Commit

Permalink
Merge pull request #4212 from meeseeksmachine/auto-backport-of-pr-421…
Browse files Browse the repository at this point in the history
…1-on-yt-4.1.x

Backport PR #4211 on branch yt-4.1.x ([bugfix] H nuclei are being double-counted in the Arepo frontend)
  • Loading branch information
neutrinoceros authored Nov 17, 2022
2 parents 7d680ea + 07ae0a8 commit 6fdd7ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 1 addition & 6 deletions yt/frontends/arepo/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ def _pressure(field, data):

if (ptype, "GFM_Metals_00") in self.field_list:
self.nuclei_names = metal_elements
self.species_names = ["H"]
if (ptype, "NeutralHydrogenAbundance") in self.field_list:
self.species_names += ["H_p0", "H_p1"]
self.species_names += metal_elements
self.species_names = ["H"] + metal_elements

if (ptype, "MagneticField") in self.field_list:
setup_magnetic_field_aliases(self, ptype, "MagneticField")
Expand Down Expand Up @@ -130,8 +127,6 @@ def _h_p1_fraction(field, data):
field = f"{species}{suf}"
self.alias(("gas", field), (ptype, field))

self.alias(("gas", "H_nuclei_density"), ("gas", "H_number_density"))

if (ptype, "ElectronAbundance") in self.field_list:

# If we have ElectronAbundance but not NeutralHydrogenAbundance, assume the
Expand Down
11 changes: 10 additions & 1 deletion yt/frontends/arepo/tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import OrderedDict

from yt.frontends.arepo.api import ArepoHDF5Dataset
from yt.testing import ParticleSelectionComparison, requires_file
from yt.testing import ParticleSelectionComparison, assert_allclose_units, requires_file
from yt.utilities.answer_testing.framework import data_dir_load, requires_ds, sph_answer

bullet_h5 = "ArepoBullet/snapshot_150.hdf5"
Expand Down Expand Up @@ -84,6 +84,15 @@ def test_index_override():
assert len(open(tmpname).read()) == 0


@requires_file(tng59_h5)
def test_nh_density():
ds = data_dir_load(tng59_h5, kwargs={"bounding_box": _tng59_bbox})
ad = ds.all_data()
assert_allclose_units(
ad["gas", "H_number_density"], (ad["gas", "H_nuclei_density"])
)


@requires_file(tng59_h5)
def test_arepo_tng59_selection():
ds = data_dir_load(tng59_h5, kwargs={"bounding_box": _tng59_bbox})
Expand Down

0 comments on commit 6fdd7ee

Please sign in to comment.