-
Notifications
You must be signed in to change notification settings - Fork 276
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
base: main
Are you sure you want to change the base?
Conversation
1aeb427
to
37490b0
Compare
37490b0
to
fee05ef
Compare
@yt-fido test this please |
Let's hold this a bit more, we probably need testing before this goes in! |
okay, converting to draft then ! |
Update: this is almost ready to review. I will add a test once #4817 is merged in. |
8612f0d
to
05c8ff0
Compare
The error is due to a missing simulation dataset on Jenkins ( |
@yt-fido test this please |
There was a problem hiding this 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/fields.py
Outdated
# 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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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 :)
be6cdae
to
6a6813c
Compare
Hydrogen abundances are defined as (1 - Y) × (1 - Z), where Y is the hard-coded primordial Helium fraction and Z is metallicity. Co-authored-by: Víctor Rufo Pastor <[email protected]>
Co-authored-by: Chris Havlin <[email protected]>
b1e35bd
to
5976261
Compare
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 asboost =exp(-nH/0.01), and the effective density used to look-up the cooling tables is
nH/boost
.PR Checklist