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

[ENH] Add support for self-shielding in heating/cooling rates calculation for RAMSES #4843

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

cphyc
Copy link
Member

@cphyc cphyc commented Mar 5, 2024

PR Summary

RAMSES uses some self-shiedling to compute the cooling/heating rates.
This parameter is used in hydro/cooling_fine.f90. When self-shielding is activated, a "boost factor" is computed as
boost =exp(-nH/0.01), and the effective density used to look-up the cooling tables is nH/boost.

PR Checklist

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

@cphyc cphyc marked this pull request as ready for review April 11, 2024 15:44
@cphyc cphyc added code frontends Things related to specific frontends refactor improve readability, maintainability, modularity labels Apr 11, 2024
yt/frontends/ramses/data_structures.py Outdated Show resolved Hide resolved
yt/frontends/ramses/data_structures.py Outdated Show resolved Hide resolved
@neutrinoceros
Copy link
Member

@yt-fido test this please

@cphyc cphyc added this to the 4.4.0 milestone Apr 12, 2024
@cphyc
Copy link
Member Author

cphyc commented Apr 18, 2024

Let's hold this a bit more, we probably need testing before this goes in!

@neutrinoceros neutrinoceros marked this pull request as draft April 18, 2024 12:28
@neutrinoceros
Copy link
Member

okay, converting to draft then !

@cphyc
Copy link
Member Author

cphyc commented Sep 18, 2024

Update: this is almost ready to review. I will add a test once #4817 is merged in.

@cphyc cphyc changed the title Add support for self-shielding in heating/cooling rates calculation [ENH] Add support for self-shielding in heating/cooling rates calculation for RAMSES Sep 18, 2024
@cphyc cphyc added bug backwards incompatible This change will change behavior labels Sep 18, 2024
@cphyc cphyc marked this pull request as ready for review September 19, 2024 09:48
@cphyc
Copy link
Member Author

cphyc commented Sep 19, 2024

The error is due to a missing simulation dataset on Jenkins (ramses_star_formation/output_00013). @Xarthisius is this something you could do?

@Xarthisius
Copy link
Member

@yt-fido test this please

Copy link
Contributor

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

generally LGTM, but left a couple of questions/comments

yt/frontends/ramses/data_structures.py Show resolved Hide resolved
# Ramses assumes a fraction X of Hydrogen within the non-metal gas.
# It has to be corrected by metallicity.
Z = data["gas", "metallicity"]
nH = (1 - _Y) * (1 - Z) * data["gas", "density"] / mh
Copy link
Contributor

Choose a reason for hiding this comment

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

nh here will have dimensions of of 1/length**3 -- any need to force a particular unit before using the numpy functions below?

# Simple context manager that overrides the value of
# the self_shielding flag in the namelist.txt file
@contextmanager
def override_self_shielding(fname: str, section: str, val: bool):
Copy link
Contributor

Choose a reason for hiding this comment

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

seems pretty unlikely it'd happen and cause issues, but this does introduce a race condition -- since this manager actually overwrites the existing namelist file, if tests were run in parallel then other tests using ramses_new_fromat could read in the overwritten namelist unintentionally (or catch the file during the active write?). It is a small enough dataset (4.4 MB) that you could instead copy the whole dataset into a temporary directory and modify the namelist files appropriately (which would be cleaner to do with pytest over in test_outputs_pytest.py). Would take a bit of extra IO but IMO worth it for the extra future-proofing, but also a small enough thing that I could be convinced that I'm overthinking this :)

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be good now :)

@cphyc cphyc force-pushed the RAMSES-self-shielding branch 2 times, most recently from be6cdae to 6a6813c Compare October 4, 2024 13:07
cphyc and others added 6 commits October 9, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible This change will change behavior bug code frontends Things related to specific frontends refactor improve readability, maintainability, modularity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants