Skip to content

Commit

Permalink
Merge pull request #78 from kyleaoman/fix_tng
Browse files Browse the repository at this point in the history
Fix a bug in nH_g calculation for TNG.
  • Loading branch information
kyleaoman authored Oct 12, 2024
2 parents b12db96 + 77e7265 commit 5fb378d
Show file tree
Hide file tree
Showing 10 changed files with 1,853 additions and 347 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ examples/*.tar
examples/sql_cookies.txt
examples/eagle_db.password
examples/tng_api.key
examples/m11e_res7100
.coverage
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"codeRepository": [
"https://github.com/kyleaoman/martini",
],
"version": "2.1.5",
"version": "2.1.6",
"license": "https://spdx.org/licenses/GPL-3.0-only.html",
}
416 changes: 345 additions & 71 deletions examples/martini_TNG.ipynb

Large diffs are not rendered by default.

434 changes: 360 additions & 74 deletions examples/martini_eagle.ipynb

Large diffs are not rendered by default.

621 changes: 547 additions & 74 deletions examples/martini_fire.ipynb

Large diffs are not rendered by default.

405 changes: 336 additions & 69 deletions examples/martini_simba.ipynb

Large diffs are not rendered by default.

296 changes: 243 additions & 53 deletions examples/martini_source_injection.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion martini/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.1.5"
__version__ = "2.1.6"
21 changes: 18 additions & 3 deletions martini/sources/tng_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,32 @@ def __init__(
xe_g = data_g["ElectronAbundance"]
rho_g = data_g["Density"] * 1e10 / h * U.Msun * np.power(a / h * U.kpc, -3)
u_g = data_g["InternalEnergy"] # unit conversion handled in T_g
mu_g = 4 * C.m_p.to(U.g).value / (1 + 3 * X_H_g + 4 * X_H_g * xe_g)
mu_g = 4 / (1 + 3 * X_H_g + 4 * X_H_g * xe_g)
gamma = 5.0 / 3.0 # see http://www.tng-project.org/data/docs/faq/#gen4
T_g = (gamma - 1) * u_g / C.k_B.to(U.erg / U.K).value * 1e10 * mu_g * U.K
T_g = (
(gamma - 1)
* u_g
/ C.k_B.to_value(U.erg / U.K)
* 1e10
* mu_g
* C.m_p.to_value(U.g)
* U.K
)
m_g = data_g["Masses"] * 1e10 / h * U.Msun
# cast to float64 to avoid underflow error
nH_g = U.Quantity(rho_g * X_H_g / mu_g, dtype=np.float64) / C.m_p
# In TNG_corrections I set f_neutral = 1 for particles with density
# > .1cm^-3. Might be possible to do a bit better here, but HI & H2
# tables for TNG will be available soon anyway.
fatomic_g = atomic_frac(
z, nH_g, T_g, rho_g, X_H_g, onlyA1=True, TNG_corrections=True
z,
nH_g,
T_g,
rho_g,
X_H_g,
mu=mu_g,
onlyA1=True,
TNG_corrections=True,
)
mHI_g = m_g * X_H_g * fatomic_g
try:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "astromartini"
version = "2.1.5"
version = "2.1.6"
authors = [
{ name="Kyle Oman", email="[email protected]" },
]
Expand Down

0 comments on commit 5fb378d

Please sign in to comment.