Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small Arepo/Gadget enhancements #4419

Merged
merged 9 commits into from
Apr 25, 2023
Merged

Conversation

jzuhone
Copy link
Contributor

@jzuhone jzuhone commented Apr 19, 2023

PR Summary

This PR:

  • Makes the "cell_volume" field for Arepo datasets have "gas" type
  • Make "star_formation_rate" an alias for "StarFormationRate" in Gadget and its derivatives
  • Expand the number of places that yt looks for unit definitions in Arepo HDF5 files
  • Fixes an issue with the pressure field (should be sampling_type="local" and not "particle")
  • If the H mass fraction is in the dataset, use that to construct the H_number_density field if there is no NeutralHydrogenAbundance field

In the course of testing this PR @Xarthisius and I found that Jenkins did not have the same version of the TNGHalo test dataset as yt-project.org/data, hence also the answer bump.

PR Checklist

  • New features are documented, with docstrings and narrative docs
  • Adds a test for any bugs fixed. Adds tests for new features.

@jzuhone jzuhone added code frontends Things related to specific frontends enhancement Making something better labels Apr 19, 2023
Copy link
Member

@matthewturk matthewturk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, just a question or two.

uvals["cmcm"] = 1.0 / uvals[unit]
else:
missing[i] = True
for grp in ["/Header", "/Parameters", "/Units"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am completely stumped as to the Jenkins test failures. I cannot reproduce the difference on this PR vs. main on my own machine--even after switching to Python 3.8 and letting pip install all of the dependencies. Can someone help check the logic here to make sure I didn't do something silly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, both answers I get (this PR vs main on my machine) agree with the "new" ones

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ @Xarthisius any special Jenkins insight would be helpful

Comment on lines +62 to 68
return data["gas", "mass"] / data["gas", "density"]

self.add_field(
(ptype, "cell_volume"),
("gas", "cell_volume"),
function=_volume,
sampling_type="local",
units=self.ds.unit_system["volume"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be changed elsewhere too? It looks reasonable to me, since in Arepo the volume (at least right now) will only make sense for the gas particles. Do we need to concern ourselves with potential two-fluid sims?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "this" you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ptype to "gas"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this also now for the "pressure" field

@@ -129,14 +129,26 @@ def _h_p1_fraction(field, data):
self.alias(("gas", field), (ptype, field))

if (ptype, "ElectronAbundance") in self.field_list:
# If we have ElectronAbundance but not NeutralHydrogenAbundance, assume the
# If we have ElectronAbundance but not NeutralHydrogenAbundance,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice will this change results for existing calculations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm actually not convinced that we've ever encountered a corner case like this. I just noticed that this was a possibility recently when someone asked me about something related.

@jzuhone
Copy link
Contributor Author

jzuhone commented Apr 21, 2023

I can't figure out the test failures

@jzuhone
Copy link
Contributor Author

jzuhone commented Apr 21, 2023

@yt-fido test this please

matthewturk
matthewturk previously approved these changes Apr 24, 2023
@jzuhone
Copy link
Contributor Author

jzuhone commented Apr 24, 2023

This is ready to go.

@neutrinoceros
Copy link
Member

I'm confused, Matt didn't write a comment, so who approved bumping answers ?

@Xarthisius
Copy link
Member

I'm confused, Matt didn't write a comment, so who approved bumping answers ?

The reason was given in the updated description of this PR.

@neutrinoceros
Copy link
Member

ah, I missed it, thanks !

yt/frontends/arepo/data_structures.py Outdated Show resolved Hide resolved
yt/frontends/arepo/data_structures.py Outdated Show resolved Hide resolved
Co-authored-by: Clément Robert <cr52@protonmail.com>
@jzuhone
Copy link
Contributor Author

jzuhone commented Apr 25, 2023

Thanks @neutrinoceros

@neutrinoceros neutrinoceros merged commit 4e3b43b into yt-project:main Apr 25, 2023
10 checks passed
@jzuhone
Copy link
Contributor Author

jzuhone commented Apr 25, 2023

thanks again all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code frontends Things related to specific frontends enhancement Making something better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants